@qwen-code/qwen-code 0.23.4 → 0.23.5-dev.codemode-responses.20260915.f024b37689
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/bundled/computer-use/SKILL.md +239 -22
- package/bundled/computer-use/references/windows-linux.md +3 -3
- package/bundled/qc-helper/docs/features/computer-use.md +2 -2
- package/bundled/qc-helper/docs/features/hooks.md +238 -75
- package/chunks/{MaxSizedBox-Q44AWRWI.js → MaxSizedBox-BFMIFJWT.js} +10 -10
- package/chunks/{StandaloneSessionPicker-UKII7M7U.js → StandaloneSessionPicker-4ZH7MOVG.js} +23 -23
- package/chunks/{acp-subagent-executor-7RUAOXE7.js → acp-subagent-executor-AHMVA4P3.js} +11 -11
- package/chunks/{acpAgent-5N3LHCO3.js → acpAgent-UMAJ3XR3.js} +43 -43
- package/chunks/{agent-LU5UJALC.js → agent-CXB2CCQN.js} +4 -4
- package/chunks/{agent-headless-LTLADUGR.js → agent-headless-7D5ZC736.js} +4 -4
- package/chunks/{bridge-P34XQP3D.js → bridge-A2WKX6IK.js} +11 -11
- package/chunks/{channel-settings-store-VE4ARRSR.js → channel-settings-store-AXJIN7HG.js} +15 -15
- package/chunks/{chunk-RJFUPP3F.js → chunk-3544ZEGZ.js} +2 -2
- package/chunks/{chunk-WLFILD4T.js → chunk-3CKAOJ4L.js} +2 -2
- package/chunks/{chunk-2P2IXKDR.js → chunk-4DTFTPTU.js} +1 -1
- package/chunks/{chunk-5JG3DAKS.js → chunk-4OQSG35W.js} +1 -1
- package/chunks/{chunk-E7HXORS7.js → chunk-54YUXX7X.js} +1 -1
- package/chunks/{chunk-2NRKLYID.js → chunk-5KJ54DY3.js} +12 -12
- package/chunks/{chunk-IUXWAKVS.js → chunk-5WLF44DS.js} +5 -5
- package/chunks/{chunk-RWKR4VNK.js → chunk-67ZDP7UX.js} +1 -1
- package/chunks/{chunk-WDB57HEI.js → chunk-6RQFMGN2.js} +3 -3
- package/chunks/{chunk-PNACDSCO.js → chunk-6XDB3FR4.js} +23 -23
- package/chunks/{chunk-BBMOAZ2E.js → chunk-6YUS5JCV.js} +3 -3
- package/chunks/{chunk-JZ3FFPES.js → chunk-A2UYI473.js} +5 -5
- package/chunks/{chunk-PCIYPEYV.js → chunk-C3YMBSLR.js} +3 -3
- package/chunks/{chunk-RKXAOP6F.js → chunk-DQ4LBRZN.js} +3 -3
- package/chunks/{chunk-UGEDTVL6.js → chunk-DWKFTUGI.js} +3 -3
- package/chunks/{chunk-PVKEYO5D.js → chunk-E7ZTAOJZ.js} +4 -4
- package/chunks/{chunk-P6XVYPWA.js → chunk-EQWKIA72.js} +22 -4
- package/chunks/{chunk-X7GOO6VM.js → chunk-EYLUKEYW.js} +1 -1
- package/chunks/{chunk-TRKIKBUW.js → chunk-FCLMJS6N.js} +1 -1
- package/chunks/{chunk-KLGCF6G7.js → chunk-FHSOZSBO.js} +2 -2
- package/chunks/{chunk-RHTNPDGD.js → chunk-FIP5QS2U.js} +1 -1
- package/chunks/{chunk-J4DRBDHX.js → chunk-FPPG5Y3W.js} +4 -4
- package/chunks/{chunk-62MWBTS7.js → chunk-FX6GJIPZ.js} +2 -2
- package/chunks/{chunk-TJDUJSVH.js → chunk-GFAK6DYU.js} +1 -1
- package/chunks/{chunk-H7L725Z6.js → chunk-GMCEFKNR.js} +8 -8
- package/chunks/{chunk-UUT7EFX3.js → chunk-GNKSR3FU.js} +1 -1
- package/chunks/{chunk-BDDE4YNP.js → chunk-HVSRWLOW.js} +3 -3
- package/chunks/{chunk-TW2RLZPC.js → chunk-HXMDDII6.js} +3 -3
- package/chunks/{chunk-E4XZSQXB.js → chunk-IANIY25T.js} +10 -10
- package/chunks/{chunk-3AYIKQTJ.js → chunk-IWOJ2FHG.js} +3 -3
- package/chunks/{chunk-7JGH6IMU.js → chunk-JIJ65YKA.js} +37 -5
- package/chunks/{chunk-UL4DXZMP.js → chunk-JLF2AQAL.js} +3 -3
- package/chunks/{chunk-MFPAVOYJ.js → chunk-JO67LVXW.js} +3 -3
- package/chunks/{chunk-4XP7WXC4.js → chunk-L5R4D5T4.js} +2 -2
- package/chunks/{chunk-7GKPKIUB.js → chunk-LBWIJ5T7.js} +1 -1
- package/chunks/{chunk-P225AM5U.js → chunk-LCAJ63TF.js} +1 -1
- package/chunks/{chunk-IR5CVY5G.js → chunk-LTINUI3O.js} +2 -2
- package/chunks/{chunk-SQCZDHBQ.js → chunk-MNRK6MIH.js} +3 -3
- package/chunks/{chunk-IGLX6UXJ.js → chunk-NJ4ZNDVP.js} +1 -1
- package/chunks/{chunk-LFNK4DGQ.js → chunk-PPE7VUMD.js} +1 -1
- package/chunks/{chunk-SYDMM6IX.js → chunk-Q4G2YPI4.js} +1 -1
- package/chunks/{chunk-ITOB3LRT.js → chunk-QI4WBHPF.js} +4 -4
- package/chunks/{chunk-L5BVU4JW.js → chunk-QJKR2P2K.js} +2 -2
- package/chunks/{chunk-6TFZIA2L.js → chunk-QLX4D55R.js} +1 -1
- package/chunks/{chunk-M6MID3FA.js → chunk-QS5Q5F42.js} +2 -2
- package/chunks/{chunk-FRISMWG3.js → chunk-QTUQV33C.js} +2 -2
- package/chunks/{chunk-WKQX4FND.js → chunk-R5OA3ONY.js} +3 -3
- package/chunks/{chunk-I6JRN375.js → chunk-RN6BU77T.js} +2 -2
- package/chunks/{chunk-PRWRNC64.js → chunk-S77FFY67.js} +1 -1
- package/chunks/{chunk-LMDMYMSS.js → chunk-SGXJQP5Q.js} +3 -3
- package/chunks/{chunk-65ANUQSV.js → chunk-SKYOAH4Z.js} +2 -2
- package/chunks/{chunk-VQ3SUPLA.js → chunk-SNT634Q6.js} +4 -4
- package/chunks/{chunk-7W2Y3PZD.js → chunk-TPEV2QHG.js} +4 -4
- package/chunks/{chunk-QM2MRAG4.js → chunk-TYBRGFYL.js} +40 -27
- package/chunks/{chunk-OXDQETZA.js → chunk-UCKM6KCJ.js} +1 -1
- package/chunks/{chunk-L56E7YUM.js → chunk-UQXURNLM.js} +1 -1
- package/chunks/{chunk-7ML2ZLQF.js → chunk-UY4OCBX4.js} +1 -1
- package/chunks/{chunk-K2DCZ6SZ.js → chunk-VI5UVPOB.js} +10 -10
- package/chunks/{chunk-ZXUKZHMV.js → chunk-W23HOFDK.js} +1 -1
- package/chunks/{chunk-VELFTVEO.js → chunk-WATHOB6X.js} +3 -3
- package/chunks/{chunk-DCRVSIK6.js → chunk-WBP64MZR.js} +79 -35
- package/chunks/{chunk-WMEX6CFP.js → chunk-XK4UQSIR.js} +1 -1
- package/chunks/{chunk-EOQXU3ZE.js → chunk-XKRYQOHS.js} +2 -2
- package/chunks/{chunk-F2IRY2TD.js → chunk-Y3ZXDBUL.js} +1 -1
- package/chunks/{chunk-ELHAQ5H4.js → chunk-YVWS4SLL.js} +2 -2
- package/chunks/{chunk-WNQRJXKP.js → chunk-Z6Q7I37O.js} +1 -1
- package/chunks/{chunk-O75ZXPOX.js → chunk-ZC75SULX.js} +1 -1
- package/chunks/{chunk-JLZ5YCMV.js → chunk-ZOQ6HC7U.js} +2 -2
- package/chunks/{chunk-DGTH4BSO.js → chunk-ZUKC5J6Q.js} +10 -10
- package/chunks/{codex-subagent-executor-WCRCJMQK.js → codex-subagent-executor-LANZAZPH.js} +11 -11
- package/chunks/{config-utils-73C3RGYN.js → config-utils-CRK2LQPA.js} +10 -10
- package/chunks/{contextCommand-4ZDPQJHD.js → contextCommand-GY5X3LIY.js} +11 -11
- package/chunks/{core-runtime-ZDUA5DYE.js → core-runtime-IJIV2LHP.js} +10 -10
- package/chunks/{create-sub-session-JK3SSJKO.js → create-sub-session-MNIVRHGB.js} +11 -11
- package/chunks/{daemon-git-worktree-guard-QU2CCJIE.js → daemon-git-worktree-guard-W6Z2BGDH.js} +10 -10
- package/chunks/{daemon-status-provider-2PO7NLDQ.js → daemon-status-provider-TJF3APU3.js} +15 -15
- package/chunks/{daemon-trust-policy-IMDTIUWB.js → daemon-trust-policy-6INCISDU.js} +15 -15
- package/chunks/{daemon-trust-policy-monitor-6IVBNUAD.js → daemon-trust-policy-monitor-JRTAQG54.js} +15 -15
- package/chunks/{deferred-core-runtime-3AZUE7F3.js → deferred-core-runtime-2JRTPTNM.js} +10 -10
- package/chunks/{edit-HXMBABZU.js → edit-JDIXXCYB.js} +4 -4
- package/chunks/{enterPlanMode-KAMW2I2C.js → enterPlanMode-YTNTBZBN.js} +4 -4
- package/chunks/{environment-HYMXOTVB.js → environment-UAI5L52V.js} +12 -12
- package/chunks/{errors-NQRH7NAM.js → errors-J4UCDCW5.js} +12 -12
- package/chunks/{exitPlanMode-SMEBS5EF.js → exitPlanMode-YMWJ2EO7.js} +4 -4
- package/chunks/{fast-path-CUWUTJUR.js → fast-path-MBAN7TK3.js} +2 -2
- package/chunks/{glob-VOM5DVZ3.js → glob-YEM24E3Z.js} +4 -4
- package/chunks/{goal-tools-YBYJ5KPM.js → goal-tools-LJIVH5T6.js} +4 -4
- package/chunks/{handleAutoUpdate-4CEHNJ2F.js → handleAutoUpdate-DYCSYDYL.js} +12 -12
- package/chunks/{i18n-G7ODGUGN.js → i18n-PTAV7SN3.js} +10 -10
- package/chunks/{initializer-GZ73HSOA.js → initializer-MPXTKQA4.js} +15 -15
- package/chunks/{installationInfo-PV472I52.js → installationInfo-U5EFA3OL.js} +10 -10
- package/chunks/{list-D4A7LFOF.js → list-YOE25QUI.js} +18 -18
- package/chunks/{llm-PJU4VT3K.js → llm-ZZ2WNQMC.js} +42 -42
- package/chunks/{llm-content-generator-ITOMDK65.js → llm-content-generator-CG2HRJZC.js} +2 -2
- package/chunks/{loadedSettingsAdapter-NNU4BY5Q.js → loadedSettingsAdapter-NPGWGURF.js} +15 -15
- package/chunks/{loggingContentGenerator-SMI2AJYY.js → loggingContentGenerator-TUL6SJVL.js} +5 -5
- package/chunks/{managed-npm-update-AN5RDI5D.js → managed-npm-update-YUDSCJP3.js} +10 -10
- package/chunks/{mcp-RIIEZ7NJ.js → mcp-EX3GDQVO.js} +15 -15
- package/chunks/{model-configuration-E5M35A3M.js → model-configuration-6DEKTXJI.js} +15 -15
- package/chunks/{modelConfigUtils-43SY2EDS.js → modelConfigUtils-4NA2MHEE.js} +11 -11
- package/chunks/{monitor-5WYDOXLI.js → monitor-PPUGNAWR.js} +4 -4
- package/chunks/{nonInteractiveCli-D3YFYXNB.js → nonInteractiveCli-6TW2XYP5.js} +37 -37
- package/chunks/{notebook-edit-GQNFJTIR.js → notebook-edit-4MUXHZHT.js} +4 -4
- package/chunks/{openaiContentGenerator-VJAKFZ32.js → openaiContentGenerator-5J73W5XZ.js} +3 -3
- package/chunks/{pidfile-I5SWEJDX.js → pidfile-M7WELKBB.js} +10 -10
- package/chunks/{processUtils-NSYM3SKR.js → processUtils-SPRINFNY.js} +2 -2
- package/chunks/{prompt-terminal-ledger-KWBANHUE.js → prompt-terminal-ledger-25BRD7FX.js} +11 -11
- package/chunks/{qwenContentGenerator-LR6HNFBU.js → qwenContentGenerator-H5AAKXPC.js} +5 -5
- package/chunks/{read-file-LOSUPKDX.js → read-file-ILGEFPB3.js} +2 -2
- package/chunks/{resumeHistoryUtils-6IFK3MQO.js → resumeHistoryUtils-RB52QOCH.js} +11 -11
- package/chunks/{ripGrep-MBSYRHNP.js → ripGrep-O6QAFHQK.js} +3 -3
- package/chunks/{run-qwen-serve-WYEEYIHV.js → run-qwen-serve-5NO3TKUL.js} +38 -38
- package/chunks/{runtime-FVTTOB4E.js → runtime-G2YUYMSZ.js} +16 -16
- package/chunks/{scheduled-tasks-RN6DUY7E.js → scheduled-tasks-HDHV3URA.js} +14 -14
- package/chunks/{scheduler-T7DDWINW.js → scheduler-6MDJX2ZK.js} +12 -12
- package/chunks/{serve-LVMPJBTV.js → serve-Z2EJQYKB.js} +15 -15
- package/chunks/{server-U7K7EJEP.js → server-JTNBK3LH.js} +38 -38
- package/chunks/{session-BQNC5QUN.js → session-5YK2BXH4.js} +38 -38
- package/chunks/{session-attachments-root-LQDHWZST.js → session-attachments-root-QO3VFJS6.js} +10 -10
- package/chunks/{session-pr-refresh-J7DQYX2I.js → session-pr-refresh-OTK3HCJZ.js} +13 -13
- package/chunks/{settings-WAWJIZHR.js → settings-2VKLACYV.js} +14 -14
- package/chunks/{shell-WFJEYGQI.js → shell-64NAVGMS.js} +4 -4
- package/chunks/{skill-RHQWSDOK.js → skill-R3ALMLLM.js} +2 -2
- package/chunks/{skill-settings-ALFUQQD6.js → skill-settings-HZ34TUMP.js} +14 -14
- package/chunks/{spawnChannel-D35CB5JB.js → spawnChannel-XGFWHEIK.js} +10 -10
- package/chunks/{standalone-update-NMMY6CAO.js → standalone-update-R32Y3XRR.js} +11 -11
- package/chunks/{start-opentui-ui-F6BN46GE.js → start-opentui-ui-YGJOUE2H.js} +50 -49
- package/chunks/{startInteractiveUI-E6U7L5AD.js → startInteractiveUI-5ZEVKSFF.js} +57 -56
- package/chunks/{team-create-DKAJ3OUY.js → team-create-GCVUXJLE.js} +4 -4
- package/chunks/{team-plan-approval-ZUG32DAK.js → team-plan-approval-NOL62FJD.js} +4 -4
- package/chunks/{terminal-image-renderer-U3Z5PMGO.js → terminal-image-renderer-WG5TLPGC.js} +10 -10
- package/chunks/{theme-manager-GA65ZFKB.js → theme-manager-HDS4YFPW.js} +10 -10
- package/chunks/{tool-search-XCEN7VXX.js → tool-search-HMT5GYUR.js} +2 -2
- package/chunks/{total-session-admission-FZSHBR32.js → total-session-admission-Y5RCHEXO.js} +11 -11
- package/chunks/{tree-sitter-4D7QS7F6.js → tree-sitter-LSORDVZ3.js} +1 -1
- package/chunks/{tree-sitter-bash-VEJGF5XF.js → tree-sitter-bash-UARELQ6C.js} +1 -1
- package/chunks/{trustedFolders-SXPNZESV.js → trustedFolders-3Y2WCXMR.js} +11 -11
- package/chunks/{update-relaunch-QOUTZZ7Q.js → update-relaunch-MTJ32SLF.js} +5 -5
- package/chunks/{updateCheck-DYRX7M34.js → updateCheck-YFX3VY6O.js} +10 -10
- package/chunks/{useAutoAcceptIndicator-QOG7LUT3.js → useAutoAcceptIndicator-FCHNQPMD.js} +16 -16
- package/chunks/{validateNonInterActiveAuth-FJPAEMDD.js → validateNonInterActiveAuth-HUFQKCGG.js} +35 -35
- package/chunks/{version-5IC46F2Z.js → version-S5TGWCA3.js} +1 -1
- package/chunks/{web-fetch-WSW4QZBA.js → web-fetch-23M7BYHB.js} +2 -2
- package/chunks/{web-search-5QFKXWUV.js → web-search-F5PNIQUA.js} +9 -3
- package/chunks/{workflow-ZF4DLK4V.js → workflow-BLJLID2C.js} +5 -5
- package/chunks/{workspace-providers-status-4E4XWBFS.js → workspace-providers-status-UH7KLZDT.js} +17 -17
- package/chunks/{workspace-registration-store-M3QEP27F.js → workspace-registration-store-3SA3V7BA.js} +1 -1
- package/chunks/{workspace-registry-H2ENI5G2.js → workspace-registry-C6C6EKQ5.js} +11 -11
- package/chunks/{workspace-runtime-coordinator-CRRNB7PC.js → workspace-runtime-coordinator-RAI6XDJB.js} +11 -11
- package/chunks/{workspace-service-GJ2GOHKU.js → workspace-service-H7UTJYJU.js} +16 -16
- package/chunks/{workspace-skills-status-CRWHV35X.js → workspace-skills-status-FPVC7XXK.js} +15 -15
- package/chunks/{workspace-trust-reconciler-GG2JA7KI.js → workspace-trust-reconciler-JS7A6UIF.js} +16 -16
- package/chunks/{write-file-LZ4EMF36.js → write-file-GQGG7NBQ.js} +5 -5
- package/chunks/{zoom-image-J5IMS3WD.js → zoom-image-EC43KL4H.js} +2 -2
- package/cli.js +12 -12
- package/export-transcript-document.js +1 -1
- package/package.json +3 -3
- package/web-shell/assets/{abnfDiagram-VCTEODGH-S_JCiANq.js → abnfDiagram-VCTEODGH-BtpzKw3A.js} +1 -1
- package/web-shell/assets/{arc-DP-839Xn.js → arc-CQiVKZJP.js} +1 -1
- package/web-shell/assets/{architectureDiagram-5GKGNRK7-C8rCd2KK.js → architectureDiagram-5GKGNRK7-ekIPBb2d.js} +1 -1
- package/web-shell/assets/{blockDiagram-NRAW4CY4-DQR82jwr.js → blockDiagram-NRAW4CY4-BrRWkWri.js} +1 -1
- package/web-shell/assets/{c4Diagram-UCG6FXSJ-D21PNMRP.js → c4Diagram-UCG6FXSJ-qYS8CYZ3.js} +1 -1
- package/web-shell/assets/channel-DSQQnOZj.js +1 -0
- package/web-shell/assets/{chunk-2Q5K7J3B-KdDInGLi.js → chunk-2Q5K7J3B-ZasyyEZm.js} +1 -1
- package/web-shell/assets/{chunk-5VM5RSS4-ltb7zRmH.js → chunk-5VM5RSS4-C_IzCGeA.js} +1 -1
- package/web-shell/assets/{chunk-F27PBJKO-DcpQA0Ng.js → chunk-F27PBJKO-C25NZOyD.js} +1 -1
- package/web-shell/assets/{chunk-G27WJ6UU-C8NDZxcy.js → chunk-G27WJ6UU-XPOHNSGX.js} +1 -1
- package/web-shell/assets/{chunk-JWPE2WC7-hXhhHTs1.js → chunk-JWPE2WC7-BQBh0Xni.js} +1 -1
- package/web-shell/assets/{chunk-LCL6LL3I-CLaOR-Hl.js → chunk-LCL6LL3I-CoShjpX7.js} +1 -1
- package/web-shell/assets/{chunk-POPQ4Y6H-Y5_qlB1N.js → chunk-POPQ4Y6H-BwRmCDSz.js} +1 -1
- package/web-shell/assets/{chunk-SVP7TREG-BWX2Voh7.js → chunk-SVP7TREG-DSzE5-Mw.js} +1 -1
- package/web-shell/assets/{chunk-XXDRQBXY-1wmj_kXI.js → chunk-XXDRQBXY-BQSQv30h.js} +1 -1
- package/web-shell/assets/classDiagram-DTDB5LWJ-V94ta08R.js +1 -0
- package/web-shell/assets/classDiagram-v2-JRS7N3AN-V94ta08R.js +1 -0
- package/web-shell/assets/{cose-bilkent-JH36ORCC-DpLc-cdd.js → cose-bilkent-JH36ORCC-XVUVTHVo.js} +1 -1
- package/web-shell/assets/{cynefin-OW5HDTMX-DhxGiPZW.js → cynefin-OW5HDTMX-CrsKx4lQ.js} +1 -1
- package/web-shell/assets/{cynefinDiagram-5FMLGOSQ-Dl3jfBry.js → cynefinDiagram-5FMLGOSQ-BPeZEuHw.js} +1 -1
- package/web-shell/assets/{dagre-3AP2YEHR-C8FA8vJk.js → dagre-3AP2YEHR-D31cQ2Qs.js} +1 -1
- package/web-shell/assets/{diagram-S7CK7UJ4-D-quIUtW.js → diagram-S7CK7UJ4-zyiG097Q.js} +1 -1
- package/web-shell/assets/{diagram-UQ7AKVKN-Bjo09Uts.js → diagram-UQ7AKVKN-Br3vtfsy.js} +1 -1
- package/web-shell/assets/{diagram-VSXAHHWV-IoI3ttq4.js → diagram-VSXAHHWV-Bxkhjx4u.js} +1 -1
- package/web-shell/assets/{diagram-VX7I27RA-BKyOZ5SO.js → diagram-VX7I27RA-BQH8QiDk.js} +1 -1
- package/web-shell/assets/{diagram-Z3DM3KII-Cu_OHEhw.js → diagram-Z3DM3KII-B_aQ1cw0.js} +1 -1
- package/web-shell/assets/{ebnfDiagram-PWID7BFC-UVB-bbPg.js → ebnfDiagram-PWID7BFC-B9N7BRQE.js} +1 -1
- package/web-shell/assets/{erDiagram-SSCWMZ5O-l8drddto.js → erDiagram-SSCWMZ5O-Cx6Hb1Re.js} +1 -1
- package/web-shell/assets/{flowDiagram-A5DVABFB-DU1I_VAI.js → flowDiagram-A5DVABFB-DTuLP7GU.js} +1 -1
- package/web-shell/assets/{ganttDiagram-EL5Y4UJY-BLRH05uB.js → ganttDiagram-EL5Y4UJY-DYS3d-sL.js} +1 -1
- package/web-shell/assets/{gitGraphDiagram-WWUBYQGX-Czg_BkRE.js → gitGraphDiagram-WWUBYQGX-Cp0EGx04.js} +1 -1
- package/web-shell/assets/{index-CmMV8Jla.js → index-45-LkPDB.js} +1 -1
- package/web-shell/assets/{index-DyMtNYuu.js → index-H8um-iEl.js} +3 -3
- package/web-shell/assets/{infoDiagram-RXCK75RN-BpBvjkro.js → infoDiagram-RXCK75RN-9--kukiT.js} +1 -1
- package/web-shell/assets/{ishikawaDiagram-5VMMS53U-phy1l3jm.js → ishikawaDiagram-5VMMS53U-CGBdsDLD.js} +1 -1
- package/web-shell/assets/{journeyDiagram-EYS64GPL-oY-9LgVS.js → journeyDiagram-EYS64GPL-DeXhcscd.js} +1 -1
- package/web-shell/assets/{kanban-definition-3QL26DDD-slZoy-sc.js → kanban-definition-3QL26DDD-CFdvsU3b.js} +1 -1
- package/web-shell/assets/{layout-0hnn_P9l.js → layout-DAnwQ3KB.js} +1 -1
- package/web-shell/assets/{linear-7Wqe8DRy.js → linear-CTo7v7Nh.js} +1 -1
- package/web-shell/assets/{mermaid.core-BaK8n0bq.js → mermaid.core-jggSxF1i.js} +6 -6
- package/web-shell/assets/{mindmap-definition-FBJOCRG2-BedUdy_E.js → mindmap-definition-FBJOCRG2-DzIepvlJ.js} +1 -1
- package/web-shell/assets/{pegDiagram-XKGWAZYB-DQLRdmxq.js → pegDiagram-XKGWAZYB-BFGS9GJv.js} +1 -1
- package/web-shell/assets/{pieDiagram-E7YTZNPT-UC20w9-5.js → pieDiagram-E7YTZNPT-B2UUcNIT.js} +1 -1
- package/web-shell/assets/{quadrantDiagram-AXDQQJYC-CQx2Hmk3.js → quadrantDiagram-AXDQQJYC-BgM6htrX.js} +1 -1
- package/web-shell/assets/{railroadDiagram-O6MQD6OU-2UEJe_y-.js → railroadDiagram-O6MQD6OU-Dk9cS7N-.js} +1 -1
- package/web-shell/assets/{requirementDiagram-EFPCY7ZU-DOAJggB4.js → requirementDiagram-EFPCY7ZU-C9oRg7xi.js} +1 -1
- package/web-shell/assets/{sankeyDiagram-P5KCCOFB-DnQ_qJo7.js → sankeyDiagram-P5KCCOFB-B-_c7GzI.js} +1 -1
- package/web-shell/assets/{sequenceDiagram-WJ2MYXX4-DZrZUoCo.js → sequenceDiagram-WJ2MYXX4-R0M-347u.js} +1 -1
- package/web-shell/assets/{sizeCapture-X5ZJPWSS-B5G4GDQB.js → sizeCapture-X5ZJPWSS-Df0f8UAW.js} +1 -1
- package/web-shell/assets/{stateDiagram-HBIQ2CUA-Bn1cT0qF.js → stateDiagram-HBIQ2CUA-CsUEfAA-.js} +1 -1
- package/web-shell/assets/stateDiagram-v2-4QOOHH4V-CnSuTPJ2.js +1 -0
- package/web-shell/assets/{swimlanes-XN3QIQJK-Bzhcdn87.js → swimlanes-XN3QIQJK-9OGHVSrx.js} +1 -1
- package/web-shell/assets/swimlanesDiagram-VK2B7HYN-Bb7TcWQw.js +8 -0
- package/web-shell/assets/{timeline-definition-24CTP7MA-BqZ_3D10.js → timeline-definition-24CTP7MA-DAfGqS2B.js} +1 -1
- package/web-shell/assets/{vennDiagram-4TSXK5OY-z9kw1kmm.js → vennDiagram-4TSXK5OY-CKATpwHi.js} +1 -1
- package/web-shell/assets/{wardleyDiagram-VM6X3IG4-Cydp1zJW.js → wardleyDiagram-VM6X3IG4-CQHdhTrm.js} +1 -1
- package/web-shell/assets/{xychartDiagram-S5SC5T6Z-j4X1lQKo.js → xychartDiagram-S5SC5T6Z-5k9NLqlY.js} +1 -1
- package/web-shell/index.html +1 -1
- package/web-shell/assets/channel-BgGrpX_z.js +0 -1
- package/web-shell/assets/classDiagram-DTDB5LWJ-jUH7ADYs.js +0 -1
- package/web-shell/assets/classDiagram-v2-JRS7N3AN-jUH7ADYs.js +0 -1
- package/web-shell/assets/stateDiagram-v2-4QOOHH4V-BF3xtNvJ.js +0 -1
- package/web-shell/assets/swimlanesDiagram-VK2B7HYN-B753mA3E.js +0 -8
|
@@ -1567,7 +1567,7 @@ License: MIT
|
|
|
1567
1567
|
})();`,zbt=`<!doctype html>
|
|
1568
1568
|
<html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${$bt}"></head>
|
|
1569
1569
|
<body><script>${Fbt}<\/script></body></html>`;function qbt(){const e=globalThis.crypto;if(!e?.getRandomValues)throw new Ts("LEGACY_SANDBOX_UNAVAILABLE","Secure random values are required by the temporary legacy sandbox");const t=new Uint32Array(4);return e.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(8,"0")).join("")}function lue(){return new DOMException("The temporary legacy chart operation was aborted","AbortError")}function Hbt(e){if(e.signal.aborted)return Promise.reject(lue());if(!Number.isSafeInteger(e.timeoutMs)||e.timeoutMs<=0)return Promise.reject(new Ts("SCHEMA_INVALID","Legacy sandbox timeout must be a positive safe integer"));if(typeof document>"u"||!document.body)return Promise.reject(new Ts("LEGACY_SANDBOX_UNAVAILABLE","The temporary legacy sandbox requires a browser document body"));const t=qbt(),n=document.createElement("iframe");return n.hidden=!0,n.setAttribute("aria-hidden","true"),n.setAttribute("title","Temporary chart sandbox"),n.setAttribute("sandbox","allow-scripts"),n.srcdoc=zbt,new Promise((s,r)=>{let i=!1,o=!1,l;const c=()=>{window.removeEventListener("message",p),e.signal.removeEventListener("abort",f),n.onload=null,n.onerror=null,l!==void 0&&clearTimeout(l),n.remove()},u=(m,g)=>{i||(i=!0,c(),m(g))},h=m=>{i||(i=!0,c(),r(m))},f=()=>h(lue()),p=m=>{if(!(m.source!==n.contentWindow||!Oo(m.data))&&!(m.data.channel!==QW||m.data.requestId!==t)){if(m.data.type==="error"){h(new Ts("LEGACY_SANDBOX_EXECUTION_FAILED","Temporary legacy chart source failed in the isolated worker"));return}if(m.data.type==="result")try{const g=oTe(m.data.option);if(!Oo(g))throw new Ts("SCHEMA_INVALID","Temporary legacy chart source must produce a JSON object option");u(s,g)}catch(g){h(g)}}};window.addEventListener("message",p),e.signal.addEventListener("abort",f,{once:!0}),n.onerror=()=>h(new Ts("LEGACY_SANDBOX_EXECUTION_FAILED","Temporary legacy chart sandbox failed to load")),n.onload=()=>{if(!o){if(o=!0,n.onload=null,i||e.signal.aborted){f();return}n.contentWindow?.postMessage({channel:QW,type:"execute",requestId:t,source:e.source,inputData:e.inputData},"*")}},l=setTimeout(()=>h(new Ts("LEGACY_SANDBOX_TIMEOUT",`Temporary legacy chart sandbox exceeded ${e.timeoutMs}ms`)),e.timeoutMs),document.body.append(n)})}var zIe=class extends Error{constructor(t,n,s){super(n,s&&"cause"in s?{cause:s.cause}:void 0);Xe(this,"code");Xe(this,"cause");this.name="LegacySandboxError",this.code=t,this.cause=s?.cause}},Ubt=Object.freeze({maxArtifactContentBytes:5*1024*1024,maxRows:2e3,maxColumns:200,maxCells:4e4,executionTimeoutMs:5e3});function Wbt(e,t){const n={...Ubt,...e,...t};for(const[s,r]of Object.entries(n))if(!Number.isSafeInteger(r)||r<=0)throw new Ts("SCHEMA_INVALID",`legacyArtifactLimits.${s} must be a positive safe integer`);return n}async function qIe(e){let t;try{t=await e.resolveContent()}catch(i){throw e.signal.aborted||e.preserveLegacySandboxError&&i instanceof zIe?i:new Ts("REF_RESOLUTION_FAILED",e.resolutionError,{cause:i})}if(typeof t!="string")throw new Ts("SCHEMA_INVALID",e.returnTypeError);if(e.signal.aborted)throw new DOMException("The temporary legacy chart operation was aborted","AbortError");const n=Pbt(t,e.limits),s=Obt(e.source);if(!s)throw new Ts("SCHEMA_INVALID","Temporary legacy chart source is empty after sanitization");const r=await Hbt({source:s,inputData:n.source,signal:e.signal,timeoutMs:e.limits.executionTimeoutMs});return{data:n,spec:r}}async function Vbt(e){return qIe({source:e.block.source,signal:e.signal,limits:e.limits,resolveContent:()=>e.resolveArtifactContent({language:e.block.language,jobId:e.block.jobId,index:e.block.index,signal:e.signal}),resolutionError:"The temporary ChatBI ArtifactContent could not be resolved",returnTypeError:"resolveLegacyArtifactContent must return the raw CSV ArtifactContent string",preserveLegacySandboxError:e.preserveLegacySandboxError===!0})}async function Gbt(e){return qIe({source:e.block.source,signal:e.signal,limits:e.limits,resolveContent:()=>e.resolveSandboxFileContent({language:e.block.language,filePath:e.block.filePath,signal:e.signal}),resolutionError:"The temporary ChatBI sandbox file could not be resolved",returnTypeError:"resolveLegacySandboxFileContent must return a raw CSV string",preserveLegacySandboxError:e.preserveLegacySandboxError===!0})}var Kbt=Object.freeze({maxRows:2e3,maxCells:4e4,maxSeries:100,maxDepth:40,maxNodes:1e5}),Ybt=new Set(["angleAxis","aria","animation","animationDelay","animationDelayUpdate","animationDuration","animationDurationUpdate","animationEasing","animationEasingUpdate","animationThreshold","axisPointer","backgroundColor","blendMode","brush","calendar","color","darkMode","dataset","dataZoom","geo","grid","hoverLayerThreshold","legend","parallel","parallelAxis","polar","progressive","progressiveChunkMode","progressiveThreshold","radar","radiusAxis","series","singleAxis","stateAnimation","textStyle","title","tooltip","useUTC","visualMap","xAxis","yAxis"]),Xbt=new Set(["__proto__","prototype","constructor","extracsstext","renderitem","graphic","image","toolbox","dataview","transform","link","sublink","href","src","url"]),Zbt=/(?:url|uri|href|src|link)$/i,Qbt=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,cue=/(?:^|[\s("'=])(?:https?:|file:|ftp:|blob:|data:|javascript:|vbscript:|\/\/|image:\/\/)/i,Jbt=/\burl\s*\(/i,e1t=/<\s*\/?\s*[a-z][^>]*>/i,t1t=/&(?:#\d+|#x[\da-f]+|[a-z][\da-z]+);/i,n1t=/^[A-Za-z_][A-Za-z0-9_]*$/;function Qo(e){throw new Ts("SCHEMA_INVALID",e)}function JW(e,t,n){for(const s of Object.keys(e))t.has(s)||Qo(`${n}.${s} is not allowed`)}function uue(e,t){if(!Array.isArray(e)||e.length===0)return Qo(`${t} must be a non-empty array`);const n=e.map((s,r)=>typeof s!="string"||!n1t.test(s)?Qo(`${t}[${r}] must be a stable ASCII identifier`):s);return new Set(n).size!==n.length?Qo(`${t} must not contain duplicate dimensions`):n}function s1t(e,t){if(!Oo(e)||typeof e.kind!="string")return Qo("echarts-fulldata.data must be an inline or ref dataset object");if(e.kind==="inline"){JW(e,new Set(["kind","dimensions","source"]),"echarts-fulldata.data");const n=uue(e.dimensions,"echarts-fulldata.data.dimensions");if(!Array.isArray(e.source))return Qo("echarts-fulldata.data.source must be an array");e.source.forEach((r,i)=>{Array.isArray(r)||Qo(`echarts-fulldata.data.source[${i}] must be an array`),r.length!==n.length&&Qo(`echarts-fulldata.data.source[${i}] must contain ${n.length} cells`)});const s=zL(e.source,t,"echarts-fulldata.data.source");return{kind:"inline",dimensions:n,source:s}}if(e.kind==="ref"){if(JW(e,new Set(["kind","ref","format","dimensions"]),"echarts-fulldata.data"),typeof e.ref!="string"||e.ref.trim().length===0)return Qo("echarts-fulldata.data.ref must be a non-empty string");if(e.format!=="csv"&&e.format!=="json")return Qo("echarts-fulldata.data.format must be csv or json");const n=uue(e.dimensions,"echarts-fulldata.data.dimensions");return{kind:"ref",ref:e.ref,format:e.format,dimensions:n}}return Qo(`Unsupported echarts-fulldata.data.kind: ${e.kind}`)}function HIe(e){const t=Array.isArray(e.title),n=t?e.title:[e.title];for(const[s,r]of n.entries()){if(!Oo(r)||typeof r.text!="string")continue;const i=r.text.trim();if(i)return{index:s,isArray:t,title:r,text:i}}}function r1t(e){return HIe(e)?.text}function i1t(e,t){const n=HIe(e);if(!(!n||n.text!==t.trim())){if(Object.prototype.hasOwnProperty.call(n.title,"subtext")){delete n.title.text;return}if(n.isArray){e.title.splice(n.index,1);return}delete e.title}}function Iw(e){return Array.isArray(e)?e.map(t=>Iw(t)):Oo(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Iw(n)])):e}function UIe(e,t){if(e!==void 0)return(!Array.isArray(e)||e.some(n=>typeof n!="string"||n.length===0))&&Qo(`${t} must be an array of non-empty strings`),[...e]}function zL(e,t,n){if(Array.isArray(e)||Qo(`${n} must be an array`),e.length>t.maxRows)throw new Ts("LIMIT_EXCEEDED",`${n} exceeds the ${t.maxRows} row limit`);let s=0;const r=e.map((i,o)=>{if(Array.isArray(i)){const l=i.map((c,u)=>(c!==null&&!["string","number","boolean"].includes(typeof c)&&Qo(`${n}[${o}][${u}] must be a JSON scalar`),c));return s+=l.length,l}if(Oo(i)){const l={};for(const[c,u]of Object.entries(i))u!==null&&!["string","number","boolean"].includes(typeof u)&&Qo(`${n}[${o}].${c} must be a JSON scalar`),l[c]=u,s+=1;return l}return Qo(`${n}[${o}] must be an array or object`)});if(s>t.maxCells)throw new Ts("LIMIT_EXCEEDED",`${n} exceeds the ${t.maxCells} cell limit`);return r}function o1t(e,t){if(!Oo(e)||typeof e.kind!="string")return Qo("echarts.data must be an inline or ref dataset object");const n=UIe(e.dimensions,"echarts.data.dimensions");if(e.kind==="inline"){const s=zL(e.source,t,"echarts.data.source");return n?{kind:"inline",dimensions:n,source:s}:{kind:"inline",source:s}}return e.kind==="ref"?typeof e.ref!="string"||e.ref.length===0?Qo("echarts.data.ref must be a non-empty string"):e.format!==void 0&&e.format!=="csv"&&e.format!=="json"?Qo("echarts.data.format must be csv or json"):{kind:"ref",ref:e.ref,...e.format?{format:e.format}:{},...n?{dimensions:n}:{}}:Qo(`Unsupported echarts.data.kind: ${e.kind}`)}function due(e,t){if(Qbt.test(e))throw new Ts("UNSAFE_SPEC",`${t} contains an ASCII control character`);const n=e.replace(/[\n\r\t]/g,""),s=e.trim();if(cue.test(s)||cue.test(n.trim())||Jbt.test(e)||e1t.test(e)||t1t.test(e))throw new Ts("UNSAFE_SPEC",`${t} contains a URL, CSS URL, or unsafe markup`)}function a1t(e,t){for(const r of Object.keys(e))if(!Ybt.has(r))throw new Ts("UNSAFE_SPEC",`echarts.option.${r} is not allowed`);let n=0;const s=(r,i,o)=>{if(n+=1,n>t.maxNodes)throw new Ts("LIMIT_EXCEEDED",`ECharts option exceeds the ${t.maxNodes} node limit`);if(o>t.maxDepth)throw new Ts("LIMIT_EXCEEDED",`ECharts option exceeds the ${t.maxDepth} depth limit`);if(typeof r=="string"){due(r,i);return}if(Array.isArray(r)){r.forEach((l,c)=>s(l,`${i}[${c}]`,o+1));return}if(Oo(r))for(const[l,c]of Object.entries(r)){const u=l.toLowerCase();if(u==="formatter"){if(typeof c!="string")throw new Ts("UNSAFE_SPEC",`${i}.${l} must be a string`);due(c,`${i}.${l}`);continue}if(Xbt.has(u)||Zbt.test(l))throw new Ts("UNSAFE_SPEC",`${i}.${l} is not allowed`);if(l==="type"&&c==="custom")throw new Ts("UNSAFE_SPEC","Custom ECharts series are not allowed");s(c,`${i}.${l}`,o+1)}};if(s(e,"echarts.option",0),Array.isArray(e.series)&&e.series.length>t.maxSeries)throw new Ts("LIMIT_EXCEEDED",`ECharts option exceeds the ${t.maxSeries} series limit`);e.dataset!==void 0&&(Array.isArray(e.dataset)?e.dataset:[e.dataset]).forEach((i,o)=>{Oo(i)||Qo(`echarts.option.dataset[${o}] must be an object`),i.source!==void 0&&zL(i.source,t,`echarts.option.dataset[${o}].source`)})}function eV(e,t,n){if(!Oo(e))return Qo("ECharts specification must be an object");if(Object.prototype.hasOwnProperty.call(e,"option")||Object.prototype.hasOwnProperty.call(e,"data"))return Qo("Canonical markdown-chart data must be a sibling of spec; spec must contain the ECharts option directly");const s=Iw(e),r=t===void 0?void 0:o1t(t,n);return r&&Object.prototype.hasOwnProperty.call(s,"dataset")?Qo("echarts.option.dataset cannot be combined with echarts.data"):(a1t(s,n),{option:s,data:r})}function l1t(e,t){if(!Oo(e))return Qo("echarts-fulldata must contain an object");if(JW(e,new Set(["version","data","option"]),"echarts-fulldata"),e.version!==1)throw new Ts("UNSUPPORTED_VERSION","Only echarts-fulldata version 1 is supported");if(!Object.prototype.hasOwnProperty.call(e,"data"))return Qo("echarts-fulldata.data is required");if(!Oo(e.option))return Qo("echarts-fulldata.option must be an object");const n=s1t(e.data,t);return eV(e.option,n,t)}function c1t(e){const t="default"in e?e.default:e;if(!t||typeof t.init!="function")throw new Ts("RUNTIME_LOAD_FAILED","The supplied ECharts runtime has no init function");return t}function hue(e,t){const n=zL(e.source,t,"resolvedDataset.source"),s=e.dimensions?UIe(e.dimensions,"resolvedDataset.dimensions"):void 0;return s?{data:{kind:"inline",dimensions:s,source:n},option:{dimensions:s,source:n}}:{data:{kind:"inline",source:n},option:{source:n}}}var u1t={light:{background:"#ffffff",foreground:"#343434",legendText:"#555555",titleText:"#343434",subtext:"#aaaaaa",axisLine:"#5d666f",valueAxisLine:"#6E7079",axisLabel:"#838d95",splitLine:"#e0e6f1",splitAreaA:"rgba(250,250,250,0.2)",splitAreaB:"rgba(210,219,238,0.2)",seriesBorder:"#ffffff",pointer:"#7c8a96",tooltipBg:"#ffffff",primary:"#6250f9",palette:["#6250F9","#33AFA9","#AB7BFF","#5F99F9","#A9AFFF","#60CCC5","#C2A5FF","#8EB8FE","#E0E3FE","#98E3DD","#E8E1FA","#D7E6FF"]},dark:{background:"#0d0d0d",foreground:"#f4f7ff",legendText:"#c8cad0",titleText:"#e0e2e8",subtext:"#8a8d93",axisLine:"#555a63",valueAxisLine:"#555a63",axisLabel:"#9da1a8",splitLine:"#3a3e47",splitAreaA:"rgba(60,60,70,0.2)",splitAreaB:"rgba(80,80,90,0.2)",seriesBorder:"#2a2d35",pointer:"#6a707a",tooltipBg:"rgba(30, 32, 40, 0.95)",primary:"#8aa0ff",palette:["#8EA0FF","#61D6D1","#C8A7FF","#8EB8FE","#C7CCFF","#8DE7E2","#D8C5FF","#B8D2FF","#EEF0FF","#C2F0ED","#F0EAFE","#E8F1FF"]}};function Qm(e,t){const n={...Iw(e),...t};for(const[s,r]of Object.entries(e)){const i=t[s];Oo(r)&&Oo(i)&&(n[s]=Qm(r,i))}return n}function XI(e,t){return Array.isArray(e)?e.map(n=>Oo(n)?Qm(t,n):n):Oo(e)?Qm(t,e):e??Iw(t)}function WIe(e){const t=n=>Oo(n)?{...n,appendToBody:!1,confine:!0,enterable:!1,renderMode:"richText"}:n;return Array.isArray(e)?e.map(t):t(e)}function YE(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function d1t(e,t){const n=s=>{if(!YE(s,"top")&&!YE(s,"bottom"))return Qm(t,s);const r=Iw(t);return delete r.top,delete r.bottom,Qm(r,s)};return Array.isArray(e)?e.map(s=>Oo(s)?n(s):s):Oo(e)?n(e):e??Iw(t)}var h1t=740,VIe=10,fue=h1t*VIe/100,f1t=24,p1t=24,pue=16,m1t=24;function GIe(e){if(typeof e=="number")return Number.isFinite(e)&&e>=0&&e<=fue?e:null;if(typeof e!="string")return null;const t=e.trim();if(t==="top")return 0;const n=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+))%$/.exec(t);if(!n)return null;const s=Number(n[1]);return Number.isFinite(s)&&s>=0&&s<=VIe?fue:null}function g1t(e){return["text","subtext"].some(t=>typeof e[t]=="string"&&e[t].trim().length>0)}function v1t(e){return e.show===!1||!g1t(e)?null:YE(e,"top")?GIe(e.top):YE(e,"bottom")?null:0}function w1t(e){return e.show===!1||!YE(e,"top")?null:GIe(e.top)}function mue(e){return Array.isArray(e)?e.filter(Oo):Oo(e)?[e]:[]}function y1t(e,t){const n=mue(e).flatMap(r=>{const i=v1t(r);return i===null?[]:[i+f1t+pue]}),s=mue(t).flatMap(r=>{const i=w1t(r);return i===null?[]:[i+p1t+pue]});return Math.max(m1t,...n,...s)}function gue(e,t){return Array.isArray(e)?e.map((n,s)=>Oo(n)?Qm(t(s),n):n):Oo(e)?Qm(t(0),e):e}function vue(e,t){const n=typeof e.type=="string"?e.type:void 0;let s={emphasis:{focus:"series",itemStyle:{borderColor:t.seriesBorder,borderWidth:2}},labelLayout:{hideOverlap:!0}};n==="line"?s=Qm(s,{lineStyle:{width:2},itemStyle:{borderWidth:1},symbol:"circle",symbolSize:4}):n==="bar"?s=Qm(s,{barCategoryGap:"48%",barMaxWidth:42,itemStyle:{borderRadius:[3,3,0,0]}}):n==="pie"&&(s=Qm(s,{itemStyle:{borderColor:t.seriesBorder,borderWidth:2}}));const r=Qm(s,e);return Object.prototype.hasOwnProperty.call(e,"tooltip")&&(r.tooltip=WIe(XI(e.tooltip,{appendToBody:!1,confine:!0,enterable:!1,renderMode:"richText"}))),r}var KIe=new Set(["pie","funnel","gauge","radar","treemap"]),b1t=new Set([...KIe,"graph","chord","themeRiver"]);function YIe(e){return Array.isArray(e.series)?e.series.filter(Oo):Oo(e.series)?[e.series]:[]}function x1t(e){if(Object.prototype.hasOwnProperty.call(e,"legend"))return!0;const t=YIe(e);return t.some(n=>typeof n.type=="string"&&b1t.has(n.type))?!0:t.filter(n=>typeof n.name=="string"&&n.name.trim().length>0).length>1}function _1t(e){if(!Object.prototype.hasOwnProperty.call(e,"xAxis")&&!Object.prototype.hasOwnProperty.call(e,"yAxis"))return"item";const t=YIe(e);return t.length>0&&t.every(n=>typeof n.type=="string"&&KIe.has(n.type))?"item":"axis"}function k1t(e){return e==null||e==="light"?"light":e==="dark"?"dark":void 0}function S1t(e,t="light"){const n=u1t[t],s=Iw(e);return s.backgroundColor??=n.background,s.color??=[...n.palette],s.textStyle=XI(s.textStyle,{color:n.foreground,fontFamily:"'pingfang SC', 'helvetica neue', arial, 'hiragino sans gb', 'microsoft yahei ui', 'microsoft yahei', sans-serif"}),s.title!==void 0&&(s.title=XI(s.title,{textStyle:{color:n.titleText},subtextStyle:{color:n.subtext}})),s.tooltip=WIe(XI(s.tooltip,{trigger:_1t(e),appendToBody:!1,confine:!0,enterable:!1,renderMode:"richText",backgroundColor:n.tooltipBg,borderColor:n.splitLine,borderWidth:1,padding:[8,10],textStyle:{color:n.titleText,fontSize:12},axisPointer:{lineStyle:{color:n.pointer,width:1},crossStyle:{color:n.pointer,width:1}}})),x1t(e)&&(s.legend=d1t(s.legend,{type:"scroll",bottom:8,padding:[4,16],textStyle:{color:n.legendText,fontSize:12},pageIconColor:n.primary,pageIconInactiveColor:n.splitLine,pageTextStyle:{color:n.legendText}})),s.grid=XI(s.grid,{top:y1t(s.title,s.legend),right:36,bottom:48,left:24,containLabel:!0}),s.xAxis!==void 0&&(s.xAxis=gue(s.xAxis,()=>({axisLine:{show:!0,lineStyle:{color:n.axisLine}},axisTick:{show:!0,lineStyle:{color:n.axisLine}},axisLabel:{color:n.axisLabel,fontSize:12,hideOverlap:!0},splitLine:{show:!1,lineStyle:{color:n.splitLine}},splitArea:{show:!1,areaStyle:{color:[n.splitAreaA,n.splitAreaB]}},nameTextStyle:{color:n.axisLabel}}))),s.yAxis!==void 0&&(s.yAxis=gue(s.yAxis,r=>({alignTicks:!0,axisLine:{show:!1,lineStyle:{color:n.valueAxisLine}},axisTick:{show:!1,lineStyle:{color:n.valueAxisLine}},axisLabel:{color:n.axisLabel,fontSize:12,hideOverlap:!0},splitLine:{show:r===0,lineStyle:{color:n.splitLine}},splitArea:{show:!1,areaStyle:{color:[n.splitAreaA,n.splitAreaB]}},nameGap:12,nameTextStyle:{color:n.axisLabel,align:r===0?"left":"right"}}))),Array.isArray(s.series)?s.series=s.series.map(r=>Oo(r)?vue(r,n):r):Oo(s.series)&&(s.series=vue(s.series,n)),s}var jF={dispose(){}};function C1t(e={}){const t={...Kbt,...e.limits},n=e.legacySandbox?.resolveLegacyArtifactContent,s=e.legacySandbox?.resolveLegacySandboxFileContent,r=e.legacySandbox?Wbt({maxRows:t.maxRows,maxCells:t.maxCells},void 0):void 0,i=e.loadECharts??(async()=>await $e(()=>import("./index-DohPy72Z.js"),[])),o=async(l,c)=>{if(e.validateDataRef&&!e.validateDataRef(l.ref))throw new Ts("REF_REJECTED","The host rejected the chart data reference");if(!e.resolveDataRef)throw new Ts("REF_RESOLVER_MISSING","A resolveDataRef callback is required");let u;try{u=await e.resolveDataRef(l.ref,{format:l.format,dimensions:l.dimensions,signal:c})}catch(f){if(c.aborted)return;throw new Ts("REF_RESOLUTION_FAILED","The chart dataset could not be resolved",{cause:f})}if(c.aborted)return;const h=u.dimensions||!l.dimensions?u:{...u,dimensions:l.dimensions};return hue(h,t).data};return{id:"echarts",aliases:["echarts-fulldata"],matchLanguage:Abt,parse(l,c){return c.language==="echarts-fulldata"?l1t(l,t):eV(l,c.data,t)},parseSource(l,c){return FIe(c.language)?{option:{},data:void 0,legacyEChartSandboxFile:Nbt(c.rawLanguage??c.language,l)}:{option:{},data:void 0,legacyEChartQuery:jbt(c.language,l)}},getTitle(l){return r1t(l.option)},async materialize(l,c){if(!l.legacyEChartQuery&&!l.legacyEChartSandboxFile){if(l.data?.kind==="ref"){const p=await o(l.data,c.signal);return p?{parsed:{...l,data:p},data:p}:{parsed:l,data:c.data}}return{parsed:l,data:l.data}}if(l.legacyEChartQuery&&!n)throw new Ts("REF_RESOLVER_MISSING","legacySandbox is required for this temporary ChatBI query fence");if(l.legacyEChartSandboxFile&&!s)throw new Ts("REF_RESOLVER_MISSING","legacySandbox is required for this temporary ChatBI sandbox-file fence");let u;try{l.legacyEChartSandboxFile?u=await Gbt({block:l.legacyEChartSandboxFile,signal:c.signal,resolveSandboxFileContent:s,limits:r,preserveLegacySandboxError:e.legacySandbox!==void 0}):u=await Vbt({block:l.legacyEChartQuery,signal:c.signal,resolveArtifactContent:n,limits:r,preserveLegacySandboxError:!0})}catch(p){if(c.signal.aborted)return{parsed:l,data:c.data};throw p instanceof Ts||p instanceof zIe?p:new Ts("REF_RESOLUTION_FAILED","The temporary ChatBI chart could not be resolved",{cause:p})}if(c.signal.aborted)return{parsed:l,data:c.data};let h;try{h=oTe(u,{maxDepth:t.maxDepth,maxNodes:t.maxNodes})}catch(p){throw p instanceof Ts?p:new Ts("SCHEMA_INVALID","Temporary ChatBI resolver returned a non-JSON result",{cause:p})}if(!Oo(h))return Qo("Temporary ChatBI resolver must return an object");if(!Object.prototype.hasOwnProperty.call(h,"data")||!Object.prototype.hasOwnProperty.call(h,"spec"))return Qo("Temporary ChatBI resolver must return data and spec");const f=eV(h.spec,h.data,t);return f.data?.kind!=="inline"?Qo("Temporary ChatBI resolver must return inline data"):{parsed:f,data:f.data}},async mount(l,c,u){if(c.legacyEChartQuery||c.legacyEChartSandboxFile)return Qo("Temporary ChatBI charts must be materialized before mounting");const h=Iw(c.option);if(u.externalizedTitle&&i1t(h,u.externalizedTitle),c.data){let w;if(c.data.kind==="inline")w=c.data;else{const b=await o(c.data,u.signal);if(!b)return jF;w=b}const y=hue(w,t);h.dataset=y.option}if(u.signal.aborted)return jF;let f;try{f=c1t(await i())}catch(w){throw w instanceof Ts?w:new Ts("RUNTIME_LOAD_FAILED","The ECharts runtime could not be loaded",{cause:w})}if(u.signal.aborted)return jF;let p,m;try{const w=typeof u.theme=="string"||Oo(u.theme)?u.theme:void 0;p=f.init(l,w);const y=k1t(u.theme),b=e.defaultStyle===!1||!y?h:S1t(h,y);p.setOption(b,{notMerge:!0,lazyUpdate:!1}),e.resizeObserver!==!1&&typeof ResizeObserver<"u"&&(m=new ResizeObserver(()=>p?.resize()),m.observe(l))}catch(w){try{m?.disconnect()}catch{}try{p?.dispose()}catch{}throw new Ts("RENDER_FAILED","ECharts failed to render the chart",{cause:w})}const g=p;let v=!1;return{resize:()=>g.resize(),dispose(){v||(v=!0,m?.disconnect(),g.dispose())}}}}}var bQ=d.createContext(null);function T1t(e){if(d.isValidElement(e))return typeof e.props.children=="string"?e.props.children:void 0}function I1t(e){const t=e.source??T1t(e.children),n=d.useMemo(()=>({registry:e.registry,theme:e.theme,streaming:e.streaming??!1,source:t,loadingLabel:e.loadingLabel,labels:e.labels,onError:e.onError}),[e.registry,e.theme,e.streaming,t,e.loadingLabel,e.labels,e.onError]);return d.createElement(bQ.Provider,{value:n},e.children)}function E1t(e){const t=d.useContext(bQ);if(!t)throw new Error("MarkdownChartBlock must be rendered inside MarkdownChartProvider");const n=d.useRef(null),s=e.streaming??t.streaming,r=e.loadingLabel??t.loadingLabel,i=e.labels??t.labels,o=d.useMemo(()=>lTe(i),[i]);d.useEffect(()=>{const c=n.current;if(!c)return;const u=new Hut(t.registry);let h=!1;return u.render(c,{language:e.language,source:e.source,theme:t.theme,streaming:s,...r!==void 0?{loadingLabel:r}:{},...i!==void 0?{labels:i}:{}}).catch(f=>{h||(c.classList.add("markdown-chart-error"),c.setAttribute("role","alert"),c.textContent=o.chartUnavailable,t.onError?.(f,{language:e.language,source:e.source}))}),()=>{h=!0,u.dispose()}},[t.registry,t.theme,t.onError,r,i,o,e.language,e.source,s]);const l=["markdown-chart-placeholder",s?"markdown-chart-streaming":void 0,e.className].filter(Boolean).join(" ");return d.createElement("div",{ref:n,className:l,style:e.style,"aria-label":o.chart,"aria-busy":s||void 0,"data-markdown-chart-complete":String(!s)})}function R1t(e,t){const n=t?.position?.start?.offset,s=t?.position?.end?.offset;if(e===void 0||n===void 0||s===void 0)return!1;const r=e.lastIndexOf(`
|
|
1570
|
-
`,Math.max(0,n-1))+1,i=e.slice(r,n),o=/^(?: {0,3}>[ \t]?)+$/.test(i)?r:n;return uTe(e.slice(o,s))||e.slice(s).trim().length>0}function XIe(e,t){return e===yN||t?.has(e)===!0}function A1t(e={}){return{code({node:n,...s}){return d.createElement("code",s)},pre:function({node:s,children:r,...i}){const o=d.useContext(bQ);if(d.isValidElement(r)){const l=r,u=/(?:^|\s)language-([^\s]+)/.exec(l.props.className??"")?.[1],h=u?.toLowerCase();if(u&&h&&XIe(h,o?.registry)){const f=d.Children.toArray(l.props.children).map(p=>typeof p=="string"||typeof p=="number"?String(p):"").join("");return d.createElement(E1t,{language:u,source:f,streaming:o?.streaming===!0&&!R1t(o.source,s),...e.chartClassName?{className:e.chartClassName}:{},...e.chartStyle?{style:e.chartStyle}:{}})}}return d.createElement("pre",i,r)}}}const j1t=3e4,N1t=["artifact://","session-file://"],M1t=/^[a-z]:/i;function P1t(e={}){const{resolveDataRef:t,validateDataRef:n=B1t,...s}=e,r=e.validateDataRef===void 0,i=t?async(o,l)=>{const c=r?ZIe(o):o;if(!c)throw new Error("Chart data reference is not supported.");return F1t(Promise.resolve(t(c,l)),"Chart data reference resolution")}:void 0;return new Iut().register(C1t({...s,resolveDataRef:i,validateDataRef:n}))}const L1t={registry:P1t()};function D1t(e,t={}){const n=A1t(t).pre;if(!n)throw new Error("markdown-chart React adapter did not provide a pre renderer");return function({children:r,...i}){if(d.isValidElement(r)){const o=r,c=/(?:^|\s)language-([^\s]+)/.exec(o.props.className??"")?.[1]?.toLowerCase();if(c&&XIe(c,e))return d.createElement(n,i,r)}return d.createElement(d.Fragment,null,r)}}function O1t({customization:e,source:t,streaming:n,theme:s,children:r}){const i=$1t(e.labels),{t:o}=mt();return a.jsx(I1t,{registry:e.registry,source:t,streaming:n,theme:s,loadingLabel:e.loadingLabel??o("echartsChart.rendering"),labels:i,onError:e.onError,children:r})}function $1t(e){const{t}=mt();return d.useMemo(()=>({chartUnavailable:t("echartsChart.renderFailed"),viewMode:t("echartsChart.viewMode"),chart:t("echartsChart.chart"),data:t("echartsChart.data"),showChart:t("echartsChart.showChart"),showData:t("echartsChart.showData"),noData:t("echartsChart.noData"),tableNotice:({visibleRows:n,totalRows:s,visibleColumns:r,totalColumns:i})=>t("echartsChart.tableNotice",{visibleRows:n,totalRows:s,visibleColumns:r,totalColumns:i,omittedRows:s-n,omittedColumns:i-r}),...e}),[e,t])}function wue(e){return/\s/.test(e)||Array.from(e).some(t=>{const n=t.codePointAt(0);return n!==void 0&&(n<=31||n===127)})}function ZIe(e){if(e.trim()!==e||!e||wue(e))return;const t=e.toLowerCase(),n=N1t.find(o=>t.startsWith(o));if(!n)return;const s=e.slice(n.length);if(!s||/[?#\\]/.test(s))return;let r;try{r=decodeURIComponent(s)}catch{return}if(/[%?#\\]/.test(r)||wue(r))return;const i=r.split("/");if(!i.some(o=>o.length===0||o==="."||o===".."||M1t.test(o)))return`${n}${i.join("/")}`}function B1t(e){return ZIe(e)!==void 0}function F1t(e,t){return new Promise((n,s)=>{const r=globalThis.setTimeout(()=>s(new Error(`${t} timed out.`)),j1t);e.then(n,s).finally(()=>globalThis.clearTimeout(r))})}const z1t="_content_1ik04_1",q1t="_streamingPlainText_1ik04_11",H1t="_inlineCode_1ik04_135",U1t="_link_1ik04_147",W1t="_tableWrapper_1ik04_157",V1t="_table_1ik04_157",G1t="_image_1ik04_187",K1t="_codeBlock_1ik04_195",Y1t="_codeBlockHeader_1ik04_204",X1t="_codeBlockLang_1ik04_213",Z1t="_codeBlockCopy_1ik04_221",Q1t="_codeBlockContent_1ik04_244",J1t="_codeBlockPlain_1ik04_264",ext="_mermaidBlock_1ik04_282",txt="_mermaidInline_1ik04_294",nxt="_mermaidLoading_1ik04_313",sxt="_mermaidActions_1ik04_320",rxt="_mermaidZoomWrapper_1ik04_325",ixt="_mermaidDragging_1ik04_333",Li={content:z1t,streamingPlainText:q1t,inlineCode:H1t,link:U1t,tableWrapper:W1t,table:V1t,image:G1t,codeBlock:K1t,codeBlockHeader:Y1t,codeBlockLang:X1t,codeBlockCopy:Z1t,codeBlockContent:Q1t,codeBlockPlain:J1t,mermaidBlock:ext,mermaidInline:txt,mermaidLoading:nxt,mermaidActions:sxt,mermaidZoomWrapper:rxt,mermaidDragging:ixt},oxt=32e3,axt=new Set(["javascript","typescript","python","rust","go","java","c","cpp","csharp","fsharp","ruby","php","swift","kotlin","scala","bash","fish","powershell","sql","html","css","scss","json","yaml","toml","xml","markdown","dockerfile","graphql","lua","r","matlab","perl","haskell","elixir","erlang","clojure","dart","vue","svelte","astro","tsx","jsx","diff"]),yue={"c++":"cpp","c#":"csharp","f#":"fsharp",ts:"typescript",js:"javascript",py:"python",rb:"ruby",rs:"rust",kt:"kotlin",cs:"csharp",sh:"bash",zsh:"bash",shell:"bash",yml:"yaml",md:"markdown",golang:"go",ps1:"powershell",docker:"dockerfile"};function xQ(e){const t=(e||"").toLowerCase(),n=Object.hasOwn(yue,t)?yue[t]:t,s=axt.has(n)?n:"text";return{label:(e||"").trim()||"text",lang:n,resolvedLang:s}}const QIe=/^(https?:|mailto:)/i,lxt=/^data:image\/(png|jpeg|gif|webp|bmp);base64,/i,JIe=/^data:image\/(png|jpeg|gif|webp);base64,[A-Za-z0-9+/]*={0,2}$/i;function _5(e){if(!e)return!1;const t=e.trim();return t?t.startsWith("#")||t.startsWith("/")&&!t.startsWith("//")?!0:QIe.test(t):!1}function bk(e,t=!1){if(!e)return!1;const n=e.trim();return n?t?JIe.test(n):n.startsWith("#")||n.startsWith("/")&&!n.startsWith("//")||lxt.test(n)?!0:QIe.test(n):!1}let bue,xue=Promise.resolve(),cxt=0;const uxt=5e4,dxt=500,hxt=1e4;function fxt({code:e}){const{t}=mt(),n=zw(),s=dl()!=="interactive",[r,i]=d.useState(null),[o,l]=d.useState(null),[c,u]=d.useState("diagram"),[h,f]=vT(),[p,m]=d.useState(1),[g,v]=d.useState({x:0,y:0}),[w,y]=d.useState(!1),b=d.useRef(null),x=n==="light"?"default":"dark",_=.5,S=3,E=.25,T=()=>{m(N=>Math.min(S,Math.round((N+E)*100)/100))},R=()=>{m(N=>Math.max(_,Math.round((N-E)*100)/100))},C=d.useCallback(()=>{b.current=null,y(!1),m(1),v({x:0,y:0})},[]),I=d.useCallback(N=>{N.preventDefault(),y(!0),b.current={startX:N.clientX,startY:N.clientY,origX:g.x,origY:g.y}},[g]);d.useEffect(()=>{if(!w)return;const N=O=>{if(!b.current)return;const B=O.clientX-b.current.startX,D=O.clientY-b.current.startY,U=1500;v({x:b.current.origX+B,y:Math.max(-U,Math.min(U,b.current.origY+D))})},j=()=>{b.current=null,y(!1)};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",j),window.addEventListener("blur",j),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",j),window.removeEventListener("blur",j)}},[w]),d.useEffect(()=>{m(1),v({x:0,y:0})},[e]),d.useEffect(()=>{let N=!1;i(null),l(null);const j=setTimeout(()=>{$e(()=>import("./mermaid.core-BaK8n0bq.js").then(O=>O.cb),[]).then(async O=>{if(N)return;const B=O.default,D=`${x}:${s?"hardened":"runtime"}`,U=xue.then(async()=>{if(N)throw new Error("Mermaid render skipped");bue!==D&&(B.initialize({startOnLoad:!1,theme:x,securityLevel:"strict",suppressErrorRendering:!0,...s?{maxTextSize:uxt,maxEdges:dxt}:{},flowchart:{wrappingWidth:300,useMaxWidth:!1}}),bue=D);const F=`mermaid-${++cxt}`;if(!s)return B.render(F,e.trim());let M;try{return await Promise.race([B.render(F,e.trim()),new Promise((X,ee)=>{M=setTimeout(()=>ee(new Error("Mermaid render timed out")),hxt)})])}finally{M!==void 0&&clearTimeout(M)}});xue=U.then(()=>{},()=>{});const{svg:V}=await U;N||i(V)}).catch(O=>{N||l(O instanceof Error?O.message:"Mermaid render failed")})},150);return()=>{N=!0,clearTimeout(j)}},[e,s,x]);const A=()=>{tf(e).then(()=>{f()}).catch(rg)};return o?a.jsxs("div",{className:Li.codeBlock,children:[a.jsx("div",{className:Li.codeBlockHeader,children:a.jsx("span",{className:Li.codeBlockLang,children:t("mermaid.errorLabel")})}),a.jsx("pre",{className:`${Li.codeBlockContent} ${Li.codeBlockPlain}`,children:a.jsx("code",{children:e})})]}):a.jsxs("div",{className:Li.codeBlock,children:[a.jsxs("div",{className:Li.codeBlockHeader,children:[a.jsx("span",{className:Li.codeBlockLang,children:t("mermaid.label")}),a.jsxs("span",{className:Li.mermaidActions,children:[c==="diagram"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:Li.codeBlockCopy,onClick:R,title:t("mermaid.zoomOut"),disabled:p<=_,children:t("mermaid.zoomOut")}),a.jsx("button",{className:Li.codeBlockCopy,onClick:C,title:t("mermaid.zoomReset"),disabled:p===1&&g.x===0&&g.y===0,children:t("mermaid.zoomReset")}),a.jsx("button",{className:Li.codeBlockCopy,onClick:T,title:t("mermaid.zoomIn"),disabled:p>=S,children:t("mermaid.zoomIn")})]}),a.jsx("button",{className:Li.codeBlockCopy,onClick:()=>u(c==="diagram"?"code":"diagram"),children:t(c==="diagram"?"mermaid.viewCode":"mermaid.viewDiagram")}),a.jsx("button",{className:Li.codeBlockCopy,onClick:A,children:t(h?"code.copied":"code.copy")})]})]}),c==="code"?a.jsx("pre",{className:`${Li.codeBlockContent} ${Li.codeBlockPlain}`,children:a.jsx("code",{children:e})}):r?a.jsx("div",{className:`${Li.mermaidZoomWrapper} ${w?Li.mermaidDragging:""}`,onMouseDown:I,onDoubleClick:C,children:a.jsx("div",{className:`${Li.mermaidBlock} ${Li.mermaidInline}`,style:{transform:`translate(${g.x}px, ${g.y}px) scale(${p})`,transformOrigin:"top center"},dangerouslySetInnerHTML:{__html:r}})}):a.jsx("div",{className:`${Li.mermaidBlock} ${Li.mermaidLoading} ${Li.mermaidInline}`,children:a.jsx("span",{children:t("mermaid.rendering")})})]})}function pxt({className:e,children:t,isStreaming:n}){const{t:s}=mt(),r=zw(),i=dl()==="document",[o,l]=d.useState(null),[c,u]=vT(),{label:h,lang:f,resolvedLang:p}=xQ(e3e(e)),m=String(t).replace(/\n$/,""),g=r==="light"?"github-light-default":"github-dark-default";d.useEffect(()=>{if(i||n||f==="mermaid"||p==="text"||KW(m)){l(null);return}const w=fwt(m,p,g);if(w!==null){l(w);return}const y=Jce(m,p,g,!0);if(y!==null){l(y);return}l(null);let b=!1;return TIe(p).then(()=>{if(b)return;const x=Jce(m,p,g,!0);x!==null&&l(x)}).catch(x=>{b||(console.warn("[web-shell] highlight failed for lang=%s",p,x),l(null))}),()=>{b=!0}},[m,i,f,p,g,n]);const v=()=>{tf(m).then(()=>{u()}).catch(rg)};return f==="mermaid"&&!n&&!i?a.jsx(fxt,{code:m}):a.jsxs("div",{className:Li.codeBlock,children:[a.jsxs("div",{className:Li.codeBlockHeader,children:[a.jsx("span",{className:Li.codeBlockLang,children:h}),a.jsx("button",{className:Li.codeBlockCopy,onClick:v,children:s(c?"code.copied":"code.copy")})]}),!i&&!n&&o!==null?a.jsx("div",{className:Li.codeBlockContent,dangerouslySetInnerHTML:{__html:o}}):a.jsx("pre",{className:`${Li.codeBlockContent} ${Li.codeBlockPlain}`,children:a.jsx("code",{children:m})})]})}function e3e(e){const t=e?.match(/(?:^|\s)language-([^\s]+)/)?.[1]??"",n=t.match(/^([\w+.#-]+)/);if(!n)return"";const s=n[1]??"",r=t[s.length];return!r||r==="{"||r===":"?s:""}function mxt({children:e}){return a.jsx("code",{className:Li.inlineCode,children:e})}function _ue({children:e}){return a.jsx("div",{className:Li.tableWrapper,children:a.jsx("table",{className:Li.table,children:e})})}const t3e=d.createContext(!1),n3e=d.createContext(void 0),s3e=d.createContext(void 0);function gxt(e,t,n){if(!n||e===void 0)return!1;const s=t?.position?.start.offset,r=t?.position?.end.offset;return s===void 0||r===void 0?!1:!uTe(e.slice(s,r))&&e.slice(r).trim().length===0}function vxt({className:e,children:t,node:n}){const s=d.useContext(t3e),r=d.useContext(s3e);return e?.startsWith("language-")||typeof t=="string"&&t.includes(`
|
|
1570
|
+
`,Math.max(0,n-1))+1,i=e.slice(r,n),o=/^(?: {0,3}>[ \t]?)+$/.test(i)?r:n;return uTe(e.slice(o,s))||e.slice(s).trim().length>0}function XIe(e,t){return e===yN||t?.has(e)===!0}function A1t(e={}){return{code({node:n,...s}){return d.createElement("code",s)},pre:function({node:s,children:r,...i}){const o=d.useContext(bQ);if(d.isValidElement(r)){const l=r,u=/(?:^|\s)language-([^\s]+)/.exec(l.props.className??"")?.[1],h=u?.toLowerCase();if(u&&h&&XIe(h,o?.registry)){const f=d.Children.toArray(l.props.children).map(p=>typeof p=="string"||typeof p=="number"?String(p):"").join("");return d.createElement(E1t,{language:u,source:f,streaming:o?.streaming===!0&&!R1t(o.source,s),...e.chartClassName?{className:e.chartClassName}:{},...e.chartStyle?{style:e.chartStyle}:{}})}}return d.createElement("pre",i,r)}}}const j1t=3e4,N1t=["artifact://","session-file://"],M1t=/^[a-z]:/i;function P1t(e={}){const{resolveDataRef:t,validateDataRef:n=B1t,...s}=e,r=e.validateDataRef===void 0,i=t?async(o,l)=>{const c=r?ZIe(o):o;if(!c)throw new Error("Chart data reference is not supported.");return F1t(Promise.resolve(t(c,l)),"Chart data reference resolution")}:void 0;return new Iut().register(C1t({...s,resolveDataRef:i,validateDataRef:n}))}const L1t={registry:P1t()};function D1t(e,t={}){const n=A1t(t).pre;if(!n)throw new Error("markdown-chart React adapter did not provide a pre renderer");return function({children:r,...i}){if(d.isValidElement(r)){const o=r,c=/(?:^|\s)language-([^\s]+)/.exec(o.props.className??"")?.[1]?.toLowerCase();if(c&&XIe(c,e))return d.createElement(n,i,r)}return d.createElement(d.Fragment,null,r)}}function O1t({customization:e,source:t,streaming:n,theme:s,children:r}){const i=$1t(e.labels),{t:o}=mt();return a.jsx(I1t,{registry:e.registry,source:t,streaming:n,theme:s,loadingLabel:e.loadingLabel??o("echartsChart.rendering"),labels:i,onError:e.onError,children:r})}function $1t(e){const{t}=mt();return d.useMemo(()=>({chartUnavailable:t("echartsChart.renderFailed"),viewMode:t("echartsChart.viewMode"),chart:t("echartsChart.chart"),data:t("echartsChart.data"),showChart:t("echartsChart.showChart"),showData:t("echartsChart.showData"),noData:t("echartsChart.noData"),tableNotice:({visibleRows:n,totalRows:s,visibleColumns:r,totalColumns:i})=>t("echartsChart.tableNotice",{visibleRows:n,totalRows:s,visibleColumns:r,totalColumns:i,omittedRows:s-n,omittedColumns:i-r}),...e}),[e,t])}function wue(e){return/\s/.test(e)||Array.from(e).some(t=>{const n=t.codePointAt(0);return n!==void 0&&(n<=31||n===127)})}function ZIe(e){if(e.trim()!==e||!e||wue(e))return;const t=e.toLowerCase(),n=N1t.find(o=>t.startsWith(o));if(!n)return;const s=e.slice(n.length);if(!s||/[?#\\]/.test(s))return;let r;try{r=decodeURIComponent(s)}catch{return}if(/[%?#\\]/.test(r)||wue(r))return;const i=r.split("/");if(!i.some(o=>o.length===0||o==="."||o===".."||M1t.test(o)))return`${n}${i.join("/")}`}function B1t(e){return ZIe(e)!==void 0}function F1t(e,t){return new Promise((n,s)=>{const r=globalThis.setTimeout(()=>s(new Error(`${t} timed out.`)),j1t);e.then(n,s).finally(()=>globalThis.clearTimeout(r))})}const z1t="_content_1ik04_1",q1t="_streamingPlainText_1ik04_11",H1t="_inlineCode_1ik04_135",U1t="_link_1ik04_147",W1t="_tableWrapper_1ik04_157",V1t="_table_1ik04_157",G1t="_image_1ik04_187",K1t="_codeBlock_1ik04_195",Y1t="_codeBlockHeader_1ik04_204",X1t="_codeBlockLang_1ik04_213",Z1t="_codeBlockCopy_1ik04_221",Q1t="_codeBlockContent_1ik04_244",J1t="_codeBlockPlain_1ik04_264",ext="_mermaidBlock_1ik04_282",txt="_mermaidInline_1ik04_294",nxt="_mermaidLoading_1ik04_313",sxt="_mermaidActions_1ik04_320",rxt="_mermaidZoomWrapper_1ik04_325",ixt="_mermaidDragging_1ik04_333",Li={content:z1t,streamingPlainText:q1t,inlineCode:H1t,link:U1t,tableWrapper:W1t,table:V1t,image:G1t,codeBlock:K1t,codeBlockHeader:Y1t,codeBlockLang:X1t,codeBlockCopy:Z1t,codeBlockContent:Q1t,codeBlockPlain:J1t,mermaidBlock:ext,mermaidInline:txt,mermaidLoading:nxt,mermaidActions:sxt,mermaidZoomWrapper:rxt,mermaidDragging:ixt},oxt=32e3,axt=new Set(["javascript","typescript","python","rust","go","java","c","cpp","csharp","fsharp","ruby","php","swift","kotlin","scala","bash","fish","powershell","sql","html","css","scss","json","yaml","toml","xml","markdown","dockerfile","graphql","lua","r","matlab","perl","haskell","elixir","erlang","clojure","dart","vue","svelte","astro","tsx","jsx","diff"]),yue={"c++":"cpp","c#":"csharp","f#":"fsharp",ts:"typescript",js:"javascript",py:"python",rb:"ruby",rs:"rust",kt:"kotlin",cs:"csharp",sh:"bash",zsh:"bash",shell:"bash",yml:"yaml",md:"markdown",golang:"go",ps1:"powershell",docker:"dockerfile"};function xQ(e){const t=(e||"").toLowerCase(),n=Object.hasOwn(yue,t)?yue[t]:t,s=axt.has(n)?n:"text";return{label:(e||"").trim()||"text",lang:n,resolvedLang:s}}const QIe=/^(https?:|mailto:)/i,lxt=/^data:image\/(png|jpeg|gif|webp|bmp);base64,/i,JIe=/^data:image\/(png|jpeg|gif|webp);base64,[A-Za-z0-9+/]*={0,2}$/i;function _5(e){if(!e)return!1;const t=e.trim();return t?t.startsWith("#")||t.startsWith("/")&&!t.startsWith("//")?!0:QIe.test(t):!1}function bk(e,t=!1){if(!e)return!1;const n=e.trim();return n?t?JIe.test(n):n.startsWith("#")||n.startsWith("/")&&!n.startsWith("//")||lxt.test(n)?!0:QIe.test(n):!1}let bue,xue=Promise.resolve(),cxt=0;const uxt=5e4,dxt=500,hxt=1e4;function fxt({code:e}){const{t}=mt(),n=zw(),s=dl()!=="interactive",[r,i]=d.useState(null),[o,l]=d.useState(null),[c,u]=d.useState("diagram"),[h,f]=vT(),[p,m]=d.useState(1),[g,v]=d.useState({x:0,y:0}),[w,y]=d.useState(!1),b=d.useRef(null),x=n==="light"?"default":"dark",_=.5,S=3,E=.25,T=()=>{m(N=>Math.min(S,Math.round((N+E)*100)/100))},R=()=>{m(N=>Math.max(_,Math.round((N-E)*100)/100))},C=d.useCallback(()=>{b.current=null,y(!1),m(1),v({x:0,y:0})},[]),I=d.useCallback(N=>{N.preventDefault(),y(!0),b.current={startX:N.clientX,startY:N.clientY,origX:g.x,origY:g.y}},[g]);d.useEffect(()=>{if(!w)return;const N=O=>{if(!b.current)return;const B=O.clientX-b.current.startX,D=O.clientY-b.current.startY,U=1500;v({x:b.current.origX+B,y:Math.max(-U,Math.min(U,b.current.origY+D))})},j=()=>{b.current=null,y(!1)};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",j),window.addEventListener("blur",j),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",j),window.removeEventListener("blur",j)}},[w]),d.useEffect(()=>{m(1),v({x:0,y:0})},[e]),d.useEffect(()=>{let N=!1;i(null),l(null);const j=setTimeout(()=>{$e(()=>import("./mermaid.core-jggSxF1i.js").then(O=>O.cb),[]).then(async O=>{if(N)return;const B=O.default,D=`${x}:${s?"hardened":"runtime"}`,U=xue.then(async()=>{if(N)throw new Error("Mermaid render skipped");bue!==D&&(B.initialize({startOnLoad:!1,theme:x,securityLevel:"strict",suppressErrorRendering:!0,...s?{maxTextSize:uxt,maxEdges:dxt}:{},flowchart:{wrappingWidth:300,useMaxWidth:!1}}),bue=D);const F=`mermaid-${++cxt}`;if(!s)return B.render(F,e.trim());let M;try{return await Promise.race([B.render(F,e.trim()),new Promise((X,ee)=>{M=setTimeout(()=>ee(new Error("Mermaid render timed out")),hxt)})])}finally{M!==void 0&&clearTimeout(M)}});xue=U.then(()=>{},()=>{});const{svg:V}=await U;N||i(V)}).catch(O=>{N||l(O instanceof Error?O.message:"Mermaid render failed")})},150);return()=>{N=!0,clearTimeout(j)}},[e,s,x]);const A=()=>{tf(e).then(()=>{f()}).catch(rg)};return o?a.jsxs("div",{className:Li.codeBlock,children:[a.jsx("div",{className:Li.codeBlockHeader,children:a.jsx("span",{className:Li.codeBlockLang,children:t("mermaid.errorLabel")})}),a.jsx("pre",{className:`${Li.codeBlockContent} ${Li.codeBlockPlain}`,children:a.jsx("code",{children:e})})]}):a.jsxs("div",{className:Li.codeBlock,children:[a.jsxs("div",{className:Li.codeBlockHeader,children:[a.jsx("span",{className:Li.codeBlockLang,children:t("mermaid.label")}),a.jsxs("span",{className:Li.mermaidActions,children:[c==="diagram"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{className:Li.codeBlockCopy,onClick:R,title:t("mermaid.zoomOut"),disabled:p<=_,children:t("mermaid.zoomOut")}),a.jsx("button",{className:Li.codeBlockCopy,onClick:C,title:t("mermaid.zoomReset"),disabled:p===1&&g.x===0&&g.y===0,children:t("mermaid.zoomReset")}),a.jsx("button",{className:Li.codeBlockCopy,onClick:T,title:t("mermaid.zoomIn"),disabled:p>=S,children:t("mermaid.zoomIn")})]}),a.jsx("button",{className:Li.codeBlockCopy,onClick:()=>u(c==="diagram"?"code":"diagram"),children:t(c==="diagram"?"mermaid.viewCode":"mermaid.viewDiagram")}),a.jsx("button",{className:Li.codeBlockCopy,onClick:A,children:t(h?"code.copied":"code.copy")})]})]}),c==="code"?a.jsx("pre",{className:`${Li.codeBlockContent} ${Li.codeBlockPlain}`,children:a.jsx("code",{children:e})}):r?a.jsx("div",{className:`${Li.mermaidZoomWrapper} ${w?Li.mermaidDragging:""}`,onMouseDown:I,onDoubleClick:C,children:a.jsx("div",{className:`${Li.mermaidBlock} ${Li.mermaidInline}`,style:{transform:`translate(${g.x}px, ${g.y}px) scale(${p})`,transformOrigin:"top center"},dangerouslySetInnerHTML:{__html:r}})}):a.jsx("div",{className:`${Li.mermaidBlock} ${Li.mermaidLoading} ${Li.mermaidInline}`,children:a.jsx("span",{children:t("mermaid.rendering")})})]})}function pxt({className:e,children:t,isStreaming:n}){const{t:s}=mt(),r=zw(),i=dl()==="document",[o,l]=d.useState(null),[c,u]=vT(),{label:h,lang:f,resolvedLang:p}=xQ(e3e(e)),m=String(t).replace(/\n$/,""),g=r==="light"?"github-light-default":"github-dark-default";d.useEffect(()=>{if(i||n||f==="mermaid"||p==="text"||KW(m)){l(null);return}const w=fwt(m,p,g);if(w!==null){l(w);return}const y=Jce(m,p,g,!0);if(y!==null){l(y);return}l(null);let b=!1;return TIe(p).then(()=>{if(b)return;const x=Jce(m,p,g,!0);x!==null&&l(x)}).catch(x=>{b||(console.warn("[web-shell] highlight failed for lang=%s",p,x),l(null))}),()=>{b=!0}},[m,i,f,p,g,n]);const v=()=>{tf(m).then(()=>{u()}).catch(rg)};return f==="mermaid"&&!n&&!i?a.jsx(fxt,{code:m}):a.jsxs("div",{className:Li.codeBlock,children:[a.jsxs("div",{className:Li.codeBlockHeader,children:[a.jsx("span",{className:Li.codeBlockLang,children:h}),a.jsx("button",{className:Li.codeBlockCopy,onClick:v,children:s(c?"code.copied":"code.copy")})]}),!i&&!n&&o!==null?a.jsx("div",{className:Li.codeBlockContent,dangerouslySetInnerHTML:{__html:o}}):a.jsx("pre",{className:`${Li.codeBlockContent} ${Li.codeBlockPlain}`,children:a.jsx("code",{children:m})})]})}function e3e(e){const t=e?.match(/(?:^|\s)language-([^\s]+)/)?.[1]??"",n=t.match(/^([\w+.#-]+)/);if(!n)return"";const s=n[1]??"",r=t[s.length];return!r||r==="{"||r===":"?s:""}function mxt({children:e}){return a.jsx("code",{className:Li.inlineCode,children:e})}function _ue({children:e}){return a.jsx("div",{className:Li.tableWrapper,children:a.jsx("table",{className:Li.table,children:e})})}const t3e=d.createContext(!1),n3e=d.createContext(void 0),s3e=d.createContext(void 0);function gxt(e,t,n){if(!n||e===void 0)return!1;const s=t?.position?.start.offset,r=t?.position?.end.offset;return s===void 0||r===void 0?!1:!uTe(e.slice(s,r))&&e.slice(r).trim().length===0}function vxt({className:e,children:t,node:n}){const s=d.useContext(t3e),r=d.useContext(s3e);return e?.startsWith("language-")||typeof t=="string"&&t.includes(`
|
|
1571
1571
|
`)?a.jsx(wxt,{className:e,isStreaming:s,isIncomplete:gxt(r,n,s),children:t}):a.jsx(mxt,{children:t})}function wxt({className:e,children:t,isStreaming:n,isIncomplete:s}){const r=d.useContext(n3e),i=zw(),{markdown:o}=bh(),l=String(t),c=l.replace(/\n$/,""),u=a.jsx(pxt,{className:e,isStreaming:n,children:l}),h=e3e(e),{resolvedLang:f}=xQ(h);if(!!r&&!!e&&!!h)try{const m=o?.renderCodeBlock?.({language:h,resolvedLanguage:f,className:e,code:c,isStreaming:!!n,isIncomplete:!!s,source:r,theme:i});if(m!=null&&typeof m!="boolean")return a.jsx(bw,{fallback:u,label:`custom code block component render (lang=${h})`,resetKeys:[h,r,i,n?"streaming":"settled",s?"incomplete":"complete",c],children:m})}catch(m){console.error("[web-shell] custom code block renderer call failed (lang=%s):",h,m)}return u}function yxt({children:e}){return a.jsx(a.Fragment,{children:e})}const tV=/^qwen-session:\/\//i;function bxt(e,t=!1){return t&&JIe.test(e.trim())||tV.test(e.trim())?e:rTe(e)}function xxt({href:e,children:t}){const n=dl(),s=vm();if(e&&tV.test(e.trim())){if(n!=="interactive")return a.jsx("span",{className:Li.link,children:t});const i=e.trim().replace(tV,"");return a.jsx("a",{href:"#",role:"button",className:Li.link,onClick:o=>{o.preventDefault(),o.stopPropagation(),window.dispatchEvent(new CustomEvent("qwen:open-session",{detail:i}))},children:t})}const r=_5(e)?e:void 0;return a.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:Li.link,onClick:i=>s(i,r),children:t})}function _xt({src:e,alt:t}){const n=dl(),s=bk(e,n==="document")?e:void 0;return a.jsx("img",{src:s,alt:t||"",className:Li.image})}function kxt(e,t,n=80){const[s,r]=d.useState(e),i=d.useRef(s);i.current=s;const o=d.useRef(0),l=d.useRef(null),c=d.useRef(e);return c.current=e,d.useEffect(()=>{if(!t){l.current&&(clearTimeout(l.current),l.current=null),i.current!==e&&r(e);return}const u=Date.now(),h=u-o.current;h>=n?(o.current=u,r(c.current)):l.current||(l.current=setTimeout(()=>{o.current=Date.now(),l.current=null,r(c.current)},n-h))},[e,t,n]),d.useEffect(()=>()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),!t||typeof e=="string"&&typeof s=="string"&&!e.startsWith(s)?e:s}function r3e(e="basic",t=""){return{code:vxt,pre:yxt,a:xxt,img:_xt,table({children:n}){if(e==="advanced"){const s=a.jsx(_ue,{children:n});return a.jsx(bw,{fallback:s,label:"enhanced markdown table",resetKeys:[t],children:a.jsx(Sbt,{fallback:s,children:n})})}return a.jsx(_ue,{children:n})}}}const Sxt=r3e(),Cxt=d.memo(function({content:t,components:n,remarkPlugins:s,rehypePlugins:r,urlTransform:i}){return a.jsx(vut,{components:n,remarkPlugins:s,rehypePlugins:r,urlTransform:i,children:t})}),rp=d.memo(function({content:t,source:n,isStreaming:s,tableMode:r}){const{markdown:i,markdownTableMode:o}=bh(),l=zw(),c=dl()==="document",u=n?i:void 0,h=kxt(t??"",s),f=s===!0&&h.length>oxt,p=d.useMemo(()=>h&&n&&u?.transformMarkdown?u.transformMarkdown(h,{source:n}):h,[n,u,h]),m=s?"basic":r??o??"basic",g=d.useMemo(()=>m==="advanced"?r3e("advanced",p):Sxt,[m,p]),v=u?.components,w=d.useMemo(()=>v?{...g,...v,...m==="advanced"?{table:g.table}:{}}:g,[g,m,v]),y=!c&&n==="assistant"&&!v?.code&&!v?.pre?u?.chart??(u?.renderCodeBlock?void 0:L1t):void 0,b=d.useMemo(()=>y?D1t(y.registry,{chartClassName:y.chartClassName,chartStyle:{minHeight:360,...y.chartStyle}}):void 0,[y]),x=d.useMemo(()=>b?{...w,pre:b}:w,[b,w]),_=d.useMemo(()=>u?.remarkPlugins?[Ple,bce,Pce,...u.remarkPlugins]:[Ple,bce,Pce],[u?.remarkPlugins]),S=d.useMemo(()=>u?.rehypePlugins?[Rce,...u.rehypePlugins]:[Rce],[u?.rehypePlugins]),E=d.useMemo(()=>C=>bxt(C,c),[c]);if(!t)return null;if(f)return a.jsx("div",{className:n!=="thinking"?Li.content:void 0,"data-markdown-source":n,"data-markdown-streaming-plain-text":"true",children:a.jsx("pre",{className:Li.streamingPlainText,children:p})});const T=a.jsx(Cxt,{content:p,components:x,remarkPlugins:_,rehypePlugins:S,urlTransform:E}),R=y?a.jsx(O1t,{customization:y,source:p,streaming:!!s,theme:l,children:T}):T;return a.jsx("div",{className:n!=="thinking"?Li.content:void 0,"data-markdown-source":n,children:a.jsx(t3e.Provider,{value:!!s,children:a.jsx(n3e.Provider,{value:n,children:a.jsx(s3e.Provider,{value:p,children:R})})})})}),NF=/https?:\/\/[A-Za-z0-9\-._~:/?#[\]{}@!$&'()*+,;=%]+/gi,Txt=new Set([...".,;:!?'*_~"]),Ixt={")":"(","]":"[","}":"{"},Ext=/^https?:\/\/./i;function kue(e,t){let n=0;for(const s of e)s===t&&(n+=1);return n}function Rxt(e){const t={};for(const[s,r]of Object.entries(Ixt))t[s]=kue(e,s)-kue(e,r);let n=e.length;for(;n>0;){const s=e.charAt(n-1);if(Object.hasOwn(t,s)){if(t[s]<=0)break;t[s]--,n--;continue}if(!Txt.has(s))break;n--}return e.slice(0,n)}function Axt(e){const t=[];let n=0;NF.lastIndex=0;for(let s=NF.exec(e);s!==null;s=NF.exec(e)){const r=Rxt(s[0]);if(!Ext.test(r))continue;const i=s.index;i>n&&t.push({type:"text",value:e.slice(n,i)}),t.push({type:"url",value:r}),n=i+r.length}return n<e.length&&t.push({type:"text",value:e.slice(n)}),t}const O9=d.memo(function({text:t}){const n=vm(),s=d.useMemo(()=>Axt(t),[t]);return s.every(r=>r.type==="text")?t:s.map((r,i)=>{if(r.type==="text")return r.value;const o=r.value.replace(/%(?![0-9A-Za-z]{2})/g,"%25"),l=_5(o)?o:void 0;return a.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:Li.link,onClick:c=>n(c,l),children:r.value},i)})});function qL(e){return`url("${e.replace(/["\\\n\r\f]/g,n=>{switch(n){case'"':case"\\":return`\\${n}`;case`
|
|
1572
1572
|
`:return"\\A ";case"\r":return"\\D ";case"\f":return"\\C ";default:return""}})}")`}function vb(e,t){return{[e]:qL(t)}}const jxt="_flash_96ig5_1",Ew={flash:jxt},Nxt="_chatMessageRow_8bn9a_41",Mxt="_chatMessageColumn_8bn9a_48",Pxt="_chatBubble_8bn9a_55",Lxt="_scheduledTaskBubble_8bn9a_68",Dxt="_scheduledTaskRun_8bn9a_76",Oxt="_scheduledTaskHeader_8bn9a_83",$xt="_scheduledTaskIcon_8bn9a_90",Bxt="_scheduledTaskHeading_8bn9a_108",Fxt="_scheduledTaskEyebrow_8bn9a_115",zxt="_scheduledTaskName_8bn9a_122",qxt="_scheduledTaskMeta_8bn9a_131",Hxt="_scheduledTaskMetaItem_8bn9a_138",Uxt="_scheduledTaskBadge_8bn9a_158",Wxt="_scheduledTaskId_8bn9a_170",Vxt="_scheduledTaskPrompt_8bn9a_181",Gxt="_sendFailure_8bn9a_191",Kxt="_retryButton_8bn9a_201",Yxt="_editArea_8bn9a_229",Xxt="_editInput_8bn9a_236",Zxt="_editActions_8bn9a_257",Qxt="_editCancel_8bn9a_263",Jxt="_editSubmit_8bn9a_264",e_t="_chatContent_8bn9a_293",t_t="_messageTag_8bn9a_298",n_t="_messageTagTooltip_8bn9a_315",s_t="_messageTagClickable_8bn9a_349",r_t="_fileTag_8bn9a_353",i_t="_messageTagIcon_8bn9a_363",o_t="_messageTagLabel_8bn9a_374",a_t="_messageTagValue_8bn9a_375",l_t="_chatContentCollapsed_8bn9a_398",c_t="_toggleButton_8bn9a_403",u_t="_toggleIcon_8bn9a_424",d_t="_toggleIconExpanded_8bn9a_431",h_t="_chatImages_8bn9a_435",f_t="_chatImageThumb_8bn9a_443",p_t="_chatImageThumbInteractive_8bn9a_451",m_t="_chatFiles_8bn9a_460",g_t="_chatFileChip_8bn9a_468",v_t="_chatFileChipPreviewable_8bn9a_481",w_t="_fileTagIcon_8bn9a_499",ei={chatMessageRow:Nxt,chatMessageColumn:Mxt,chatBubble:Pxt,scheduledTaskBubble:Lxt,scheduledTaskRun:Dxt,scheduledTaskHeader:Oxt,scheduledTaskIcon:$xt,scheduledTaskHeading:Bxt,scheduledTaskEyebrow:Fxt,scheduledTaskName:zxt,scheduledTaskMeta:qxt,scheduledTaskMetaItem:Hxt,scheduledTaskBadge:Uxt,scheduledTaskId:Wxt,scheduledTaskPrompt:Vxt,sendFailure:Gxt,retryButton:Kxt,editArea:Yxt,editInput:Xxt,editActions:Zxt,editCancel:Qxt,editSubmit:Jxt,chatContent:e_t,messageTag:t_t,messageTagTooltip:n_t,messageTagClickable:s_t,fileTag:r_t,messageTagIcon:i_t,messageTagLabel:o_t,messageTagValue:a_t,chatContentCollapsed:l_t,toggleButton:c_t,toggleIcon:u_t,toggleIconExpanded:d_t,chatImages:h_t,chatImageThumb:f_t,chatImageThumbInteractive:p_t,chatFiles:m_t,chatFileChip:g_t,chatFileChipPreviewable:v_t,fileTagIcon:w_t},y_t="This is a scheduled task run. Execute the instructions below now. Do not create or modify a schedule unless the instructions explicitly ask you to.";function b_t(e){const t=`
|
|
1573
1573
|
|
|
@@ -2142,7 +2142,7 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
|
|
|
2142
2142
|
\x1B[33m[${o("terminal.notice.exited",{exitCode:pe})}]\x1B[0m`),!0}else if(ae.type==="error"){const pe=typeof ae.message=="string"?ae.message:o("terminal.notice.unknownError");return(j?.term??m).writeln(`\r
|
|
2143
2143
|
\x1B[31m[${o("terminal.notice.error",{message:pe})}]\x1B[0m`),!0}}catch{}return!1}function V(ce){(!ce.startsWith(zy)||!U(ce))&&m.write(ce)}function F(ce,ae){if(!(b||h.current!==ae))if(typeof ce.data=="string")V(ce.data);else{const pe=new TextDecoder().decode(ce.data);N?D(pe,ae):A?(I=!0,T=!0,ae.send(zy+JSON.stringify({type:"release"})),m.writeln(`\r
|
|
2144
2144
|
${o("terminal.notice.protocolMismatch")}`),ae.close(4002,"Terminal protocol mismatch")):(j?.term??m).write(pe)}}function M(ce=!1){if(b&&!ce)return;ce&&(R+=1);const ae=new WebSocket(BNe(i,e,t,ce),y.length>0?y:void 0);ae.binaryType="arraybuffer",h.current=ae,ae.onopen=()=>{if(T){ae.send(zy+JSON.stringify({type:"release"})),ae.close();return}if(b){ae.close();return}A=!0,N=void 0,_=Sq,S=!1,ae.readyState===WebSocket.OPEN&&ae.send(zy+JSON.stringify({type:"resize",cols:m.cols,rows:m.rows}))},ae.onmessage=ce?null:pe=>F(pe,ae),ae.onerror=()=>{},ae.onclose=pe=>{if(ce){pe.code!==4004&&R<3&&(C=setTimeout(()=>M(!0),Sq));return}b||T||I||mSn.has(pe.code)||(j?.term.dispose(),j=void 0,S||(m.writeln(`\r
|
|
2145
|
-
\x1B[33m[${o("terminal.notice.reconnecting")}]\x1B[0m`),S=!0),x=setTimeout(M,_),_=Math.min(_*2,pSn))}}const X=requestAnimationFrame(()=>M()),ee=()=>{if(T)return;T=!0,x&&clearTimeout(x);const ce=h.current;ce?.readyState===WebSocket.OPEN?(ce.send(zy+JSON.stringify({type:"release"})),ce.close()):(!ce||ce.readyState!==WebSocket.CONNECTING)&&M(!0)};e_.set(e,ee);const P=new ResizeObserver(()=>{!u.current||!c.current||(clearTimeout(E),E=setTimeout(()=>{try{u.current?.fit(),w()}catch{}},100))});return P.observe(l.current),f.current&&m.focus(),()=>{b=!0,e_.get(e)===ee&&e_.delete(e),x&&clearTimeout(x),C&&clearTimeout(C),cancelAnimationFrame(X),clearTimeout(E),P.disconnect(),B.dispose(),j?.term.dispose(),(!T||h.current?.readyState!==WebSocket.CONNECTING)&&h.current?.close(),m.dispose(),c.current=null,u.current=null,h.current=null}},[s]),d.useEffect(()=>{const p=c.current;if(n){try{u.current?.fit(),p&&p.refresh(0,p.rows-1);const m=h.current;p&&m?.readyState===WebSocket.OPEN&&m.send(zy+JSON.stringify({type:"resize",cols:p.cols,rows:p.rows}))}catch{}p?.focus()}else p?.blur()},[n]),a.jsx("div",{"data-web-terminal":!0,style:{display:"flex",flexDirection:"column",height:"100%",background:r!=="light"?"#0a0a0a":"#ffffff"},children:a.jsx("div",{ref:l,style:{flex:1,overflow:"hidden",padding:"0.25rem 0.5rem"}})})}function bSn({state:e,onChange:t}){const{t:n}=mt(),{baseUrl:s}=vi(),r=vm(),[i,o]=d.useState(e.url),[l,c]=d.useState(!1),[u,h]=d.useState(0),f=ZU(e.url,window.location.href,s);return d.useEffect(()=>{o(e.url),c(!1)},[e.url]),a.jsxs("section",{className:"flex h-full min-h-0 flex-col gap-3 bg-background text-foreground","data-web-shell-web-preview":!0,"aria-label":n("webPreview.title"),children:[a.jsxs("form",{className:"flex shrink-0 gap-2",onSubmit:p=>{p.preventDefault();const m=ZU(i,window.location.href,s);c(!m),m&&(o(m.href),h(g=>g+1),t({...e,url:m.href}))},children:[a.jsx(oi,{"aria-label":n("webPreview.address"),"aria-invalid":l||!!e.url&&!f,placeholder:"http://localhost:3000",value:i,onChange:p=>{o(p.target.value),c(!1)},autoComplete:"off",spellCheck:!1}),a.jsx(Nt,{type:"submit",children:n("webPreview.open")})]}),l||e.url&&!f?a.jsx("p",{role:"alert",className:"text-sm text-destructive",children:n("webPreview.invalidUrl")}):null,a.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-1",children:[a.jsx(Nt,{type:"button",variant:"ghost",size:"icon",disabled:!f,title:n("webPreview.refresh"),"aria-label":n("webPreview.refresh"),onClick:()=>h(p=>p+1),children:a.jsx(GCe,{})}),["desktop","mobile"].map(p=>a.jsx(Nt,{type:"button",variant:e.viewport===p?"secondary":"ghost",size:"icon","aria-pressed":e.viewport===p,title:n(`webPreview.${p}`),"aria-label":n(`webPreview.${p}`),onClick:()=>t({...e,viewport:p}),children:p==="desktop"?a.jsx(Znt,{}):a.jsx(qst,{})},p)),f&&a.jsx(Nt,{asChild:!0,variant:"ghost",size:"sm",className:"ml-auto",children:a.jsxs("a",{href:f.href,target:"_blank",rel:"noopener noreferrer",onClick:p=>r(p,f.href),children:[a.jsx(GU,{}),n("webPreview.external")]})})]}),f?a.jsx("div",{className:"min-h-0 flex-1 overflow-auto rounded-lg border border-border bg-muted",children:a.jsx("iframe",{title:n("webPreview.frame"),className:"mx-auto block h-full border-0 bg-white",style:{width:e.viewport==="mobile"?390:"100%"},referrerPolicy:"no-referrer",srcDoc:vrt(f,n("webPreview.page"))},`${f.href}:${u}`)}):a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border p-6 text-center text-sm text-muted-foreground",children:[a.jsx(gN,{className:"size-8"}),a.jsx("p",{children:n("webPreview.empty")})]}),f&&a.jsx("p",{className:"shrink-0 text-xs text-muted-foreground",children:n("webPreview.live")}),a.jsx("p",{className:"shrink-0 text-xs text-muted-foreground",children:n(f?"webPreview.fallback":"webPreview.reachable")})]})}function xSn({artifact:e,sourceSessionId:t}){const{t:n}=mt(),{client:s}=vi(),r=Ra(),i=t??r.sessionId,o=i===r.sessionId?r.clientId:void 0,[l,c]=d.useState(0),[u,h]=d.useState(0),[f,p]=d.useState(),m=`${i}:${e.id}:${l}`;d.useEffect(()=>{const y=new AbortController;if(!i){p({key:m,failed:"request"});return}return s.readSessionArtifactContent(i,e.id,{clientId:o,signal:y.signal}).then(b=>{y.signal.aborted||p({key:m,html:b})},b=>{y.signal.aborted||p({key:m,failed:b instanceof _o&&b.status===404&&typeof b.body=="object"&&b.body!==null&&"error"in b.body&&b.body.error==="artifact_snapshot_unavailable"?"unavailable":"request"})}),()=>y.abort()},[e.id,s,o,m,i]);const g=f?.key===m?f:void 0,v=n("webPreview.savedFrame"),w=d.useMemo(()=>g?.html===void 0?void 0:p2e(g.html,v),[g?.html,v]);return a.jsxs("section",{className:"flex h-full min-h-0 flex-col gap-3","data-web-shell-saved-preview":!0,children:[a.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 text-xs text-muted-foreground",children:[a.jsxs("p",{children:[n("webPreview.saved")," ·"," ",a.jsx("time",{dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleString()})]}),g?.failed!=="unavailable"&&a.jsx(Nt,{variant:"outline",size:"sm",onClick:()=>{g?.html!==void 0?h(y=>y+1):c(y=>y+1)},children:n(g?.failed?"common.retry":"webPreview.refresh")})]}),g?.failed?a.jsx("p",{role:"alert",className:"text-sm text-destructive",children:n(g.failed==="unavailable"?"webPreview.savedUnavailable":"webPreview.savedLoadFailed")}):g?.html!==void 0?a.jsx("iframe",{className:"min-h-0 w-full flex-1 rounded-lg border border-border bg-white",title:n("webPreview.savedFrame"),referrerPolicy:"no-referrer",sandbox:"allow-scripts",srcDoc:w},u):a.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:n("common.loading")})]})}const _Sn="_panel_1khd0_1",kSn="_heroHeader_1khd0_5",SSn="_updatedAt_1khd0_12",CSn="_hero_1khd0_5",TSn="_heroValue_1khd0_24",ISn="_heroMeta_1khd0_35",ESn="_refreshButton_1khd0_42",RSn="_legend_1khd0_61",ASn="_legendEntry_1khd0_69",jSn="_legendSwatch_1khd0_76",NSn="_legendValue_1khd0_83",MSn="_legendPercent_1khd0_88",PSn="_modelList_1khd0_97",LSn="_section_1khd0_103",DSn="_sectionTitle_1khd0_111",OSn="_collapsibleSummary_1khd0_118",$Sn="_collapseIcon_1khd0_146",BSn="_modelCard_1khd0_155",FSn="_modelHeader_1khd0_162",zSn="_modelName_1khd0_170",qSn="_modelMeta_1khd0_178",HSn="_modelBreakdown_1khd0_185",USn="_toolList_1khd0_193",WSn="_toolCard_1khd0_199",VSn="_toolHeader_1khd0_206",GSn="_toolName_1khd0_213",KSn="_toolWireName_1khd0_223",YSn="_toolMeta_1khd0_230",XSn="_subagentList_1khd0_237",ZSn="_subagentCard_1khd0_243",QSn="_subagentHeader_1khd0_250",JSn="_subagentName_1khd0_258",eCn="_subagentType_1khd0_267",tCn="_subagentBreakdown_1khd0_273",nCn="_error_1khd0_280",sCn="_retryButton_1khd0_292",rCn="_empty_1khd0_302",ti={panel:_Sn,heroHeader:kSn,updatedAt:SSn,hero:CSn,heroValue:TSn,heroMeta:ISn,refreshButton:ESn,legend:RSn,legendEntry:ASn,legendSwatch:jSn,legendValue:NSn,legendPercent:MSn,modelList:PSn,section:LSn,sectionTitle:DSn,collapsibleSummary:OSn,collapseIcon:$Sn,modelCard:BSn,modelHeader:FSn,modelName:zSn,modelMeta:qSn,modelBreakdown:HSn,toolList:USn,toolCard:WSn,toolHeader:VSn,toolName:GSn,toolWireName:KSn,toolMeta:YSn,subagentList:XSn,subagentCard:ZSn,subagentHeader:QSn,subagentName:JSn,subagentType:eCn,subagentBreakdown:tCn,error:nCn,retryButton:sCn,empty:rCn},iCn=2e3;function OT(e){return e.prompt>0?e.prompt:e.cached}function h2(e){const t=OT(e);return e.total>0?Math.max(e.total,t+e.candidates):t+e.candidates+e.thoughts}function Hee(e){return Math.max(0,h2(e)-OT(e))}const Jv={input:"var(--success-color)",cached:"color-mix(in srgb, var(--success-color) 70%, var(--foreground))",output:"var(--primary)",thoughts:"var(--warning-color)"};function FNe(e){return Object.entries(e).filter(([,t])=>t.api.totalRequests>0).map(([t,n])=>({key:t,label:t,metrics:n})).sort((t,n)=>h2(n.metrics.tokens)-h2(t.metrics.tokens))}function oCn(e){const{thoughts:t,cached:n}=e.tokens;return[{key:"input",value:OT(e.tokens)},{key:"cached",value:n},{key:"output",value:Hee(e.tokens)},{key:"thoughts",value:t}].filter(r=>r.value>0)}function zNe(e){return e.toLocaleString("en-US")}function qNe(e){return e>=999995e3?Cq((e/1e9).toFixed(2))+"B":e>=999950?Cq((e/1e6).toFixed(2))+"M":e>=1e3?Cq((e/1e3).toFixed(1))+"K":String(e)}function Cq(e){return e.replace(/\.?0+$/,"")}function aCn({sessionActions:e,sessionId:t}){const{t:n}=mt(),[s,r]=d.useState(null),[i,o]=d.useState(null),[l,c]=d.useState(!1),[u,h]=d.useState(0),f=d.useRef(!1),p=d.useRef(!1),m=d.useRef(!0),g=d.useCallback((w=!1)=>{!e||f.current||!w&&p.current||(w&&(p.current=!1),f.current=!0,e.getStats().then(y=>{if(m.current){if(t&&y.sessionId!==t){r(null),c(!0),o(null);return}c(!1),r(y),h(Date.now()),o(null)}}).catch(y=>{if(m.current){if(rX(y)){o(null);return}p.current=!0,o(y instanceof Error?y.message:n("tokenUsage.loadError"))}}).finally(()=>{f.current=!1}))},[e,t,n]);d.useEffect(()=>{if(m.current=!0,!e)return()=>{m.current=!1};p.current=!1,c(!1),g();const w=window.setInterval(()=>{document.visibilityState==="visible"&&g()},iCn);return()=>{m.current=!1,window.clearInterval(w)}},[g,e]);const v=s!==null&&FNe(s.models).length>0;return a.jsx("div",{className:ti.panel,children:i?a.jsxs("div",{className:ti.error,role:"alert",children:[a.jsx("span",{children:i}),a.jsx("button",{type:"button",className:ti.retryButton,onClick:()=>g(!0),children:n("tokenUsage.retry")})]}):!e||l?a.jsx("div",{className:ti.empty,children:n("tokenUsage.unavailable")}):s===null?a.jsx("div",{className:ti.empty,children:n("common.loading")}):v?a.jsx(lCn,{status:s,lastUpdated:u,onRefresh:()=>g(!0)}):a.jsx("div",{className:ti.empty,children:n("tokenUsage.noData")})})}function lCn({status:e,lastUpdated:t,onRefresh:n}){const{t:s}=mt(),r=FNe(e.models),i=r.reduce((c,u)=>(c.prompt+=OT(u.metrics.tokens),c.cached+=u.metrics.tokens.cached,c.output+=Hee(u.metrics.tokens),c.thoughts+=u.metrics.tokens.thoughts,c.total+=h2(u.metrics.tokens),c),{prompt:0,cached:0,output:0,thoughts:0,total:0}),o=i.total,l=[...e.sources??[]].sort((c,u)=>h2(u.tokens)-h2(c.tokens));return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ti.hero,children:[a.jsxs("div",{className:ti.heroHeader,children:[a.jsx("div",{className:ti.heroValue,children:qNe(o)}),a.jsxs("span",{className:ti.heroMeta,children:[a.jsx("button",{type:"button",className:ti.refreshButton,"aria-label":s("tokenUsage.refresh"),title:s("tokenUsage.refresh"),onClick:n,children:a.jsx(af,{size:14,"aria-hidden":"true"})}),t>0&&a.jsx("span",{className:ti.updatedAt,children:s("tokenUsage.updatedAt",{time:new Date(t).toLocaleTimeString()})})]})]}),a.jsxs("div",{className:ti.legend,children:[a.jsx(ew,{label:s("tokenUsage.input"),value:i.prompt,color:Jv.input}),a.jsx(ew,{label:s("tokenUsage.cached"),value:i.cached,color:Jv.cached,percent:i.cached>0&&i.prompt>0?`${(i.cached/i.prompt*100).toFixed(1)}%`:void 0}),a.jsx(ew,{label:s("tokenUsage.output"),value:i.output,color:Jv.output}),a.jsx(ew,{label:s("tokenUsage.thoughts"),value:i.thoughts,color:Jv.thoughts})]})]}),a.jsxs("section",{className:ti.section,children:[a.jsx("h3",{className:ti.sectionTitle,children:s("tokenUsage.models")}),a.jsx("div",{className:ti.modelList,children:r.map(c=>a.jsx(cCn,{entry:c},c.key))})]}),e.sources!==void 0&&a.jsxs("details",{className:ti.section,children:[a.jsxs("summary",{className:ti.collapsibleSummary,children:[a.jsx("h3",{className:ti.sectionTitle,children:s("tokenUsage.subagents")}),a.jsx(bl,{className:ti.collapseIcon,size:14,"aria-hidden":"true"})]}),l.length>0?a.jsx("div",{className:ti.subagentList,children:l.map(c=>a.jsx(uCn,{source:c},c.id))}):a.jsx("div",{className:ti.empty,children:s("tokenUsage.noSubagents")})]}),e.tools.byName!==void 0&&a.jsxs("details",{className:ti.section,children:[a.jsxs("summary",{className:ti.collapsibleSummary,children:[a.jsx("h3",{className:ti.sectionTitle,children:s("tokenUsage.tools")}),a.jsx(bl,{className:ti.collapseIcon,size:14,"aria-hidden":"true"})]}),a.jsx(dCn,{status:e})]})]})}function ew({label:e,value:t,color:n,percent:s}){return t<=0?null:a.jsxs("span",{className:ti.legendEntry,children:[n&&a.jsx("span",{className:ti.legendSwatch,style:{background:n},"aria-hidden":"true"}),a.jsx("span",{children:e}),a.jsx("span",{className:ti.legendValue,children:qNe(t)}),s&&a.jsx("span",{className:ti.legendPercent,children:s})]})}function cCn({entry:e}){const{t}=mt(),n=e.metrics,s=OT(n.tokens),r=n.api.totalRequests>0?n.api.totalLatencyMs/n.api.totalRequests:0;return a.jsxs("div",{className:ti.modelCard,children:[a.jsxs("div",{className:ti.modelHeader,children:[a.jsx("span",{className:ti.modelName,title:e.key,children:e.label}),a.jsxs("span",{className:ti.modelMeta,children:[t("tokenUsage.requests")," ",zNe(n.api.totalRequests),n.api.totalRequests>0&&a.jsxs(a.Fragment,{children:[" · ",t("tokenUsage.avgLatency")," ",og(r)]})]})]}),a.jsx("div",{className:ti.modelBreakdown,children:oCn(n).map(i=>a.jsx(ew,{label:t(`tokenUsage.${i.key}`),value:i.value,color:Jv[i.key],percent:i.key==="cached"&&s>0?`${(n.tokens.cached/s*100).toFixed(1)}%`:void 0},i.key))})]})}function uCn({source:e}){const{t}=mt(),{tokens:n}=e,s=OT(n);return a.jsxs("div",{className:ti.subagentCard,children:[a.jsxs("div",{className:ti.subagentHeader,children:[a.jsx("span",{className:ti.subagentName,title:e.name,children:e.name}),e.type&&a.jsx("span",{className:ti.subagentType,children:RT(e.type,t)})]}),a.jsxs("div",{className:ti.subagentBreakdown,children:[a.jsx(ew,{label:t("tokenUsage.input"),value:s,color:Jv.input}),a.jsx(ew,{label:t("tokenUsage.cached"),value:n.cached,color:Jv.cached,percent:s>0?`${(n.cached/s*100).toFixed(1)}%`:void 0}),a.jsx(ew,{label:t("tokenUsage.output"),value:Hee(n),color:Jv.output}),a.jsx(ew,{label:t("tokenUsage.thoughts"),value:n.thoughts,color:Jv.thoughts})]})]})}function dCn({status:e}){const{t}=mt(),{tools:n}=e,s=Object.entries(n.byName??{}).filter(([,r])=>r.count>0).sort((r,i)=>i[1].count-r[1].count);return s.length===0?a.jsx("div",{className:ti.empty,children:t("tokenUsage.noTools")}):a.jsx("div",{className:ti.toolList,children:s.map(([r,i])=>{const o=i.success/i.count*100,l=i.durationMs/i.count,c=$0(r,t);return a.jsx("div",{className:ti.toolCard,children:a.jsxs("div",{className:ti.toolHeader,children:[a.jsxs("span",{className:ti.toolName,title:r,children:[c,c!==r&&a.jsxs("span",{className:ti.toolWireName,children:["(",r,")"]})]}),a.jsx("span",{className:ti.toolMeta,children:t("tokenUsage.toolRow",{count:zNe(i.count),rate:o.toFixed(0),duration:og(l)})})]})},r)})})}const hCn="_panel_pwtdr_1",fCn="_toolbar_pwtdr_5",pCn="_actions_pwtdr_15",mCn="_feedback_pwtdr_21",gCn="_state_pwtdr_31",Cv={panel:hCn,toolbar:fCn,actions:pCn,feedback:mCn,state:gCn};function vCn({sessionActions:e,sessionId:t,controls:n}){const{t:s}=mt(),[r,i]=d.useState(null),[o,l]=d.useState(!0),[c,u]=d.useState(!1),h=d.useRef(0),f=d.useRef(()=>{}),p=d.useRef(null),m=n?.sessionId===t?n:void 0,g=m?.getContextUsage??e?.getContextUsage,v=d.useRef(m);v.current=m;const w=m?.result,[y,b]=d.useState(w),x=!!(w&&w!==y&&(w.kind!=="completed"||!c));d.useEffect(()=>{w?.kind==="completed"&&(h.current++,i(w.usage),u(!1))},[w]),d.useEffect(()=>{let E=!0,T=!1;const R=v.current?.result;i(I=>I?.sessionId===t?I:R?.kind==="completed"?R.usage:null),u(!1),l(!!g);const C=async()=>{if(!E||T||!g)return;T=!0,l(!0),u(!1);const I=h.current,A=p.current,N=A&&A.getContextUsage===g&&A.sessionId===t?A:{getContextUsage:g,sessionId:t,promise:g({detail:!0,silent:!0,...v.current?.result?{syncCounters:!0}:{}})};p.current=N;try{const j=await N.promise;if(!E||I!==h.current)return;i(j.sessionId===t&&j.usage.contextWindowSize>0?j:null)}catch(j){if(!E||I!==h.current)return;u(rX(j)?"transient":"hard")}finally{T=!1,p.current===N&&(p.current=null),E&&l(!1)}};return f.current=()=>void C(),C(),()=>{E=!1}},[g,t]);const _=!g||o||m?.compressing,S=()=>{b(w),f.current()};return a.jsxs("div",{className:Cv.panel,"aria-busy":o,children:[a.jsxs("div",{className:Cv.toolbar,children:[a.jsx("span",{children:s("contextUsage.title")}),a.jsxs("div",{className:Cv.actions,children:[a.jsx(Nt,{type:"button",variant:"ghost",size:"icon-sm","aria-label":s("contextUsage.refresh"),title:s("contextUsage.refresh"),disabled:_,onClick:S,children:a.jsx(af,{"aria-hidden":"true"})}),a.jsx("span",{title:m?.compressing?void 0:m?.canCompress?o?s("common.loading"):void 0:s("contextUsage.compressUnavailable"),children:a.jsx(Nt,{type:"button",variant:"outline",size:"sm",disabled:!m?.canCompress||o,onClick:()=>void m?.compress(),children:s(m?.compressing?"contextUsage.compressing":"contextUsage.compress")})})]})]}),(m?.compressing||x)&&a.jsx(Eje,{controls:m,className:Cv.feedback}),c==="transient"&&r&&a.jsx("div",{className:Cv.feedback,role:"status",children:s("contextUsage.previousReading")}),c==="hard"?a.jsxs("div",{className:Cv.state,role:"alert",children:[a.jsx("span",{children:s("contextUsage.loadError")}),a.jsx(Nt,{type:"button",variant:"outline",size:"sm",disabled:_,onClick:S,children:s("contextUsage.retry")})]}):g?o&&!r?a.jsx("div",{className:Cv.state,role:"status",children:s("common.loading")}):r?a.jsx(p3e,{status:r,compact:!0}):a.jsx("div",{className:Cv.state,children:s("contextUsage.unavailable")}):a.jsx("div",{className:Cv.state,children:s("contextUsage.unavailable")})]})}const wCn=700,yCn=["daily","weekdays","weekly","hourly","minutes","custom"],bCn=[1,2,3,4,5,6,10,12,15,20,30],xCn=(e,t)=>{},_Cn=(e,t,n)=>{},kCn=()=>Promise.reject(new Error("Side-task session creation is unavailable"));function xge(e){return e.kind==="review"||e.kind==="file"||e.kind==="artifact"||e.kind==="scheduled_task"}function Tv(e){return e.kind==="pending"?e.targetKind:e.kind}function SCn(e){return`image.${(e.match(/^data:image\/([a-z0-9+.+-]+)/i)?.[1]??"png").split("+")[0].toLowerCase()}`}const CCn=["review","sideTask"];function _ge({contextUsageControls:e,artifacts:t,tabs:n,activeTabId:s,reviewChanges:r,selectedReviewPath:i,panelWidth:o,workspaceCwd:l,loading:c,restoring:u=!1,error:h,onSelectTab:f,onCloseTab:p,onOpenFilePreview:m,latestReviewAvailable:g=!1,onOpenLatestReview:v,onOpenTerminal:w,onOpenWebPreview:y,onWebPreviewChange:b,items:x=CCn,sideTaskAvailable:_=!1,sideTasks:S=[],sideTasksLoading:E=!1,onCreateSideTask:T,onOpenSideTask:R,onCreateSideTaskSession:C,onSideTaskCreated:I,onSideTaskTitleChange:A,onNestedRightPanelOpen:N,onNestedArtifactsChange:j,onOpenNestedSubagent:O,agentTasks:B=[],agentTraceLoading:D=!1,agentTraceError:U,onOpenWorkflowAgent:V,onError:F,sessionWorkflowEnabled:M,workflow:X,onImageIngestionNotice:ee,deferSubagentMount:P=!1,onClose:ce,variant:ae="docked",fullscreen:pe=!1,onToggleFullscreen:q}){const{t:K}=mt(),[oe,W]=d.useState(!1),[ge,le]=d.useState(),ye=d.useRef(null),se=d.useCallback(()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),W(!0)},[]),Se=d.useCallback(()=>{ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{W(!1),ye.current=null},120)},[]);d.useEffect(()=>()=>{ye.current&&clearTimeout(ye.current)},[]);const re=n.find(we=>we.id===s)??n[0],me=re?.kind==="file"&&re.sourcePreview&&(/\.html?$/i.test(re.workspacePath)||kw(re.previewMimeType||re.previewData?.type)==="text/html"),Le=re?.kind==="file"&&re.previewOnly===!0&&!me&&/\.(?:html?|md|markdown)$/i.test(re.workspacePath)&&(re.previewContent!==void 0||!re.previewData||!!X2(re.previewMimeType||re.previewData.type,re.workspacePath)),Pe=ge===re?.id,st=x.includes("review")&&!n.some(we=>Tv(we)==="review"),He=x.includes("sideTask")&&_&&!!T,Te=!!w,Ke=x.includes("webPreview")&&!!y,H=!!re&&(st||He||Te||Ke),Z=re&&xge(re)?{workspaceCwd:re.workspaceCwd,workspaceId:re.workspaceId}:void 0,$=L5(Z?.workspaceCwd),Y=$?.workspaceId===Z?.workspaceId?$?.actions:void 0,de=re?.kind==="artifact"?t.find(we=>we.id===re.artifactId):void 0;return a.jsxs("aside",{className:`${ot.panel} ${ae==="drawer"?ot.panelDrawer:""} ${pe?ot.panelFullscreen:""}`,style:ae==="docked"&&o&&!pe?{flexBasis:o,width:o}:void 0,"aria-label":"Right panel",children:[a.jsxs("div",{className:ot.header,children:[n.length>0&&a.jsx("div",{className:ot.tabs,role:"tablist","aria-label":"Right panel",children:n.map(we=>a.jsxs("div",{className:[ot.tabItem,we.id===re?.id?ot.tabActive:""].filter(Boolean).join(" "),children:[a.jsxs("button",{type:"button",role:"tab","aria-selected":we.id===re?.id,className:ot.tab,onClick:()=>f(we.id),onMouseEnter:Re=>r2(Re.currentTarget),onFocus:Re=>r2(Re.currentTarget),title:we.title,children:[a.jsx("span",{className:`${ot.tabIcon} ${Tv(we)==="artifact"?ot.tabArtifactIcon:""}`,"aria-hidden":"true",children:Tv(we)==="review"?a.jsx(Tq,{}):we.kind==="workflow"?a.jsx(HCe,{className:ot.tabIconSvg,strokeWidth:1.6}):we.kind==="file"?a.jsx(cg,{name:we.workspacePath,className:ot.tabIconSvg,strokeWidth:1.6}):Tv(we)==="artifact"?a.jsx(v2e,{artifact:t.find(Re=>"artifactId"in we&&Re.id===we.artifactId),className:ot.tabIconSvg}):Tv(we)==="subagent"?a.jsx(TCn,{}):Tv(we)==="monitor"?a.jsx(XCe,{className:ot.tabIconSvg,strokeWidth:1.6}):Tv(we)==="shell"?a.jsx(EC,{className:ot.tabIconSvg,strokeWidth:1.6}):Tv(we)==="side_task"?a.jsx(rj,{className:ot.tabIconSvg,strokeWidth:1.6}):we.kind==="web_preview"?a.jsx(gN,{className:ot.tabIconSvg}):we.kind==="terminal"?a.jsx(EC,{className:ot.tabIconSvg,strokeWidth:1.6}):Tv(we)==="image"?a.jsx(_nt,{className:ot.tabIconSvg,strokeWidth:1.6}):we.kind==="context_usage"?a.jsx(hL,{className:ot.tabIconSvg,strokeWidth:1.6}):we.kind==="token_usage"?a.jsx(uZ,{className:ot.tabIconSvg,strokeWidth:1.6}):a.jsx(ECn,{})}),a.jsx("span",{className:ot.tabTitle,"data-web-shell-session-title":!0,children:a.jsx("span",{className:ot.tabTitleInner,children:we.title})})]}),a.jsx("button",{type:"button",className:ot.tabCloseButton,onClick:()=>p(we.id),"aria-label":`Close ${we.title}`,title:"Close",children:a.jsx(ICn,{})})]},we.id))}),a.jsxs("div",{className:ot.headerActions,children:[H&&a.jsxs(gm,{modal:!1,children:[a.jsx(op,{asChild:!0,children:a.jsx("button",{type:"button",className:`${ot.iconButton} ${ot.addButton}`,"aria-label":K("rightPanel.add"),title:K("rightPanel.add"),children:a.jsx(of,{className:ot.toolbarIcon})})}),a.jsxs(ap,{align:"end",className:"w-64",children:[st&&a.jsxs(Ni,{disabled:!g||!v,onSelect:v,children:[a.jsx(Tq,{}),a.jsx("span",{className:ot.sideTaskListTitle,children:K("turnOutputs.review")})]}),st&&He&&a.jsx(Bb,{}),He&&a.jsxs(Ni,{disabled:E,onSelect:T,children:[a.jsx(rj,{className:ot.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:ot.sideTaskListTitle,children:K("sideTask.create")})]}),Te&&(st||He)&&a.jsx(Bb,{}),Te&&a.jsxs(Ni,{onSelect:()=>w?.(),children:[a.jsx(EC,{className:ot.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:ot.sideTaskListTitle,children:K("terminal.title")})]}),Ke&&a.jsxs(Ni,{onSelect:y,children:[a.jsx(gN,{className:ot.sideTaskNewIcon}),a.jsx("span",{className:ot.sideTaskListTitle,children:K("webPreview.title")})]})]})]}),q&&a.jsx("button",{type:"button",className:`${ot.iconButton} ${ot.fullscreenButton} ${pe?ot.iconButtonActive:""}`,onClick:q,"aria-label":K(pe?"common.exitFullscreen":"common.fullscreen"),"aria-pressed":pe,title:K(pe?"common.exitFullscreen":"common.fullscreen"),children:pe?a.jsx(hZ,{className:ot.toolbarIcon,"aria-hidden":!0}):a.jsx(lZ,{className:ot.toolbarIcon,"aria-hidden":!0})}),a.jsx("button",{type:"button",className:`${ot.iconButton} ${ot.panelToggleButton}`,onClick:ce,"aria-label":K("chatHeader.toggleRightPanel"),"aria-pressed":"true",title:K("chatHeader.toggleRightPanel"),children:a.jsx(UCe,{className:ot.panelToggleIcon})})]})]}),a.jsxs("div",{className:`${ot.body} ${re?.kind==="side_task"?ot.bodySideTask:""}`.trim(),children:[n.filter(we=>we.kind==="web_preview").map(we=>a.jsx("div",{className:"h-full",hidden:we.id!==re?.id,children:a.jsx(bSn,{state:we,onChange:Re=>b?.(we.id,Re)})},we.id)),n.filter(we=>we.kind==="terminal").map(we=>a.jsx("div",{className:`${ot.terminalPane} ${we.id===re?.id?"":ot.terminalPaneHidden}`.trim(),"aria-hidden":we.id===re?.id?void 0:!0,children:a.jsx(ySn,{terminalId:we.id,cwd:we.workspaceCwd??l,active:we.id===re?.id,enabled:we.initialized!==!1})},we.id)),Le&&a.jsxs("button",{type:"button",className:ot.attachmentPreviewButton,onClick:()=>le(Pe?void 0:re?.id),"aria-label":K(Pe?"attachment.showSource":"attachment.showPreview"),"aria-pressed":Pe,children:[Pe?a.jsx(btt,{"aria-hidden":!0}):a.jsx(LCe,{"aria-hidden":!0}),K(Pe?"attachment.showSource":"attachment.showPreview")]}),u&&!re?a.jsxs("div",{className:"flex flex-col gap-4 p-5","data-testid":"right-panel-loading-skeleton",role:"status","aria-label":K("common.loading"),children:[a.jsx(g0,{className:"h-5 w-2/5"}),a.jsx(g0,{className:"h-32 w-full"}),a.jsx(g0,{className:"h-4 w-4/5"}),a.jsx(g0,{className:"h-4 w-3/5"})]}):re?.kind==="terminal"||re?.kind==="web_preview"?null:re?re.kind==="pending"?a.jsx("div",{className:ot.empty,role:re.loadError?"alert":"status",children:re.loadError??K("common.loading")}):re.kind==="workflow"?re.sessionId?a.jsx(f1n,{tasks:B,loading:D,error:U,onOpenAgent:V}):X?a.jsx(txn,{...X}):a.jsx("div",{className:ot.empty,children:K("workflow.empty.title")}):xge(re)&&(re.kind!=="scheduled_task"||re.task.durable)&&(re.kind!=="file"||!re.previewOnly)&&(re.kind!=="artifact"||de?.metadata?.artifactType!=="web_preview_snapshot")&&!Y?a.jsx("div",{className:ot.empty,role:"alert",children:K("workspace.notFoundDescription")}):re.kind==="review"?a.jsx(jCn,{changes:re.changes??r,selectedPath:re.selectedPath??i,workspaceCwd:re.workspaceCwd??l,onOpenFilePreview:we=>m(we,re.workspaceCwd??l,re.workspaceId),onDownloadFile:(we,Re)=>gL(Y,we.path,xit(we.path),Re),onDownloadError:we=>{const Re=K("common.downloadFailed",{message:sl(we)});F?F(new Error(Re,{cause:we}),Re):console.error(Re,we)}}):re.kind==="file"?re.attachmentId&&!re.previewData&&re.previewContent===void 0?a.jsx("div",{className:ot.empty,role:re.loadError?"alert":"status",children:re.loadError??K("common.loading")}):re.sourcePreview&&re.previewData&&kw(re.previewMimeType||re.previewData.type)!=="application/pdf"&&!X2(re.previewMimeType||re.previewData.type,re.workspacePath)?a.jsx(GNe,{data:re.previewData,title:re.title,image:!!wT(re.workspacePath)&&re.previewData.type.startsWith("image/")}):a.jsx(ID,{workspacePath:re.workspacePath,workspaceActions:Y,previewContent:re.previewContent,previewData:re.previewData,previewMimeType:re.previewMimeType,previewOnly:re.previewOnly,previewKind:me||re.previewOnly&&!Pe?"source":void 0},re.id):re.kind==="source"?a.jsx(KCn,{tab:re},re.id):re.kind==="artifact"?a.jsx(RCn,{artifacts:t,artifactId:re.artifactId,sourceSessionId:re.sourceSessionId,workspaceActions:Y,previewContent:re.previewContent,loading:c,error:h},re.id):re.kind==="subagent"?P?null:a.jsx(Ybn,{sessionId:re.sessionId,rootToolCallId:re.rootToolCallId,initialRootTool:re.rootTool,workspaceCwd:re.workspaceCwd??l,onRightPanelOpen:N,onArtifactsChange:j,onOpenSubagent:O,onError:F}):re.kind==="monitor"?a.jsx(EIt,{task:re.task,actions:re.sessionActions},re.id):re.kind==="shell"?a.jsx(RIt,{task:re.task,actions:re.sessionActions},re.id):re.kind==="side_task"?a.jsx(m1n,{tabId:re.id,sessionId:re.sessionId,parentSessionId:re.parentSessionId,workspaceCwd:re.workspaceCwd??l,title:re.title,shouldNameFromFirstPrompt:re.nameFromFirstPrompt,initialPrompt:re.initialPrompt,createSession:C??kCn,onCreated:I??xCn,onTitleChange:A??_Cn,onRightPanelOpen:N,onArtifactsChange:j,onError:F,sessionWorkflowEnabled:M,onImageIngestionNotice:ee},re.id):re.kind==="image"?re.src?a.jsxs("div",{className:ot.imagePreviewWrap,children:[a.jsx("img",{src:re.src,alt:re.alt??re.title,className:ot.imagePreview}),a.jsx("a",{className:ot.imageDownloadButton,href:re.src,download:SCn(re.src),"aria-label":K("common.download"),title:K("common.download"),children:a.jsx(aw,{size:16,strokeWidth:1.8})})]}):a.jsx("div",{className:ot.empty,role:re.loadError?"alert":"status",children:re.loadError??K("common.loading")}):re.kind==="context_usage"?a.jsx(vCn,{controls:e?.[re.sessionId],sessionActions:re.sessionActions,sessionId:re.sessionId},re.id):re.kind==="token_usage"?a.jsx(aCn,{sessionActions:re.sessionActions,sessionId:re.sessionId},re.id):a.jsx(ACn,{task:re.task,actions:Y},re.id):a.jsxs("div",{className:ot.emptyActions,"data-testid":"right-panel-empty-actions",children:[x.includes("review")&&a.jsxs("button",{type:"button",className:ot.emptyAction,disabled:!g||!v,onClick:v,children:[a.jsx("span",{className:ot.emptyActionIcon,"aria-hidden":"true",children:a.jsx(Tq,{})}),a.jsx("span",{className:ot.emptyActionTitle,children:K("turnOutputs.review")}),a.jsx("span",{className:ot.emptyActionHint,children:K("turnOutputs.reviewLatest")}),a.jsx(bl,{className:ot.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}),x.includes("sideTask")&&_&&T&&(S.length===0?a.jsxs("button",{type:"button",className:ot.emptyAction,disabled:E,"aria-busy":E,onClick:T,children:[a.jsx("span",{className:ot.emptyActionIcon,"aria-hidden":"true",children:a.jsx(rj,{strokeWidth:1.6})}),a.jsx("span",{className:ot.emptyActionTitle,children:K("sideTask.title")}),a.jsx("span",{className:ot.emptyActionHint,children:K("sideTask.description")}),a.jsx(bl,{className:ot.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}):a.jsxs(gm,{open:oe,onOpenChange:W,modal:!1,children:[a.jsx(op,{asChild:!0,children:a.jsxs("button",{type:"button",className:ot.emptyAction,"aria-expanded":oe,onMouseEnter:se,onMouseLeave:Se,children:[a.jsx("span",{className:ot.emptyActionIcon,"aria-hidden":"true",children:a.jsx(rj,{strokeWidth:1.6})}),a.jsx("span",{className:ot.emptyActionTitle,children:K("sideTask.title")}),a.jsx("span",{className:ot.emptyActionHint,children:K("sideTask.description")}),a.jsx(bl,{className:ot.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]})}),a.jsxs(ap,{align:"end",className:"w-80",onMouseEnter:se,onMouseLeave:Se,children:[S.map(we=>a.jsxs(Ni,{onSelect:()=>R?.(we),children:[a.jsx("span",{className:ot.sideTaskListTitle,children:we.title}),we.updatedAt&&a.jsx("span",{className:ot.sideTaskListTime,children:Z2(we.updatedAt,K)})]},we.sessionId)),a.jsx(Bb,{}),a.jsxs(Ni,{onSelect:T,children:[a.jsx(ltt,{className:ot.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:ot.sideTaskListTitle,children:K("sideTask.new")})]})]})]})),Ke&&a.jsxs("button",{type:"button",className:ot.emptyAction,onClick:y,children:[a.jsx("span",{className:ot.emptyActionIcon,"aria-hidden":"true",children:a.jsx(gN,{strokeWidth:1.6})}),a.jsx("span",{className:ot.emptyActionTitle,children:K("webPreview.title")}),a.jsx("span",{className:ot.emptyActionHint,children:K("webPreview.openHint")}),a.jsx(bl,{className:ot.emptyActionChevron,"aria-hidden":"true"})]}),w&&a.jsxs("button",{type:"button",className:ot.emptyAction,onClick:()=>w(),children:[a.jsx("span",{className:ot.emptyActionIcon,"aria-hidden":"true",children:a.jsx(EC,{strokeWidth:1.6})}),a.jsx("span",{className:ot.emptyActionTitle,children:K("terminal.title")}),a.jsx("span",{className:ot.emptyActionHint,children:K("terminal.open")}),a.jsx(bl,{className:ot.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]})]})]})]})}function TCn(){return a.jsxs("svg",{className:ot.tabIconSvg,viewBox:"0 0 24 24",fill:"none",focusable:"false","aria-hidden":"true",children:[a.jsx("circle",{cx:"12",cy:"8",r:"3",stroke:"currentColor",strokeWidth:"1.6"}),a.jsx("path",{d:"M6.5 19c.7-3.1 2.5-4.7 5.5-4.7s4.8 1.6 5.5 4.7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function ICn(){return a.jsx("svg",{className:ot.tabCloseIcon,viewBox:"0 0 16 16",fill:"none",focusable:"false","aria-hidden":"true",children:a.jsx("path",{d:"m4.5 4.5 7 7M11.5 4.5l-7 7",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function Tq(){return a.jsxs("svg",{className:ot.tabIconSvg,viewBox:"0 0 24 24",fill:"none",focusable:"false",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"1.6"}),a.jsx("path",{d:"M9 9.5h6M12 6.5v6",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),a.jsx("path",{d:"M9 16h6",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]})}function ECn(){return a.jsxs("svg",{className:ot.tabIconSvg,viewBox:"0 0 24 24",fill:"none",focusable:"false",children:[a.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"3",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("path",{d:"M12 8v4l3 2",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}function RCn({artifacts:e,artifactId:t,sourceSessionId:n,workspaceActions:s,previewContent:r,loading:i,error:o}){const l=e.find(c=>c.id===t);return l?a.jsx(qCn,{artifact:l,sourceSessionId:n,workspaceActions:s,previewContent:r}):i?a.jsx("div",{className:ot.empty,children:"Loading artifact..."}):o?a.jsx("div",{className:ot.empty,children:o}):a.jsx("div",{className:ot.empty,children:"Artifact not found."})}function ACn({task:e,actions:t}){const{t:n}=mt(),[s,r]=d.useState(null),[i,o]=d.useState(!0),[l,c]=d.useState(null),[u,h]=d.useState(""),[f,p]=d.useState(e.prompt),[m,g]=d.useState(()=>Gy(e.cron)),[v,w]=d.useState(!1),[y,b]=d.useState(!1),[x,_]=d.useState(!1),[S,E]=d.useState(!1),[T,R]=d.useState(null),C=d.useRef(0),I=d.useRef(0),A=d.useRef({actions:t,taskId:e.id,workspaceId:e.workspaceId});A.current={actions:t,taskId:e.id,workspaceId:e.workspaceId};const N=d.useCallback((W,ge,le,ye)=>{const se=A.current;return W===C.current&&se.actions===ge&&se.taskId===le&&se.workspaceId===ye},[]),j=d.useCallback((W,ge,le,ye)=>{const se=A.current;return W===I.current&&se.actions===ge&&se.taskId===le&&se.workspaceId===ye},[]);d.useEffect(()=>()=>{C.current+=1,I.current+=1},[]),d.useEffect(()=>{_(!1),E(!1),R(null)},[t,e.id,e.workspaceId]);const O=d.useCallback(async()=>{const W=++C.current,ge=++I.current,le=e.id,ye=e.workspaceId;if(!e.durable||!t){r(null),h(""),p(e.prompt),g(Gy(e.cron)),c(null),o(!1);return}o(!0),c(null);try{const se=await t.listScheduledTasks(ye);if(!N(W,t,le,ye))return;const Se=se.find(re=>re.id===e.id)??null;r(Se),Se?(h(Se.name??""),p(Se.prompt),g(Gy(Se.cron))):(h(""),p(e.prompt),g(Gy(e.cron)))}catch(se){j(ge,t,le,ye)&&c(se instanceof Error?se.message:String(se))}finally{j(ge,t,le,ye)&&o(!1)}},[t,j,N,e.cron,e.durable,e.id,e.prompt,e.workspaceId]);d.useEffect(()=>{O()},[O]);const B=!e.durable,D=e.durable&&!i&&!l&&!s,U=!!s,V=s?.name||s?.prompt||e.title,F=s?.prompt??e.prompt,M=s?.cron??e.cron,X=s?.recurring??e.recurring,ee=s?.enabled,P=d.useCallback(()=>{s&&(h(s.name??""),p(s.prompt),g(Gy(s.cron)),R(null),w(!0))},[s]),ce=d.useCallback(()=>{w(!1),R(null),s&&(h(s.name??""),p(s.prompt),g(Gy(s.cron)))},[s]),ae=d.useCallback(async()=>{if(!s||!t)return;const W=u9(m);if(!W){R(n("scheduledTasks.error.invalidSchedule"));return}if(f.trim().length===0){R(n("scheduledTasks.error.emptyPrompt"));return}const ge=++C.current,le=e.id,ye=e.workspaceId;E(!0),R(null);try{const se=await t.updateScheduledTask(s.id,{cron:W,prompt:f.trim(),name:u.trim()||null},ye);if(!N(ge,t,le,ye))return;r(se),h(se.name??""),p(se.prompt),g(Gy(se.cron)),w(!1)}catch(se){N(ge,t,le,ye)&&R(se instanceof Error?se.message:String(se))}finally{N(ge,t,le,ye)&&E(!1)}},[t,m,N,s,u,f,n,e.id,e.workspaceId]),pe=d.useCallback(async()=>{if(!s||!t)return;const W=++C.current,ge=e.id,le=e.workspaceId;_(!0),R(null);try{const ye=await t.updateScheduledTask(s.id,{enabled:!s.enabled},le);if(!N(W,t,ge,le))return;r(ye)}catch(ye){N(W,t,ge,le)&&R(ye instanceof Error?ye.message:String(ye))}finally{N(W,t,ge,le)&&_(!1)}},[t,N,s,e.id,e.workspaceId]),q=d.useCallback(async()=>{if(!s||!t)return;const W=++C.current,ge=e.id,le=e.workspaceId;_(!0),R(null);try{if(await t.deleteScheduledTask(s.id,le),!N(W,t,ge,le))return;r(null),b(!1)}catch(ye){N(W,t,ge,le)&&R(ye instanceof Error?ye.message:String(ye))}finally{N(W,t,ge,le)&&_(!1)}},[t,N,s,e.id,e.workspaceId]),K=u9(m),oe=K?j2(K,n):null;return a.jsxs("div",{className:ot.detail,children:[i&&a.jsx("div",{className:ot.empty,children:n("scheduledTasks.loading")}),l&&a.jsx("div",{className:zt.loadError,children:l}),D&&a.jsx("div",{className:ot.empty,children:n("scheduledTasks.deletedSnapshot")}),B&&a.jsx("div",{className:ot.empty,children:n("scheduledTasks.sessionScopedSnapshot")}),!D&&a.jsx("div",{className:ot.section,children:a.jsxs("div",{className:ot.fieldGrid,children:[a.jsx("span",{className:ot.fieldLabel,children:n("scheduledTasks.name")}),a.jsx("span",{className:ot.fieldValue,children:V}),a.jsx("span",{className:ot.fieldLabel,children:n("scheduledTasks.taskId")}),a.jsx("span",{className:ot.fieldValue,children:e.id}),a.jsx("span",{className:ot.fieldLabel,children:n("scheduledTasks.schedule")}),a.jsx("span",{className:ot.fieldValue,children:j2(M,n)}),a.jsx("span",{className:ot.fieldLabel,children:"Cron"}),a.jsx("span",{className:ot.fieldValue,children:M}),a.jsx("span",{className:ot.fieldLabel,children:n("scheduledTasks.type")}),a.jsx("span",{className:ot.fieldValue,children:n(X?"scheduledTasks.repeats":"scheduledTasks.runsOnce")}),ee!==void 0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:ot.fieldLabel,children:n("scheduledTasks.status")}),a.jsx("span",{className:ot.fieldValue,children:n(ee?"scheduledTasks.enable":"scheduledTasks.disable")})]})]})}),!D&&a.jsxs("div",{className:ot.section,children:[a.jsx("div",{className:ot.sectionTitle,children:"Prompt"}),a.jsx("div",{className:ot.description,children:F})]}),T&&a.jsx("div",{className:zt.formError,children:T}),a.jsxs("div",{className:ot.actionsRow,children:[a.jsx("button",{type:"button",className:zt.primaryButton,disabled:!U||x,onClick:P,children:n("scheduledTasks.edit")}),a.jsx("button",{type:"button",className:zt.secondaryButton,disabled:!U||x,onClick:()=>void pe(),children:s?.enabled?n("scheduledTasks.disable"):n("scheduledTasks.enable")}),a.jsx("button",{type:"button",className:zt.secondaryButton,disabled:!U||x,onClick:()=>b(!0),children:n("scheduledTasks.delete")})]}),y&&s&&a.jsx(ga,{title:n("scheduledTasks.deleteConfirmTitle"),size:"sm",onClose:()=>b(!1),children:a.jsxs("div",{className:zt.formFields,children:[a.jsx("div",{className:ot.description,children:n("scheduledTasks.deleteConfirm",{name:s.name||s.prompt})}),T&&a.jsx("div",{className:zt.formError,children:T}),a.jsxs("div",{className:zt.formActions,children:[a.jsx("button",{type:"button",className:zt.secondaryButton,onClick:()=>b(!1),disabled:x,children:n("scheduledTasks.cancel")}),a.jsx("button",{type:"button",className:zt.primaryButton,onClick:()=>void q(),disabled:x,children:n("scheduledTasks.delete")})]})]})}),v&&a.jsx(ga,{title:n("scheduledTasks.editTitle"),size:"md",onClose:ce,children:a.jsxs("div",{className:zt.formFields,children:[a.jsxs("label",{className:zt.field,children:[a.jsx("span",{className:zt.fieldLabel,children:n("scheduledTasks.name")}),a.jsx("input",{className:zt.input,type:"text",value:u,maxLength:200,placeholder:n("scheduledTasks.namePlaceholder"),onChange:W=>h(W.target.value)})]}),a.jsxs("label",{className:zt.field,children:[a.jsxs("span",{className:zt.fieldLabel,children:[n("scheduledTasks.prompt"),a.jsx("span",{className:zt.required,children:"*"})]}),a.jsx("textarea",{className:zt.textarea,value:f,rows:4,maxLength:1e5,placeholder:n("scheduledTasks.promptPlaceholder"),onChange:W=>p(W.target.value)})]}),a.jsxs("div",{className:zt.scheduleRow,children:[a.jsxs("label",{className:zt.field,children:[a.jsx("span",{className:zt.fieldLabel,children:n("scheduledTasks.frequency")}),a.jsx("select",{className:zt.select,value:m.frequency,onChange:W=>{const ge=W.target.value;g(le=>({...le,frequency:ge,...ge==="hourly"?{time:"00:00"}:{}}))},children:yCn.map(W=>a.jsx("option",{value:W,children:n(`scheduledTasks.freq.${W}`)},W))})]}),(m.frequency==="daily"||m.frequency==="weekdays"||m.frequency==="weekly")&&a.jsxs("label",{className:zt.field,children:[a.jsx("span",{className:zt.fieldLabel,children:n("scheduledTasks.time")}),a.jsx("input",{className:zt.input,type:"time",value:m.time,onChange:W=>g(ge=>({...ge,time:W.target.value}))})]}),m.frequency==="weekly"&&a.jsxs("label",{className:zt.field,children:[a.jsx("span",{className:zt.fieldLabel,children:n("scheduledTasks.weekday")}),a.jsx("select",{className:zt.select,value:m.weekday,onChange:W=>g(ge=>({...ge,weekday:Number(W.target.value)})),children:n("scheduledTasks.weekdayNames").split(",").map((W,ge)=>a.jsx("option",{value:ge,children:W},ge))})]}),m.frequency==="minutes"&&a.jsxs("label",{className:zt.field,children:[a.jsx("span",{className:zt.fieldLabel,children:n("scheduledTasks.interval")}),a.jsx("select",{className:zt.select,value:m.minuteInterval,onChange:W=>g(ge=>({...ge,minuteInterval:Number(W.target.value)})),children:bCn.map(W=>a.jsx("option",{value:W,children:W},W))})]}),m.frequency==="custom"&&a.jsxs("label",{className:`${zt.field} ${zt.fieldGrow}`,children:[a.jsx("span",{className:zt.fieldLabel,children:n("scheduledTasks.cron")}),a.jsx("input",{className:zt.input,type:"text",value:m.customCron,spellCheck:!1,placeholder:"0 9 * * 1-5",onChange:W=>g(ge=>({...ge,customCron:W.target.value}))})]})]}),a.jsx("div",{className:zt.preview,children:oe?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:zt.previewLabel,children:oe}),a.jsx("code",{className:zt.previewCron,children:K})]}):a.jsx("span",{className:zt.previewInvalid,children:n("scheduledTasks.error.invalidSchedule")})}),T&&a.jsx("div",{className:zt.formError,children:T}),a.jsxs("div",{className:zt.formActions,children:[a.jsx("button",{type:"button",className:zt.secondaryButton,onClick:ce,disabled:S,children:n("scheduledTasks.cancel")}),a.jsx("button",{type:"button",className:zt.primaryButton,onClick:()=>void ae(),disabled:S,children:n(S?"scheduledTasks.saving":"scheduledTasks.save")})]})]})})]})}function jCn({changes:e,selectedPath:t,workspaceCwd:n,onOpenFilePreview:s,onDownloadFile:r,onDownloadError:i}){const{t:o}=mt(),[l,c]=d.useState(!1),[u,h]=d.useState(!0),[f,p]=d.useState(!1),[m,g]=d.useState(520),v=d.useRef(m),w=d.useRef(null),y=d.useRef(null),[b,x]=d.useState(null),[_,S]=d.useState(()=>new Set),E=d.useRef(!0);d.useEffect(()=>(E.current=!0,()=>{E.current=!1}),[]);const T=l,R=d.useMemo(()=>zCn(e,n),[e,n]);d.useEffect(()=>{x(t)},[t]),d.useEffect(()=>{v.current=m},[m]),d.useEffect(()=>{const j=w.current;if(!j)return;const O=()=>{p(j.clientWidth<wCn)};O();const B=new ResizeObserver(O);return B.observe(j),()=>B.disconnect()},[u]),d.useEffect(()=>()=>y.current?.(),[]);const C=d.useCallback(j=>{const O=w.current;if(!O)return;j.preventDefault();const B=j.currentTarget;B.setPointerCapture(j.pointerId);const D=j.clientX,U=v.current,V=O.getBoundingClientRect().width,F=Math.max(180,V-180),M=document.body.style.cursor,X=document.body.style.userSelect;let ee=U,P=null;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const ce=()=>{P=null,g(ee)},ae=K=>{ee=Math.min(F,Math.max(180,U+(K.clientX-D))),P===null&&(P=window.requestAnimationFrame(ce))};let pe=()=>{};const q=K=>{y.current=null,P!==null&&(window.cancelAnimationFrame(P),P=null),K&&g(ee),B.hasPointerCapture(j.pointerId)&&B.releasePointerCapture(j.pointerId),document.body.style.cursor=M,document.body.style.userSelect=X,window.removeEventListener("pointermove",ae),window.removeEventListener("pointerup",pe),window.removeEventListener("pointercancel",pe)};pe=()=>q(!0),y.current=()=>q(!1),window.addEventListener("pointermove",ae),window.addEventListener("pointerup",pe),window.addEventListener("pointercancel",pe)},[]);if(e.length===0)return a.jsx("div",{className:ot.empty,children:"No file changes to review."});const I=cRe(e),A=j=>{x(O=>O===j?null:j)},N=async j=>{if(!_.has(j.path)){S(O=>new Set(O).add(j.path));try{await r(j,()=>!E.current)}catch(O){E.current&&i(O)}finally{S(O=>{const B=new Set(O);return B.delete(j.path),B})}}};return a.jsxs("div",{className:ot.review,children:[a.jsxs("div",{className:ot.reviewToolbar,children:[a.jsxs("div",{className:ot.reviewToolbarTitle,children:[a.jsx("span",{children:o("turnOutputs.previousTurn")}),a.jsx(Z9,{additions:I?.additions,deletions:I?.deletions,className:ot.lineStats,additionsClassName:ot.additions,deletionsClassName:ot.deletions})]}),a.jsxs("div",{className:ot.reviewToolbarActions,children:[a.jsxs("button",{type:"button",className:ot.reviewTotalsButton,onClick:()=>h(j=>!j),"aria-expanded":u,children:[a.jsx("span",{children:o("turnOutputs.fileCount",{count:e.length})}),a.jsx("span",{className:[ot.chevron,u?ot.chevronOpen:""].filter(Boolean).join(" "),"aria-hidden":"true",children:a.jsx(Sge,{})})]}),a.jsx("button",{type:"button",className:[ot.iconButton,l?ot.iconButtonActive:""].filter(Boolean).join(" "),onClick:()=>c(j=>!j),"aria-label":o(l?"turnOutputs.closeFileTree":"turnOutputs.openFileTree"),title:o(l?"turnOutputs.closeFileTree":"turnOutputs.openFileTree"),children:l?a.jsx(BCn,{}):a.jsx($Cn,{})})]})]}),u&&a.jsxs("div",{ref:w,className:[ot.reviewContent,T?"":ot.reviewContentListOnly,T&&f?ot.reviewContentStacked:""].filter(Boolean).join(" "),style:{"--review-list-width":`${m}px`},children:[a.jsx("div",{className:[ot.reviewList,b?ot.reviewListWithExpanded:""].filter(Boolean).join(" "),children:e.map(j=>{const O=b===j.path,B=fRe(j.path),D=x7t(j.path);return a.jsxs("div",{className:[ot.reviewItem,O?ot.reviewItemExpanded:""].filter(Boolean).join(" "),children:[a.jsxs("div",{className:ot.reviewRow,"data-selected":j.path===t||void 0,children:[a.jsx("button",{type:"button",className:ot.reviewRowToggle,onClick:()=>A(j.path),"aria-label":j.path,"aria-expanded":O}),a.jsx("span",{className:ot.fileIcon,children:VNe(j.path)}),a.jsxs("span",{className:ot.reviewFileName,children:[a.jsx(LCn,{path:JL(j.path,n),title:j.path}),B&&a.jsx("button",{type:"button",className:ot.reviewOpenButton,onClick:()=>s(j),title:`${o("turnOutputs.preview")} ${j.path}`,children:o("turnOutputs.preview")}),D&&a.jsx("button",{type:"button",className:ot.reviewOpenButton,onClick:()=>void N(j),title:`${o("common.download")} ${j.path}`,disabled:_.has(j.path),children:o(_.has(j.path)?"common.downloading":"common.download")})]}),a.jsx(Z9,{additions:j.additions,deletions:j.deletions,className:ot.lineStats,additionsClassName:ot.additions,deletionsClassName:ot.deletions}),a.jsx("span",{className:[ot.chevron,O?ot.chevronOpen:""].filter(Boolean).join(" "),"aria-hidden":"true",children:a.jsx(Sge,{})})]}),O&&a.jsx(NCn,{change:j})]},`${j.toolCallId}:${j.path}`)})}),T&&!f&&a.jsx("div",{className:ot.reviewSplitHandle,role:"separator","aria-orientation":"vertical",onPointerDown:C}),T&&a.jsx("div",{className:ot.tree,children:R.children.map(j=>a.jsx(HNe,{node:j,depth:0,selectedPath:t},j.path))})]})]})}function NCn({change:e}){if(e.diffs.length===0)return a.jsx("div",{className:ot.diffEmpty,children:"No diff available."});const t=MCn(e.diffs);return a.jsx("div",{className:ot.diffPreview,children:t.map((n,s)=>n.fileDiff&&!n.fullContent?a.jsx(M3e,{diff:n.fileDiff},s):a.jsx(PCn,{oldText:n.oldText,newText:n.newText},s))})}function MCn(e){for(let t=e.length-1;t>=0;t--)if(e[t]?.fullContent)return e.slice(t);return e}function PCn({oldText:e,newText:t}){const n=d.useRef(null),[s,r]=d.useState(null),[i,o]=d.useState(null);return d.useEffect(()=>{const l=n.current;if(!l)return;const c=()=>r(l.clientWidth>=720);c();const u=new ResizeObserver(c);return u.observe(l),()=>u.disconnect()},[]),d.useEffect(()=>{const l=n.current;if(!l||s===null)return;l.replaceChildren(),o(null);let c=!1,u=null;const h=[tje,ts.editable.of(!1),yo.readOnly.of(!0),ts.lineWrapping],f={scanLimit:1e3,timeout:500},p={margin:3,minSize:8};return $e(async()=>{const{MergeView:m,unifiedMergeView:g}=await import("./index-CmMV8Jla.js");return{MergeView:m,unifiedMergeView:g}},[]).then(({MergeView:m,unifiedMergeView:g})=>{if(!c)try{if(s){u=new m({a:{doc:e,extensions:h},b:{doc:t,extensions:h},parent:l,highlightChanges:!0,gutter:!0,revertControls:void 0,collapseUnchanged:p,diffConfig:f});return}u=new ts({doc:t,extensions:[...h,g({original:e,highlightChanges:!0,gutter:!0,mergeControls:!1,allowInlineDiffs:!0,collapseUnchanged:p,diffConfig:f})],parent:l})}catch(v){c||o(v instanceof Error?v.message:String(v))}}).catch(m=>{c||o(m instanceof Error?m.message:String(m))}),()=>{c=!0,u?.destroy()}},[s,t,e]),a.jsxs("div",{className:ot.codeMirrorDiffWrap,children:[a.jsx("div",{ref:n,className:ot.codeMirrorDiff}),i&&a.jsxs("div",{className:ot.diffError,children:["Diff unavailable: ",i]})]})}function HNe({node:e,depth:t,selectedPath:n}){const s=!!e.file,[r,i]=d.useState(!0),o=[ot.treeRow,s?ot.treeFile:ot.treeFolder].filter(Boolean).join(" "),l={paddingLeft:10+t*18,"--tree-row-line-left":`${19+Math.max(0,t-1)*18}px`},c={"--tree-children-line-left":`${19+t*18}px`},u=a.jsxs(a.Fragment,{children:[a.jsx("span",{className:ot.treeTwisty,children:!s&&a.jsx("span",{className:[ot.treeChevron,r?"":ot.treeChevronClosed].filter(Boolean).join(" "),children:a.jsx(FCn,{})})}),a.jsxs("span",{className:ot.treeContent,children:[s&&a.jsx("span",{className:ot.fileIcon,children:VNe(e.path)}),a.jsx("span",{className:ot.treeName,children:e.name})]}),e.file?.isArtifact&&a.jsx("span",{className:ot.reviewBadge,children:"artifact"})]});return a.jsxs("div",{className:ot.treeNode,children:[s?a.jsx("div",{className:o,"data-selected":e.file?.path===n||void 0,"data-depth":t,style:l,title:e.path,children:u}):a.jsx("button",{type:"button",className:o,"data-depth":t,style:l,title:e.path,"aria-expanded":r,onClick:()=>i(h=>!h),children:u}),!s&&r&&e.children.length>0&&a.jsx("div",{className:ot.treeChildren,style:c,children:e.children.map(h=>a.jsx(HNe,{node:h,depth:t+1,selectedPath:n},h.path))})]})}function LCn({path:e,title:t}){const n=d.useRef(null),[s,r]=d.useState(()=>UNe(e));return d.useLayoutEffect(()=>{const i=n.current;if(!i)return;const o=()=>r(DCn(e,i));o();const l=new ResizeObserver(o);return l.observe(i),()=>l.disconnect()},[e]),a.jsxs("span",{ref:n,className:ot.reviewPath,title:t??e,children:[s.prefix&&a.jsx("span",{className:ot.pathPrefix,children:s.prefix}),a.jsx("span",{className:ot.pathFileName,children:s.leaf})]})}function UNe(e){const t=e.lastIndexOf("/");return t<0?{prefix:"",leaf:e}:{prefix:e.slice(0,t+1),leaf:e.slice(t+1)}}let kge=null;function DCn(e,t){const n=UNe(e),s=t.clientWidth;if(s<=0)return n;const r=OCn(t);if(r(e)<=s)return n;const i=e.split("/").filter(Boolean),o=i.at(-1)??e,l=r(o);if(i.length<=1||l+r(".../")>s)return{prefix:"",leaf:o};let c=".../";for(let u=1;u<i.length;u++){const f=`.../${i.slice(i.length-1-u,-1).join("/")}/`;if(r(f)+l>s)break;c=f}return{prefix:c,leaf:o}}function OCn(e){kge??=document.createElement("canvas");const t=kge.getContext("2d"),n=window.getComputedStyle(e);return t&&(t.font=[n.fontStyle,n.fontVariant,n.fontWeight,n.fontSize,n.fontFamily].join(" ")),s=>t?.measureText(s).width??s.length*8}function $Cn(){return a.jsxs("svg",{className:ot.toolbarIcon,viewBox:"0 0 24 24",fill:"none",focusable:"false","aria-hidden":"true",children:[a.jsx("path",{d:"M3.5 7.5h6l1.6 2h9.4v8.2a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2V7.5Z",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),a.jsx("path",{d:"M3.5 7.5V5.8a1.5 1.5 0 0 1 1.5-1.5h4l1.8 2.1h7.2a1.5 1.5 0 0 1 1.5 1.5v1.6",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"})]})}function BCn(){return a.jsxs("svg",{className:ot.toolbarIcon,viewBox:"0 0 24 24",fill:"none",focusable:"false","aria-hidden":"true",children:[a.jsx("path",{d:"M3.5 8.2V5.8A1.5 1.5 0 0 1 5 4.3h4l1.8 2.1h7.2a1.5 1.5 0 0 1 1.5 1.5v1.4",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),a.jsx("path",{d:"M4.8 19.7h12.9a2 2 0 0 0 1.9-1.4l2-7H6.4l-2.8 7.1a.9.9 0 0 0 1.2 1.3Z",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"})]})}function Sge(){return a.jsx("svg",{className:ot.chevronIcon,viewBox:"0 0 16 16",fill:"none",focusable:"false","aria-hidden":"true",children:a.jsx("path",{d:"m6 4 4 4-4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function FCn(){return a.jsx("svg",{className:ot.treeChevronIcon,viewBox:"0 0 16 16",fill:"none",focusable:"false","aria-hidden":"true",children:a.jsx("path",{d:"m4 6 4 4 4-4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function zCn(e,t){const n={name:"",path:"",children:[]};for(const s of e){const r=JL(s.path,t).split("/").filter(Boolean);let i=n;for(let o=0;o<r.length;o++){const l=r[o],c=r.slice(0,o+1).join("/");let u=i.children.find(h=>h.name===l);u||(u={name:l,path:c,children:[]},i.children.push(u)),o===r.length-1&&(u.file=s),i=u}}return WNe(n),n}function WNe(e){e.children.sort((t,n)=>!!t.file!=!!n.file?t.file?1:-1:t.name.localeCompare(n.name));for(const t of e.children)WNe(t)}function tM(e){return Sw(e).split("/").filter(Boolean).at(-1)??e}function VNe(e){const t=tM(e),n=t.includes(".")?t.split(".").pop()?.toLowerCase():"";return n?{css:"CSS",html:"HTML",js:"JS",json:"JSON",jsx:"JSX",md:"MD",ts:"TS",tsx:"TSX"}[n]??n.slice(0,3).toUpperCase():"FILE"}function qCn({artifact:e,sourceSessionId:t,workspaceActions:n,previewContent:s}){const{t:r}=mt(),i=vm(),o=f2e(e),l=_5(e.url)?e.url:void 0,c=e.metadata?.artifactType==="automation_snapshot",u=e.metadata?.artifactType==="code_review",h=e.storage==="workspace"&&!!e.workspacePath,f=h2e(e);return e.metadata?.artifactType==="web_preview_snapshot"?a.jsx(xSn,{artifact:e,sourceSessionId:t}):u?e.status!=="available"?a.jsx(HCn,{status:e.status}):!h||!e.workspacePath?a.jsx(UCn,{}):a.jsx(Nbn,{workspacePath:e.workspacePath,artifactVersion:Nae(e),workspaceActions:n}):h&&e.workspacePath?u2e(e)?a.jsx(GCn,{artifact:e,workspaceActions:n}):a.jsx(ID,{workspacePath:e.workspacePath,artifactVersion:Nae(e),workspaceActions:n,previewContent:s,imageMimeType:f,previewKind:WCn(e)?"html":VCn(e)?"markdown":f?"image":"source"}):a.jsxs("div",{className:ot.detail,children:[a.jsxs("div",{className:ot.section,children:[a.jsx("div",{className:ot.sectionTitle,children:c?"Automation Snapshot":"Artifact"}),a.jsxs("div",{className:ot.fieldGrid,children:[a.jsx(Fh,{label:"Type",value:gZ(e.kind,e.workspacePath)}),a.jsx(Fh,{label:"Storage",value:e.storage}),a.jsx(Fh,{label:"Status",value:e.status}),a.jsx(Fh,{label:"Source",value:e.source}),a.jsx(Fh,{label:"Size",value:mL(e.sizeBytes)}),a.jsx(Fh,{label:"Created",value:e.createdAt}),a.jsx(Fh,{label:"Updated",value:e.updatedAt}),e.toolName&&a.jsx(Fh,{label:"Tool",value:e.toolName}),e.toolCallId&&a.jsx(Fh,{label:"Tool call",value:e.toolCallId})]})]}),e.description&&a.jsxs("div",{className:ot.section,children:[a.jsx("div",{className:ot.sectionTitle,children:"Description"}),a.jsx("div",{className:ot.description,children:e.description})]}),c&&e.metadata&&a.jsxs("div",{className:ot.section,children:[a.jsx("div",{className:ot.sectionTitle,children:"Details"}),a.jsxs("div",{className:ot.fieldGrid,children:[zS(e.metadata,"automationId","Automation ID"),zS(e.metadata,"schedule","Schedule"),zS(e.metadata,"timezone","Timezone"),zS(e.metadata,"status","Status"),zS(e.metadata,"nextRunAt","Next run"),zS(e.metadata,"prompt","Prompt")]})]}),(o||l)&&a.jsxs("div",{className:ot.section,children:[a.jsx("div",{className:ot.sectionTitle,children:"Location"}),l?a.jsxs("div",{className:ot.locationRow,children:[a.jsx("a",{className:ot.link,href:l,target:"_blank",rel:"noopener noreferrer",onClick:p=>i(p,l),children:l}),a.jsx("a",{className:ot.openButton,href:l,target:"_blank",rel:"noopener noreferrer",onClick:p=>i(p,l),children:r("artifact.openLink")})]}):a.jsx("div",{className:ot.meta,children:o})]})]})}function HCn({status:e}){const{t}=mt();return a.jsx("div",{className:ot.previewError,role:"alert",children:t("codeReview.unavailable",{status:e})})}function UCn(){const{t:e}=mt();return a.jsx("div",{className:ot.previewError,role:"alert",children:e("codeReview.workspaceRequired")})}function WCn(e){const t=e.workspacePath?.toLowerCase()??"",n=kw(e.mimeType);return e.kind==="html"||t.endsWith(".html")||t.endsWith(".htm")||n==="text/html"}function VCn(e){const t=e.workspacePath?.toLowerCase()??"",n=kw(e.mimeType);return t.endsWith(".md")||t.endsWith(".markdown")||n==="text/markdown"}function GCn({artifact:e,workspaceActions:t}){const{t:n}=mt(),[s,r]=d.useState(null),[i,o]=d.useState(!1),l=d.useRef(!0),c=f2e(e);d.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const u=async()=>{if(e.workspacePath){o(!0),r(null);try{await gL(t,e.workspacePath,e.mimeType,()=>!l.current)}catch(h){if(!l.current)return;r(h instanceof Error?h.message:String(h))}finally{l.current&&o(!1)}}};return a.jsx("div",{className:ot.detail,children:a.jsxs("div",{className:ot.section,children:[a.jsx("div",{className:ot.sectionTitle,children:n("common.download")}),a.jsxs("div",{className:ot.fieldGrid,children:[a.jsx(Fh,{label:"Type",value:gZ(e.kind,e.workspacePath)}),a.jsx(Fh,{label:"Size",value:mL(e.sizeBytes)}),c?a.jsx(Fh,{label:"Location",value:c}):null,e.status!=="available"&&e.status!=="changed"?a.jsx(Fh,{label:"Status",value:e.status??"missing"}):null]}),a.jsx("div",{className:ot.downloadRow,children:a.jsx("button",{type:"button",className:ot.downloadButton,onClick:()=>{u()},disabled:i||e.status!=="available"&&e.status!=="changed",children:n(i?"common.downloading":"common.download")})}),s&&a.jsx("div",{className:ot.previewError,children:s})]})})}function KCn({tab:e}){const{t}=mt(),n=Ra(),s=L5(e.workspaceCwd),r=s?.actions,i=vm(),[o,l]=d.useState(0),[c,u]=d.useState(),[h,f]=d.useState(),[p,m]=d.useState(),g=e.source,v=g.locator,w=e.owner.isCurrent()&&n.sessionId===e.sourceSessionId&&n.capabilities?.features.includes("session_sources")&&s?.workspaceId===e.workspaceId&&(!!s||e.workspaceCwd===void 0&&v.type!=="workspace_file")&&(v.type!=="workspace_file"||g.workspaceCwd===n.workspaceCwd),y=v.type==="workspace_file"?v.workspacePath:v.type==="attachment"?v.attachmentId:"",b=/\.pdf$/i.test(y);if(d.useEffect(()=>{let _=!1;return u(void 0),f(void 0),m(void 0),!w||v.type==="url"?void 0:((async()=>{if(v.type==="attachment"){const E=await e.sessionActions.readAttachment(v.attachmentId);if(_||!e.owner.isCurrent())return;const T=Uint8Array.from(atob(E.data),R=>R.charCodeAt(0));u(new Blob([T],{type:E.mimeType}))}else if(b&&r){const E=await d5(r.readFileBytes,y,"application/pdf",{statFile:r.stat,isCancelled:()=>_||!e.owner.isCurrent()});!_&&e.owner.isCurrent()&&u(E)}})().catch(E=>{!_&&e.owner.isCurrent()&&f(sl(E))}),()=>{_=!0})},[o,w,v,y,b,e.owner,e.sessionActions,r]),w&&v.type==="url")return a.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[a.jsx("h3",{children:g.title}),g.description&&a.jsx("p",{children:g.description}),a.jsx("p",{className:"break-all text-sm text-muted-foreground",children:v.url}),_5(v.url)&&a.jsx("a",{className:"text-primary underline",href:v.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>i(_,v.url),children:t("sources.openOriginal")})]});if(!w||!s&&v.type!=="attachment")return a.jsx("div",{className:ot.empty,role:"alert",children:t("sources.unavailable")});const x=v.type==="workspace_file"&&!b&&u2e({workspacePath:y});return a.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:y,children:y}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[p&&a.jsx(Nt,{variant:"ghost",size:"icon-sm",asChild:!0,children:a.jsx("a",{href:p,download:g.title,"aria-label":`Download ${g.title}`,title:t("common.download"),children:a.jsx(aw,{})})}),h&&a.jsx(Nt,{variant:"ghost",size:"sm",onClick:()=>l(_=>_+1),children:t("common.retry")})]})]}),h?a.jsx("div",{className:ot.previewError,role:"alert",children:h}):x?a.jsxs("div",{className:"p-4",children:[a.jsx("p",{children:t("attachment.previewUnsupported")}),a.jsx(Nt,{onClick:()=>void gL(r,y,"application/octet-stream",()=>!e.owner.isCurrent()).catch(_=>{e.owner.isCurrent()&&f(sl(_))}),children:t("common.download")})]}):(v.type==="attachment"||b)&&!c?a.jsx("div",{className:ot.empty,role:"status",children:t("common.loading")}):c&&c.type!=="application/pdf"&&!X2(c.type,y)?a.jsx(GNe,{data:c,title:g.title,onDownloadUrl:m,showDownload:!1,image:!!wT(y)&&c.type.startsWith("image/")}):a.jsx(ID,{workspacePath:y,workspaceActions:r,onLoadError:f,previewData:c,previewOnly:v.type==="attachment",previewMimeType:c?.type,previewKind:/\.html?$/i.test(y)||kw(c?.type)==="text/html"?"source":void 0},o)]})}function GNe({data:e,title:t,image:n,onDownloadUrl:s,showDownload:r=!0}){const[i,o]=d.useState();return d.useEffect(()=>{const l=URL.createObjectURL(e);return o(l),s?.(l),()=>URL.revokeObjectURL(l)},[e,s]),i?a.jsxs("div",{className:ot.imagePreviewWrap,children:[n?a.jsx("img",{className:ot.imagePreview,src:i,alt:t}):a.jsx(KNe,{name:t,mimeType:e.type,size:e.size}),r&&a.jsx("a",{href:i,download:t,"aria-label":`Download ${t}`,children:a.jsx(aw,{})})]}):null}function ID({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewData:r,previewMimeType:i,imageMimeType:o,previewKind:l,previewOnly:c,onLoadError:u}){if(r)return a.jsx(YCn,{workspacePath:e,workspaceActions:n,data:r,mimeType:i,previewKind:l,onLoadError:u});const h=e.toLowerCase(),f=o??wT(e),p=l??(h.endsWith(".html")||h.endsWith(".htm")?"html":h.endsWith(".md")||h.endsWith(".markdown")?"markdown":f?"image":"source");return p==="html"?a.jsx(JCn,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:c,onLoadError:u}):p==="markdown"?a.jsx(t2n,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:c,onLoadError:u}):p==="image"&&f?a.jsx(QCn,{workspacePath:e,artifactVersion:t,workspaceActions:n,mimeType:f,onLoadError:u}):a.jsx(e2n,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:c,onLoadError:u})}function YCn({workspacePath:e,workspaceActions:t,data:n,mimeType:s,previewKind:r,onLoadError:i}){const o=(s||n.type||"application/octet-stream").split(";",1)[0].trim().toLowerCase();return o==="application/pdf"?a.jsx(ZCn,{data:n,mimeType:o,title:e}):X2(o,e)?a.jsx(XCn,{workspacePath:e,workspaceActions:t,data:n,previewKind:r,onLoadError:i}):a.jsx(KNe,{name:e,mimeType:o,size:n.size})}function XCn({workspacePath:e,workspaceActions:t,data:n,previewKind:s,onLoadError:r}){const{t:i}=mt(),[o,l]=d.useState(),[c,u]=d.useState();return d.useEffect(()=>{const h=new FileReader;return l(void 0),u(void 0),h.onload=()=>l(String(h.result??"")),h.onerror=()=>{const f=i("attachment.readFailed");u(f),r?.(f)},h.readAsText(n),()=>{h.readyState===FileReader.LOADING&&h.abort()}},[n,r,i]),c?a.jsx("div",{className:ot.previewError,children:c}):o===void 0?a.jsx("div",{className:ot.empty,children:i("attachment.loadingFile")}):a.jsx(ID,{workspacePath:e,workspaceActions:t,previewContent:o,previewOnly:!0,previewKind:s})}function ZCn({data:e,mimeType:t,title:n}){const{t:s}=mt(),[r,i]=d.useState();return d.useEffect(()=>{const o=URL.createObjectURL(e.type===t?e:new Blob([e],{type:t}));return i(o),()=>URL.revokeObjectURL(o)},[e,t]),r?a.jsx("iframe",{className:ot.pdfAttachmentPreview,src:r,title:`Preview ${n}`}):a.jsx("div",{className:ot.empty,children:s("attachment.loadingPreview")})}function KNe({name:e,mimeType:t,size:n}){const{t:s}=mt();return a.jsxs("div",{className:ot.unsupportedAttachmentPreview,children:[a.jsx(cg,{name:e,mimeType:t,"aria-hidden":"true"}),a.jsx("div",{children:s("attachment.previewUnsupported")}),a.jsxs("div",{className:ot.unsupportedAttachmentMeta,children:[t," · ",mL(n)]})]})}function QCn({workspacePath:e,artifactVersion:t,workspaceActions:n,mimeType:s,onLoadError:r}){const[i,o]=d.useState(null),[l,c]=d.useState(null);return d.useEffect(()=>{let u=!1,h;return o(null),c(null),d5((f,p)=>n.readFileBytes(f,p),e,s,{statFile:f=>n.stat(f),isCancelled:()=>u}).then(f=>{u||(h=URL.createObjectURL(f),o(h))}).catch(f=>{if(u)return;const p=f instanceof Error?f.message:String(f);c(p),r?.(p)}),()=>{u=!0,h&&URL.revokeObjectURL(h)}},[t,s,r,n,e]),a.jsxs("div",{className:ot.imagePreviewWrap,children:[i?a.jsxs(a.Fragment,{children:[a.jsx("img",{className:ot.imagePreview,src:i,alt:tM(e)}),a.jsx("a",{className:ot.imageDownloadButton,href:i,download:tM(e),"aria-label":`Download ${tM(e)}`,title:"Download",children:a.jsx(aw,{size:16,strokeWidth:1.8})})]}):l?null:a.jsx("div",{className:ot.empty,children:"Loading image..."}),l&&a.jsx("div",{className:ot.previewError,children:l})]})}function Uee({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,truncatedMessage:i,onLoadError:o}){const[l,c]=d.useState(s??null),[u,h]=d.useState(null);return d.useEffect(()=>{let f=!1;if(c(s??null),h(null),!r)return n.stat(e).then(p=>{if(!f){if(p.type==="directory")throw new Error("Directories cannot be opened as artifacts.");return n.readWorkspaceFile(e)}}).then(p=>{f||!p||(c(p.content),p.truncated&&h(i))}).catch(p=>{if(f)return;const m=p instanceof Error?p.message:String(p);h(m),o?.(m)}),()=>{f=!0}},[t,s,r,i,o,n,e]),{content:l,error:u}}function JCn({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:i}){const{content:o,error:l}=Uee({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,truncatedMessage:"Preview is truncated because the file is too large.",onLoadError:i});return a.jsxs("div",{className:ot.htmlPreviewWrap,children:[o===null?a.jsx("div",{className:ot.empty,children:"Loading preview..."}):a.jsx("iframe",{className:ot.htmlPreview,referrerPolicy:"no-referrer",sandbox:"allow-scripts",srcDoc:p2e(o,`Preview ${e}`),title:`Preview ${e}`}),l&&a.jsx("div",{className:ot.previewError,children:l})]})}function e2n({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:i}){const o=d.useRef(null),[l,c]=d.useState(null),{content:u,error:h}=Uee({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,truncatedMessage:"File is truncated because it is too large.",onLoadError:i});return d.useEffect(()=>{const f=o.current;if(!f||u===null)return;f.replaceChildren(),c(null);let p;try{p=new ts({doc:u,extensions:[tje,ts.editable.of(!1),yo.readOnly.of(!0),ts.lineWrapping],parent:f})}catch(m){c(m instanceof Error?m.message:String(m));return}return()=>p.destroy()},[u]),a.jsxs("div",{className:ot.filePreviewWrap,children:[u===null?a.jsx("div",{className:ot.empty,children:"Loading file..."}):a.jsx("div",{ref:o,className:ot.codeMirrorFile}),(h||l)&&a.jsx("div",{className:ot.previewError,children:h||l})]})}function t2n({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:i}){const{content:o,error:l}=Uee({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,truncatedMessage:"Preview is truncated because the file is too large.",onLoadError:i});return a.jsxs("div",{className:ot.markdownPreviewWrap,children:[o===null?a.jsx("div",{className:ot.empty,children:"Loading preview..."}):a.jsx(rp,{content:o}),l&&a.jsx("div",{className:ot.previewError,children:l})]})}function Fh({label:e,value:t}){return t?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:ot.fieldLabel,children:e}),a.jsx("span",{className:ot.fieldValue,children:t})]}):null}function zS(e,t,n){const s=e[t];return s==null||s===""?null:a.jsx(Fh,{label:n,value:String(s)},t)}function n2n(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const YNe=Gs.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),nA=()=>{const e=Gs.useContext(YNe);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};n2n(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
|
|
2145
|
+
\x1B[33m[${o("terminal.notice.reconnecting")}]\x1B[0m`),S=!0),x=setTimeout(M,_),_=Math.min(_*2,pSn))}}const X=requestAnimationFrame(()=>M()),ee=()=>{if(T)return;T=!0,x&&clearTimeout(x);const ce=h.current;ce?.readyState===WebSocket.OPEN?(ce.send(zy+JSON.stringify({type:"release"})),ce.close()):(!ce||ce.readyState!==WebSocket.CONNECTING)&&M(!0)};e_.set(e,ee);const P=new ResizeObserver(()=>{!u.current||!c.current||(clearTimeout(E),E=setTimeout(()=>{try{u.current?.fit(),w()}catch{}},100))});return P.observe(l.current),f.current&&m.focus(),()=>{b=!0,e_.get(e)===ee&&e_.delete(e),x&&clearTimeout(x),C&&clearTimeout(C),cancelAnimationFrame(X),clearTimeout(E),P.disconnect(),B.dispose(),j?.term.dispose(),(!T||h.current?.readyState!==WebSocket.CONNECTING)&&h.current?.close(),m.dispose(),c.current=null,u.current=null,h.current=null}},[s]),d.useEffect(()=>{const p=c.current;if(n){try{u.current?.fit(),p&&p.refresh(0,p.rows-1);const m=h.current;p&&m?.readyState===WebSocket.OPEN&&m.send(zy+JSON.stringify({type:"resize",cols:p.cols,rows:p.rows}))}catch{}p?.focus()}else p?.blur()},[n]),a.jsx("div",{"data-web-terminal":!0,style:{display:"flex",flexDirection:"column",height:"100%",background:r!=="light"?"#0a0a0a":"#ffffff"},children:a.jsx("div",{ref:l,style:{flex:1,overflow:"hidden",padding:"0.25rem 0.5rem"}})})}function bSn({state:e,onChange:t}){const{t:n}=mt(),{baseUrl:s}=vi(),r=vm(),[i,o]=d.useState(e.url),[l,c]=d.useState(!1),[u,h]=d.useState(0),f=ZU(e.url,window.location.href,s);return d.useEffect(()=>{o(e.url),c(!1)},[e.url]),a.jsxs("section",{className:"flex h-full min-h-0 flex-col gap-3 bg-background text-foreground","data-web-shell-web-preview":!0,"aria-label":n("webPreview.title"),children:[a.jsxs("form",{className:"flex shrink-0 gap-2",onSubmit:p=>{p.preventDefault();const m=ZU(i,window.location.href,s);c(!m),m&&(o(m.href),h(g=>g+1),t({...e,url:m.href}))},children:[a.jsx(oi,{"aria-label":n("webPreview.address"),"aria-invalid":l||!!e.url&&!f,placeholder:"http://localhost:3000",value:i,onChange:p=>{o(p.target.value),c(!1)},autoComplete:"off",spellCheck:!1}),a.jsx(Nt,{type:"submit",children:n("webPreview.open")})]}),l||e.url&&!f?a.jsx("p",{role:"alert",className:"text-sm text-destructive",children:n("webPreview.invalidUrl")}):null,a.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-1",children:[a.jsx(Nt,{type:"button",variant:"ghost",size:"icon",disabled:!f,title:n("webPreview.refresh"),"aria-label":n("webPreview.refresh"),onClick:()=>h(p=>p+1),children:a.jsx(GCe,{})}),["desktop","mobile"].map(p=>a.jsx(Nt,{type:"button",variant:e.viewport===p?"secondary":"ghost",size:"icon","aria-pressed":e.viewport===p,title:n(`webPreview.${p}`),"aria-label":n(`webPreview.${p}`),onClick:()=>t({...e,viewport:p}),children:p==="desktop"?a.jsx(Znt,{}):a.jsx(qst,{})},p)),f&&a.jsx(Nt,{asChild:!0,variant:"ghost",size:"sm",className:"ml-auto",children:a.jsxs("a",{href:f.href,target:"_blank",rel:"noopener noreferrer",onClick:p=>r(p,f.href),children:[a.jsx(GU,{}),n("webPreview.external")]})})]}),f?a.jsx("div",{className:"min-h-0 flex-1 overflow-auto rounded-lg border border-border bg-muted",children:a.jsx("iframe",{title:n("webPreview.frame"),className:"mx-auto block h-full border-0 bg-white",style:{width:e.viewport==="mobile"?390:"100%"},referrerPolicy:"no-referrer",srcDoc:vrt(f,n("webPreview.page"))},`${f.href}:${u}`)}):a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border p-6 text-center text-sm text-muted-foreground",children:[a.jsx(gN,{className:"size-8"}),a.jsx("p",{children:n("webPreview.empty")})]}),f&&a.jsx("p",{className:"shrink-0 text-xs text-muted-foreground",children:n("webPreview.live")}),a.jsx("p",{className:"shrink-0 text-xs text-muted-foreground",children:n(f?"webPreview.fallback":"webPreview.reachable")})]})}function xSn({artifact:e,sourceSessionId:t}){const{t:n}=mt(),{client:s}=vi(),r=Ra(),i=t??r.sessionId,o=i===r.sessionId?r.clientId:void 0,[l,c]=d.useState(0),[u,h]=d.useState(0),[f,p]=d.useState(),m=`${i}:${e.id}:${l}`;d.useEffect(()=>{const y=new AbortController;if(!i){p({key:m,failed:"request"});return}return s.readSessionArtifactContent(i,e.id,{clientId:o,signal:y.signal}).then(b=>{y.signal.aborted||p({key:m,html:b})},b=>{y.signal.aborted||p({key:m,failed:b instanceof _o&&b.status===404&&typeof b.body=="object"&&b.body!==null&&"error"in b.body&&b.body.error==="artifact_snapshot_unavailable"?"unavailable":"request"})}),()=>y.abort()},[e.id,s,o,m,i]);const g=f?.key===m?f:void 0,v=n("webPreview.savedFrame"),w=d.useMemo(()=>g?.html===void 0?void 0:p2e(g.html,v),[g?.html,v]);return a.jsxs("section",{className:"flex h-full min-h-0 flex-col gap-3","data-web-shell-saved-preview":!0,children:[a.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 text-xs text-muted-foreground",children:[a.jsxs("p",{children:[n("webPreview.saved")," ·"," ",a.jsx("time",{dateTime:e.createdAt,children:new Date(e.createdAt).toLocaleString()})]}),g?.failed!=="unavailable"&&a.jsx(Nt,{variant:"outline",size:"sm",onClick:()=>{g?.html!==void 0?h(y=>y+1):c(y=>y+1)},children:n(g?.failed?"common.retry":"webPreview.refresh")})]}),g?.failed?a.jsx("p",{role:"alert",className:"text-sm text-destructive",children:n(g.failed==="unavailable"?"webPreview.savedUnavailable":"webPreview.savedLoadFailed")}):g?.html!==void 0?a.jsx("iframe",{className:"min-h-0 w-full flex-1 rounded-lg border border-border bg-white",title:n("webPreview.savedFrame"),referrerPolicy:"no-referrer",sandbox:"allow-scripts",srcDoc:w},u):a.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:n("common.loading")})]})}const _Sn="_panel_1khd0_1",kSn="_heroHeader_1khd0_5",SSn="_updatedAt_1khd0_12",CSn="_hero_1khd0_5",TSn="_heroValue_1khd0_24",ISn="_heroMeta_1khd0_35",ESn="_refreshButton_1khd0_42",RSn="_legend_1khd0_61",ASn="_legendEntry_1khd0_69",jSn="_legendSwatch_1khd0_76",NSn="_legendValue_1khd0_83",MSn="_legendPercent_1khd0_88",PSn="_modelList_1khd0_97",LSn="_section_1khd0_103",DSn="_sectionTitle_1khd0_111",OSn="_collapsibleSummary_1khd0_118",$Sn="_collapseIcon_1khd0_146",BSn="_modelCard_1khd0_155",FSn="_modelHeader_1khd0_162",zSn="_modelName_1khd0_170",qSn="_modelMeta_1khd0_178",HSn="_modelBreakdown_1khd0_185",USn="_toolList_1khd0_193",WSn="_toolCard_1khd0_199",VSn="_toolHeader_1khd0_206",GSn="_toolName_1khd0_213",KSn="_toolWireName_1khd0_223",YSn="_toolMeta_1khd0_230",XSn="_subagentList_1khd0_237",ZSn="_subagentCard_1khd0_243",QSn="_subagentHeader_1khd0_250",JSn="_subagentName_1khd0_258",eCn="_subagentType_1khd0_267",tCn="_subagentBreakdown_1khd0_273",nCn="_error_1khd0_280",sCn="_retryButton_1khd0_292",rCn="_empty_1khd0_302",ti={panel:_Sn,heroHeader:kSn,updatedAt:SSn,hero:CSn,heroValue:TSn,heroMeta:ISn,refreshButton:ESn,legend:RSn,legendEntry:ASn,legendSwatch:jSn,legendValue:NSn,legendPercent:MSn,modelList:PSn,section:LSn,sectionTitle:DSn,collapsibleSummary:OSn,collapseIcon:$Sn,modelCard:BSn,modelHeader:FSn,modelName:zSn,modelMeta:qSn,modelBreakdown:HSn,toolList:USn,toolCard:WSn,toolHeader:VSn,toolName:GSn,toolWireName:KSn,toolMeta:YSn,subagentList:XSn,subagentCard:ZSn,subagentHeader:QSn,subagentName:JSn,subagentType:eCn,subagentBreakdown:tCn,error:nCn,retryButton:sCn,empty:rCn},iCn=2e3;function OT(e){return e.prompt>0?e.prompt:e.cached}function h2(e){const t=OT(e);return e.total>0?Math.max(e.total,t+e.candidates):t+e.candidates+e.thoughts}function Hee(e){return Math.max(0,h2(e)-OT(e))}const Jv={input:"var(--success-color)",cached:"color-mix(in srgb, var(--success-color) 70%, var(--foreground))",output:"var(--primary)",thoughts:"var(--warning-color)"};function FNe(e){return Object.entries(e).filter(([,t])=>t.api.totalRequests>0).map(([t,n])=>({key:t,label:t,metrics:n})).sort((t,n)=>h2(n.metrics.tokens)-h2(t.metrics.tokens))}function oCn(e){const{thoughts:t,cached:n}=e.tokens;return[{key:"input",value:OT(e.tokens)},{key:"cached",value:n},{key:"output",value:Hee(e.tokens)},{key:"thoughts",value:t}].filter(r=>r.value>0)}function zNe(e){return e.toLocaleString("en-US")}function qNe(e){return e>=999995e3?Cq((e/1e9).toFixed(2))+"B":e>=999950?Cq((e/1e6).toFixed(2))+"M":e>=1e3?Cq((e/1e3).toFixed(1))+"K":String(e)}function Cq(e){return e.replace(/\.?0+$/,"")}function aCn({sessionActions:e,sessionId:t}){const{t:n}=mt(),[s,r]=d.useState(null),[i,o]=d.useState(null),[l,c]=d.useState(!1),[u,h]=d.useState(0),f=d.useRef(!1),p=d.useRef(!1),m=d.useRef(!0),g=d.useCallback((w=!1)=>{!e||f.current||!w&&p.current||(w&&(p.current=!1),f.current=!0,e.getStats().then(y=>{if(m.current){if(t&&y.sessionId!==t){r(null),c(!0),o(null);return}c(!1),r(y),h(Date.now()),o(null)}}).catch(y=>{if(m.current){if(rX(y)){o(null);return}p.current=!0,o(y instanceof Error?y.message:n("tokenUsage.loadError"))}}).finally(()=>{f.current=!1}))},[e,t,n]);d.useEffect(()=>{if(m.current=!0,!e)return()=>{m.current=!1};p.current=!1,c(!1),g();const w=window.setInterval(()=>{document.visibilityState==="visible"&&g()},iCn);return()=>{m.current=!1,window.clearInterval(w)}},[g,e]);const v=s!==null&&FNe(s.models).length>0;return a.jsx("div",{className:ti.panel,children:i?a.jsxs("div",{className:ti.error,role:"alert",children:[a.jsx("span",{children:i}),a.jsx("button",{type:"button",className:ti.retryButton,onClick:()=>g(!0),children:n("tokenUsage.retry")})]}):!e||l?a.jsx("div",{className:ti.empty,children:n("tokenUsage.unavailable")}):s===null?a.jsx("div",{className:ti.empty,children:n("common.loading")}):v?a.jsx(lCn,{status:s,lastUpdated:u,onRefresh:()=>g(!0)}):a.jsx("div",{className:ti.empty,children:n("tokenUsage.noData")})})}function lCn({status:e,lastUpdated:t,onRefresh:n}){const{t:s}=mt(),r=FNe(e.models),i=r.reduce((c,u)=>(c.prompt+=OT(u.metrics.tokens),c.cached+=u.metrics.tokens.cached,c.output+=Hee(u.metrics.tokens),c.thoughts+=u.metrics.tokens.thoughts,c.total+=h2(u.metrics.tokens),c),{prompt:0,cached:0,output:0,thoughts:0,total:0}),o=i.total,l=[...e.sources??[]].sort((c,u)=>h2(u.tokens)-h2(c.tokens));return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:ti.hero,children:[a.jsxs("div",{className:ti.heroHeader,children:[a.jsx("div",{className:ti.heroValue,children:qNe(o)}),a.jsxs("span",{className:ti.heroMeta,children:[a.jsx("button",{type:"button",className:ti.refreshButton,"aria-label":s("tokenUsage.refresh"),title:s("tokenUsage.refresh"),onClick:n,children:a.jsx(af,{size:14,"aria-hidden":"true"})}),t>0&&a.jsx("span",{className:ti.updatedAt,children:s("tokenUsage.updatedAt",{time:new Date(t).toLocaleTimeString()})})]})]}),a.jsxs("div",{className:ti.legend,children:[a.jsx(ew,{label:s("tokenUsage.input"),value:i.prompt,color:Jv.input}),a.jsx(ew,{label:s("tokenUsage.cached"),value:i.cached,color:Jv.cached,percent:i.cached>0&&i.prompt>0?`${(i.cached/i.prompt*100).toFixed(1)}%`:void 0}),a.jsx(ew,{label:s("tokenUsage.output"),value:i.output,color:Jv.output}),a.jsx(ew,{label:s("tokenUsage.thoughts"),value:i.thoughts,color:Jv.thoughts})]})]}),a.jsxs("section",{className:ti.section,children:[a.jsx("h3",{className:ti.sectionTitle,children:s("tokenUsage.models")}),a.jsx("div",{className:ti.modelList,children:r.map(c=>a.jsx(cCn,{entry:c},c.key))})]}),e.sources!==void 0&&a.jsxs("details",{className:ti.section,children:[a.jsxs("summary",{className:ti.collapsibleSummary,children:[a.jsx("h3",{className:ti.sectionTitle,children:s("tokenUsage.subagents")}),a.jsx(bl,{className:ti.collapseIcon,size:14,"aria-hidden":"true"})]}),l.length>0?a.jsx("div",{className:ti.subagentList,children:l.map(c=>a.jsx(uCn,{source:c},c.id))}):a.jsx("div",{className:ti.empty,children:s("tokenUsage.noSubagents")})]}),e.tools.byName!==void 0&&a.jsxs("details",{className:ti.section,children:[a.jsxs("summary",{className:ti.collapsibleSummary,children:[a.jsx("h3",{className:ti.sectionTitle,children:s("tokenUsage.tools")}),a.jsx(bl,{className:ti.collapseIcon,size:14,"aria-hidden":"true"})]}),a.jsx(dCn,{status:e})]})]})}function ew({label:e,value:t,color:n,percent:s}){return t<=0?null:a.jsxs("span",{className:ti.legendEntry,children:[n&&a.jsx("span",{className:ti.legendSwatch,style:{background:n},"aria-hidden":"true"}),a.jsx("span",{children:e}),a.jsx("span",{className:ti.legendValue,children:qNe(t)}),s&&a.jsx("span",{className:ti.legendPercent,children:s})]})}function cCn({entry:e}){const{t}=mt(),n=e.metrics,s=OT(n.tokens),r=n.api.totalRequests>0?n.api.totalLatencyMs/n.api.totalRequests:0;return a.jsxs("div",{className:ti.modelCard,children:[a.jsxs("div",{className:ti.modelHeader,children:[a.jsx("span",{className:ti.modelName,title:e.key,children:e.label}),a.jsxs("span",{className:ti.modelMeta,children:[t("tokenUsage.requests")," ",zNe(n.api.totalRequests),n.api.totalRequests>0&&a.jsxs(a.Fragment,{children:[" · ",t("tokenUsage.avgLatency")," ",og(r)]})]})]}),a.jsx("div",{className:ti.modelBreakdown,children:oCn(n).map(i=>a.jsx(ew,{label:t(`tokenUsage.${i.key}`),value:i.value,color:Jv[i.key],percent:i.key==="cached"&&s>0?`${(n.tokens.cached/s*100).toFixed(1)}%`:void 0},i.key))})]})}function uCn({source:e}){const{t}=mt(),{tokens:n}=e,s=OT(n);return a.jsxs("div",{className:ti.subagentCard,children:[a.jsxs("div",{className:ti.subagentHeader,children:[a.jsx("span",{className:ti.subagentName,title:e.name,children:e.name}),e.type&&a.jsx("span",{className:ti.subagentType,children:RT(e.type,t)})]}),a.jsxs("div",{className:ti.subagentBreakdown,children:[a.jsx(ew,{label:t("tokenUsage.input"),value:s,color:Jv.input}),a.jsx(ew,{label:t("tokenUsage.cached"),value:n.cached,color:Jv.cached,percent:s>0?`${(n.cached/s*100).toFixed(1)}%`:void 0}),a.jsx(ew,{label:t("tokenUsage.output"),value:Hee(n),color:Jv.output}),a.jsx(ew,{label:t("tokenUsage.thoughts"),value:n.thoughts,color:Jv.thoughts})]})]})}function dCn({status:e}){const{t}=mt(),{tools:n}=e,s=Object.entries(n.byName??{}).filter(([,r])=>r.count>0).sort((r,i)=>i[1].count-r[1].count);return s.length===0?a.jsx("div",{className:ti.empty,children:t("tokenUsage.noTools")}):a.jsx("div",{className:ti.toolList,children:s.map(([r,i])=>{const o=i.success/i.count*100,l=i.durationMs/i.count,c=$0(r,t);return a.jsx("div",{className:ti.toolCard,children:a.jsxs("div",{className:ti.toolHeader,children:[a.jsxs("span",{className:ti.toolName,title:r,children:[c,c!==r&&a.jsxs("span",{className:ti.toolWireName,children:["(",r,")"]})]}),a.jsx("span",{className:ti.toolMeta,children:t("tokenUsage.toolRow",{count:zNe(i.count),rate:o.toFixed(0),duration:og(l)})})]})},r)})})}const hCn="_panel_pwtdr_1",fCn="_toolbar_pwtdr_5",pCn="_actions_pwtdr_15",mCn="_feedback_pwtdr_21",gCn="_state_pwtdr_31",Cv={panel:hCn,toolbar:fCn,actions:pCn,feedback:mCn,state:gCn};function vCn({sessionActions:e,sessionId:t,controls:n}){const{t:s}=mt(),[r,i]=d.useState(null),[o,l]=d.useState(!0),[c,u]=d.useState(!1),h=d.useRef(0),f=d.useRef(()=>{}),p=d.useRef(null),m=n?.sessionId===t?n:void 0,g=m?.getContextUsage??e?.getContextUsage,v=d.useRef(m);v.current=m;const w=m?.result,[y,b]=d.useState(w),x=!!(w&&w!==y&&(w.kind!=="completed"||!c));d.useEffect(()=>{w?.kind==="completed"&&(h.current++,i(w.usage),u(!1))},[w]),d.useEffect(()=>{let E=!0,T=!1;const R=v.current?.result;i(I=>I?.sessionId===t?I:R?.kind==="completed"?R.usage:null),u(!1),l(!!g);const C=async()=>{if(!E||T||!g)return;T=!0,l(!0),u(!1);const I=h.current,A=p.current,N=A&&A.getContextUsage===g&&A.sessionId===t?A:{getContextUsage:g,sessionId:t,promise:g({detail:!0,silent:!0,...v.current?.result?{syncCounters:!0}:{}})};p.current=N;try{const j=await N.promise;if(!E||I!==h.current)return;i(j.sessionId===t&&j.usage.contextWindowSize>0?j:null)}catch(j){if(!E||I!==h.current)return;u(rX(j)?"transient":"hard")}finally{T=!1,p.current===N&&(p.current=null),E&&l(!1)}};return f.current=()=>void C(),C(),()=>{E=!1}},[g,t]);const _=!g||o||m?.compressing,S=()=>{b(w),f.current()};return a.jsxs("div",{className:Cv.panel,"aria-busy":o,children:[a.jsxs("div",{className:Cv.toolbar,children:[a.jsx("span",{children:s("contextUsage.title")}),a.jsxs("div",{className:Cv.actions,children:[a.jsx(Nt,{type:"button",variant:"ghost",size:"icon-sm","aria-label":s("contextUsage.refresh"),title:s("contextUsage.refresh"),disabled:_,onClick:S,children:a.jsx(af,{"aria-hidden":"true"})}),a.jsx("span",{title:m?.compressing?void 0:m?.canCompress?o?s("common.loading"):void 0:s("contextUsage.compressUnavailable"),children:a.jsx(Nt,{type:"button",variant:"outline",size:"sm",disabled:!m?.canCompress||o,onClick:()=>void m?.compress(),children:s(m?.compressing?"contextUsage.compressing":"contextUsage.compress")})})]})]}),(m?.compressing||x)&&a.jsx(Eje,{controls:m,className:Cv.feedback}),c==="transient"&&r&&a.jsx("div",{className:Cv.feedback,role:"status",children:s("contextUsage.previousReading")}),c==="hard"?a.jsxs("div",{className:Cv.state,role:"alert",children:[a.jsx("span",{children:s("contextUsage.loadError")}),a.jsx(Nt,{type:"button",variant:"outline",size:"sm",disabled:_,onClick:S,children:s("contextUsage.retry")})]}):g?o&&!r?a.jsx("div",{className:Cv.state,role:"status",children:s("common.loading")}):r?a.jsx(p3e,{status:r,compact:!0}):a.jsx("div",{className:Cv.state,children:s("contextUsage.unavailable")}):a.jsx("div",{className:Cv.state,children:s("contextUsage.unavailable")})]})}const wCn=700,yCn=["daily","weekdays","weekly","hourly","minutes","custom"],bCn=[1,2,3,4,5,6,10,12,15,20,30],xCn=(e,t)=>{},_Cn=(e,t,n)=>{},kCn=()=>Promise.reject(new Error("Side-task session creation is unavailable"));function xge(e){return e.kind==="review"||e.kind==="file"||e.kind==="artifact"||e.kind==="scheduled_task"}function Tv(e){return e.kind==="pending"?e.targetKind:e.kind}function SCn(e){return`image.${(e.match(/^data:image\/([a-z0-9+.+-]+)/i)?.[1]??"png").split("+")[0].toLowerCase()}`}const CCn=["review","sideTask"];function _ge({contextUsageControls:e,artifacts:t,tabs:n,activeTabId:s,reviewChanges:r,selectedReviewPath:i,panelWidth:o,workspaceCwd:l,loading:c,restoring:u=!1,error:h,onSelectTab:f,onCloseTab:p,onOpenFilePreview:m,latestReviewAvailable:g=!1,onOpenLatestReview:v,onOpenTerminal:w,onOpenWebPreview:y,onWebPreviewChange:b,items:x=CCn,sideTaskAvailable:_=!1,sideTasks:S=[],sideTasksLoading:E=!1,onCreateSideTask:T,onOpenSideTask:R,onCreateSideTaskSession:C,onSideTaskCreated:I,onSideTaskTitleChange:A,onNestedRightPanelOpen:N,onNestedArtifactsChange:j,onOpenNestedSubagent:O,agentTasks:B=[],agentTraceLoading:D=!1,agentTraceError:U,onOpenWorkflowAgent:V,onError:F,sessionWorkflowEnabled:M,workflow:X,onImageIngestionNotice:ee,deferSubagentMount:P=!1,onClose:ce,variant:ae="docked",fullscreen:pe=!1,onToggleFullscreen:q}){const{t:K}=mt(),[oe,W]=d.useState(!1),[ge,le]=d.useState(),ye=d.useRef(null),se=d.useCallback(()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),W(!0)},[]),Se=d.useCallback(()=>{ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{W(!1),ye.current=null},120)},[]);d.useEffect(()=>()=>{ye.current&&clearTimeout(ye.current)},[]);const re=n.find(we=>we.id===s)??n[0],me=re?.kind==="file"&&re.sourcePreview&&(/\.html?$/i.test(re.workspacePath)||kw(re.previewMimeType||re.previewData?.type)==="text/html"),Le=re?.kind==="file"&&re.previewOnly===!0&&!me&&/\.(?:html?|md|markdown)$/i.test(re.workspacePath)&&(re.previewContent!==void 0||!re.previewData||!!X2(re.previewMimeType||re.previewData.type,re.workspacePath)),Pe=ge===re?.id,st=x.includes("review")&&!n.some(we=>Tv(we)==="review"),He=x.includes("sideTask")&&_&&!!T,Te=!!w,Ke=x.includes("webPreview")&&!!y,H=!!re&&(st||He||Te||Ke),Z=re&&xge(re)?{workspaceCwd:re.workspaceCwd,workspaceId:re.workspaceId}:void 0,$=L5(Z?.workspaceCwd),Y=$?.workspaceId===Z?.workspaceId?$?.actions:void 0,de=re?.kind==="artifact"?t.find(we=>we.id===re.artifactId):void 0;return a.jsxs("aside",{className:`${ot.panel} ${ae==="drawer"?ot.panelDrawer:""} ${pe?ot.panelFullscreen:""}`,style:ae==="docked"&&o&&!pe?{flexBasis:o,width:o}:void 0,"aria-label":"Right panel",children:[a.jsxs("div",{className:ot.header,children:[n.length>0&&a.jsx("div",{className:ot.tabs,role:"tablist","aria-label":"Right panel",children:n.map(we=>a.jsxs("div",{className:[ot.tabItem,we.id===re?.id?ot.tabActive:""].filter(Boolean).join(" "),children:[a.jsxs("button",{type:"button",role:"tab","aria-selected":we.id===re?.id,className:ot.tab,onClick:()=>f(we.id),onMouseEnter:Re=>r2(Re.currentTarget),onFocus:Re=>r2(Re.currentTarget),title:we.title,children:[a.jsx("span",{className:`${ot.tabIcon} ${Tv(we)==="artifact"?ot.tabArtifactIcon:""}`,"aria-hidden":"true",children:Tv(we)==="review"?a.jsx(Tq,{}):we.kind==="workflow"?a.jsx(HCe,{className:ot.tabIconSvg,strokeWidth:1.6}):we.kind==="file"?a.jsx(cg,{name:we.workspacePath,className:ot.tabIconSvg,strokeWidth:1.6}):Tv(we)==="artifact"?a.jsx(v2e,{artifact:t.find(Re=>"artifactId"in we&&Re.id===we.artifactId),className:ot.tabIconSvg}):Tv(we)==="subagent"?a.jsx(TCn,{}):Tv(we)==="monitor"?a.jsx(XCe,{className:ot.tabIconSvg,strokeWidth:1.6}):Tv(we)==="shell"?a.jsx(EC,{className:ot.tabIconSvg,strokeWidth:1.6}):Tv(we)==="side_task"?a.jsx(rj,{className:ot.tabIconSvg,strokeWidth:1.6}):we.kind==="web_preview"?a.jsx(gN,{className:ot.tabIconSvg}):we.kind==="terminal"?a.jsx(EC,{className:ot.tabIconSvg,strokeWidth:1.6}):Tv(we)==="image"?a.jsx(_nt,{className:ot.tabIconSvg,strokeWidth:1.6}):we.kind==="context_usage"?a.jsx(hL,{className:ot.tabIconSvg,strokeWidth:1.6}):we.kind==="token_usage"?a.jsx(uZ,{className:ot.tabIconSvg,strokeWidth:1.6}):a.jsx(ECn,{})}),a.jsx("span",{className:ot.tabTitle,"data-web-shell-session-title":!0,children:a.jsx("span",{className:ot.tabTitleInner,children:we.title})})]}),a.jsx("button",{type:"button",className:ot.tabCloseButton,onClick:()=>p(we.id),"aria-label":`Close ${we.title}`,title:"Close",children:a.jsx(ICn,{})})]},we.id))}),a.jsxs("div",{className:ot.headerActions,children:[H&&a.jsxs(gm,{modal:!1,children:[a.jsx(op,{asChild:!0,children:a.jsx("button",{type:"button",className:`${ot.iconButton} ${ot.addButton}`,"aria-label":K("rightPanel.add"),title:K("rightPanel.add"),children:a.jsx(of,{className:ot.toolbarIcon})})}),a.jsxs(ap,{align:"end",className:"w-64",children:[st&&a.jsxs(Ni,{disabled:!g||!v,onSelect:v,children:[a.jsx(Tq,{}),a.jsx("span",{className:ot.sideTaskListTitle,children:K("turnOutputs.review")})]}),st&&He&&a.jsx(Bb,{}),He&&a.jsxs(Ni,{disabled:E,onSelect:T,children:[a.jsx(rj,{className:ot.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:ot.sideTaskListTitle,children:K("sideTask.create")})]}),Te&&(st||He)&&a.jsx(Bb,{}),Te&&a.jsxs(Ni,{onSelect:()=>w?.(),children:[a.jsx(EC,{className:ot.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:ot.sideTaskListTitle,children:K("terminal.title")})]}),Ke&&a.jsxs(Ni,{onSelect:y,children:[a.jsx(gN,{className:ot.sideTaskNewIcon}),a.jsx("span",{className:ot.sideTaskListTitle,children:K("webPreview.title")})]})]})]}),q&&a.jsx("button",{type:"button",className:`${ot.iconButton} ${ot.fullscreenButton} ${pe?ot.iconButtonActive:""}`,onClick:q,"aria-label":K(pe?"common.exitFullscreen":"common.fullscreen"),"aria-pressed":pe,title:K(pe?"common.exitFullscreen":"common.fullscreen"),children:pe?a.jsx(hZ,{className:ot.toolbarIcon,"aria-hidden":!0}):a.jsx(lZ,{className:ot.toolbarIcon,"aria-hidden":!0})}),a.jsx("button",{type:"button",className:`${ot.iconButton} ${ot.panelToggleButton}`,onClick:ce,"aria-label":K("chatHeader.toggleRightPanel"),"aria-pressed":"true",title:K("chatHeader.toggleRightPanel"),children:a.jsx(UCe,{className:ot.panelToggleIcon})})]})]}),a.jsxs("div",{className:`${ot.body} ${re?.kind==="side_task"?ot.bodySideTask:""}`.trim(),children:[n.filter(we=>we.kind==="web_preview").map(we=>a.jsx("div",{className:"h-full",hidden:we.id!==re?.id,children:a.jsx(bSn,{state:we,onChange:Re=>b?.(we.id,Re)})},we.id)),n.filter(we=>we.kind==="terminal").map(we=>a.jsx("div",{className:`${ot.terminalPane} ${we.id===re?.id?"":ot.terminalPaneHidden}`.trim(),"aria-hidden":we.id===re?.id?void 0:!0,children:a.jsx(ySn,{terminalId:we.id,cwd:we.workspaceCwd??l,active:we.id===re?.id,enabled:we.initialized!==!1})},we.id)),Le&&a.jsxs("button",{type:"button",className:ot.attachmentPreviewButton,onClick:()=>le(Pe?void 0:re?.id),"aria-label":K(Pe?"attachment.showSource":"attachment.showPreview"),"aria-pressed":Pe,children:[Pe?a.jsx(btt,{"aria-hidden":!0}):a.jsx(LCe,{"aria-hidden":!0}),K(Pe?"attachment.showSource":"attachment.showPreview")]}),u&&!re?a.jsxs("div",{className:"flex flex-col gap-4 p-5","data-testid":"right-panel-loading-skeleton",role:"status","aria-label":K("common.loading"),children:[a.jsx(g0,{className:"h-5 w-2/5"}),a.jsx(g0,{className:"h-32 w-full"}),a.jsx(g0,{className:"h-4 w-4/5"}),a.jsx(g0,{className:"h-4 w-3/5"})]}):re?.kind==="terminal"||re?.kind==="web_preview"?null:re?re.kind==="pending"?a.jsx("div",{className:ot.empty,role:re.loadError?"alert":"status",children:re.loadError??K("common.loading")}):re.kind==="workflow"?re.sessionId?a.jsx(f1n,{tasks:B,loading:D,error:U,onOpenAgent:V}):X?a.jsx(txn,{...X}):a.jsx("div",{className:ot.empty,children:K("workflow.empty.title")}):xge(re)&&(re.kind!=="scheduled_task"||re.task.durable)&&(re.kind!=="file"||!re.previewOnly)&&(re.kind!=="artifact"||de?.metadata?.artifactType!=="web_preview_snapshot")&&!Y?a.jsx("div",{className:ot.empty,role:"alert",children:K("workspace.notFoundDescription")}):re.kind==="review"?a.jsx(jCn,{changes:re.changes??r,selectedPath:re.selectedPath??i,workspaceCwd:re.workspaceCwd??l,onOpenFilePreview:we=>m(we,re.workspaceCwd??l,re.workspaceId),onDownloadFile:(we,Re)=>gL(Y,we.path,xit(we.path),Re),onDownloadError:we=>{const Re=K("common.downloadFailed",{message:sl(we)});F?F(new Error(Re,{cause:we}),Re):console.error(Re,we)}}):re.kind==="file"?re.attachmentId&&!re.previewData&&re.previewContent===void 0?a.jsx("div",{className:ot.empty,role:re.loadError?"alert":"status",children:re.loadError??K("common.loading")}):re.sourcePreview&&re.previewData&&kw(re.previewMimeType||re.previewData.type)!=="application/pdf"&&!X2(re.previewMimeType||re.previewData.type,re.workspacePath)?a.jsx(GNe,{data:re.previewData,title:re.title,image:!!wT(re.workspacePath)&&re.previewData.type.startsWith("image/")}):a.jsx(ID,{workspacePath:re.workspacePath,workspaceActions:Y,previewContent:re.previewContent,previewData:re.previewData,previewMimeType:re.previewMimeType,previewOnly:re.previewOnly,previewKind:me||re.previewOnly&&!Pe?"source":void 0},re.id):re.kind==="source"?a.jsx(KCn,{tab:re},re.id):re.kind==="artifact"?a.jsx(RCn,{artifacts:t,artifactId:re.artifactId,sourceSessionId:re.sourceSessionId,workspaceActions:Y,previewContent:re.previewContent,loading:c,error:h},re.id):re.kind==="subagent"?P?null:a.jsx(Ybn,{sessionId:re.sessionId,rootToolCallId:re.rootToolCallId,initialRootTool:re.rootTool,workspaceCwd:re.workspaceCwd??l,onRightPanelOpen:N,onArtifactsChange:j,onOpenSubagent:O,onError:F}):re.kind==="monitor"?a.jsx(EIt,{task:re.task,actions:re.sessionActions},re.id):re.kind==="shell"?a.jsx(RIt,{task:re.task,actions:re.sessionActions},re.id):re.kind==="side_task"?a.jsx(m1n,{tabId:re.id,sessionId:re.sessionId,parentSessionId:re.parentSessionId,workspaceCwd:re.workspaceCwd??l,title:re.title,shouldNameFromFirstPrompt:re.nameFromFirstPrompt,initialPrompt:re.initialPrompt,createSession:C??kCn,onCreated:I??xCn,onTitleChange:A??_Cn,onRightPanelOpen:N,onArtifactsChange:j,onError:F,sessionWorkflowEnabled:M,onImageIngestionNotice:ee},re.id):re.kind==="image"?re.src?a.jsxs("div",{className:ot.imagePreviewWrap,children:[a.jsx("img",{src:re.src,alt:re.alt??re.title,className:ot.imagePreview}),a.jsx("a",{className:ot.imageDownloadButton,href:re.src,download:SCn(re.src),"aria-label":K("common.download"),title:K("common.download"),children:a.jsx(aw,{size:16,strokeWidth:1.8})})]}):a.jsx("div",{className:ot.empty,role:re.loadError?"alert":"status",children:re.loadError??K("common.loading")}):re.kind==="context_usage"?a.jsx(vCn,{controls:e?.[re.sessionId],sessionActions:re.sessionActions,sessionId:re.sessionId},re.id):re.kind==="token_usage"?a.jsx(aCn,{sessionActions:re.sessionActions,sessionId:re.sessionId},re.id):a.jsx(ACn,{task:re.task,actions:Y},re.id):a.jsxs("div",{className:ot.emptyActions,"data-testid":"right-panel-empty-actions",children:[x.includes("review")&&a.jsxs("button",{type:"button",className:ot.emptyAction,disabled:!g||!v,onClick:v,children:[a.jsx("span",{className:ot.emptyActionIcon,"aria-hidden":"true",children:a.jsx(Tq,{})}),a.jsx("span",{className:ot.emptyActionTitle,children:K("turnOutputs.review")}),a.jsx("span",{className:ot.emptyActionHint,children:K("turnOutputs.reviewLatest")}),a.jsx(bl,{className:ot.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}),x.includes("sideTask")&&_&&T&&(S.length===0?a.jsxs("button",{type:"button",className:ot.emptyAction,disabled:E,"aria-busy":E,onClick:T,children:[a.jsx("span",{className:ot.emptyActionIcon,"aria-hidden":"true",children:a.jsx(rj,{strokeWidth:1.6})}),a.jsx("span",{className:ot.emptyActionTitle,children:K("sideTask.title")}),a.jsx("span",{className:ot.emptyActionHint,children:K("sideTask.description")}),a.jsx(bl,{className:ot.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]}):a.jsxs(gm,{open:oe,onOpenChange:W,modal:!1,children:[a.jsx(op,{asChild:!0,children:a.jsxs("button",{type:"button",className:ot.emptyAction,"aria-expanded":oe,onMouseEnter:se,onMouseLeave:Se,children:[a.jsx("span",{className:ot.emptyActionIcon,"aria-hidden":"true",children:a.jsx(rj,{strokeWidth:1.6})}),a.jsx("span",{className:ot.emptyActionTitle,children:K("sideTask.title")}),a.jsx("span",{className:ot.emptyActionHint,children:K("sideTask.description")}),a.jsx(bl,{className:ot.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]})}),a.jsxs(ap,{align:"end",className:"w-80",onMouseEnter:se,onMouseLeave:Se,children:[S.map(we=>a.jsxs(Ni,{onSelect:()=>R?.(we),children:[a.jsx("span",{className:ot.sideTaskListTitle,children:we.title}),we.updatedAt&&a.jsx("span",{className:ot.sideTaskListTime,children:Z2(we.updatedAt,K)})]},we.sessionId)),a.jsx(Bb,{}),a.jsxs(Ni,{onSelect:T,children:[a.jsx(ltt,{className:ot.sideTaskNewIcon,strokeWidth:1.6,"aria-hidden":"true"}),a.jsx("span",{className:ot.sideTaskListTitle,children:K("sideTask.new")})]})]})]})),Ke&&a.jsxs("button",{type:"button",className:ot.emptyAction,onClick:y,children:[a.jsx("span",{className:ot.emptyActionIcon,"aria-hidden":"true",children:a.jsx(gN,{strokeWidth:1.6})}),a.jsx("span",{className:ot.emptyActionTitle,children:K("webPreview.title")}),a.jsx("span",{className:ot.emptyActionHint,children:K("webPreview.openHint")}),a.jsx(bl,{className:ot.emptyActionChevron,"aria-hidden":"true"})]}),w&&a.jsxs("button",{type:"button",className:ot.emptyAction,onClick:()=>w(),children:[a.jsx("span",{className:ot.emptyActionIcon,"aria-hidden":"true",children:a.jsx(EC,{strokeWidth:1.6})}),a.jsx("span",{className:ot.emptyActionTitle,children:K("terminal.title")}),a.jsx("span",{className:ot.emptyActionHint,children:K("terminal.open")}),a.jsx(bl,{className:ot.emptyActionChevron,strokeWidth:1.6,"aria-hidden":"true"})]})]})]})]})}function TCn(){return a.jsxs("svg",{className:ot.tabIconSvg,viewBox:"0 0 24 24",fill:"none",focusable:"false","aria-hidden":"true",children:[a.jsx("circle",{cx:"12",cy:"8",r:"3",stroke:"currentColor",strokeWidth:"1.6"}),a.jsx("path",{d:"M6.5 19c.7-3.1 2.5-4.7 5.5-4.7s4.8 1.6 5.5 4.7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function ICn(){return a.jsx("svg",{className:ot.tabCloseIcon,viewBox:"0 0 16 16",fill:"none",focusable:"false","aria-hidden":"true",children:a.jsx("path",{d:"m4.5 4.5 7 7M11.5 4.5l-7 7",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})})}function Tq(){return a.jsxs("svg",{className:ot.tabIconSvg,viewBox:"0 0 24 24",fill:"none",focusable:"false",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"1.6"}),a.jsx("path",{d:"M9 9.5h6M12 6.5v6",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),a.jsx("path",{d:"M9 16h6",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]})}function ECn(){return a.jsxs("svg",{className:ot.tabIconSvg,viewBox:"0 0 24 24",fill:"none",focusable:"false",children:[a.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"3",stroke:"currentColor",strokeWidth:"1.8"}),a.jsx("path",{d:"M12 8v4l3 2",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}function RCn({artifacts:e,artifactId:t,sourceSessionId:n,workspaceActions:s,previewContent:r,loading:i,error:o}){const l=e.find(c=>c.id===t);return l?a.jsx(qCn,{artifact:l,sourceSessionId:n,workspaceActions:s,previewContent:r}):i?a.jsx("div",{className:ot.empty,children:"Loading artifact..."}):o?a.jsx("div",{className:ot.empty,children:o}):a.jsx("div",{className:ot.empty,children:"Artifact not found."})}function ACn({task:e,actions:t}){const{t:n}=mt(),[s,r]=d.useState(null),[i,o]=d.useState(!0),[l,c]=d.useState(null),[u,h]=d.useState(""),[f,p]=d.useState(e.prompt),[m,g]=d.useState(()=>Gy(e.cron)),[v,w]=d.useState(!1),[y,b]=d.useState(!1),[x,_]=d.useState(!1),[S,E]=d.useState(!1),[T,R]=d.useState(null),C=d.useRef(0),I=d.useRef(0),A=d.useRef({actions:t,taskId:e.id,workspaceId:e.workspaceId});A.current={actions:t,taskId:e.id,workspaceId:e.workspaceId};const N=d.useCallback((W,ge,le,ye)=>{const se=A.current;return W===C.current&&se.actions===ge&&se.taskId===le&&se.workspaceId===ye},[]),j=d.useCallback((W,ge,le,ye)=>{const se=A.current;return W===I.current&&se.actions===ge&&se.taskId===le&&se.workspaceId===ye},[]);d.useEffect(()=>()=>{C.current+=1,I.current+=1},[]),d.useEffect(()=>{_(!1),E(!1),R(null)},[t,e.id,e.workspaceId]);const O=d.useCallback(async()=>{const W=++C.current,ge=++I.current,le=e.id,ye=e.workspaceId;if(!e.durable||!t){r(null),h(""),p(e.prompt),g(Gy(e.cron)),c(null),o(!1);return}o(!0),c(null);try{const se=await t.listScheduledTasks(ye);if(!N(W,t,le,ye))return;const Se=se.find(re=>re.id===e.id)??null;r(Se),Se?(h(Se.name??""),p(Se.prompt),g(Gy(Se.cron))):(h(""),p(e.prompt),g(Gy(e.cron)))}catch(se){j(ge,t,le,ye)&&c(se instanceof Error?se.message:String(se))}finally{j(ge,t,le,ye)&&o(!1)}},[t,j,N,e.cron,e.durable,e.id,e.prompt,e.workspaceId]);d.useEffect(()=>{O()},[O]);const B=!e.durable,D=e.durable&&!i&&!l&&!s,U=!!s,V=s?.name||s?.prompt||e.title,F=s?.prompt??e.prompt,M=s?.cron??e.cron,X=s?.recurring??e.recurring,ee=s?.enabled,P=d.useCallback(()=>{s&&(h(s.name??""),p(s.prompt),g(Gy(s.cron)),R(null),w(!0))},[s]),ce=d.useCallback(()=>{w(!1),R(null),s&&(h(s.name??""),p(s.prompt),g(Gy(s.cron)))},[s]),ae=d.useCallback(async()=>{if(!s||!t)return;const W=u9(m);if(!W){R(n("scheduledTasks.error.invalidSchedule"));return}if(f.trim().length===0){R(n("scheduledTasks.error.emptyPrompt"));return}const ge=++C.current,le=e.id,ye=e.workspaceId;E(!0),R(null);try{const se=await t.updateScheduledTask(s.id,{cron:W,prompt:f.trim(),name:u.trim()||null},ye);if(!N(ge,t,le,ye))return;r(se),h(se.name??""),p(se.prompt),g(Gy(se.cron)),w(!1)}catch(se){N(ge,t,le,ye)&&R(se instanceof Error?se.message:String(se))}finally{N(ge,t,le,ye)&&E(!1)}},[t,m,N,s,u,f,n,e.id,e.workspaceId]),pe=d.useCallback(async()=>{if(!s||!t)return;const W=++C.current,ge=e.id,le=e.workspaceId;_(!0),R(null);try{const ye=await t.updateScheduledTask(s.id,{enabled:!s.enabled},le);if(!N(W,t,ge,le))return;r(ye)}catch(ye){N(W,t,ge,le)&&R(ye instanceof Error?ye.message:String(ye))}finally{N(W,t,ge,le)&&_(!1)}},[t,N,s,e.id,e.workspaceId]),q=d.useCallback(async()=>{if(!s||!t)return;const W=++C.current,ge=e.id,le=e.workspaceId;_(!0),R(null);try{if(await t.deleteScheduledTask(s.id,le),!N(W,t,ge,le))return;r(null),b(!1)}catch(ye){N(W,t,ge,le)&&R(ye instanceof Error?ye.message:String(ye))}finally{N(W,t,ge,le)&&_(!1)}},[t,N,s,e.id,e.workspaceId]),K=u9(m),oe=K?j2(K,n):null;return a.jsxs("div",{className:ot.detail,children:[i&&a.jsx("div",{className:ot.empty,children:n("scheduledTasks.loading")}),l&&a.jsx("div",{className:zt.loadError,children:l}),D&&a.jsx("div",{className:ot.empty,children:n("scheduledTasks.deletedSnapshot")}),B&&a.jsx("div",{className:ot.empty,children:n("scheduledTasks.sessionScopedSnapshot")}),!D&&a.jsx("div",{className:ot.section,children:a.jsxs("div",{className:ot.fieldGrid,children:[a.jsx("span",{className:ot.fieldLabel,children:n("scheduledTasks.name")}),a.jsx("span",{className:ot.fieldValue,children:V}),a.jsx("span",{className:ot.fieldLabel,children:n("scheduledTasks.taskId")}),a.jsx("span",{className:ot.fieldValue,children:e.id}),a.jsx("span",{className:ot.fieldLabel,children:n("scheduledTasks.schedule")}),a.jsx("span",{className:ot.fieldValue,children:j2(M,n)}),a.jsx("span",{className:ot.fieldLabel,children:"Cron"}),a.jsx("span",{className:ot.fieldValue,children:M}),a.jsx("span",{className:ot.fieldLabel,children:n("scheduledTasks.type")}),a.jsx("span",{className:ot.fieldValue,children:n(X?"scheduledTasks.repeats":"scheduledTasks.runsOnce")}),ee!==void 0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:ot.fieldLabel,children:n("scheduledTasks.status")}),a.jsx("span",{className:ot.fieldValue,children:n(ee?"scheduledTasks.enable":"scheduledTasks.disable")})]})]})}),!D&&a.jsxs("div",{className:ot.section,children:[a.jsx("div",{className:ot.sectionTitle,children:"Prompt"}),a.jsx("div",{className:ot.description,children:F})]}),T&&a.jsx("div",{className:zt.formError,children:T}),a.jsxs("div",{className:ot.actionsRow,children:[a.jsx("button",{type:"button",className:zt.primaryButton,disabled:!U||x,onClick:P,children:n("scheduledTasks.edit")}),a.jsx("button",{type:"button",className:zt.secondaryButton,disabled:!U||x,onClick:()=>void pe(),children:s?.enabled?n("scheduledTasks.disable"):n("scheduledTasks.enable")}),a.jsx("button",{type:"button",className:zt.secondaryButton,disabled:!U||x,onClick:()=>b(!0),children:n("scheduledTasks.delete")})]}),y&&s&&a.jsx(ga,{title:n("scheduledTasks.deleteConfirmTitle"),size:"sm",onClose:()=>b(!1),children:a.jsxs("div",{className:zt.formFields,children:[a.jsx("div",{className:ot.description,children:n("scheduledTasks.deleteConfirm",{name:s.name||s.prompt})}),T&&a.jsx("div",{className:zt.formError,children:T}),a.jsxs("div",{className:zt.formActions,children:[a.jsx("button",{type:"button",className:zt.secondaryButton,onClick:()=>b(!1),disabled:x,children:n("scheduledTasks.cancel")}),a.jsx("button",{type:"button",className:zt.primaryButton,onClick:()=>void q(),disabled:x,children:n("scheduledTasks.delete")})]})]})}),v&&a.jsx(ga,{title:n("scheduledTasks.editTitle"),size:"md",onClose:ce,children:a.jsxs("div",{className:zt.formFields,children:[a.jsxs("label",{className:zt.field,children:[a.jsx("span",{className:zt.fieldLabel,children:n("scheduledTasks.name")}),a.jsx("input",{className:zt.input,type:"text",value:u,maxLength:200,placeholder:n("scheduledTasks.namePlaceholder"),onChange:W=>h(W.target.value)})]}),a.jsxs("label",{className:zt.field,children:[a.jsxs("span",{className:zt.fieldLabel,children:[n("scheduledTasks.prompt"),a.jsx("span",{className:zt.required,children:"*"})]}),a.jsx("textarea",{className:zt.textarea,value:f,rows:4,maxLength:1e5,placeholder:n("scheduledTasks.promptPlaceholder"),onChange:W=>p(W.target.value)})]}),a.jsxs("div",{className:zt.scheduleRow,children:[a.jsxs("label",{className:zt.field,children:[a.jsx("span",{className:zt.fieldLabel,children:n("scheduledTasks.frequency")}),a.jsx("select",{className:zt.select,value:m.frequency,onChange:W=>{const ge=W.target.value;g(le=>({...le,frequency:ge,...ge==="hourly"?{time:"00:00"}:{}}))},children:yCn.map(W=>a.jsx("option",{value:W,children:n(`scheduledTasks.freq.${W}`)},W))})]}),(m.frequency==="daily"||m.frequency==="weekdays"||m.frequency==="weekly")&&a.jsxs("label",{className:zt.field,children:[a.jsx("span",{className:zt.fieldLabel,children:n("scheduledTasks.time")}),a.jsx("input",{className:zt.input,type:"time",value:m.time,onChange:W=>g(ge=>({...ge,time:W.target.value}))})]}),m.frequency==="weekly"&&a.jsxs("label",{className:zt.field,children:[a.jsx("span",{className:zt.fieldLabel,children:n("scheduledTasks.weekday")}),a.jsx("select",{className:zt.select,value:m.weekday,onChange:W=>g(ge=>({...ge,weekday:Number(W.target.value)})),children:n("scheduledTasks.weekdayNames").split(",").map((W,ge)=>a.jsx("option",{value:ge,children:W},ge))})]}),m.frequency==="minutes"&&a.jsxs("label",{className:zt.field,children:[a.jsx("span",{className:zt.fieldLabel,children:n("scheduledTasks.interval")}),a.jsx("select",{className:zt.select,value:m.minuteInterval,onChange:W=>g(ge=>({...ge,minuteInterval:Number(W.target.value)})),children:bCn.map(W=>a.jsx("option",{value:W,children:W},W))})]}),m.frequency==="custom"&&a.jsxs("label",{className:`${zt.field} ${zt.fieldGrow}`,children:[a.jsx("span",{className:zt.fieldLabel,children:n("scheduledTasks.cron")}),a.jsx("input",{className:zt.input,type:"text",value:m.customCron,spellCheck:!1,placeholder:"0 9 * * 1-5",onChange:W=>g(ge=>({...ge,customCron:W.target.value}))})]})]}),a.jsx("div",{className:zt.preview,children:oe?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:zt.previewLabel,children:oe}),a.jsx("code",{className:zt.previewCron,children:K})]}):a.jsx("span",{className:zt.previewInvalid,children:n("scheduledTasks.error.invalidSchedule")})}),T&&a.jsx("div",{className:zt.formError,children:T}),a.jsxs("div",{className:zt.formActions,children:[a.jsx("button",{type:"button",className:zt.secondaryButton,onClick:ce,disabled:S,children:n("scheduledTasks.cancel")}),a.jsx("button",{type:"button",className:zt.primaryButton,onClick:()=>void ae(),disabled:S,children:n(S?"scheduledTasks.saving":"scheduledTasks.save")})]})]})})]})}function jCn({changes:e,selectedPath:t,workspaceCwd:n,onOpenFilePreview:s,onDownloadFile:r,onDownloadError:i}){const{t:o}=mt(),[l,c]=d.useState(!1),[u,h]=d.useState(!0),[f,p]=d.useState(!1),[m,g]=d.useState(520),v=d.useRef(m),w=d.useRef(null),y=d.useRef(null),[b,x]=d.useState(null),[_,S]=d.useState(()=>new Set),E=d.useRef(!0);d.useEffect(()=>(E.current=!0,()=>{E.current=!1}),[]);const T=l,R=d.useMemo(()=>zCn(e,n),[e,n]);d.useEffect(()=>{x(t)},[t]),d.useEffect(()=>{v.current=m},[m]),d.useEffect(()=>{const j=w.current;if(!j)return;const O=()=>{p(j.clientWidth<wCn)};O();const B=new ResizeObserver(O);return B.observe(j),()=>B.disconnect()},[u]),d.useEffect(()=>()=>y.current?.(),[]);const C=d.useCallback(j=>{const O=w.current;if(!O)return;j.preventDefault();const B=j.currentTarget;B.setPointerCapture(j.pointerId);const D=j.clientX,U=v.current,V=O.getBoundingClientRect().width,F=Math.max(180,V-180),M=document.body.style.cursor,X=document.body.style.userSelect;let ee=U,P=null;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const ce=()=>{P=null,g(ee)},ae=K=>{ee=Math.min(F,Math.max(180,U+(K.clientX-D))),P===null&&(P=window.requestAnimationFrame(ce))};let pe=()=>{};const q=K=>{y.current=null,P!==null&&(window.cancelAnimationFrame(P),P=null),K&&g(ee),B.hasPointerCapture(j.pointerId)&&B.releasePointerCapture(j.pointerId),document.body.style.cursor=M,document.body.style.userSelect=X,window.removeEventListener("pointermove",ae),window.removeEventListener("pointerup",pe),window.removeEventListener("pointercancel",pe)};pe=()=>q(!0),y.current=()=>q(!1),window.addEventListener("pointermove",ae),window.addEventListener("pointerup",pe),window.addEventListener("pointercancel",pe)},[]);if(e.length===0)return a.jsx("div",{className:ot.empty,children:"No file changes to review."});const I=cRe(e),A=j=>{x(O=>O===j?null:j)},N=async j=>{if(!_.has(j.path)){S(O=>new Set(O).add(j.path));try{await r(j,()=>!E.current)}catch(O){E.current&&i(O)}finally{S(O=>{const B=new Set(O);return B.delete(j.path),B})}}};return a.jsxs("div",{className:ot.review,children:[a.jsxs("div",{className:ot.reviewToolbar,children:[a.jsxs("div",{className:ot.reviewToolbarTitle,children:[a.jsx("span",{children:o("turnOutputs.previousTurn")}),a.jsx(Z9,{additions:I?.additions,deletions:I?.deletions,className:ot.lineStats,additionsClassName:ot.additions,deletionsClassName:ot.deletions})]}),a.jsxs("div",{className:ot.reviewToolbarActions,children:[a.jsxs("button",{type:"button",className:ot.reviewTotalsButton,onClick:()=>h(j=>!j),"aria-expanded":u,children:[a.jsx("span",{children:o("turnOutputs.fileCount",{count:e.length})}),a.jsx("span",{className:[ot.chevron,u?ot.chevronOpen:""].filter(Boolean).join(" "),"aria-hidden":"true",children:a.jsx(Sge,{})})]}),a.jsx("button",{type:"button",className:[ot.iconButton,l?ot.iconButtonActive:""].filter(Boolean).join(" "),onClick:()=>c(j=>!j),"aria-label":o(l?"turnOutputs.closeFileTree":"turnOutputs.openFileTree"),title:o(l?"turnOutputs.closeFileTree":"turnOutputs.openFileTree"),children:l?a.jsx(BCn,{}):a.jsx($Cn,{})})]})]}),u&&a.jsxs("div",{ref:w,className:[ot.reviewContent,T?"":ot.reviewContentListOnly,T&&f?ot.reviewContentStacked:""].filter(Boolean).join(" "),style:{"--review-list-width":`${m}px`},children:[a.jsx("div",{className:[ot.reviewList,b?ot.reviewListWithExpanded:""].filter(Boolean).join(" "),children:e.map(j=>{const O=b===j.path,B=fRe(j.path),D=x7t(j.path);return a.jsxs("div",{className:[ot.reviewItem,O?ot.reviewItemExpanded:""].filter(Boolean).join(" "),children:[a.jsxs("div",{className:ot.reviewRow,"data-selected":j.path===t||void 0,children:[a.jsx("button",{type:"button",className:ot.reviewRowToggle,onClick:()=>A(j.path),"aria-label":j.path,"aria-expanded":O}),a.jsx("span",{className:ot.fileIcon,children:VNe(j.path)}),a.jsxs("span",{className:ot.reviewFileName,children:[a.jsx(LCn,{path:JL(j.path,n),title:j.path}),B&&a.jsx("button",{type:"button",className:ot.reviewOpenButton,onClick:()=>s(j),title:`${o("turnOutputs.preview")} ${j.path}`,children:o("turnOutputs.preview")}),D&&a.jsx("button",{type:"button",className:ot.reviewOpenButton,onClick:()=>void N(j),title:`${o("common.download")} ${j.path}`,disabled:_.has(j.path),children:o(_.has(j.path)?"common.downloading":"common.download")})]}),a.jsx(Z9,{additions:j.additions,deletions:j.deletions,className:ot.lineStats,additionsClassName:ot.additions,deletionsClassName:ot.deletions}),a.jsx("span",{className:[ot.chevron,O?ot.chevronOpen:""].filter(Boolean).join(" "),"aria-hidden":"true",children:a.jsx(Sge,{})})]}),O&&a.jsx(NCn,{change:j})]},`${j.toolCallId}:${j.path}`)})}),T&&!f&&a.jsx("div",{className:ot.reviewSplitHandle,role:"separator","aria-orientation":"vertical",onPointerDown:C}),T&&a.jsx("div",{className:ot.tree,children:R.children.map(j=>a.jsx(HNe,{node:j,depth:0,selectedPath:t},j.path))})]})]})}function NCn({change:e}){if(e.diffs.length===0)return a.jsx("div",{className:ot.diffEmpty,children:"No diff available."});const t=MCn(e.diffs);return a.jsx("div",{className:ot.diffPreview,children:t.map((n,s)=>n.fileDiff&&!n.fullContent?a.jsx(M3e,{diff:n.fileDiff},s):a.jsx(PCn,{oldText:n.oldText,newText:n.newText},s))})}function MCn(e){for(let t=e.length-1;t>=0;t--)if(e[t]?.fullContent)return e.slice(t);return e}function PCn({oldText:e,newText:t}){const n=d.useRef(null),[s,r]=d.useState(null),[i,o]=d.useState(null);return d.useEffect(()=>{const l=n.current;if(!l)return;const c=()=>r(l.clientWidth>=720);c();const u=new ResizeObserver(c);return u.observe(l),()=>u.disconnect()},[]),d.useEffect(()=>{const l=n.current;if(!l||s===null)return;l.replaceChildren(),o(null);let c=!1,u=null;const h=[tje,ts.editable.of(!1),yo.readOnly.of(!0),ts.lineWrapping],f={scanLimit:1e3,timeout:500},p={margin:3,minSize:8};return $e(async()=>{const{MergeView:m,unifiedMergeView:g}=await import("./index-45-LkPDB.js");return{MergeView:m,unifiedMergeView:g}},[]).then(({MergeView:m,unifiedMergeView:g})=>{if(!c)try{if(s){u=new m({a:{doc:e,extensions:h},b:{doc:t,extensions:h},parent:l,highlightChanges:!0,gutter:!0,revertControls:void 0,collapseUnchanged:p,diffConfig:f});return}u=new ts({doc:t,extensions:[...h,g({original:e,highlightChanges:!0,gutter:!0,mergeControls:!1,allowInlineDiffs:!0,collapseUnchanged:p,diffConfig:f})],parent:l})}catch(v){c||o(v instanceof Error?v.message:String(v))}}).catch(m=>{c||o(m instanceof Error?m.message:String(m))}),()=>{c=!0,u?.destroy()}},[s,t,e]),a.jsxs("div",{className:ot.codeMirrorDiffWrap,children:[a.jsx("div",{ref:n,className:ot.codeMirrorDiff}),i&&a.jsxs("div",{className:ot.diffError,children:["Diff unavailable: ",i]})]})}function HNe({node:e,depth:t,selectedPath:n}){const s=!!e.file,[r,i]=d.useState(!0),o=[ot.treeRow,s?ot.treeFile:ot.treeFolder].filter(Boolean).join(" "),l={paddingLeft:10+t*18,"--tree-row-line-left":`${19+Math.max(0,t-1)*18}px`},c={"--tree-children-line-left":`${19+t*18}px`},u=a.jsxs(a.Fragment,{children:[a.jsx("span",{className:ot.treeTwisty,children:!s&&a.jsx("span",{className:[ot.treeChevron,r?"":ot.treeChevronClosed].filter(Boolean).join(" "),children:a.jsx(FCn,{})})}),a.jsxs("span",{className:ot.treeContent,children:[s&&a.jsx("span",{className:ot.fileIcon,children:VNe(e.path)}),a.jsx("span",{className:ot.treeName,children:e.name})]}),e.file?.isArtifact&&a.jsx("span",{className:ot.reviewBadge,children:"artifact"})]});return a.jsxs("div",{className:ot.treeNode,children:[s?a.jsx("div",{className:o,"data-selected":e.file?.path===n||void 0,"data-depth":t,style:l,title:e.path,children:u}):a.jsx("button",{type:"button",className:o,"data-depth":t,style:l,title:e.path,"aria-expanded":r,onClick:()=>i(h=>!h),children:u}),!s&&r&&e.children.length>0&&a.jsx("div",{className:ot.treeChildren,style:c,children:e.children.map(h=>a.jsx(HNe,{node:h,depth:t+1,selectedPath:n},h.path))})]})}function LCn({path:e,title:t}){const n=d.useRef(null),[s,r]=d.useState(()=>UNe(e));return d.useLayoutEffect(()=>{const i=n.current;if(!i)return;const o=()=>r(DCn(e,i));o();const l=new ResizeObserver(o);return l.observe(i),()=>l.disconnect()},[e]),a.jsxs("span",{ref:n,className:ot.reviewPath,title:t??e,children:[s.prefix&&a.jsx("span",{className:ot.pathPrefix,children:s.prefix}),a.jsx("span",{className:ot.pathFileName,children:s.leaf})]})}function UNe(e){const t=e.lastIndexOf("/");return t<0?{prefix:"",leaf:e}:{prefix:e.slice(0,t+1),leaf:e.slice(t+1)}}let kge=null;function DCn(e,t){const n=UNe(e),s=t.clientWidth;if(s<=0)return n;const r=OCn(t);if(r(e)<=s)return n;const i=e.split("/").filter(Boolean),o=i.at(-1)??e,l=r(o);if(i.length<=1||l+r(".../")>s)return{prefix:"",leaf:o};let c=".../";for(let u=1;u<i.length;u++){const f=`.../${i.slice(i.length-1-u,-1).join("/")}/`;if(r(f)+l>s)break;c=f}return{prefix:c,leaf:o}}function OCn(e){kge??=document.createElement("canvas");const t=kge.getContext("2d"),n=window.getComputedStyle(e);return t&&(t.font=[n.fontStyle,n.fontVariant,n.fontWeight,n.fontSize,n.fontFamily].join(" ")),s=>t?.measureText(s).width??s.length*8}function $Cn(){return a.jsxs("svg",{className:ot.toolbarIcon,viewBox:"0 0 24 24",fill:"none",focusable:"false","aria-hidden":"true",children:[a.jsx("path",{d:"M3.5 7.5h6l1.6 2h9.4v8.2a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2V7.5Z",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),a.jsx("path",{d:"M3.5 7.5V5.8a1.5 1.5 0 0 1 1.5-1.5h4l1.8 2.1h7.2a1.5 1.5 0 0 1 1.5 1.5v1.6",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"})]})}function BCn(){return a.jsxs("svg",{className:ot.toolbarIcon,viewBox:"0 0 24 24",fill:"none",focusable:"false","aria-hidden":"true",children:[a.jsx("path",{d:"M3.5 8.2V5.8A1.5 1.5 0 0 1 5 4.3h4l1.8 2.1h7.2a1.5 1.5 0 0 1 1.5 1.5v1.4",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"}),a.jsx("path",{d:"M4.8 19.7h12.9a2 2 0 0 0 1.9-1.4l2-7H6.4l-2.8 7.1a.9.9 0 0 0 1.2 1.3Z",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round"})]})}function Sge(){return a.jsx("svg",{className:ot.chevronIcon,viewBox:"0 0 16 16",fill:"none",focusable:"false","aria-hidden":"true",children:a.jsx("path",{d:"m6 4 4 4-4 4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function FCn(){return a.jsx("svg",{className:ot.treeChevronIcon,viewBox:"0 0 16 16",fill:"none",focusable:"false","aria-hidden":"true",children:a.jsx("path",{d:"m4 6 4 4 4-4",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function zCn(e,t){const n={name:"",path:"",children:[]};for(const s of e){const r=JL(s.path,t).split("/").filter(Boolean);let i=n;for(let o=0;o<r.length;o++){const l=r[o],c=r.slice(0,o+1).join("/");let u=i.children.find(h=>h.name===l);u||(u={name:l,path:c,children:[]},i.children.push(u)),o===r.length-1&&(u.file=s),i=u}}return WNe(n),n}function WNe(e){e.children.sort((t,n)=>!!t.file!=!!n.file?t.file?1:-1:t.name.localeCompare(n.name));for(const t of e.children)WNe(t)}function tM(e){return Sw(e).split("/").filter(Boolean).at(-1)??e}function VNe(e){const t=tM(e),n=t.includes(".")?t.split(".").pop()?.toLowerCase():"";return n?{css:"CSS",html:"HTML",js:"JS",json:"JSON",jsx:"JSX",md:"MD",ts:"TS",tsx:"TSX"}[n]??n.slice(0,3).toUpperCase():"FILE"}function qCn({artifact:e,sourceSessionId:t,workspaceActions:n,previewContent:s}){const{t:r}=mt(),i=vm(),o=f2e(e),l=_5(e.url)?e.url:void 0,c=e.metadata?.artifactType==="automation_snapshot",u=e.metadata?.artifactType==="code_review",h=e.storage==="workspace"&&!!e.workspacePath,f=h2e(e);return e.metadata?.artifactType==="web_preview_snapshot"?a.jsx(xSn,{artifact:e,sourceSessionId:t}):u?e.status!=="available"?a.jsx(HCn,{status:e.status}):!h||!e.workspacePath?a.jsx(UCn,{}):a.jsx(Nbn,{workspacePath:e.workspacePath,artifactVersion:Nae(e),workspaceActions:n}):h&&e.workspacePath?u2e(e)?a.jsx(GCn,{artifact:e,workspaceActions:n}):a.jsx(ID,{workspacePath:e.workspacePath,artifactVersion:Nae(e),workspaceActions:n,previewContent:s,imageMimeType:f,previewKind:WCn(e)?"html":VCn(e)?"markdown":f?"image":"source"}):a.jsxs("div",{className:ot.detail,children:[a.jsxs("div",{className:ot.section,children:[a.jsx("div",{className:ot.sectionTitle,children:c?"Automation Snapshot":"Artifact"}),a.jsxs("div",{className:ot.fieldGrid,children:[a.jsx(Fh,{label:"Type",value:gZ(e.kind,e.workspacePath)}),a.jsx(Fh,{label:"Storage",value:e.storage}),a.jsx(Fh,{label:"Status",value:e.status}),a.jsx(Fh,{label:"Source",value:e.source}),a.jsx(Fh,{label:"Size",value:mL(e.sizeBytes)}),a.jsx(Fh,{label:"Created",value:e.createdAt}),a.jsx(Fh,{label:"Updated",value:e.updatedAt}),e.toolName&&a.jsx(Fh,{label:"Tool",value:e.toolName}),e.toolCallId&&a.jsx(Fh,{label:"Tool call",value:e.toolCallId})]})]}),e.description&&a.jsxs("div",{className:ot.section,children:[a.jsx("div",{className:ot.sectionTitle,children:"Description"}),a.jsx("div",{className:ot.description,children:e.description})]}),c&&e.metadata&&a.jsxs("div",{className:ot.section,children:[a.jsx("div",{className:ot.sectionTitle,children:"Details"}),a.jsxs("div",{className:ot.fieldGrid,children:[zS(e.metadata,"automationId","Automation ID"),zS(e.metadata,"schedule","Schedule"),zS(e.metadata,"timezone","Timezone"),zS(e.metadata,"status","Status"),zS(e.metadata,"nextRunAt","Next run"),zS(e.metadata,"prompt","Prompt")]})]}),(o||l)&&a.jsxs("div",{className:ot.section,children:[a.jsx("div",{className:ot.sectionTitle,children:"Location"}),l?a.jsxs("div",{className:ot.locationRow,children:[a.jsx("a",{className:ot.link,href:l,target:"_blank",rel:"noopener noreferrer",onClick:p=>i(p,l),children:l}),a.jsx("a",{className:ot.openButton,href:l,target:"_blank",rel:"noopener noreferrer",onClick:p=>i(p,l),children:r("artifact.openLink")})]}):a.jsx("div",{className:ot.meta,children:o})]})]})}function HCn({status:e}){const{t}=mt();return a.jsx("div",{className:ot.previewError,role:"alert",children:t("codeReview.unavailable",{status:e})})}function UCn(){const{t:e}=mt();return a.jsx("div",{className:ot.previewError,role:"alert",children:e("codeReview.workspaceRequired")})}function WCn(e){const t=e.workspacePath?.toLowerCase()??"",n=kw(e.mimeType);return e.kind==="html"||t.endsWith(".html")||t.endsWith(".htm")||n==="text/html"}function VCn(e){const t=e.workspacePath?.toLowerCase()??"",n=kw(e.mimeType);return t.endsWith(".md")||t.endsWith(".markdown")||n==="text/markdown"}function GCn({artifact:e,workspaceActions:t}){const{t:n}=mt(),[s,r]=d.useState(null),[i,o]=d.useState(!1),l=d.useRef(!0),c=f2e(e);d.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const u=async()=>{if(e.workspacePath){o(!0),r(null);try{await gL(t,e.workspacePath,e.mimeType,()=>!l.current)}catch(h){if(!l.current)return;r(h instanceof Error?h.message:String(h))}finally{l.current&&o(!1)}}};return a.jsx("div",{className:ot.detail,children:a.jsxs("div",{className:ot.section,children:[a.jsx("div",{className:ot.sectionTitle,children:n("common.download")}),a.jsxs("div",{className:ot.fieldGrid,children:[a.jsx(Fh,{label:"Type",value:gZ(e.kind,e.workspacePath)}),a.jsx(Fh,{label:"Size",value:mL(e.sizeBytes)}),c?a.jsx(Fh,{label:"Location",value:c}):null,e.status!=="available"&&e.status!=="changed"?a.jsx(Fh,{label:"Status",value:e.status??"missing"}):null]}),a.jsx("div",{className:ot.downloadRow,children:a.jsx("button",{type:"button",className:ot.downloadButton,onClick:()=>{u()},disabled:i||e.status!=="available"&&e.status!=="changed",children:n(i?"common.downloading":"common.download")})}),s&&a.jsx("div",{className:ot.previewError,children:s})]})})}function KCn({tab:e}){const{t}=mt(),n=Ra(),s=L5(e.workspaceCwd),r=s?.actions,i=vm(),[o,l]=d.useState(0),[c,u]=d.useState(),[h,f]=d.useState(),[p,m]=d.useState(),g=e.source,v=g.locator,w=e.owner.isCurrent()&&n.sessionId===e.sourceSessionId&&n.capabilities?.features.includes("session_sources")&&s?.workspaceId===e.workspaceId&&(!!s||e.workspaceCwd===void 0&&v.type!=="workspace_file")&&(v.type!=="workspace_file"||g.workspaceCwd===n.workspaceCwd),y=v.type==="workspace_file"?v.workspacePath:v.type==="attachment"?v.attachmentId:"",b=/\.pdf$/i.test(y);if(d.useEffect(()=>{let _=!1;return u(void 0),f(void 0),m(void 0),!w||v.type==="url"?void 0:((async()=>{if(v.type==="attachment"){const E=await e.sessionActions.readAttachment(v.attachmentId);if(_||!e.owner.isCurrent())return;const T=Uint8Array.from(atob(E.data),R=>R.charCodeAt(0));u(new Blob([T],{type:E.mimeType}))}else if(b&&r){const E=await d5(r.readFileBytes,y,"application/pdf",{statFile:r.stat,isCancelled:()=>_||!e.owner.isCurrent()});!_&&e.owner.isCurrent()&&u(E)}})().catch(E=>{!_&&e.owner.isCurrent()&&f(sl(E))}),()=>{_=!0})},[o,w,v,y,b,e.owner,e.sessionActions,r]),w&&v.type==="url")return a.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[a.jsx("h3",{children:g.title}),g.description&&a.jsx("p",{children:g.description}),a.jsx("p",{className:"break-all text-sm text-muted-foreground",children:v.url}),_5(v.url)&&a.jsx("a",{className:"text-primary underline",href:v.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>i(_,v.url),children:t("sources.openOriginal")})]});if(!w||!s&&v.type!=="attachment")return a.jsx("div",{className:ot.empty,role:"alert",children:t("sources.unavailable")});const x=v.type==="workspace_file"&&!b&&u2e({workspacePath:y});return a.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:y,children:y}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[p&&a.jsx(Nt,{variant:"ghost",size:"icon-sm",asChild:!0,children:a.jsx("a",{href:p,download:g.title,"aria-label":`Download ${g.title}`,title:t("common.download"),children:a.jsx(aw,{})})}),h&&a.jsx(Nt,{variant:"ghost",size:"sm",onClick:()=>l(_=>_+1),children:t("common.retry")})]})]}),h?a.jsx("div",{className:ot.previewError,role:"alert",children:h}):x?a.jsxs("div",{className:"p-4",children:[a.jsx("p",{children:t("attachment.previewUnsupported")}),a.jsx(Nt,{onClick:()=>void gL(r,y,"application/octet-stream",()=>!e.owner.isCurrent()).catch(_=>{e.owner.isCurrent()&&f(sl(_))}),children:t("common.download")})]}):(v.type==="attachment"||b)&&!c?a.jsx("div",{className:ot.empty,role:"status",children:t("common.loading")}):c&&c.type!=="application/pdf"&&!X2(c.type,y)?a.jsx(GNe,{data:c,title:g.title,onDownloadUrl:m,showDownload:!1,image:!!wT(y)&&c.type.startsWith("image/")}):a.jsx(ID,{workspacePath:y,workspaceActions:r,onLoadError:f,previewData:c,previewOnly:v.type==="attachment",previewMimeType:c?.type,previewKind:/\.html?$/i.test(y)||kw(c?.type)==="text/html"?"source":void 0},o)]})}function GNe({data:e,title:t,image:n,onDownloadUrl:s,showDownload:r=!0}){const[i,o]=d.useState();return d.useEffect(()=>{const l=URL.createObjectURL(e);return o(l),s?.(l),()=>URL.revokeObjectURL(l)},[e,s]),i?a.jsxs("div",{className:ot.imagePreviewWrap,children:[n?a.jsx("img",{className:ot.imagePreview,src:i,alt:t}):a.jsx(KNe,{name:t,mimeType:e.type,size:e.size}),r&&a.jsx("a",{href:i,download:t,"aria-label":`Download ${t}`,children:a.jsx(aw,{})})]}):null}function ID({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewData:r,previewMimeType:i,imageMimeType:o,previewKind:l,previewOnly:c,onLoadError:u}){if(r)return a.jsx(YCn,{workspacePath:e,workspaceActions:n,data:r,mimeType:i,previewKind:l,onLoadError:u});const h=e.toLowerCase(),f=o??wT(e),p=l??(h.endsWith(".html")||h.endsWith(".htm")?"html":h.endsWith(".md")||h.endsWith(".markdown")?"markdown":f?"image":"source");return p==="html"?a.jsx(JCn,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:c,onLoadError:u}):p==="markdown"?a.jsx(t2n,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:c,onLoadError:u}):p==="image"&&f?a.jsx(QCn,{workspacePath:e,artifactVersion:t,workspaceActions:n,mimeType:f,onLoadError:u}):a.jsx(e2n,{workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:c,onLoadError:u})}function YCn({workspacePath:e,workspaceActions:t,data:n,mimeType:s,previewKind:r,onLoadError:i}){const o=(s||n.type||"application/octet-stream").split(";",1)[0].trim().toLowerCase();return o==="application/pdf"?a.jsx(ZCn,{data:n,mimeType:o,title:e}):X2(o,e)?a.jsx(XCn,{workspacePath:e,workspaceActions:t,data:n,previewKind:r,onLoadError:i}):a.jsx(KNe,{name:e,mimeType:o,size:n.size})}function XCn({workspacePath:e,workspaceActions:t,data:n,previewKind:s,onLoadError:r}){const{t:i}=mt(),[o,l]=d.useState(),[c,u]=d.useState();return d.useEffect(()=>{const h=new FileReader;return l(void 0),u(void 0),h.onload=()=>l(String(h.result??"")),h.onerror=()=>{const f=i("attachment.readFailed");u(f),r?.(f)},h.readAsText(n),()=>{h.readyState===FileReader.LOADING&&h.abort()}},[n,r,i]),c?a.jsx("div",{className:ot.previewError,children:c}):o===void 0?a.jsx("div",{className:ot.empty,children:i("attachment.loadingFile")}):a.jsx(ID,{workspacePath:e,workspaceActions:t,previewContent:o,previewOnly:!0,previewKind:s})}function ZCn({data:e,mimeType:t,title:n}){const{t:s}=mt(),[r,i]=d.useState();return d.useEffect(()=>{const o=URL.createObjectURL(e.type===t?e:new Blob([e],{type:t}));return i(o),()=>URL.revokeObjectURL(o)},[e,t]),r?a.jsx("iframe",{className:ot.pdfAttachmentPreview,src:r,title:`Preview ${n}`}):a.jsx("div",{className:ot.empty,children:s("attachment.loadingPreview")})}function KNe({name:e,mimeType:t,size:n}){const{t:s}=mt();return a.jsxs("div",{className:ot.unsupportedAttachmentPreview,children:[a.jsx(cg,{name:e,mimeType:t,"aria-hidden":"true"}),a.jsx("div",{children:s("attachment.previewUnsupported")}),a.jsxs("div",{className:ot.unsupportedAttachmentMeta,children:[t," · ",mL(n)]})]})}function QCn({workspacePath:e,artifactVersion:t,workspaceActions:n,mimeType:s,onLoadError:r}){const[i,o]=d.useState(null),[l,c]=d.useState(null);return d.useEffect(()=>{let u=!1,h;return o(null),c(null),d5((f,p)=>n.readFileBytes(f,p),e,s,{statFile:f=>n.stat(f),isCancelled:()=>u}).then(f=>{u||(h=URL.createObjectURL(f),o(h))}).catch(f=>{if(u)return;const p=f instanceof Error?f.message:String(f);c(p),r?.(p)}),()=>{u=!0,h&&URL.revokeObjectURL(h)}},[t,s,r,n,e]),a.jsxs("div",{className:ot.imagePreviewWrap,children:[i?a.jsxs(a.Fragment,{children:[a.jsx("img",{className:ot.imagePreview,src:i,alt:tM(e)}),a.jsx("a",{className:ot.imageDownloadButton,href:i,download:tM(e),"aria-label":`Download ${tM(e)}`,title:"Download",children:a.jsx(aw,{size:16,strokeWidth:1.8})})]}):l?null:a.jsx("div",{className:ot.empty,children:"Loading image..."}),l&&a.jsx("div",{className:ot.previewError,children:l})]})}function Uee({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,truncatedMessage:i,onLoadError:o}){const[l,c]=d.useState(s??null),[u,h]=d.useState(null);return d.useEffect(()=>{let f=!1;if(c(s??null),h(null),!r)return n.stat(e).then(p=>{if(!f){if(p.type==="directory")throw new Error("Directories cannot be opened as artifacts.");return n.readWorkspaceFile(e)}}).then(p=>{f||!p||(c(p.content),p.truncated&&h(i))}).catch(p=>{if(f)return;const m=p instanceof Error?p.message:String(p);h(m),o?.(m)}),()=>{f=!0}},[t,s,r,i,o,n,e]),{content:l,error:u}}function JCn({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:i}){const{content:o,error:l}=Uee({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,truncatedMessage:"Preview is truncated because the file is too large.",onLoadError:i});return a.jsxs("div",{className:ot.htmlPreviewWrap,children:[o===null?a.jsx("div",{className:ot.empty,children:"Loading preview..."}):a.jsx("iframe",{className:ot.htmlPreview,referrerPolicy:"no-referrer",sandbox:"allow-scripts",srcDoc:p2e(o,`Preview ${e}`),title:`Preview ${e}`}),l&&a.jsx("div",{className:ot.previewError,children:l})]})}function e2n({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:i}){const o=d.useRef(null),[l,c]=d.useState(null),{content:u,error:h}=Uee({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,truncatedMessage:"File is truncated because it is too large.",onLoadError:i});return d.useEffect(()=>{const f=o.current;if(!f||u===null)return;f.replaceChildren(),c(null);let p;try{p=new ts({doc:u,extensions:[tje,ts.editable.of(!1),yo.readOnly.of(!0),ts.lineWrapping],parent:f})}catch(m){c(m instanceof Error?m.message:String(m));return}return()=>p.destroy()},[u]),a.jsxs("div",{className:ot.filePreviewWrap,children:[u===null?a.jsx("div",{className:ot.empty,children:"Loading file..."}):a.jsx("div",{ref:o,className:ot.codeMirrorFile}),(h||l)&&a.jsx("div",{className:ot.previewError,children:h||l})]})}function t2n({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,onLoadError:i}){const{content:o,error:l}=Uee({workspacePath:e,artifactVersion:t,workspaceActions:n,previewContent:s,previewOnly:r,truncatedMessage:"Preview is truncated because the file is too large.",onLoadError:i});return a.jsxs("div",{className:ot.markdownPreviewWrap,children:[o===null?a.jsx("div",{className:ot.empty,children:"Loading preview..."}):a.jsx(rp,{content:o}),l&&a.jsx("div",{className:ot.previewError,children:l})]})}function Fh({label:e,value:t}){return t?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:ot.fieldLabel,children:e}),a.jsx("span",{className:ot.fieldValue,children:t})]}):null}function zS(e,t,n){const s=e[t];return s==null||s===""?null:a.jsx(Fh,{label:n,value:String(s)},t)}function n2n(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const YNe=Gs.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),nA=()=>{const e=Gs.useContext(YNe);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};n2n(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
|
|
2146
2146
|
[data-state=closed]
|
|
2147
2147
|
){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}`);function s2n(){const e=navigator.userAgent;return typeof window<"u"&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))}function r2n(){return Wee(/^Mac/)}function i2n(){return Wee(/^iPhone/)}function Cge(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function o2n(){return Wee(/^iPad/)||r2n()&&navigator.maxTouchPoints>1}function XNe(){return i2n()||o2n()}function Wee(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.platform):void 0}const a2n=24,l2n=typeof window<"u"?d.useLayoutEffect:d.useEffect;function Tge(...e){return(...t)=>{for(let n of e)typeof n=="function"&&n(...t)}}const Iq=typeof document<"u"&&window.visualViewport;function Ige(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function ZNe(e){for(Ige(e)&&(e=e.parentElement);e&&!Ige(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const c2n=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let j8=0,Eq;function u2n(e={}){let{isDisabled:t}=e;l2n(()=>{if(!t)return j8++,j8===1&&XNe()&&(Eq=d2n()),()=>{j8--,j8===0&&Eq?.()}},[t])}function d2n(){let e,t=0,n=f=>{e=ZNe(f.target),!(e===document.documentElement&&e===document.body)&&(t=f.changedTouches[0].pageY)},s=f=>{if(!e||e===document.documentElement||e===document.body){f.preventDefault();return}let p=f.changedTouches[0].pageY,m=e.scrollTop,g=e.scrollHeight-e.clientHeight;g!==0&&((m<=0&&p>t||m>=g&&p<t)&&f.preventDefault(),t=p)},r=f=>{let p=f.target;jK(p)&&p!==document.activeElement&&(f.preventDefault(),p.style.transform="translateY(-2000px)",p.focus(),requestAnimationFrame(()=>{p.style.transform=""}))},i=f=>{let p=f.target;jK(p)&&(p.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{p.style.transform="",Iq&&(Iq.height<window.innerHeight?requestAnimationFrame(()=>{Ege(p)}):Iq.addEventListener("resize",()=>Ege(p),{once:!0}))}))},o=()=>{window.scrollTo(0,0)},l=window.pageXOffset,c=window.pageYOffset,u=Tge(h2n(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let h=Tge(II(document,"touchstart",n,{passive:!1,capture:!0}),II(document,"touchmove",s,{passive:!1,capture:!0}),II(document,"touchend",r,{passive:!1,capture:!0}),II(document,"focus",i,!0),II(window,"scroll",o));return()=>{u(),h(),window.scrollTo(l,c)}}function h2n(e,t,n){let s=e.style[t];return e.style[t]=n,()=>{e.style[t]=s}}function II(e,t,n,s){return e.addEventListener(t,n,s),()=>{e.removeEventListener(t,n,s)}}function Ege(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let n=ZNe(e);if(n!==document.documentElement&&n!==document.body&&n!==e){let s=n.getBoundingClientRect().top,r=e.getBoundingClientRect().top,i=e.getBoundingClientRect().bottom;const o=n.getBoundingClientRect().bottom+a2n;i>o&&(n.scrollTop+=r-s)}e=n.parentElement}}function jK(e){return e instanceof HTMLInputElement&&!c2n.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function f2n(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function p2n(...e){return t=>e.forEach(n=>f2n(n,t))}function QNe(...e){return d.useCallback(p2n(...e),e)}const JNe=new WeakMap;function ru(e,t,n=!1){if(!e||!(e instanceof HTMLElement))return;let s={};Object.entries(t).forEach(([r,i])=>{if(r.startsWith("--")){e.style.setProperty(r,i);return}s[r]=e.style[r],e.style[r]=i}),!n&&JNe.set(e,s)}function m2n(e,t){if(!e||!(e instanceof HTMLElement))return;let n=JNe.get(e);n&&(e.style[t]=n[t])}const Dc=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function N8(e,t){if(!e)return null;const n=window.getComputedStyle(e),s=n.transform||n.webkitTransform||n.mozTransform;let r=s.match(/^matrix3d\((.+)\)$/);return r?parseFloat(r[1].split(", ")[Dc(t)?13:12]):(r=s.match(/^matrix\((.+)\)$/),r?parseFloat(r[1].split(", ")[Dc(t)?5:4]):null)}function g2n(e){return 8*(Math.log(e+1)-2)}function Rq(e,t){if(!e)return()=>{};const n=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=n}}function v2n(...e){return(...t)=>{for(const n of e)typeof n=="function"&&n(...t)}}const Bl={DURATION:.5,EASE:[.32,.72,0,1]},eMe=.4,w2n=.25,y2n=100,tMe=8,Ox=16,NK=26,Aq="vaul-dragging";function nMe(e){const t=Gs.useRef(e);return Gs.useEffect(()=>{t.current=e}),Gs.useMemo(()=>(...n)=>t.current==null?void 0:t.current.call(t,...n),[])}function b2n({defaultProp:e,onChange:t}){const n=Gs.useState(e),[s]=n,r=Gs.useRef(s),i=nMe(t);return Gs.useEffect(()=>{r.current!==s&&(i(s),r.current=s)},[s,r,i]),n}function sMe({prop:e,defaultProp:t,onChange:n=()=>{}}){const[s,r]=b2n({defaultProp:t,onChange:n}),i=e!==void 0,o=i?e:s,l=nMe(n),c=Gs.useCallback(u=>{if(i){const f=typeof u=="function"?u(e):u;f!==e&&l(f)}else r(u)},[i,e,r,l]);return[o,c]}function x2n({activeSnapPointProp:e,setActiveSnapPointProp:t,snapPoints:n,drawerRef:s,overlayRef:r,fadeFromIndex:i,onSnapPointChange:o,direction:l="bottom",container:c,snapToSequentialPoint:u}){const[h,f]=sMe({prop:e,defaultProp:n?.[0],onChange:t}),[p,m]=Gs.useState(typeof window<"u"?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);Gs.useEffect(()=>{function T(){m({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[]);const g=Gs.useMemo(()=>h===n?.[n.length-1]||null,[n,h]),v=Gs.useMemo(()=>{var T;return(T=n?.findIndex(R=>R===h))!=null?T:null},[n,h]),w=n&&n.length>0&&(i||i===0)&&!Number.isNaN(i)&&n[i]===h||!n,y=Gs.useMemo(()=>{const T=c?{width:c.getBoundingClientRect().width,height:c.getBoundingClientRect().height}:typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var R;return(R=n?.map(C=>{const I=typeof C=="string";let A=0;if(I&&(A=parseInt(C,10)),Dc(l)){const j=I?A:p?C*T.height:0;return p?l==="bottom"?T.height-j:-T.height+j:j}const N=I?A:p?C*T.width:0;return p?l==="right"?T.width-N:-T.width+N:N}))!=null?R:[]},[n,p,c]),b=Gs.useMemo(()=>v!==null?y?.[v]:null,[y,v]),x=Gs.useCallback(T=>{var R;const C=(R=y?.findIndex(I=>I===T))!=null?R:null;o(C),ru(s.current,{transition:`transform ${Bl.DURATION}s cubic-bezier(${Bl.EASE.join(",")})`,transform:Dc(l)?`translate3d(0, ${T}px, 0)`:`translate3d(${T}px, 0, 0)`}),y&&C!==y.length-1&&i!==void 0&&C!==i&&C<i?ru(r.current,{transition:`opacity ${Bl.DURATION}s cubic-bezier(${Bl.EASE.join(",")})`,opacity:"0"}):ru(r.current,{transition:`opacity ${Bl.DURATION}s cubic-bezier(${Bl.EASE.join(",")})`,opacity:"1"}),f(n?.[Math.max(C,0)])},[s.current,n,y,i,r,f]);Gs.useEffect(()=>{if(h||e){var T;const R=(T=n?.findIndex(C=>C===e||C===h))!=null?T:-1;y&&R!==-1&&typeof y[R]=="number"&&x(y[R])}},[h,e,n,y,x]);function _({draggedDistance:T,closeDrawer:R,velocity:C,dismissible:I}){if(i===void 0)return;const A=l==="bottom"||l==="right"?(b??0)-T:(b??0)+T,N=v===i-1,j=v===0,O=T>0;if(N&&ru(r.current,{transition:`opacity ${Bl.DURATION}s cubic-bezier(${Bl.EASE.join(",")})`}),!u&&C>2&&!O){I?R():x(y[0]);return}if(!u&&C>2&&O&&y&&n){x(y[n.length-1]);return}const B=y?.reduce((U,V)=>typeof U!="number"||typeof V!="number"?U:Math.abs(V-A)<Math.abs(U-A)?V:U),D=Dc(l)?window.innerHeight:window.innerWidth;if(C>eMe&&Math.abs(T)<D*.4){const U=O?1:-1;if(U>0&&g&&n){x(y[n.length-1]);return}if(j&&U<0&&I&&R(),v===null)return;x(y[v+U]);return}x(B)}function S({draggedDistance:T}){if(b===null)return;const R=l==="bottom"||l==="right"?b-T:b+T;(l==="bottom"||l==="right")&&R<y[y.length-1]||(l==="top"||l==="left")&&R>y[y.length-1]||ru(s.current,{transform:Dc(l)?`translate3d(0, ${R}px, 0)`:`translate3d(${R}px, 0, 0)`})}function E(T,R){if(!n||typeof v!="number"||!y||i===void 0)return null;const C=v===i-1;if(v>=i&&R)return 0;if(C&&!R)return 1;if(!w&&!C)return null;const A=C?v+1:v-1,N=C?y[A]-y[A-1]:y[A+1]-y[A],j=T/Math.abs(N);return C?1-j:j}return{isLastSnapPoint:g,activeSnapPoint:h,shouldFade:w,getPercentageDragged:E,setActiveSnapPoint:f,activeSnapPointIndex:v,onRelease:_,onDrag:S,snapPointsOffset:y}}const _2n=()=>()=>{};function k2n(){const{direction:e,isOpen:t,shouldScaleBackground:n,setBackgroundColorOnScale:s,noBodyStyles:r}=nA(),i=Gs.useRef(null),o=d.useMemo(()=>document.body.style.backgroundColor,[]);function l(){return(window.innerWidth-NK)/window.innerWidth}Gs.useEffect(()=>{if(t&&n){i.current&&clearTimeout(i.current);const c=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!c)return;v2n(s&&!r?Rq(document.body,{background:"black"}):_2n,Rq(c,{transformOrigin:Dc(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${Bl.DURATION}s`,transitionTimingFunction:`cubic-bezier(${Bl.EASE.join(",")})`}));const u=Rq(c,{borderRadius:`${tMe}px`,overflow:"hidden",...Dc(e)?{transform:`scale(${l()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${l()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{u(),i.current=window.setTimeout(()=>{o?document.body.style.background=o:document.body.style.removeProperty("background")},Bl.DURATION*1e3)}}},[t,n,o])}let EI=null;function S2n({isOpen:e,modal:t,nested:n,hasBeenOpened:s,preventScrollRestoration:r,noBodyStyles:i}){const[o,l]=Gs.useState(()=>typeof window<"u"?window.location.href:""),c=Gs.useRef(0),u=Gs.useCallback(()=>{if(Cge()&&EI===null&&e&&!i){EI={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:f,innerHeight:p}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-c.current}px`,left:`${-f}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const m=p-window.innerHeight;m&&c.current>=p&&(document.body.style.top=`${-(c.current+m)}px`)}),300)}},[e]),h=Gs.useCallback(()=>{if(Cge()&&EI!==null&&!i){const f=-parseInt(document.body.style.top,10),p=-parseInt(document.body.style.left,10);Object.assign(document.body.style,EI),window.requestAnimationFrame(()=>{if(r&&o!==window.location.href){l(window.location.href);return}window.scrollTo(p,f)}),EI=null}},[o]);return Gs.useEffect(()=>{function f(){c.current=window.scrollY}return f(),window.addEventListener("scroll",f),()=>{window.removeEventListener("scroll",f)}},[]),Gs.useEffect(()=>{if(t)return()=>{typeof document>"u"||document.querySelector("[data-vaul-drawer]")||h()}},[t,h]),Gs.useEffect(()=>{n||!s||(e?(!window.matchMedia("(display-mode: standalone)").matches&&u(),t||window.setTimeout(()=>{h()},500)):h())},[e,s,o,t,n,u,h]),{restorePositionSetting:h}}function C2n({open:e,onOpenChange:t,children:n,onDrag:s,onRelease:r,snapPoints:i,shouldScaleBackground:o=!1,setBackgroundColorOnScale:l=!0,closeThreshold:c=w2n,scrollLockTimeout:u=y2n,dismissible:h=!0,handleOnly:f=!1,fadeFromIndex:p=i&&i.length-1,activeSnapPoint:m,setActiveSnapPoint:g,fixed:v,modal:w=!0,onClose:y,nested:b,noBodyStyles:x=!1,direction:_="bottom",defaultOpen:S=!1,disablePreventScroll:E=!0,snapToSequentialPoint:T=!1,preventScrollRestoration:R=!1,repositionInputs:C=!0,onAnimationEnd:I,container:A,autoFocus:N=!1}){var j,O;const[B=!1,D]=sMe({defaultProp:S,prop:e,onChange:et=>{t?.(et),!et&&!b&&Y(),setTimeout(()=>{I?.(et)},Bl.DURATION*1e3),et&&!w&&typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),et||(document.body.style.pointerEvents="auto")}}),[U,V]=Gs.useState(!1),[F,M]=Gs.useState(!1),[X,ee]=Gs.useState(!1),P=Gs.useRef(null),ce=Gs.useRef(null),ae=Gs.useRef(null),pe=Gs.useRef(null),q=Gs.useRef(null),K=Gs.useRef(!1),oe=Gs.useRef(null),W=Gs.useRef(0),ge=Gs.useRef(!1),le=Gs.useRef(!S),ye=Gs.useRef(0),se=Gs.useRef(null),Se=Gs.useRef(((j=se.current)==null?void 0:j.getBoundingClientRect().height)||0),re=Gs.useRef(((O=se.current)==null?void 0:O.getBoundingClientRect().width)||0),me=Gs.useRef(0),Le=Gs.useCallback(et=>{i&&et===Ke.length-1&&(ce.current=new Date)},[]),{activeSnapPoint:Pe,activeSnapPointIndex:st,setActiveSnapPoint:He,onRelease:Te,snapPointsOffset:Ke,onDrag:H,shouldFade:Z,getPercentageDragged:$}=x2n({snapPoints:i,activeSnapPointProp:m,setActiveSnapPointProp:g,drawerRef:se,fadeFromIndex:p,overlayRef:P,onSnapPointChange:Le,direction:_,container:A,snapToSequentialPoint:T});u2n({isDisabled:!B||F||!w||X||!U||!C||!E});const{restorePositionSetting:Y}=S2n({isOpen:B,modal:w,nested:b??!1,hasBeenOpened:U,preventScrollRestoration:R,noBodyStyles:x});function de(){return(window.innerWidth-NK)/window.innerWidth}function we(et){var We,_t;!h&&!i||se.current&&!se.current.contains(et.target)||(Se.current=((We=se.current)==null?void 0:We.getBoundingClientRect().height)||0,re.current=((_t=se.current)==null?void 0:_t.getBoundingClientRect().width)||0,M(!0),ae.current=new Date,XNe()&&window.addEventListener("touchend",()=>K.current=!1,{once:!0}),et.target.setPointerCapture(et.pointerId),W.current=Dc(_)?et.pageY:et.pageX)}function Re(et,We){var _t;let pt=et;const Et=(_t=window.getSelection())==null?void 0:_t.toString(),_n=se.current?N8(se.current,_):null,Ze=new Date;if(pt.tagName==="SELECT"||pt.hasAttribute("data-vaul-no-drag")||pt.closest("[data-vaul-no-drag]"))return!1;if(_==="right"||_==="left")return!0;if(ce.current&&Ze.getTime()-ce.current.getTime()<500)return!1;if(_n!==null&&(_==="bottom"?_n>0:_n<0))return!0;if(Et&&Et.length>0)return!1;if(q.current&&Ze.getTime()-q.current.getTime()<u&&_n===0||We)return q.current=Ze,!1;for(;pt;){if(pt.scrollHeight>pt.clientHeight){if(pt.scrollTop!==0)return q.current=new Date,!1;if(pt.getAttribute("role")==="dialog")return!0}pt=pt.parentNode}return!0}function fe(et){if(se.current&&F){const We=_==="bottom"||_==="right"?1:-1,_t=(W.current-(Dc(_)?et.pageY:et.pageX))*We,pt=_t>0,Et=i&&!h&&!pt;if(Et&&st===0)return;const _n=Math.abs(_t),Ze=document.querySelector("[data-vaul-drawer-wrapper]"),Wt=_==="bottom"||_==="top"?Se.current:re.current;let gn=_n/Wt;const Hn=$(_n,pt);if(Hn!==null&&(gn=Hn),Et&&gn>=1||!K.current&&!Re(et.target,pt))return;if(se.current.classList.add(Aq),K.current=!0,ru(se.current,{transition:"none"}),ru(P.current,{transition:"none"}),i&&H({draggedDistance:_t}),pt&&!i){const rt=g2n(_t),Dt=Math.min(rt*-1,0)*We;ru(se.current,{transform:Dc(_)?`translate3d(0, ${Dt}px, 0)`:`translate3d(${Dt}px, 0, 0)`});return}const Me=1-gn;if((Z||p&&st===p-1)&&(s?.(et,gn),ru(P.current,{opacity:`${Me}`,transition:"none"},!0)),Ze&&P.current&&o){const rt=Math.min(de()+gn*(1-de()),1),Dt=8-gn*8,Jt=Math.max(0,14-gn*14);ru(Ze,{borderRadius:`${Dt}px`,transform:Dc(_)?`scale(${rt}) translate3d(0, ${Jt}px, 0)`:`scale(${rt}) translate3d(${Jt}px, 0, 0)`,transition:"none"},!0)}if(!i){const rt=_n*We;ru(se.current,{transform:Dc(_)?`translate3d(0, ${rt}px, 0)`:`translate3d(${rt}px, 0, 0)`})}}}Gs.useEffect(()=>{window.requestAnimationFrame(()=>{le.current=!0})},[]),Gs.useEffect(()=>{var et;function We(){if(!se.current||!C)return;const _t=document.activeElement;if(jK(_t)||ge.current){var pt;const Et=((pt=window.visualViewport)==null?void 0:pt.height)||0,_n=window.innerHeight;let Ze=_n-Et;const Wt=se.current.getBoundingClientRect().height||0,gn=Wt>_n*.8;me.current||(me.current=Wt);const Hn=se.current.getBoundingClientRect().top;if(Math.abs(ye.current-Ze)>60&&(ge.current=!ge.current),i&&i.length>0&&Ke&&st){const Me=Ke[st]||0;Ze+=Me}if(ye.current=Ze,Wt>Et||ge.current){const Me=se.current.getBoundingClientRect().height;let rt=Me;Me>Et&&(rt=Et-(gn?Hn:NK)),v?se.current.style.height=`${Me-Math.max(Ze,0)}px`:se.current.style.height=`${Math.max(rt,Et-Hn)}px`}else s2n()||(se.current.style.height=`${me.current}px`);i&&i.length>0&&!ge.current?se.current.style.bottom="0px":se.current.style.bottom=`${Math.max(Ze,0)}px`}}return(et=window.visualViewport)==null||et.addEventListener("resize",We),()=>{var _t;return(_t=window.visualViewport)==null?void 0:_t.removeEventListener("resize",We)}},[st,i,Ke]);function _e(et){ze(),y?.(),et||D(!1),setTimeout(()=>{i&&He(i[0])},Bl.DURATION*1e3)}function Ne(){if(!se.current)return;const et=document.querySelector("[data-vaul-drawer-wrapper]"),We=N8(se.current,_);ru(se.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${Bl.DURATION}s cubic-bezier(${Bl.EASE.join(",")})`}),ru(P.current,{transition:`opacity ${Bl.DURATION}s cubic-bezier(${Bl.EASE.join(",")})`,opacity:"1"}),o&&We&&We>0&&B&&ru(et,{borderRadius:`${tMe}px`,overflow:"hidden",...Dc(_)?{transform:`scale(${de()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${de()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${Bl.DURATION}s`,transitionTimingFunction:`cubic-bezier(${Bl.EASE.join(",")})`},!0)}function ze(){!F||!se.current||(se.current.classList.remove(Aq),K.current=!1,M(!1),pe.current=new Date)}function Fe(et){if(!F||!se.current)return;se.current.classList.remove(Aq),K.current=!1,M(!1),pe.current=new Date;const We=N8(se.current,_);if(!et||!Re(et.target,!1)||!We||Number.isNaN(We)||ae.current===null)return;const _t=pe.current.getTime()-ae.current.getTime(),pt=W.current-(Dc(_)?et.pageY:et.pageX),Et=Math.abs(pt)/_t;if(Et>.05&&(ee(!0),setTimeout(()=>{ee(!1)},200)),i){Te({draggedDistance:pt*(_==="bottom"||_==="right"?1:-1),closeDrawer:_e,velocity:Et,dismissible:h}),r?.(et,!0);return}if(_==="bottom"||_==="right"?pt>0:pt<0){Ne(),r?.(et,!0);return}if(Et>eMe){_e(),r?.(et,!1);return}var _n;const Ze=Math.min((_n=se.current.getBoundingClientRect().height)!=null?_n:0,window.innerHeight);var Wt;const gn=Math.min((Wt=se.current.getBoundingClientRect().width)!=null?Wt:0,window.innerWidth),Hn=_==="left"||_==="right";if(Math.abs(We)>=(Hn?gn:Ze)*c){_e(),r?.(et,!1);return}r?.(et,!0),Ne()}Gs.useEffect(()=>(B&&(ru(document.documentElement,{scrollBehavior:"auto"}),ce.current=new Date),()=>{m2n(document.documentElement,"scrollBehavior")}),[B]);function lt(et){const We=et?(window.innerWidth-Ox)/window.innerWidth:1,_t=et?-Ox:0;oe.current&&window.clearTimeout(oe.current),ru(se.current,{transition:`transform ${Bl.DURATION}s cubic-bezier(${Bl.EASE.join(",")})`,transform:Dc(_)?`scale(${We}) translate3d(0, ${_t}px, 0)`:`scale(${We}) translate3d(${_t}px, 0, 0)`}),!et&&se.current&&(oe.current=setTimeout(()=>{const pt=N8(se.current,_);ru(se.current,{transition:"none",transform:Dc(_)?`translate3d(0, ${pt}px, 0)`:`translate3d(${pt}px, 0, 0)`})},500))}function Be(et,We){if(We<0)return;const _t=(window.innerWidth-Ox)/window.innerWidth,pt=_t+We*(1-_t),Et=-Ox+We*Ox;ru(se.current,{transform:Dc(_)?`scale(${pt}) translate3d(0, ${Et}px, 0)`:`scale(${pt}) translate3d(${Et}px, 0, 0)`,transition:"none"})}function kt(et,We){const _t=Dc(_)?window.innerHeight:window.innerWidth,pt=We?(_t-Ox)/_t:1,Et=We?-Ox:0;We&&ru(se.current,{transition:`transform ${Bl.DURATION}s cubic-bezier(${Bl.EASE.join(",")})`,transform:Dc(_)?`scale(${pt}) translate3d(0, ${Et}px, 0)`:`scale(${pt}) translate3d(${Et}px, 0, 0)`})}return Gs.useEffect(()=>{w||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[w]),Gs.createElement(NP,{defaultOpen:S,onOpenChange:et=>{!h&&!et||(et?V(!0):_e(!0),D(et))},open:B},Gs.createElement(YNe.Provider,{value:{activeSnapPoint:Pe,snapPoints:i,setActiveSnapPoint:He,drawerRef:se,overlayRef:P,onOpenChange:t,onPress:we,onRelease:Fe,onDrag:fe,dismissible:h,shouldAnimate:le,handleOnly:f,isOpen:B,isDragging:F,shouldFade:Z,closeDrawer:_e,onNestedDrag:Be,onNestedOpenChange:lt,onNestedRelease:kt,keyboardIsOpen:ge,modal:w,snapPointsOffset:Ke,activeSnapPointIndex:st,direction:_,shouldScaleBackground:o,setBackgroundColorOnScale:l,noBodyStyles:x,container:A,autoFocus:N}},n))}const rMe=Gs.forwardRef(function({...e},t){const{overlayRef:n,snapPoints:s,onRelease:r,shouldFade:i,isOpen:o,modal:l,shouldAnimate:c}=nA(),u=QNe(t,n),h=s&&s.length>0;if(!l)return null;const f=Gs.useCallback(p=>r(p),[r]);return Gs.createElement(PP,{onMouseUp:f,ref:u,"data-vaul-overlay":"","data-vaul-snap-points":o&&h?"true":"false","data-vaul-snap-points-overlay":o&&i?"true":"false","data-vaul-animate":c?.current?"true":"false",...e})});rMe.displayName="Drawer.Overlay";const iMe=Gs.forwardRef(function({onPointerDownOutside:e,style:t,onOpenAutoFocus:n,...s},r){const{drawerRef:i,onPress:o,onRelease:l,onDrag:c,keyboardIsOpen:u,snapPointsOffset:h,activeSnapPointIndex:f,modal:p,isOpen:m,direction:g,snapPoints:v,container:w,handleOnly:y,shouldAnimate:b,autoFocus:x}=nA(),[_,S]=Gs.useState(!1),E=QNe(r,i),T=Gs.useRef(null),R=Gs.useRef(null),C=Gs.useRef(!1),I=v&&v.length>0;k2n();const A=(j,O,B=0)=>{if(C.current)return!0;const D=Math.abs(j.y),U=Math.abs(j.x),V=U>D,F=["bottom","right"].includes(O)?1:-1;if(O==="left"||O==="right"){if(!(j.x*F<0)&&U>=0&&U<=B)return V}else if(!(j.y*F<0)&&D>=0&&D<=B)return!V;return C.current=!0,!0};Gs.useEffect(()=>{I&&window.requestAnimationFrame(()=>{S(!0)})},[]);function N(j){T.current=null,C.current=!1,l(j)}return Gs.createElement(LP,{"data-vaul-drawer-direction":g,"data-vaul-drawer":"","data-vaul-delayed-snap-points":_?"true":"false","data-vaul-snap-points":m&&I?"true":"false","data-vaul-custom-container":w?"true":"false","data-vaul-animate":b?.current?"true":"false",...s,ref:E,style:h&&h.length>0?{"--snap-point-height":`${h[f??0]}px`,...t}:t,onPointerDown:j=>{y||(s.onPointerDown==null||s.onPointerDown.call(s,j),T.current={x:j.pageX,y:j.pageY},o(j))},onOpenAutoFocus:j=>{n?.(j),x||j.preventDefault()},onPointerDownOutside:j=>{if(e?.(j),!p||j.defaultPrevented){j.preventDefault();return}u.current&&(u.current=!1)},onFocusOutside:j=>{if(!p){j.preventDefault();return}},onPointerMove:j=>{if(R.current=j,y||(s.onPointerMove==null||s.onPointerMove.call(s,j),!T.current))return;const O=j.pageY-T.current.y,B=j.pageX-T.current.x,D=j.pointerType==="touch"?10:2;A({x:B,y:O},g,D)?c(j):(Math.abs(B)>D||Math.abs(O)>D)&&(T.current=null)},onPointerUp:j=>{s.onPointerUp==null||s.onPointerUp.call(s,j),T.current=null,C.current=!1,l(j)},onPointerOut:j=>{s.onPointerOut==null||s.onPointerOut.call(s,j),N(R.current)},onContextMenu:j=>{s.onContextMenu==null||s.onContextMenu.call(s,j),R.current&&N(R.current)}})});iMe.displayName="Drawer.Content";const T2n=250,I2n=120,E2n=Gs.forwardRef(function({preventCycle:e=!1,children:t,...n},s){const{closeDrawer:r,isDragging:i,snapPoints:o,activeSnapPoint:l,setActiveSnapPoint:c,dismissible:u,handleOnly:h,isOpen:f,onPress:p,onDrag:m}=nA(),g=Gs.useRef(null),v=Gs.useRef(!1);function w(){if(v.current){x();return}window.setTimeout(()=>{y()},I2n)}function y(){if(i||e||v.current){x();return}if(x(),!o||o.length===0){u||r();return}if(l===o[o.length-1]&&u){r();return}const S=o.findIndex(T=>T===l);if(S===-1)return;const E=o[S+1];c(E)}function b(){g.current=window.setTimeout(()=>{v.current=!0},T2n)}function x(){g.current&&window.clearTimeout(g.current),v.current=!1}return Gs.createElement("div",{onClick:w,onPointerCancel:x,onPointerDown:_=>{h&&p(_),b()},onPointerMove:_=>{h&&m(_)},ref:s,"data-vaul-drawer-visible":f?"true":"false","data-vaul-handle":"","aria-hidden":"true",...n},Gs.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},t))});E2n.displayName="Drawer.Handle";function R2n(e){const t=nA(),{container:n=t.container,...s}=e;return Gs.createElement(MP,{container:n,...s})}const sA={Root:C2n,Content:iMe,Overlay:rMe,Portal:R2n,Title:DP};function A2n({...e}){return a.jsx(sA.Root,{"data-slot":"drawer",...e})}function j2n({container:e,...t}){const n=up();return a.jsx(sA.Portal,{"data-slot":"drawer-portal",container:e??n??void 0,...t})}const N2n=d.forwardRef(function({className:t,...n},s){return a.jsx(sA.Overlay,{ref:s,"data-slot":"drawer-overlay",className:zn("fixed inset-0 isolate z-[var(--web-shell-dialog-backdrop-z-index,50)] bg-black/10 duration-150 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",t),...n})}),M2n=d.forwardRef(function({className:t,children:n,overlayProps:s,...r},i){return a.jsxs(j2n,{children:[a.jsx(N2n,{...s}),a.jsx(sA.Content,{ref:i,"data-slot":"drawer-content",className:zn("group/drawer-content fixed z-[var(--web-shell-dialog-backdrop-z-index,50)] flex h-auto flex-col bg-popover text-sm text-popover-foreground outline-none data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-xl data-[vaul-drawer-direction=bottom]:border-t data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:rounded-r-xl data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:rounded-l-xl data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-xl data-[vaul-drawer-direction=top]:border-b data-[vaul-drawer-direction=left]:sm:max-w-sm data-[vaul-drawer-direction=right]:sm:max-w-sm",t),...r,children:n})]})});function P2n({className:e,...t}){return a.jsx(sA.Title,{"data-slot":"drawer-title",className:zn("text-base font-medium text-foreground",e),...t})}/**
|
|
2148
2148
|
* @license
|
|
@@ -2169,7 +2169,7 @@ ${e.replace(/\n?$/,`
|
|
|
2169
2169
|
* SPDX-License-Identifier: Apache-2.0
|
|
2170
2170
|
*/const OK={dingtalk:"D",dws:"DWS",wecom:"W",feishu:"F",github:"GH",gitlab:"GL"},vIn=new Set(["dingtalk","dws","wecom","feishu","github","gitlab"]);function wMe(e){return typeof e=="string"&&vIn.has(e)}function wIn(e){return e.manageable&&wMe(e.type)}const P8={dingtalk:{clientId:"channels.editor.field.dingtalk.clientId",clientSecret:"channels.editor.field.dingtalk.clientSecret"},wecom:{botId:"channels.editor.field.wecom.botId",secret:"channels.editor.field.wecom.secret",wsUrl:"channels.editor.field.wecom.wsUrl"},feishu:{clientId:"channels.editor.field.feishu.clientId",clientSecret:"channels.editor.field.feishu.clientSecret"},dws:{senderPolicy:"channels.editor.field.dws.senderPolicy",dmPolicy:"channels.editor.field.dws.dmPolicy"},github:{token:"channels.editor.field.github.token",useLocalGh:"channels.editor.field.github.useLocalGh",baseUrl:"channels.editor.field.github.baseUrl",groupPolicy:"channels.editor.field.github.groupPolicy",senderPolicy:"channels.editor.field.github.senderPolicy",allowedUsers:"channels.editor.field.github.allowedUsers",reasonFilter:"channels.editor.field.github.reasonFilter"},gitlab:{token:"channels.editor.field.gitlab.token",baseUrl:"channels.editor.field.gitlab.baseUrl",groupPolicy:"channels.editor.field.gitlab.groupPolicy",senderPolicy:"channels.editor.field.gitlab.senderPolicy",allowedUsers:"channels.editor.field.gitlab.allowedUsers",action_prompt_template:"channels.editor.field.gitlab.action_prompt_template"}},Kge=new Set(["senderPolicy","allowedUsers","groupPolicy","dmPolicy"]),Yge=new Set(["sessionScope","multiSession","instructions"]),Fq={senderPolicy:"channels.editor.field.shared.senderPolicy",allowedUsers:"channels.editor.field.shared.allowedUsers",groupPolicy:"channels.editor.field.shared.groupPolicy",sessionScope:"channels.editor.field.shared.sessionScope",multiSession:"channels.editor.field.shared.multiSession",instructions:"channels.editor.field.shared.instructions"};function yIn(e){const t=e?.config.allowedUsers;return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}function bIn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ev({id:e,label:t,required:n,hint:s,description:r,error:i,children:o}){return a.jsxs("div",{className:to.field,children:[a.jsxs("div",{className:to.fieldHeader,children:[a.jsxs(lm,{htmlFor:e,children:[t,n?a.jsx("span",{className:to.required,"aria-hidden":"true",children:"*"}):null]}),s?a.jsx("span",{className:to.hint,children:s}):null]}),o,r?a.jsx("p",{className:to.fieldDescription,children:r}):null,i?a.jsx("p",{role:"alert",className:"text-xs text-destructive",children:i}):null]})}function xIn({open:e,descriptor:t,instance:n,expectedRevision:s,existingNames:r,workspaces:i,workspaceCwd:o,workspaceLoading:l=!1,onWorkspaceChange:c,onOpenChange:u,onSave:h,onReload:f,listPairingRequests:p,approvePairingRequest:m,listPairingApprovals:g,revokePairingApproval:v}){const{t:w}=mt(),y=d.useId(),[b,x]=d.useState(()=>Vge(t,n)),[_,S]=d.useState({}),[E,T]=d.useState(),[R,C]=d.useState(!1),[I,A]=d.useState(!1),N=d.useRef(!1),j=t.fields.filter(q=>Kge.has(q.key)),O=t.fields.filter(q=>Yge.has(q.key)),B=O.find(q=>q.key==="sessionScope"&&q.kind==="enum"),D=(B?.options??[]).filter(q=>q.value!=="thread"||n?.config.sessionScope==="thread"||n!==void 0&&n.config.sessionScope===void 0&&B?.default==="thread"),U=O.filter(q=>q!==B),V=t.fields.filter(q=>!Kge.has(q.key)&&!Yge.has(q.key));d.useEffect(()=>{e&&(N.current=!1,x(Vge(t,n)),S({}),T(void 0))},[t,n,e]),d.useEffect(()=>{S({}),T(void 0)},[o]);const F=q=>{const K=P8[t.type]?.[q.key]??Fq[q.key];return K?w(K):q.label},M=q=>{const K=P8[t.type]?.[q.key]??Fq[q.key];if(K){const oe=`${K}.description`,W=w(oe);if(W!==oe)return W}return q.description},X=(q,K,oe)=>{const W=[P8[t.type]?.[q.key],Fq[q.key]].filter(ge=>!!ge);for(const ge of W){const le=`${ge}.option.${K}`,ye=w(le);if(ye!==le)return ye}return oe},ee=(q,K)=>K==="duplicate"?w("channels.editor.validation.duplicate"):K==="credential"?w("channels.editor.validation.credential"):K==="invalid"?w("channels.editor.validation.invalidName"):K==="invalidGroupId"?w("channels.editor.validation.invalidGroupId"):K==="invalidOption"?w("channels.editor.validation.invalidOption"):K==="number"?w("channels.editor.validation.number"):K==="outOfRange"?w("channels.editor.validation.outOfRange",{min:q&&q.kind==="number"?q.exclusiveMinimum??0:0}):K==="policy"?w("channels.editor.validation.policy"):w("channels.editor.validation.required",{label:q?F(q):w("channels.editor.instanceName")}),P=async q=>{q.preventDefault();const K=hIn(t,b,r);if(Object.keys(K).length>0){S(Object.fromEntries(Object.entries(K).map(([oe,W])=>[oe,ee(t.fields.find(ge=>ge.key===oe),W)])));return}C(!0),T(void 0);try{await h(b.name.trim(),gIn(t,b,s,n)),N.current||u(!1)}catch(oe){T(sl(oe))}finally{C(!1)}},ce=async()=>{A(!0);try{await f(),u(!1)}catch(q){T(sl(q))}finally{A(!1)}},ae=q=>{const K=`${y}-${q.key}`,oe=n?.secrets[q.key],W=b.secrets[q.key]??{operation:"replace",value:""},ge=_[q.key],le=W.operation==="replace",ye=q.required?["preserve","replace"]:["preserve","replace","clear"];return a.jsxs(Ev,{id:K,label:F(q),required:q.required,description:M(q),hint:q.envResolvable?w("channels.editor.environmentReference"):void 0,error:ge,children:[oe?.present?a.jsxs("div",{className:to.secretState,children:[a.jsxs("span",{className:to.secretStatus,children:[a.jsx(gT,{size:15}),oe.source==="environment"?w("channels.editor.secret.environment"):w("channels.editor.secret.stored")]}),a.jsx("div",{className:to.secretActions,children:ye.map(se=>a.jsx(Nt,{type:"button",size:"xs",variant:W.operation===se?"secondary":"ghost","aria-pressed":W.operation===se,onClick:()=>x(Se=>({...Se,secrets:{...Se.secrets,[q.key]:se==="replace"?{operation:se,value:""}:{operation:se}}})),children:w(`channels.editor.secret.${se}`)},se))})]}):null,le?a.jsx(oi,{id:K,type:"password",autoComplete:"new-password",value:W.value??"","aria-invalid":!!ge,"aria-required":q.required,placeholder:w("channels.editor.secret.placeholder",{label:F(q)}),onChange:se=>x(Se=>({...Se,secrets:{...Se.secrets,[q.key]:{operation:"replace",value:se.target.value}}}))}):null,W.operation==="clear"?a.jsx("p",{className:to.hint,children:w("channels.editor.secret.clearHint")}):null]},q.key)},pe=q=>{if(q.kind==="object")return null;if(q.kind==="secret")return ae(q);const K=`${y}-${q.key}`,oe=b.values[q.key],W=_[q.key],ge=le=>x(ye=>({...ye,values:{...ye.values,[q.key]:le,...q.key==="multiSession"&&le===!0?{sessionScope:"user"}:{}}}));if(q.kind==="boolean")return a.jsx(Ev,{id:K,label:F(q),required:q.required,description:M(q),error:W,children:a.jsx(ag,{id:K,checked:oe===!0,"aria-required":q.required,onCheckedChange:le=>ge(le)})},q.key);if(q.kind==="enum")return a.jsx(Ev,{id:K,label:F(q),required:q.required,description:M(q),error:W,children:a.jsxs(sc,{value:String(oe??""),onValueChange:ge,children:[a.jsx(ic,{id:K,className:"w-full","aria-required":q.required,children:a.jsx(rc,{})}),a.jsx(oc,{children:q.options?.map(le=>a.jsx(Ho,{value:le.value,children:X(q,le.value,le.label)},le.value))})]})},q.key);if(q.kind==="record"){let le={};if(typeof oe=="string"&&oe)try{const se=JSON.parse(oe);bIn(se)&&(le=se)}catch{}const ye=(se,Se)=>{const re={...le,[se]:Se};ge(JSON.stringify(re))};return a.jsx(Ev,{id:K,label:F(q),required:q.required,description:M(q),error:W,children:a.jsx("div",{className:to.recordFields,children:q.options?.map(se=>{const Se=`${P8[t.type]?.[q.key]??""}.option.${se.value}`,re=w(Se),me=re!==Se?re:se.label;return a.jsxs("div",{className:to.recordRow,children:[a.jsx(lm,{htmlFor:`${K}-${se.value}`,className:to.recordLabel,children:me}),a.jsx(oi,{id:`${K}-${se.value}`,value:le[se.value]??"",onChange:Le=>ye(se.value,Le.target.value)})]},se.value)})})},q.key)}return q.kind==="string"&&q.multiline?a.jsx(Ev,{id:K,label:F(q),required:q.required,description:M(q),error:W,children:a.jsx(eb,{id:K,value:String(oe??""),"aria-invalid":!!W,"aria-required":q.required,onChange:le=>ge(le.target.value)})},q.key):a.jsx(Ev,{id:K,label:F(q),required:q.required,description:M(q),hint:q.envResolvable?w("channels.editor.environmentReference"):void 0,error:W,children:a.jsx(oi,{id:K,type:q.kind==="number"?"number":"text",value:String(oe??""),"aria-invalid":!!W,"aria-required":q.required,onChange:le=>ge(le.target.value)})},q.key)};return a.jsx(M0,{open:e,onOpenChange:q=>{q||(N.current=!0),u(q)},children:a.jsxs(P0,{className:"max-w-[calc(100%-2rem)] p-5 sm:max-w-xl",children:[a.jsx(L0,{children:a.jsxs("div",{className:to.platformHeader,children:[a.jsx("span",{className:to.platformMark,"aria-hidden":"true",children:OK[t.type]??t.displayName[0]?.toUpperCase()??"?"}),a.jsxs("div",{children:[a.jsx(O0,{children:w(n?"channels.editor.editTitle":"channels.editor.addTitle",{platform:t.displayName})}),a.jsx(Tw,{className:"mt-1",children:w(n?"channels.editor.editDescription":"channels.editor.addDescription")})]})]})}),a.jsxs("form",{className:to.form,onSubmit:P,children:[a.jsxs("div",{className:to.body,children:[E?a.jsxs(ol,{variant:"destructive",children:[a.jsx(_ae,{}),a.jsx(Wh,{children:w("channels.editor.saveError")}),a.jsx(al,{children:E}),a.jsxs(Nt,{className:"mt-2 w-fit",type:"button",size:"sm",variant:"outline",disabled:I,onClick:()=>void ce(),children:[I?a.jsx(Lr,{}):null,w("channels.editor.reloadLatest")]})]}):null,a.jsxs("section",{className:to.section,children:[a.jsx("h3",{className:to.sectionHeading,children:w("channels.editor.section.identity")}),a.jsx(Ev,{id:`${y}-name`,label:w("channels.editor.instanceName"),required:!0,error:_.name,children:a.jsx(oi,{id:`${y}-name`,value:b.name,disabled:!!n,"aria-invalid":!!_.name,"aria-required":!0,placeholder:w("channels.editor.instanceNamePlaceholder"),onChange:q=>x(K=>({...K,name:q.target.value}))})}),a.jsx(Ev,{id:`${y}-workspace`,label:w("channels.editor.workspace"),required:!0,description:w(n?"channels.editor.workspace.lockedDescription":"channels.editor.workspace.description"),children:a.jsxs(sc,{value:o,disabled:!!n||l||R,onValueChange:c,children:[a.jsx(ic,{id:`${y}-workspace`,className:"w-full","aria-required":!0,children:a.jsx(rc,{})}),a.jsx(oc,{children:i.map(q=>a.jsxs(Ho,{value:q.cwd,disabled:!q.trusted,children:[dg(q),q.primary?` · ${w("channels.workspace.primary")}`:""]},q.id))})]})})]}),a.jsxs("section",{className:to.section,children:[a.jsx("h3",{className:to.sectionHeading,children:w("channels.editor.section.credentials")}),V.map(pe)]}),O.length>0?a.jsxs("section",{className:to.settingsPanel,children:[a.jsx("h3",{className:to.settingsPanelTitle,children:w("channels.editor.section.session")}),B?a.jsxs("div",{className:to.sessionScopeField,children:[a.jsx("span",{className:to.sessionScopeLabel,children:w("channels.editor.session.isolation")}),a.jsx(MK,{className:to.sessionScopeControl,value:String(b.values[B.key]??""),"aria-label":w("channels.editor.session.isolation"),"aria-invalid":!!_[B.key],"aria-required":B.required,onValueChange:q=>x(K=>({...K,values:{...K.values,[B.key]:q}})),children:D.map(q=>a.jsxs(lm,{htmlFor:`${y}-${B.key}-${q.value}`,className:to.sessionScopeOption,"data-selected":b.values[B.key]===q.value,children:[a.jsx(PK,{id:`${y}-${B.key}-${q.value}`,className:to.sessionScopeRadio,value:q.value}),a.jsx("span",{children:X(B,q.value,q.label)})]},q.value))}),a.jsx("p",{className:to.sessionScopeDescription,"aria-live":"polite",children:w(`channels.editor.field.shared.sessionScope.detail.${String(b.values[B.key]??"user")}`)}),_[B.key]?a.jsx("p",{role:"alert",className:"text-xs text-destructive",children:_[B.key]}):null]}):null,U.map(pe)]}):null,(()=>{const q=RD(t),K=q?String(b.values.senderPolicy??""):b.senderPolicy,oe=!q,W=gMe(t),ge=String(W?b.values.groupPolicy??"":n?.config.groupPolicy??""),le=K==="pairing"||ge==="pairing",ye=j.filter(se=>se.key!=="allowedUsers"||K==="allowlist");return!oe&&ye.length===0&&!le?null:a.jsxs("section",{className:to.settingsPanel,children:[a.jsxs("div",{className:to.settingsPanelHeader,children:[a.jsx("h3",{className:to.settingsPanelTitle,children:w("channels.editor.section.access")}),a.jsx("p",{className:to.settingsPanelDescription,children:w("channels.editor.section.access.description")})]}),oe?a.jsxs(a.Fragment,{children:[a.jsx(MK,{className:to.policyGrid,value:b.senderPolicy,"aria-invalid":!!_.senderPolicy,onValueChange:se=>x(Se=>({...Se,senderPolicy:se==="pairing"||se==="open"?se:""})),children:["pairing","open"].map(se=>a.jsxs(lm,{className:to.policyCard,"data-selected":b.senderPolicy===se,children:[a.jsx(PK,{value:se}),a.jsxs("span",{className:to.policyCopy,children:[a.jsx("span",{className:to.policyTitle,children:w(`channels.editor.policy.${se}.title`)}),a.jsx("span",{className:to.policyDescription,children:w(`channels.editor.policy.${se}.description`)})]})]},se))}),_.senderPolicy?a.jsx("p",{role:"alert",className:"text-xs text-destructive",children:_.senderPolicy}):null]}):null,ye.map(pe),ge==="allowlist"?a.jsx(Ev,{id:`${y}-allowedGroupIds`,label:w("channels.editor.field.shared.allowedGroupIds"),description:w("channels.editor.field.shared.allowedGroupIds.description"),error:_.allowedGroupIds,children:a.jsx(oi,{id:`${y}-allowedGroupIds`,value:b.allowedGroupIds,"aria-invalid":!!_.allowedGroupIds,placeholder:w("channels.editor.field.shared.allowedGroupIds.placeholder"),onChange:se=>x(Se=>({...Se,allowedGroupIds:se.target.value}))})}):null,le?n?.config.senderPolicy==="pairing"||n?.config.groupPolicy==="pairing"?a.jsx(cIn,{channelName:n.name,listRequests:p,approveRequest:m,listApprovals:g,revokeApproval:v,staticAllowedUsers:yIn(n)}):a.jsxs(ol,{children:[a.jsx(_ae,{}),a.jsx(Wh,{children:w("channels.editor.pairing.saveFirst.title")}),a.jsx(al,{children:w("channels.editor.pairing.saveFirst.description")})]}):null]})})()]}),a.jsxs(D0,{className:"mt-4",children:[a.jsx(Nt,{type:"button",variant:"outline",onClick:()=>{N.current=!0,u(!1)},children:w("channels.editor.cancel")}),a.jsxs(Nt,{type:"submit",disabled:R||I||l||!s,children:[R?a.jsx(Lr,{}):null,w("channels.editor.save")]})]})]})]})})}const _In="_page_2cn2n_1",kIn="_pageHeader_2cn2n_8",SIn="_backButton_2cn2n_18",CIn="_title_2cn2n_25",TIn="_pageBody_2cn2n_34",IIn="_intro_2cn2n_42",EIn="_toolbar_2cn2n_48",RIn="_count_2cn2n_55",AIn="_toolbarActions_2cn2n_63",jIn="_workspacePicker_2cn2n_70",NIn="_workspacePickerLabel_2cn2n_76",MIn="_workspacePickerTrigger_2cn2n_83",PIn="_refreshButton_2cn2n_89",LIn="_loadingState_2cn2n_93",DIn="_section_2cn2n_103",OIn="_sectionHeader_2cn2n_110",$In="_sectionTitle_2cn2n_117",BIn="_sectionDescription_2cn2n_124",FIn="_emptyState_2cn2n_130",zIn="_channelGrid_2cn2n_136",qIn="_channelCard_2cn2n_143",HIn="_channelHeader_2cn2n_149",UIn="_channelIdentity_2cn2n_156",WIn="_channelIdentityCopy_2cn2n_163",VIn="_channelNameRow_2cn2n_167",GIn="_channelName_2cn2n_167",KIn="_channelMeta_2cn2n_185",YIn="_runtimeBadge_2cn2n_194",XIn="_cardActionGroup_2cn2n_205",ZIn="_errorAlert_2cn2n_211",QIn="_channelFooter_2cn2n_215",JIn="_startupControl_2cn2n_221",e3n="_startupCopy_2cn2n_230",t3n="_startupLabel_2cn2n_237",n3n="_startupDescription_2cn2n_244",s3n="_platformSection_2cn2n_250",r3n="_platformGrid_2cn2n_254",i3n="_platformCard_2cn2n_260",o3n="_platformMark_2cn2n_291",a3n="_platformCopy_2cn2n_306",l3n="_platformName_2cn2n_314",c3n="_platformHint_2cn2n_323",u3n="_platformAction_2cn2n_328",Kr={page:_In,pageHeader:kIn,backButton:SIn,title:CIn,pageBody:TIn,intro:IIn,toolbar:EIn,count:RIn,toolbarActions:AIn,workspacePicker:jIn,workspacePickerLabel:NIn,workspacePickerTrigger:MIn,refreshButton:PIn,loadingState:LIn,section:DIn,sectionHeader:OIn,sectionTitle:$In,sectionDescription:BIn,emptyState:FIn,channelGrid:zIn,channelCard:qIn,channelHeader:HIn,channelIdentity:UIn,channelIdentityCopy:WIn,channelNameRow:VIn,channelName:GIn,channelMeta:KIn,runtimeBadge:YIn,cardActionGroup:XIn,errorAlert:ZIn,channelFooter:QIn,startupControl:JIn,startupCopy:e3n,startupLabel:t3n,startupDescription:n3n,platformSection:s3n,platformGrid:r3n,platformCard:i3n,platformMark:o3n,platformCopy:a3n,platformName:l3n,platformHint:c3n,platformAction:u3n};function zq(e,t){return`${e??""}\0${t}`}const d3n={stopped:"channels.status.stopped",starting:"channels.status.starting",connected:"channels.status.connected",partial:"channels.status.partial",error:"channels.status.error"},h3n={stopped:"channels.statusDescription.stopped",starting:"channels.statusDescription.starting",connected:"channels.statusDescription.connected",partial:"channels.statusDescription.partial",error:"channels.statusDescription.error"};function f3n(e){return e==="error"?"destructive":e==="connected"?"secondary":"outline"}function p3n({onClose:e,initialFocusRef:t}){const{t:n}=mt(),s=vi(),r=s.capabilities?.features.includes("channel_management")===!0,i=!!s.token,{report:o,loading:l}=KM({autoLoad:r&&!i,enabled:r&&!i}),c=i||o?.security.loopbackBind===!0&&o.security.tokenConfigured===!1&&o.security.requireAuth===!1,u=d.useMemo(()=>{const me=(s.capabilities?.workspaces??[]).filter(Le=>Le.kind!=="live");return me.length>0?me:s.workspaceCwd?[{id:"primary",cwd:s.workspaceCwd,primary:!0,trusted:!0}]:[]},[s.capabilities?.workspaces,s.workspaceCwd]),h=u.find(me=>me.primary)??u.find(me=>me.trusted)??u[0],[f,p]=d.useState(),m=u.find(me=>me.cwd===f)??h,[g,v]=d.useState(),w=d.useRef(g);d.useEffect(()=>{w.current=g},[g]);const y=g?.workspaceCwd??m?.cwd,b=u.find(me=>me.cwd===y),{catalog:x,snapshot:_,channels:S,loading:E,error:T,reload:R,createOrUpdate:C,remove:I,setStartup:A,start:N,stop:j,restart:O,pairing:B}=rxe({autoLoad:r,enabled:r,workspaceCwd:y}),D=r&&c&&!!y&&b?.trusted===!0,[U,V]=d.useState({}),F=y?U[y]??null:null,[M,X]=d.useState({}),[ee,P]=d.useState(),[ce,ae]=d.useState(),[pe,q]=d.useState(!1);d.useEffect(()=>{P(void 0),ae(void 0),q(!1)},[y]),d.useEffect(()=>{f&&!u.some(me=>me.cwd===f)&&p(void 0),g&&!u.some(me=>me.cwd===g.workspaceCwd)&&v(void 0)},[g,f,u]);const K=d.useMemo(()=>x.filter(wIn),[x]),oe=d.useMemo(()=>Object.values(S).filter(me=>wMe(me.config.type)).sort((me,Le)=>me.name.localeCompare(Le.name)),[S]),W=b?dg(b):n("channels.workspace.current"),ge=d.useCallback(me=>{const Le=String(me.config.type);return x.find(Pe=>Pe.type===Le)?.displayName??Le},[x]),le=d.useCallback(me=>K.find(Le=>Le.type===me.config.type),[K]),ye=d.useCallback(async(me,Le)=>{const Pe=g?.workspaceCwd,st=await C(me,Le);return Pe&&w.current?.workspaceCwd===Pe&&p(Pe),st},[C,g?.workspaceCwd]),se=d.useCallback(async()=>{if(!(!ee||ee.workspaceCwd!==y||!_||pe)){q(!0),ae(void 0);try{await I(ee.instance.name,{expectedRevision:_.revision}),X(me=>{const Le={...me};return delete Le[zq(ee.workspaceCwd,ee.instance.name)],Le}),P(void 0)}catch(me){ae(sl(me))}finally{q(!1)}}},[y,ee,pe,I,_]),Se=d.useCallback(async(me,Le,Pe)=>{if(!D||F||!y)return;const st=y,He=zq(st,me.name);V(Te=>({...Te,[st]:{workspaceCwd:st,name:me.name,action:Le}})),X(Te=>{const Ke={...Te};return delete Ke[He],Ke});try{await Pe()}catch(Te){X(Ke=>({...Ke,[He]:sl(Te)}))}finally{V(Te=>{const Ke=Te[st];if(Ke?.name!==me.name||Ke.action!==Le)return Te;const H={...Te};return delete H[st],H})}},[y,F,D]),re=me=>{const Le=!D||F!==null;return me.runtime.state==="stopped"?a.jsxs(Nt,{size:"sm",disabled:Le,onClick:()=>void Se(me,"start",()=>N(me.name)),children:[F?.workspaceCwd===y&&F.name===me.name&&F.action==="start"?a.jsx(Lr,{}):null,n("channels.action.start")]}):me.runtime.state==="error"?a.jsxs(Nt,{size:"sm",disabled:Le,onClick:()=>void Se(me,"restart",()=>O(me.name)),children:[F?.workspaceCwd===y&&F.name===me.name&&F.action==="restart"?a.jsx(Lr,{}):null,n("channels.action.retry")]}):a.jsxs(Nt,{size:"sm",variant:"outline",disabled:Le,onClick:()=>void Se(me,"stop",()=>j(me.name)),children:[F?.workspaceCwd===y&&F.name===me.name&&F.action==="stop"?a.jsx(Lr,{}):null,n("channels.action.stop")]})};return a.jsxs("div",{className:Kr.page,children:[a.jsxs("header",{className:Kr.pageHeader,children:[a.jsx(Nt,{variant:"ghost",size:"icon",className:Kr.backButton,onClick:e,"aria-label":n("channels.action.back"),children:a.jsx(mk,{})}),a.jsx("h1",{ref:t,tabIndex:-1,className:Kr.title,children:n("channels.title")})]}),a.jsxs("div",{className:Kr.pageBody,children:[a.jsx("p",{className:Kr.intro,children:n("channels.description")}),a.jsxs("div",{className:Kr.toolbar,children:[a.jsx("p",{className:Kr.count,children:n("channels.summary",{workspace:W,count:oe.length})}),a.jsxs("div",{className:Kr.toolbarActions,children:[u.length>0?a.jsxs("div",{className:Kr.workspacePicker,children:[a.jsx("span",{className:Kr.workspacePickerLabel,children:n("channels.workspace.label")}),a.jsxs(sc,{value:m?.cwd??"",disabled:!r||!!g||E||pe,onValueChange:me=>p(me),children:[a.jsx(ic,{className:Kr.workspacePickerTrigger,"aria-label":n("channels.workspace.label"),children:a.jsx(rc,{})}),a.jsx(oc,{children:u.map(me=>a.jsxs(Ho,{value:me.cwd,disabled:!me.trusted,children:[dg(me),me.primary?` · ${n("channels.workspace.primary")}`:""]},me.id))})]})]}):null,a.jsxs(Nt,{variant:"outline",className:Kr.refreshButton,disabled:!r||E||!!g||F!==null||pe,onClick:()=>void R(),children:[E?a.jsx(Lr,{}):a.jsx(af,{}),n("channels.action.refresh")]})]})]}),r?null:a.jsxs(ol,{children:[a.jsx(nc,{}),a.jsx(Wh,{children:n("channels.unsupported.title")}),a.jsx(al,{children:n("channels.unsupported.description")})]}),r&&!c&&!l?a.jsxs(ol,{children:[a.jsx(nc,{}),a.jsx(Wh,{children:n("channels.readOnly.title")}),a.jsx(al,{children:n("channels.readOnly.description")})]}):null,E&&oe.length===0?a.jsxs("div",{className:Kr.loadingState,role:"status","aria-label":n("channels.loading"),children:[a.jsx(Lr,{}),n("channels.loading")]}):null,T?a.jsxs(ol,{variant:"destructive",children:[a.jsx(nc,{}),a.jsx(Wh,{children:n("channels.loadError.title")}),a.jsx(al,{children:sl(T)}),a.jsx(Nt,{className:"mt-2 w-fit",size:"sm",variant:"outline",onClick:()=>void R(),children:n("channels.action.retry")})]}):null,a.jsxs("section",{className:Kr.section,"aria-labelledby":"configured-channels",children:[a.jsxs("div",{className:Kr.sectionHeader,children:[a.jsx("h2",{id:"configured-channels",className:Kr.sectionTitle,children:n("channels.configured")}),a.jsx("p",{className:Kr.sectionDescription,children:n("channels.configured.description")})]}),!E&&!T&&oe.length===0?a.jsx(C0,{className:Kr.emptyState,children:a.jsxs(T0,{children:[a.jsx(I0,{variant:"icon",children:a.jsx(A2,{})}),a.jsx(E0,{children:n("channels.empty.title")}),a.jsx(X5,{children:n("channels.empty.description")})]})}):null,oe.length>0?a.jsx("div",{className:Kr.channelGrid,children:oe.map(me=>{const Le=le(me),Pe=M[zq(y,me.name)]??me.runtime.lastError,st=me.runtime.state!=="stopped"&&me.runtime.state!=="error";return a.jsxs(_c,{size:"sm",className:Kr.channelCard,children:[a.jsxs(jd,{className:Kr.channelHeader,children:[a.jsxs("div",{className:Kr.channelIdentity,children:[a.jsx("span",{className:Kr.platformMark,"aria-hidden":"true",children:OK[String(me.config.type)]??ge(me)[0]?.toUpperCase()??"?"}),a.jsxs("div",{className:Kr.channelIdentityCopy,children:[a.jsxs(Nd,{className:Kr.channelNameRow,children:[a.jsx("span",{className:Kr.channelName,children:me.name}),a.jsx(zi,{variant:f3n(me.runtime.state),className:Kr.runtimeBadge,"data-runtime-state":me.runtime.state,children:n(d3n[me.runtime.state])})]}),a.jsxs(qf,{className:Kr.channelMeta,children:[a.jsx("span",{children:ge(me)}),a.jsx("span",{"aria-hidden":"true",children:"·"}),a.jsx("span",{children:n(h3n[me.runtime.state])})]})]})]}),a.jsxs(ICe,{className:Kr.cardActionGroup,children:[re(me),Le?a.jsxs(Nt,{size:"sm",variant:"ghost",disabled:!D||F!==null||!_,"aria-label":n("channels.action.editNamed",{name:me.name}),onClick:()=>v({workspaceCwd:y,descriptor:Le,instance:me}),children:[a.jsx(sg,{}),n("channels.action.edit")]}):null,a.jsxs(gm,{children:[a.jsx(op,{asChild:!0,children:a.jsx(Nt,{size:"icon-sm",variant:"ghost",disabled:!D||F!==null||!_,"aria-label":n("channels.action.moreNamed",{name:me.name}),children:F?.workspaceCwd===y&&F.name===me.name&&F.action==="restart"?a.jsx(Lr,{}):a.jsx(Jb,{})})}),a.jsx(ap,{align:"end",className:"min-w-40",children:a.jsxs(Nw,{children:[st?a.jsxs(Ni,{onSelect:()=>void Se(me,"restart",()=>O(me.name)),children:[a.jsx(GCe,{"data-icon":"inline-start"}),n("channels.action.restart")]}):null,st?a.jsx(Bb,{}):null,a.jsxs(Ni,{variant:"destructive","aria-label":n("channels.action.deleteNamed",{name:me.name}),onSelect:()=>{ae(void 0),P({workspaceCwd:y,instance:me})},children:[a.jsx(ef,{"data-icon":"inline-start"}),n("channels.action.delete")]})]})})]})]})]}),Pe?a.jsx(ih,{children:a.jsxs(ol,{variant:"destructive",className:Kr.errorAlert,children:[a.jsx(nc,{}),a.jsx(Wh,{children:n("channels.runtimeError")}),a.jsx(al,{children:Pe})]})}):null,a.jsx(ECe,{className:Kr.channelFooter,children:a.jsxs("label",{className:Kr.startupControl,children:[a.jsxs("span",{className:Kr.startupCopy,children:[a.jsx("span",{className:Kr.startupLabel,children:n("channels.startsWithServe")}),a.jsx("span",{className:Kr.startupDescription,children:n("channels.startsWithServe.description")})]}),a.jsx(ag,{size:"sm",checked:me.startsWithServe,disabled:!D||F!==null||!_,"aria-label":n("channels.action.startWithServeNamed",{name:me.name}),onCheckedChange:He=>void Se(me,"startup",()=>A(me.name,{expectedRevision:_?.revision??"",enabled:He}))})]})})]},me.name)})}):null]}),K.length>0?a.jsxs("section",{className:`${Kr.section} ${Kr.platformSection}`,"aria-labelledby":"channel-platforms",children:[a.jsxs("div",{className:Kr.sectionHeader,children:[a.jsx("h2",{id:"channel-platforms",className:Kr.sectionTitle,children:n("channels.availablePlatforms")}),a.jsx("p",{className:Kr.sectionDescription,children:n("channels.availablePlatforms.description")})]}),a.jsx("div",{className:Kr.platformGrid,children:K.map(me=>a.jsxs("button",{type:"button",className:Kr.platformCard,"data-testid":`channel-platform-${me.type}`,disabled:!D||!_,"aria-label":n("channels.platform.configureNamed",{platform:me.displayName}),onClick:()=>v({workspaceCwd:y,descriptor:me}),children:[a.jsx("span",{className:Kr.platformMark,"aria-hidden":"true",children:OK[me.type]??me.displayName[0]?.toUpperCase()??"?"}),a.jsxs("span",{className:Kr.platformCopy,children:[a.jsx("span",{className:Kr.platformName,children:me.displayName}),a.jsx("span",{className:Kr.platformHint,children:n("channels.platform.add")})]}),a.jsx("span",{className:Kr.platformAction,"aria-hidden":"true",children:a.jsx(of,{})})]},me.type))})]}):null]}),g?a.jsx(xIn,{open:!0,descriptor:g.descriptor,instance:g.instance,expectedRevision:_?.revision??"",existingNames:oe.filter(me=>me.name!==g.instance?.name).map(me=>me.name),workspaces:u,workspaceCwd:g.workspaceCwd,workspaceLoading:E,onWorkspaceChange:me=>v(Le=>Le&&{...Le,workspaceCwd:me}),onOpenChange:me=>{me||v(void 0)},onSave:ye,onReload:R,listPairingRequests:B.list,approvePairingRequest:B.approve,listPairingApprovals:B.approvals,revokePairingApproval:B.revoke}):null,a.jsx(Mw,{open:!!(ee&&ee.workspaceCwd===y),onOpenChange:me=>{!me&&!pe&&(P(void 0),ae(void 0))},children:a.jsxs(Pw,{children:[a.jsxs(Lw,{children:[a.jsx(Ow,{children:n("channels.delete.title",{name:ee?.instance.name??""})}),a.jsx($w,{children:n("channels.delete.description")})]}),ce?a.jsxs(ol,{variant:"destructive",children:[a.jsx(nc,{}),a.jsx(Wh,{children:n("channels.delete.error")}),a.jsx(al,{children:ce}),a.jsx(Nt,{className:"mt-2 w-fit",size:"sm",variant:"outline",onClick:()=>{R().then(()=>{P(void 0),ae(void 0)},me=>{ae(sl(me))})},children:n("channels.editor.reloadLatest")})]}):null,a.jsxs(Dw,{children:[a.jsx(Bw,{disabled:pe,children:n("channels.editor.cancel")}),a.jsxs(Nt,{variant:"destructive",disabled:pe,onClick:()=>void se(),children:[pe?a.jsx(Lr,{}):null,n("channels.action.delete")]})]})]})})]})}const m3n=new Set(["plugins","extensions","mcp","skills","agents","channels"]);function g3n(e){return e!==null&&m3n.has(e)}function v3n(e){return typeof e=="boolean"?{plugins:e,portals:e}:{plugins:e?.plugins??!1,portals:e?.portals??!1,styles:e?.styles}}const Xge=new WeakMap;function w3n(e){const t=Array.from(e.querySelectorAll('style[data-qwen-web-shell="component"]')).map(n=>n.textContent??"").filter(Boolean).join(`
|
|
2171
2171
|
`);return t||Array.from(e.querySelectorAll("style[data-vite-dev-id]")).filter(n=>{const s=n.dataset.viteDevId??"";return s.includes("/packages/web-shell/")||s.includes("/web-shell/client/")}).map(n=>n.textContent??"").filter(Boolean).join(`
|
|
2172
|
-
`)}function yMe(e,t){const n=e.defaultView?.CSSStyleSheet;if(!n||typeof n.prototype.replaceSync!="function")return null;const s=new n;return s.replaceSync(t),s}function y3n(e,t){const n=Xge.get(e);if(n?.css===t)return n.sheet;const s=yMe(e,t);return s&&Xge.set(e,{css:t,sheet:s}),s}function bMe(e,t){const n=w3n(e.ownerDocument),s=[n,t].filter(i=>!!i);try{const i=n?y3n(e.ownerDocument,n):null,o=t?yMe(e.ownerDocument,t):null,l=[i,o].filter(c=>!!c);if(l.length===s.length&&l.length>0)return e.adoptedStyleSheets=[...e.adoptedStyleSheets,...l],()=>{e.adoptedStyleSheets=e.adoptedStyleSheets.filter(c=>!l.includes(c))}}catch{}const r=s.map(i=>{const o=e.ownerDocument.createElement("style");return o.dataset.qwenWebShellShadow="",o.textContent=i,e.appendChild(o),o});return()=>{for(const i of r)i.remove()}}function b3n({children:e,enabled:t,language:n,themeClassName:s,styles:r,initialFocusRef:i}){const o=d.useRef(null),[l,c]=d.useState(null);return d.useLayoutEffect(()=>{if(!t||!o.current)return;o.current.style.setProperty("all","initial","important"),o.current.style.setProperty("display","block","important"),o.current.style.setProperty("min-width","0","important"),o.current.style.setProperty("width","100%","important");const u=o.current.shadowRoot??o.current.attachShadow({mode:"open"}),h=u.ownerDocument.createElement("div");h.dataset.webShellRoot="",h.dataset.webShellShadcn="",h.dataset.webShellShadowRoot="plugins";const f=bMe(u,r);return u.appendChild(h),c(h),()=>{h.remove(),f(),c(null)}},[t,r]),d.useLayoutEffect(()=>{l&&(l.className=s,l.lang=n)},[n,l,s]),d.useLayoutEffect(()=>{l&&i?.current?.focus()},[i,l]),t?a.jsx("div",{ref:o,"data-web-shell-shadow-host":"plugins",children:l?cp.createPortal(e,l):null}):e}const x3n={ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",Backspace:"Backspace",Delete:"Delete",End:"End",Enter:"Enter",Home:"Home",PageDown:"PageDown",PageUp:"PageUp",Space:"Space",Tab:"Tab"},_3n={Backquote:"`",Backslash:"\\",BracketLeft:"[",BracketRight:"]",Comma:",",Equal:"=",Minus:"-",Period:".",Quote:"'",Semicolon:";",Slash:"/"};function k3n(e){return/^Key[A-Z]$/.test(e.code)?e.code.slice(3):/^Digit[0-9]$/.test(e.code)?e.code.slice(5):/^F(?:[1-9]|1[0-9]|2[0-4])$/.test(e.code)?e.code:x3n[e.key]??_3n[e.code]??null}function S3n(e){const t=k3n(e);if(!t)return null;const n=[];return e.metaKey&&n.push("Command"),e.ctrlKey&&n.push("Control"),e.altKey&&n.push("Alt"),e.shiftKey&&n.push("Shift"),n.push(t),n.join("+")}function C3n(e){return e?e.split("+").map(t=>t==="Command"?"⌘":t==="Control"?"⌃":t==="Alt"?"⌥":t==="Shift"?"⇧":t==="Space"?"Space":t).join(""):""}function T3n({accelerator:e,disabled:t,captureLabel:n,clearLabel:s,offLabel:r,onChange:i}){const[o,l]=d.useState(!1),[c,u]=d.useState(),[h,f]=d.useState(!1),p=d.useRef(null);d.useEffect(()=>{o&&p.current?.focus()},[o]);const m=async g=>{l(!1),u(void 0),f(!0);try{await i(g)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}};return a.jsxs("div",{className:"flex min-w-0 flex-col items-end gap-1 max-md:items-start",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[o?a.jsx(oi,{ref:p,readOnly:!0,"aria-label":n,value:n,className:"w-40",onBlur:()=>l(!1),onKeyDown:g=>{if(g.preventDefault(),g.stopPropagation(),g.key==="Escape"){l(!1);return}if(g.repeat)return;const v=S3n(g);v&&m(v)}}):a.jsx(Nt,{type:"button",variant:"outline",size:"sm",disabled:t||h,"aria-label":n,onClick:()=>{u(void 0),l(!0)},children:e?C3n(e):r}),e&&!o?a.jsx(Nt,{type:"button",variant:"ghost",size:"sm",disabled:t||h,onClick:()=>void m(""),children:s}):null]}),c?a.jsx("span",{className:"max-w-72 text-right text-xs text-destructive max-md:text-left",children:c}):null]})}function Zge({state:e}){const{t}=mt(),n=e??"checking";return a.jsx(zi,{variant:n==="ready"?"secondary":n==="denied"||n==="unavailable"?"destructive":"outline",children:t(`settings.liveSetup.requirement.${n}`)})}function I3n({setup:e}){const{t}=mt(),[n,s]=d.useState(""),[r,i]=d.useState(!1),o=e.status,l=o?.enabled===!0,c=e.mutating||e.loading,u=o!==void 0&&r5e.has(o.install.state),h=o?.live.requirements,f=async()=>{const w=n.trim();if(w)try{await e.update({apiKey:{operation:"replace",value:w}}),s("")}catch{}},p=async()=>{try{await e.update({apiKey:{operation:"clear"}}),s("")}catch{}},m=async w=>{if(w){i(!0);return}try{await e.update({enabled:!1})}catch{}},g=()=>{e.update({enabled:!0}).catch(()=>{})},v=()=>{(o?.install.state==="error"?e.retryInstall():e.launchHost()).catch(()=>{})};return a.jsxs("div",{className:"space-y-5 p-5 max-md:p-4",children:[a.jsxs("div",{className:"flex items-start justify-between gap-6",children:[a.jsxs("div",{className:"min-w-0 space-y-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"font-medium",children:t("settings.liveSetup.title")}),a.jsx(zi,{variant:"outline",children:t("settings.liveSetup.experimental")})]}),a.jsx("p",{className:"max-w-3xl text-sm text-muted-foreground",children:t("settings.liveSetup.description")})]}),e.loading&&!o?a.jsx(Lr,{}):a.jsx(ag,{checked:l,disabled:c||!l&&o?.keyConfigured!==!0,"aria-label":t("settings.liveSetup.enable"),onCheckedChange:w=>void m(w)})]}),a.jsx(TR,{}),a.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("label",{htmlFor:"live-realtime-key",className:"text-sm font-medium",children:t("settings.liveSetup.apiKey")}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(zi,{variant:o?.keyConfigured?"secondary":"outline",children:t(o?.keyConfigured?"settings.liveSetup.configured":"settings.liveSetup.notConfigured")}),o?.keyConfigured&&!l?a.jsx(Nt,{type:"button",size:"xs",variant:"ghost",disabled:e.mutating,onClick:()=>void p(),children:t("settings.liveSetup.removeKey")}):null]})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(oi,{id:"live-realtime-key",type:"password",autoComplete:"off",value:n,disabled:e.mutating,placeholder:o?.keyConfigured?t("settings.liveSetup.apiKeyReplace"):t("settings.liveSetup.apiKeyPlaceholder"),onChange:w=>s(w.target.value),onKeyDown:w=>{w.key==="Enter"&&f()}}),a.jsx(Nt,{type:"button",size:"sm",variant:"outline",disabled:!n.trim()||e.mutating,onClick:()=>void f(),children:e.mutating?a.jsx(Lr,{}):t("settings.liveSetup.save")})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:o?.model??"qwen3.5-omni-plus-realtime"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"text-sm font-medium",children:t("settings.liveSetup.shortcut")}),a.jsx(T3n,{accelerator:o?.shortcut??"Command+E",disabled:e.mutating,captureLabel:t("settings.liveShortcut.capture"),clearLabel:t("settings.liveShortcut.clear"),offLabel:t("settings.liveShortcut.off"),onChange:async w=>e.update({shortcut:w})})]})]}),l&&o?a.jsxs(a.Fragment,{children:[a.jsx(TR,{}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-medium",children:t("settings.liveSetup.host")}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[t(`settings.liveSetup.install.${o.install.state}`),o.install.version?` · ${o.install.version}`:""]})]}),u?a.jsx(Lr,{}):o.install.state==="error"||o.install.state==="installed"&&h?.host!=="ready"?a.jsx(Nt,{type:"button",size:"sm",variant:"outline",disabled:e.mutating,onClick:v,children:o.install.state==="error"?t("settings.liveSetup.retry"):t("settings.liveSetup.openHost")}):a.jsx(Zge,{state:h?.host})]}),typeof o.install.progress=="number"&&u?a.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted",children:a.jsx("div",{className:"h-full rounded-full bg-primary transition-[width]",style:{width:`${Math.round(o.install.progress*100)}%`}})}):null,a.jsx("div",{className:"grid gap-2 sm:grid-cols-3",children:[["microphone",h?.microphone],["accessibility",h?.accessibility],["screenRecording",h?.screenRecording]].map(([w,y])=>a.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-border px-3 py-2",children:[a.jsx("span",{className:"text-xs",children:t(`settings.liveSetup.permission.${w}`)}),a.jsx(Zge,{state:y})]},w))}),a.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.liveSetup.permissionHint")})]})]}):null,(e.error||l&&o?.install.message)&&a.jsx("p",{className:"text-sm text-destructive",role:"alert",children:e.error?.message??o?.install.message}),a.jsx(Mw,{open:r,onOpenChange:i,children:a.jsxs(Pw,{children:[a.jsxs(Lw,{children:[a.jsx(Qin,{children:a.jsx(FCe,{})}),a.jsx(Ow,{children:t("settings.liveSetup.confirmTitle")}),a.jsx($w,{children:t("settings.liveSetup.confirmDescription")})]}),a.jsxs(Dw,{children:[a.jsx(Bw,{children:t("settings.liveSetup.cancel")}),a.jsx(tk,{onClick:g,children:t("settings.liveSetup.confirm")})]})]})})]})}const E3n="_section_iwuxi_1",R3n="_header_iwuxi_12",A3n="_title_iwuxi_19",j3n="_addButton_iwuxi_24",N3n="_hint_iwuxi_38",M3n="_empty_iwuxi_39",P3n="_provider_iwuxi_45",L3n="_providerName_iwuxi_51",D3n="_modelRow_iwuxi_59",O3n="_modelInfo_iwuxi_70",$3n="_modelName_iwuxi_78",B3n="_modelBaseUrl_iwuxi_84",F3n="_modelId_iwuxi_91",z3n="_modelDescription_iwuxi_98",q3n="_modelDetails_iwuxi_99",H3n="_capability_iwuxi_113",U3n="_currentBadge_iwuxi_119",W3n="_runtimeBadge_iwuxi_127",V3n="_modelActions_iwuxi_135",G3n="_actionButton_iwuxi_142",K3n="_deleteButton_iwuxi_143",Y3n="_confirmButton_iwuxi_144",La={section:E3n,header:R3n,title:A3n,addButton:j3n,hint:N3n,empty:M3n,provider:P3n,providerName:L3n,modelRow:D3n,modelInfo:O3n,modelName:$3n,modelBaseUrl:B3n,modelId:F3n,modelDescription:z3n,modelDetails:q3n,capability:H3n,currentBadge:U3n,runtimeBadge:W3n,modelActions:V3n,actionButton:G3n,deleteButton:K3n,confirmButton:Y3n};function nM(e,t){return`${e.authType}:${t.modelId}:${t.baseUrl??""}`}function X3n(e,t){const n=e.flatMap(r=>r.models.map(i=>({provider:r,model:i})));if(t){const r=n.find(({model:o})=>o.modelId===t);if(r)return nM(r.provider,r.model);const i=n.filter(({model:o})=>o.baseModelId===t);if(i.length===1)return nM(i[0].provider,i[0].model)}const s=n.find(({model:r})=>r.isCurrent);return s?nM(s.provider,s.model):void 0}function Z3n({providers:e,configurations:t=[],onUpdateContextWindow:n,currentModelId:s,loading:r,error:i,busy:o,onSelectModel:l,onDeleteModel:c,onAddModel:u}){const{t:h}=mt(),[f,p]=d.useState(null);d.useEffect(()=>{if(f===null)return;const b=x=>{x.key==="Escape"&&p(null)};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[f]);const m=e.map(b=>({...b,models:[...b.models]})),v=[...new Map(t.map(b=>[b.key,b])).values()].filter(b=>!e.some(x=>x.models.some(_=>_.configurationKey===b.key)));for(const b of v){let x=m.find(_=>_.authType===b.authType);x||(x={kind:"model_provider",status:"ok",authType:b.authType,current:!1,models:[]},m.push(x)),x.models.push({configurationKey:b.key,modelId:b.key,baseModelId:b.modelId,name:b.name||b.modelId,baseUrl:b.baseUrl,envKey:b.envKey,contextLimit:b.contextWindowSize,isCurrent:!1,isRuntime:!1})}const w=m.some(b=>b.models.length>0),y=X3n(e,s);return a.jsxs("div",{className:La.section,"data-testid":"model-management",children:[a.jsxs("div",{className:La.header,children:[a.jsx("span",{className:La.title,children:h("settings.models.title")}),a.jsx("button",{type:"button",className:La.addButton,disabled:o,onClick:u,children:h("settings.models.add")})]}),i&&a.jsx("div",{className:La.hint,children:i.message}),r&&!w&&a.jsx("div",{className:La.hint,children:h("settings.models.loading")}),!r&&!w&&!i&&a.jsx("div",{className:La.empty,children:h("settings.models.empty")}),m.map((b,x)=>b.models.length===0?null:a.jsxs("div",{className:La.provider,children:[a.jsx("div",{className:La.providerName,children:b.authType}),b.models.map(_=>{const S=t.filter(N=>N.key===_.configurationKey),E=S.length===1?S[0]:void 0,T=e.some(N=>N.models.includes(_)),R=nM(b,_),C=R===y,I=f===R,A=_.name||_.baseModelId;return a.jsxs("div",{className:La.modelRow,children:[a.jsxs("div",{className:La.modelInfo,children:[a.jsx("span",{className:La.modelName,children:_.name||_.baseModelId}),C&&a.jsx("span",{className:La.currentBadge,children:h("settings.models.current")}),_.isRuntime&&a.jsx("span",{className:La.runtimeBadge,children:h("settings.models.runtime")}),!T&&a.jsx("span",{className:La.runtimeBadge,children:h("settings.models.savedConfiguration")}),_.name&&_.name!==_.baseModelId&&a.jsx("span",{className:La.modelId,children:_.baseModelId}),_.description&&a.jsx("div",{className:La.modelDescription,children:_.description}),_.baseUrl&&a.jsx("span",{className:La.modelBaseUrl,children:_.baseUrl.split(/[?#]/)[0]}),(_.contextLimit||_.modalities||_.envKey)&&a.jsxs("div",{className:La.modelDetails,children:[_.contextLimit!==void 0&&_.contextLimit>0&&a.jsx("span",{children:h("settings.models.context",{tokens:_.contextLimit.toLocaleString()})}),[["image","auth.advanced.modalityImage"],["video","auth.advanced.modalityVideo"],["audio","auth.advanced.modalityAudio"],["pdf","auth.advanced.modalityPdf"]].map(([N,j])=>_.modalities?.[N]?a.jsx("span",{className:La.capability,children:h(j)},N):null),_.envKey&&a.jsxs("span",{children:[h("settings.models.credentialEnv"),":"," ",a.jsx("code",{children:_.envKey})]})]}),E&&a.jsxs(a.Fragment,{children:[E.purpose!=="chat"&&a.jsx("span",{className:La.capability,children:h(`auth.purpose.${E.purpose}`)}),E.canEditContextWindow===!1&&a.jsx("div",{className:La.modelDescription,children:h("settings.models.ambiguousWindow")}),n&&E.canEditContextWindow!==!1&&a.jsx(Q3n,{configuration:E,busy:o,onSave:n})]})]}),a.jsxs("div",{className:La.modelActions,children:[!C&&T&&a.jsx("button",{type:"button",className:La.actionButton,disabled:o,"aria-label":`${h("settings.models.setCurrent")} ${A}`,onClick:()=>l(_.modelId),children:h("settings.models.setCurrent")}),!_.isRuntime&&(I?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:La.confirmButton,disabled:o,"aria-label":`${h("settings.models.confirmDelete")} ${A}`,onClick:()=>{p(null),c({..._.configurationKey?{key:_.configurationKey}:{},authType:b.authType,modelId:_.baseModelId,..._.baseUrl?{baseUrl:_.baseUrl}:{}})},children:h("settings.models.confirmDelete")}),a.jsx("button",{type:"button",className:La.actionButton,disabled:o,"aria-label":`${h("settings.models.cancel")} ${A}`,onClick:()=>p(null),children:h("settings.models.cancel")})]}):a.jsx("button",{type:"button",className:La.deleteButton,disabled:o,"aria-label":`${h("settings.models.delete")} ${A}`,onClick:()=>p(R),children:h("settings.models.delete")}))]})]},R)})]},`${b.authType}:${x}`))]})}function Q3n({configuration:e,busy:t,onSave:n}){const{t:s}=mt(),r=d.useId(),[i,o]=d.useState(!1),[l,c]=d.useState(""),[u,h]=d.useState(!1),[f,p]=d.useState(""),[m,g]=d.useState(""),v=!l.trim()||/^\d+$/.test(l.trim())&&Number(l)>=1&&Number(l)<=1e7;return i?a.jsxs("form",{className:"mt-3 flex max-w-md flex-col gap-2",onSubmit:w=>{w.preventDefault(),!(!v||u||t)&&(h(!0),p(""),n(e.key,l.trim()?Number(l):null).then(y=>{o(!1),g(y.runtimeSync?.status==="failed"?s("settings.models.runtimeSyncFailed"):y.requiresRestart?s("settings.models.windowSaved"):s("settings.models.saved"))}).catch(y=>p(y instanceof Error?y.message:String(y))).finally(()=>h(!1)))},children:[a.jsxs(ka,{children:[a.jsx(nl,{htmlFor:r,children:s("auth.advanced.contextWindow")}),a.jsx(oi,{id:r,value:l,inputMode:"numeric",placeholder:s("common.auto"),disabled:u||t,"aria-invalid":!v,"aria-describedby":`${r}-hint`,onChange:w=>c(w.target.value)}),a.jsx(th,{id:`${r}-hint`,children:v?s("settings.models.windowHint"):s("auth.advanced.tokenLimitInvalid",{field:s("auth.advanced.contextWindow")})})]}),f&&a.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Nt,{type:"submit",size:"sm","aria-label":`${s("common.save")} ${e.name||e.modelId}`,disabled:!v||u||t,children:s("common.save")}),a.jsx(Nt,{type:"button",variant:"outline",size:"sm",disabled:u||t,"aria-label":`${s("settings.models.cancel")} ${e.name||e.modelId}`,onClick:()=>o(!1),children:s("settings.models.cancel")})]})]}):a.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[a.jsx(Nt,{size:"sm",variant:"outline",disabled:t,"aria-label":`${s("settings.models.editWindow")} ${e.name||e.modelId}`,onClick:()=>{c(e.contextWindowSize?.toString()??""),p(""),g(""),o(!0)},children:s("settings.models.editWindow")}),m&&a.jsx("span",{role:"status",className:"text-xs text-muted-foreground",children:m})]})}function J3n(){const e=new URL(window.location.href);return e.searchParams.delete("daemon"),e.searchParams.delete("token"),`${e.pathname}${e.search}`}function qq(e,t){return e?e.length===1?e[0].address:t&&!e.some(n=>n.address===t)?"":t:t}function eEn(){const{t:e}=mt(),{baseUrl:t,token:n}=vi(),[s,r]=d.useState(),[i,o]=d.useState(""),[l,c]=d.useState(!1),[u,h]=d.useState("");d.useEffect(()=>{let m=!1;return h(""),QU(t,n,"GET","/workspace/local-control").then(g=>{m||(r(g),o(v=>qq(g.interfaces,v)))}).catch(g=>{m||h(g instanceof Error?g.message:String(g))}),()=>{m=!0}},[t,n]);const f=async()=>{if(s){c(!0),h("");try{const m=s.active?"/workspace/local-control/disable":"/workspace/local-control/enable",g=s.active?void 0:{address:i||void 0,target:J3n()},v=await QU(t,n,"POST",m,g);r(v),o(w=>qq(v.interfaces,w))}catch(m){h(m instanceof Error?m.message:String(m));const g=m instanceof e2e?m.payload?.interfaces:void 0;g&&(r(v=>v&&{...v,interfaces:g}),o(v=>qq(g,v)))}finally{c(!1)}}},p=(s?.interfaces?.length??0)>1;return a.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4 max-md:px-4","aria-live":"polite",children:[a.jsxs("div",{className:"flex items-start justify-between gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[a.jsx(frt,{className:"size-4","aria-hidden":"true"}),e("settings.localControl.title"),a.jsx(zi,{variant:s?.active?"default":"secondary",children:s?.active?e("settings.localControl.on"):e("settings.localControl.off")})]}),a.jsx("p",{className:"mt-1 max-w-3xl text-sm text-muted-foreground",children:e("settings.localControl.description")})]}),!s&&!u&&a.jsx(Lr,{})]}),!s?.active&&p&&a.jsxs(sc,{value:i,onValueChange:o,children:[a.jsx(ic,{className:"w-full max-w-sm","aria-label":e("settings.localControl.network"),children:a.jsx(rc,{placeholder:e("settings.localControl.selectNetwork")})}),a.jsx(oc,{children:(s?.interfaces??[]).map(m=>a.jsxs(Ho,{value:m.address,children:[m.interfaceName," · ",m.address]},m.address))})]}),s?.active&&s.url&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[s.qrText&&a.jsx("pre",{"aria-label":e("settings.localControl.qr"),className:"w-fit overflow-hidden rounded-lg bg-white p-3 font-mono text-[7px] leading-[7px] tracking-normal text-black select-none",children:s.qrText}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[a.jsx("div",{className:"break-all rounded-md bg-muted px-3 py-2 font-mono text-xs",children:s.url}),a.jsxs(Nt,{type:"button",variant:"outline",size:"sm",onClick:()=>void tf(s.url).catch(rg),children:[a.jsx(gk,{"aria-hidden":"true"}),e("common.copy")]}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.encrypted?e("settings.localControl.encrypted"):e("settings.localControl.unencrypted")," ","·"," ",s.sleepInhibited?e("settings.localControl.awake"):e("settings.localControl.maySleep")]})]})]}),s?.active&&!s.url&&s.urlRedacted&&a.jsx("p",{className:"max-w-3xl text-sm text-muted-foreground",children:e("settings.localControl.urlRedacted")}),u&&a.jsx("p",{className:"text-sm text-destructive",role:"alert",children:u}),a.jsxs(Nt,{type:"button",variant:s?.active?"destructive":"default",className:"w-fit",disabled:l||!s||!s.active&&p&&!i,onClick:f,children:[l&&a.jsx(Lr,{}),s?.active?e("settings.localControl.disable"):e("settings.localControl.enable")]})]})}const tEn=new Set(["advisorModel","imageModel","fastModel","visionModel","voiceModel","modelFallbacks"]),nEn=new Set(["ui.hideTips","ui.enableUserFeedback","ui.compactMode","mcpServers","model.reasoningEffort"]),sEn=new Set(["experimental.liveVoice.enabled","experimental.liveVoice.shortcut"]);function AD(e,t,n){const s=e(t);return s===t?n:s}function L8(e,t){return AD(t,`settings.category.${e}`,e)}function US(e,t){return AD(t,`settings.label.${e.key}`,e.label)}function rEn(e,t){if(e.description)return AD(t,`settings.description.${e.key}`,e.description)}function xMe(e,t,n,s){return AD(s,`settings.option.${e.key}.${String(t)}`,n)}function iEn(e,t,n){const s=kMe(e,t);if(s==null)return"";if(e.key==="advisorModel"&&s==="")return n("model.useMain");if(e.key==="imageModel"&&s==="")return n("model.disabled");if(e.key===f_){const i=kX(s,ua.Dark);return n(`theme.${i}`)}if(e.key===YM){const i=bX(s);return i?xX(i):String(s)}if(e.type==="boolean")return n(s===!0?"settings.value.on":"settings.value.off");if(e.type==="enum"&&e.options){const i=e.options.find(o=>o.value===s);return i?xMe(e,i.value,i.label,n):String(s)}const r=String(s).replaceAll("\0"," · ");return r.length>24?`${r.slice(0,21)}…`:r}function _Me(e,t){return(t==="user"?e.values.user:e.values.workspace)!==void 0}function oEn(e,t){if(t==="workspace"?e.values.user!==void 0:e.values.workspace!==void 0)return _Me(e,t)?"settings.alsoModifiedIn":"settings.modifiedIn"}function kMe(e,t){const n=t==="user"?e.values.user:e.values.workspace;return n!==void 0?n:e.values.effective}function aEn(e){const t=new Map;for(const n of e){let s=t.get(n.category);s||(s=[],t.set(n.category,s)),s.push(n)}return Array.from(t.entries()).map(([n,s])=>({category:n,items:s}))}function Qge({category:e}){const t=e.toLowerCase(),n=t.includes("ui")?ist:t.includes("tool")?XU:t.includes("context")?YU:t.includes("privacy")?Lst:t.includes("model")?Db:t.includes("daemon")?L3:t.includes("advanced")?Fst:t.includes("experimental")?FCe:KCe;return a.jsx(n,{"data-icon":"inline-start","aria-hidden":"true"})}function Hq({title:e,description:t,metadata:n,control:s}){return a.jsxs(ka,{orientation:"responsive",className:"min-h-20 gap-6 px-5 py-4 max-md:px-4",children:[a.jsxs(_ee,{className:"min-w-0",children:[a.jsxs(Din,{children:[e,n]}),t&&a.jsx(th,{className:"max-w-3xl",children:t})]}),a.jsx("div",{className:"flex min-w-0 justify-end max-md:justify-start",children:s})]})}function lEn({name:e,label:t,type:n,value:s,disabled:r,onCommit:i,onInvalid:o}){const l=String(s??""),[c,u]=d.useState(l);d.useEffect(()=>u(l),[l]);const h=()=>{if(n==="number"){const f=c.trim(),p=Number(f);if(!f||!Number.isFinite(p)){u(l),o();return}p!==s&&i(p);return}c!==l&&i(c)};return a.jsx(oi,{type:n,name:e,autoComplete:"off","aria-label":t,value:c,disabled:r,className:"w-[min(80px,50vw)] max-md:w-full",onChange:f=>u(f.target.value),onBlur:h,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur(),f.key==="Escape"&&(u(l),f.currentTarget.blur())}})}function cEn({settingsState:e,onLanguageChange:t,onSubDialog:n,onThemeChange:s,chatWidthMode:r,onChatWidthModeChange:i,modelManagement:o,embedded:l=!1,initialCategory:c}){const{language:u,t:h}=mt(),f=zw(),p=uxe(),m=p?.refreshPermission;d.useEffect(()=>{m?.()},[m]);const{status:g,settings:v,loading:w,error:y,reload:b,setValue:x,liveSetup:_}=e,[S,E]=d.useState("workspace"),[T,R]=d.useState(""),[C,I]=d.useState(null),[A,N]=d.useState(null),[j,O]=d.useState(!1),B=p!==void 0,D=w&&!g,U=d.useMemo(()=>{const P=v.filter(K=>!nEn.has(K.key)&&!sEn.has(K.key)),ce=aEn(P).map(K=>({id:K.category,label:L8(K.category,h),items:K.items.map(oe=>({type:"setting",setting:oe}))})),ae={type:"local",localKey:"chatWidth"},pe=ce.find(K=>K.items.some(oe=>oe.type==="setting"&&oe.setting.key===f_));if(pe){const K=pe.items.findIndex(oe=>oe.type==="setting"&&oe.setting.key===f_);pe.items.splice(K+1,0,ae)}else ce.push({id:"UI",label:L8("UI",h),items:[ae]});if(B&&ce.find(oe=>oe.items.includes(ae))?.items.push({type:"local",localKey:"browserNotifications"}),_?.supported){const K=ce.find(oe=>oe.id==="Experimental");K?K.items.unshift({type:"live"}):ce.push({id:"Experimental",label:L8("Experimental",h),items:[{type:"live"}]})}const q=ce.find(K=>K.id==="Daemon");return q?q.items.unshift({type:"local-control"}):ce.push({id:"Daemon",label:L8("Daemon",h),items:[{type:"local-control"}]}),ce},[_,v,h,B]);d.useEffect(()=>{if(U.length!==0&&!U.some(P=>P.id===T)){const P=c&&U.some(ce=>ce.id===c)?c:U[0].id;R(P)}},[T,U,c]),d.useEffect(()=>{y?N(y.message):g?.warnings?.length?N(g.warnings.map(P=>h("settings.corrupted",{recovered:P.recovered?"true":"false"})).join("; ")):v.length>0&&N(null)},[y,v,g,h]);const V=d.useCallback((P,ce)=>{j||N(null),I(P),x(S,P,ce).then(async ae=>{try{await b()}catch{}ae?.requiresRestart&&P!==YM&&O(!0)}).catch(ae=>{N(ae instanceof Error?ae.message:String(ae))}).finally(()=>I(null))},[b,j,S,x]),F=U.find(P=>P.id===T)??U[0],M=F?.items.some(P=>P.type==="setting"&&P.setting.category==="Model"),X=(P,ce,ae,pe,q=!1)=>a.jsxs(sc,{value:P,disabled:q,onValueChange:ce,children:[a.jsx(ic,{size:"sm","aria-label":pe,className:"w-[min(160px,50vw)] bg-background max-md:w-full",children:a.jsx(rc,{})}),a.jsx(oc,{position:"popper",align:"end",children:a.jsx(jIe,{children:ae.map(K=>a.jsx(Ho,{value:K.value,children:K.label},K.value))})})]}),ee=P=>{const ce=kMe(P,S),pe=C===P.key;if(P.key===f_)return X(kX(ce)??f,q=>{const K=q;s(K),V(f_,yxe(K))},vxe.map(q=>({value:q,label:h(`theme.${q}`)})),US(P,h),pe);if(P.key===YM)return X(bX(ce)??u,q=>t(q,S),DUe.map(q=>({value:q,label:xX(q)})),US(P,h),pe);if(tEn.has(P.key))return a.jsx(Nt,{type:"button",variant:"outline",size:"sm",disabled:pe,className:"max-w-[260px] truncate",onClick:()=>n(P.key,S),children:iEn(P,S,h)||h("settings.action.select")});if(P.type==="boolean"){const q=ce===!0;return a.jsx(ag,{checked:q,disabled:pe,onCheckedChange:K=>V(P.key,K),"aria-label":US(P,h)})}if(P.type==="enum"&&P.options?.length){const q=P.options.findIndex(K=>K.value===ce);return X(q>=0?String(q):"",K=>{const oe=P.options?.[Number(K)];oe&&V(P.key,oe.value)},P.options.map((K,oe)=>({value:String(oe),label:xMe(P,K.value,K.label,h)})),US(P,h),pe)}return a.jsx(lEn,{name:P.key,label:US(P,h),type:P.type==="number"?"number":"text",value:ce,disabled:pe,onCommit:q=>V(P.key,q),onInvalid:()=>N(h("settings.invalidNumber"))})};return a.jsxs("div",{className:l?"flex min-h-0 flex-1 flex-col text-sm text-foreground":"flex max-w-[min(var(--chat-regular-content-width,1000px),calc(100vw-64px))] flex-col overflow-hidden rounded-xl border border-border bg-background text-sm text-foreground","data-keyboard-scope":!0,children:[!l&&a.jsx("div",{className:"flex items-center justify-between border-b border-border px-5 py-4",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-base font-semibold text-balance",children:h("settings.title")}),a.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:h("settings.scope.workspace")})]})}),(A||D)&&a.jsxs(ol,{className:"mx-4 mt-3 w-auto",children:[D&&a.jsx(Lr,{}),a.jsx(al,{children:A||h("settings.loading")})]}),a.jsxs(fg,{value:S,className:"flex min-h-0 flex-1 flex-col gap-0",onValueChange:P=>{E(P)},children:[a.jsxs("div",{className:"flex items-center justify-between gap-4 border-b border-border px-3 py-2",children:[a.jsxs(pg,{className:"p-0",children:[a.jsx(io,{value:"workspace",children:h("settings.scope.workspace")}),a.jsx(io,{value:"user",children:h("settings.scope.user")})]}),j&&a.jsx(zi,{variant:"secondary",children:h("settings.requiresRestart")})]}),a.jsxs(Zo,{value:S,forceMount:!0,className:"grid min-h-0 flex-1 grid-cols-[190px_minmax(0,1fr)] outline-none max-md:grid-cols-1",children:[a.jsx("nav",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto border-r border-border bg-muted/20 p-3 max-md:flex-row max-md:overflow-x-auto max-md:border-r-0 max-md:border-b","aria-label":h("settings.title"),children:U.map(P=>a.jsxs(Nt,{type:"button",variant:P.id===T?"secondary":"ghost",size:"sm","aria-current":P.id===T?"page":void 0,className:"w-full justify-start gap-2 px-2.5 max-md:w-auto max-md:shrink-0",onClick:()=>R(P.id),children:[a.jsx(Qge,{category:P.id}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:P.label}),a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:P.items.length})]},P.id))}),a.jsxs("section",{className:"min-h-0 min-w-0 overflow-y-auto bg-background p-5 max-md:p-3",children:[!w&&!F&&a.jsx(C0,{className:"min-h-60",children:a.jsxs(T0,{children:[a.jsx(I0,{variant:"icon",children:a.jsx(KCe,{})}),a.jsx(E0,{children:h("settings.empty")}),a.jsx(X5,{children:h("settings.empty")})]})}),F&&a.jsxs("div",{className:"mx-auto w-full max-w-5xl",children:[a.jsxs(_c,{children:[a.jsx(jd,{children:a.jsxs(Nd,{className:"flex items-center gap-2",children:[a.jsx(Qge,{category:F.id}),F.label]})}),a.jsx(ih,{className:"-mb-(--card-spacing) p-0",children:a.jsx(Fb,{className:"gap-0",children:F.items.map((P,ce)=>{const ae=ce>0&&a.jsx(TR,{className:"mx-5 w-auto max-md:mx-4"});if(P.type==="local"&&P.localKey==="browserNotifications"&&p){const ge=p.permission==="unavailable",le=ge?"unavailable":p.pending?"requesting":p.permission==="denied"?"denied":p.error?"error":p.enabled?p.permission==="granted"?"enabled":"waiting":"disabled";return a.jsxs("div",{children:[ae,a.jsx(Hq,{title:h("browserNotifications.label"),description:[h("browserNotifications.description"),h(`browserNotifications.${le}`),...p.persistent?[]:[h("browserNotifications.temporary")]].join(" "),control:a.jsxs("div",{className:"flex items-center gap-2",children:[p.enabled&&p.permission==="default"&&a.jsx(Nt,{variant:"outline",size:"sm",disabled:p.pending,onClick:()=>void p.setEnabled(!0),children:h("browserNotifications.allow")}),a.jsx(ag,{"aria-label":h("browserNotifications.label"),checked:p.enabled,disabled:p.pending||ge&&!p.enabled,onCheckedChange:ye=>void p.setEnabled(ye)})]})})]},P.localKey)}if(P.type==="local")return a.jsxs("div",{children:[ae,a.jsx(Hq,{title:h("settings.label.ui.chatWidth"),description:h("settings.description.ui.chatWidth"),control:X(r,ge=>i(ge),[{value:"1000",label:h("settings.option.ui.chatWidth.1000")},{value:"wide",label:h("settings.option.ui.chatWidth.wide")}],h("settings.label.ui.chatWidth"),!1)})]},P.localKey);if(P.type==="live")return _?a.jsxs("div",{children:[ae,a.jsx(I3n,{setup:_})]},"live-voice-setup"):null;if(P.type==="local-control")return a.jsxs("div",{children:[ae,a.jsx(eEn,{})]},"local-control");const pe=P.setting,q=rEn(pe,h),K=oEn(pe,S),oe=_Me(pe,S),W=K?h(K,{scope:h(S==="workspace"?"settings.scope.user":"settings.scope.workspace")}):void 0;return a.jsxs("div",{children:[ae,a.jsx(Hq,{title:US(pe,h),description:[q,W].filter(Boolean).join(" · ")||void 0,metadata:oe?a.jsx(zi,{variant:"secondary",children:h(S==="workspace"?"settings.scope.workspace":"settings.scope.user")}):void 0,control:C===pe.key?a.jsx(Lr,{}):ee(pe)})]},pe.key)})})})]}),M&&o&&a.jsx("div",{className:"mt-4",children:a.jsx(Z3n,{...o})})]})]})]})]}),!l&&a.jsx("div",{className:"border-t border-border px-5 py-3 text-xs text-muted-foreground",children:h("settings.footer")})]})}const uEn="_dialog_1ymqd_1",dEn="_toolbar_1ymqd_12",hEn="_tabs_1ymqd_21",fEn="_tab_1ymqd_21",pEn="_tabActive_1ymqd_39",mEn="_search_1ymqd_48",gEn="_general_1ymqd_60",vEn="_shortcuts_1ymqd_67",wEn="_shortcut_1ymqd_67",yEn="_shortcutKey_1ymqd_87",bEn="_shortcutDesc_1ymqd_95",xEn="_commandList_1ymqd_101",_En="_commandCard_1ymqd_108",kEn="_commandCardExpanded_1ymqd_115",SEn="_commandRow_1ymqd_119",CEn="_commandName_1ymqd_135",TEn="_commandTag_1ymqd_142",IEn="_chevron_1ymqd_152",EEn="_chevronExpanded_1ymqd_160",REn="_commandDetail_1ymqd_164",AEn="_commandDescription_1ymqd_174",jEn="_commandSubcommands_1ymqd_175",NEn="_empty_1ymqd_182",Fl={dialog:uEn,toolbar:dEn,tabs:hEn,tab:fEn,tabActive:pEn,search:mEn,general:gEn,shortcuts:vEn,shortcut:wEn,shortcutKey:yEn,shortcutDesc:bEn,commandList:xEn,commandCard:_En,commandCardExpanded:kEn,commandRow:SEn,commandName:CEn,commandTag:TEn,chevron:IEn,chevronExpanded:EEn,commandDetail:REn,commandDescription:AEn,commandSubcommands:jEn,empty:NEn},MEn=[{id:"general",labelKey:"help.tab.general"},{id:"commands",labelKey:"help.tab.commands"},{id:"custom-commands",labelKey:"help.tab.custom"}],PEn=new Set(["about","agents","approval-mode","arena","auth","branch","btw","bug","clear","compress","context","copy","release","diff","directory","docs","doctor","dream","editor","export","extensions","forget","goal","help","hooks","ide","init","insight","language","lsp","mcp","memory","model","new","permissions","plan","quit","recap","remember","rename","reset","restore","resume","rewind","settings","setup-github","skills","stats","status","statusline","summary","tasks","terminal-setup","theme","tools","trust","vim"]),LEn=[["@","help.shortcut.addContext"],["!","help.shortcut.shell"],["/","help.shortcut.commandMenu"],["Tab","help.shortcut.completion"],["Esc","help.shortcut.cancel"],["Ctrl+J","help.shortcut.newline"],["Ctrl+L","help.shortcut.clear"],["Ctrl+Y","help.shortcut.retry"],["Shift+Tab","help.shortcut.approvals"],["Alt+Left/Right","help.shortcut.altWords"],["Up/Down","help.shortcut.history"]];function DEn(e){return[`/${e.name}`,e.argumentHint].filter(Boolean).join(" ")}function $K(e){return!PEn.has(e.name)}function OEn(e,t){return $K(e)?t("help.commandMeta.custom"):t("help.commandMeta.builtIn")}function $En(e,t,n){const s=n.trim().toLowerCase();return e.filter(r=>r.name&&r.description!==void 0).filter(r=>t==="commands"?!$K(r):t==="custom-commands"?$K(r):!0).filter(r=>s?r.name.toLowerCase().includes(s)||(r.description??"").toLowerCase().includes(s)||(r.argumentHint??"").toLowerCase().includes(s):!0).sort((r,i)=>r.name.localeCompare(i.name))}function BEn(){const{t:e}=mt();return a.jsx("div",{className:Fl.general,children:a.jsx("div",{className:Fl.shortcuts,children:LEn.map(([t,n])=>a.jsxs("div",{className:Fl.shortcut,children:[a.jsx("span",{className:Fl.shortcutDesc,children:e(n)}),a.jsx("span",{className:Fl.shortcutKey,children:t})]},t))})})}function FEn({commands:e,tab:t,query:n}){const{t:s}=mt(),[r,i]=d.useState(null),o=d.useMemo(()=>$En(e,t,n),[e,n,t]);return o.length===0?a.jsx("div",{className:Fl.empty,children:s(t==="custom-commands"?"help.emptyCustom":"help.empty")}):a.jsx("div",{className:Fl.commandList,children:o.map(l=>{const c=r===l.name;return a.jsxs("article",{className:`${Fl.commandCard} ${c?Fl.commandCardExpanded:""}`,children:[a.jsxs("button",{type:"button",className:Fl.commandRow,onClick:()=>i(c?null:l.name),"aria-expanded":c,children:[a.jsx("span",{className:Fl.commandName,children:DEn(l)}),a.jsx("span",{className:Fl.commandTag,children:OEn(l,s)}),a.jsx("svg",{className:`${Fl.chevron} ${c?Fl.chevronExpanded:""}`,viewBox:"0 0 16 16","aria-hidden":"true",children:a.jsx("path",{d:"M6 4.5 9.5 8 6 11.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})})]}),c&&a.jsxs("div",{className:Fl.commandDetail,children:[l.description&&a.jsx("div",{className:Fl.commandDescription,children:l.description}),!!l.subcommands?.length&&a.jsxs("div",{className:Fl.commandSubcommands,children:[s("help.subcommands"),": ",l.subcommands.join(", ")]})]})]},l.name)})})}function zEn({commands:e}){const{t}=mt(),[n,s]=d.useState("general"),{filterValue:r,inputProps:i}=bD(),o=n!=="general";return a.jsxs("div",{className:Fl.dialog,children:[a.jsxs("div",{className:Fl.toolbar,children:[a.jsx("div",{className:Fl.tabs,children:MEn.map(l=>a.jsx("button",{type:"button",className:`${Fl.tab} ${l.id===n?Fl.tabActive:""}`,onClick:()=>s(l.id),children:t(l.labelKey)},l.id))}),o&&a.jsx("input",{className:Fl.search,...i,placeholder:t("help.search")})]}),n==="general"?a.jsx(BEn,{}):a.jsx(FEn,{commands:e,tab:n,query:r})]})}function qEn({currentTheme:e,onSelect:t,onClose:n}){const{t:s}=mt(),r=vxe.map(h=>({id:h,label:s(`theme.${h}`),description:s(`theme.${h}.desc`)})),[i,o]=d.useState(()=>{const h=r.findIndex(f=>f.id===e);return h>=0?h:0}),l=d.useRef(null),c=h=>{const f=r[h];f&&(t(f.id),n())},{keyboardMode:u}=B1({itemCount:r.length,activeIndex:i,onActiveIndexChange:o,onConfirm:c});return d.useEffect(()=>{l.current?.children[i]?.scrollIntoView({block:"nearest"})},[i]),a.jsx("div",{className:Os("picker-list","picker-list-compact",u?"picker-keyboard-only":void 0),ref:l,role:"listbox","aria-label":s("theme.title"),tabIndex:0,"aria-activedescendant":r.length>0?`theme-opt-${i}`:void 0,"data-web-shell-theme-dialog":!0,children:r.map((h,f)=>{const p=h.id===e;return a.jsxs("div",{id:`theme-opt-${f}`,role:"option","aria-selected":p,className:Os("picker-item","picker-session-item",f===i?"selected":void 0,p?"dialog-current":void 0),"data-web-shell-theme-option":!0,"data-theme-id":h.id,onClick:()=>c(f),onMouseMove:()=>o(f),children:[a.jsx("div",{className:Os("picker-item-row"),children:a.jsx("span",{className:Os("picker-item-title"),children:h.label})}),a.jsx("div",{className:Os("picker-item-meta"),children:h.description})]},h.id)})})}const BK="delete-session-list",Jge=e=>`${BK}-opt-${e}`;function HEn({onDeleted:e,onError:t,onClose:n,workspaceCwd:s}){const{t:r}=mt(),i=Ra(),{sessions:o,loading:l,error:c,deleteSession:u,deleteSessions:h}=Y5(s,{autoLoad:!0,maxAgeMs:1e3}),f=i.sessionId,[p,m]=d.useState(!1),[g,v]=d.useState(-1),[w,y]=d.useState(new Set),{filterValue:b,inputProps:x}=bD(()=>{v(-1),y(new Set)}),[_,S]=d.useState(null),E=d.useRef(null),T=d.useRef(null);d.useEffect(()=>{c&&S(c.message)},[c]);const R=d.useMemo(()=>b?o.filter(O=>{const B=b.toLowerCase();return(O.displayName||"").toLowerCase().includes(B)||O.sessionId.toLowerCase().includes(B)||B5(O,B)}):o,[o,b]),C=d.useCallback(O=>{O!==f&&y(B=>{const D=new Set(B);return D.has(O)?D.delete(O):D.add(O),D})},[f]);d.useEffect(()=>{if(w.size===0)return;const O=new Set(R.map(B=>B.sessionId));y(B=>{const D=new Set([...B].filter(U=>O.has(U)));return D.size===B.size?B:D})},[R,w.size]),d.useEffect(()=>{g>=R.length&&R.length>0&&v(R.length-1)},[R.length,g]),d.useEffect(()=>{E.current?.children[g]?.scrollIntoView({block:"nearest"})},[g]),d.useEffect(()=>{T.current?.focus()},[]);const{keyboardMode:I}=B1({itemCount:R.length,activeIndex:g,onActiveIndexChange:v,onConfirm:O=>{const B=R[O];B&&C(B.sessionId)}}),A=d.useCallback(()=>{if(p)return;if(w.size>0){const B=new Set(R.map(U=>U.sessionId)),D=Array.from(w).filter(U=>B.has(U));if(D.length===0)return;m(!0),h(D).then(U=>{const V=U.removed.length+U.notFound.length,F=U.errors.length;if(F>0&&V>0){t(new Error(r("delete.partialFail",{removed:V,failed:F,detail:U.errors[0].error}))),n();return}if(F>0){S(r("delete.allFailed",{count:F,reason:U.errors[0].error})),m(!1),y(new Set);return}if(V===0){S(r("delete.nonRemoved")),m(!1),y(new Set);return}e([...U.removed,...U.notFound]),n()}).catch(U=>{t(U),m(!1)});return}const O=R[g];if(O){if(O.sessionId===f){S(r("delete.cannotCurrent"));return}m(!0),u(O.sessionId).then(B=>{if(!B){S(r("delete.notFound")),m(!1);return}e([O.sessionId]),n()}).catch(B=>{t(B),m(!1)})}},[f,u,h,p,R,n,e,t,g,w,r]),N=w.size>0,j=!p&&!l&&N;return a.jsxs("div",{className:Os("picker","picker-in-shell"),children:[a.jsxs("div",{className:Os("picker-search"),children:[a.jsxs("span",{className:Os("picker-search-label"),children:[r("resume.search"),":"," "]}),a.jsx("input",{ref:T,className:Os("picker-search-input"),"aria-label":r("resume.search"),role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":BK,"aria-activedescendant":g>=0&&g<R.length?Jge(g):void 0,...x,placeholder:""}),a.jsx("span",{className:Os("picker-search-hint"),children:_||(p?r("delete.deleting"):l?r("common.loading"):N?r("delete.selected",{count:w.size}):b?r("delete.matches",{count:R.length}):"")})]}),a.jsx("div",{className:Os("picker-sep")}),a.jsxs("div",{id:BK,role:"listbox","aria-multiselectable":"true",className:Os("picker-list",I?"picker-keyboard-only":void 0),ref:E,children:[l&&a.jsx("div",{className:Os("picker-empty"),children:r("common.loading")}),!l&&c&&a.jsx("div",{className:Os("picker-empty"),children:c.message}),!l&&!c&&R.length===0&&a.jsx("div",{className:Os("picker-empty"),children:b?r("delete.noMatch",{query:b}):r("delete.none")}),!l&&R.map((O,B)=>{const D=O.sessionId===f,U=w.has(O.sessionId);return a.jsx(xee,{session:O,optionId:Jge(B),active:B===g,ariaSelected:U,current:!1,disabled:D,leading:a.jsx("span",{className:Os("picker-item-checkbox",U?"picker-item-checkbox-checked":void 0),children:U?"[x] ":"[ ] "}),trailing:D?a.jsx("span",{className:Os("picker-item-badge"),children:r("resume.current")}):void 0,onClick:()=>{v(B),D||C(O.sessionId)},onActivate:()=>v(B)},O.sessionId)})]}),a.jsx("div",{className:Os("picker-sep")}),a.jsxs("div",{className:Os("dialog-footer-actions"),children:[a.jsx("button",{type:"button",className:Os("dialog-inline-button"),onClick:n,disabled:p,children:r("common.cancel")}),a.jsx("button",{type:"button",className:Os("dialog-danger-button"),onClick:A,disabled:!j,children:r(p?"delete.deleting":"delete.action")})]})]})}const FK="release-session-list",e0e=e=>`${FK}-opt-${e}`;function UEn({onReleased:e,onError:t,onClose:n,workspaceCwd:s}){const{t:r}=mt(),i=Ra(),{sessions:o,loading:l,error:c,releaseSession:u}=Y5(s,{autoLoad:!0,maxAgeMs:1e3}),h=i.sessionId,[f,p]=d.useState(!1),[m,g]=d.useState(-1),[v,w]=d.useState(null),{filterValue:y,inputProps:b}=bD(()=>{g(-1),w(null)}),[x,_]=d.useState(null),S=d.useRef(null),E=d.useRef(null);d.useEffect(()=>{c&&_(c.message)},[c]);const T=y?o.filter(O=>{const B=y.toLowerCase();return(O.displayName||"").toLowerCase().includes(B)||O.sessionId.toLowerCase().includes(B)||B5(O,B)}):o,R=O=>{const B=T[O];if(!B)return;const D=B.sessionId===h,U=(B.clientCount??0)>0||B.hasActivePrompt===!0;D||!U||(g(O),w(B.sessionId))};d.useEffect(()=>{m>=T.length&&T.length>0&&g(T.length-1)},[T.length,m]),d.useEffect(()=>{S.current?.children[m]?.scrollIntoView({block:"nearest"})},[m]),d.useEffect(()=>{E.current?.focus()},[]);const{keyboardMode:C}=B1({itemCount:T.length,activeIndex:m,onActiveIndexChange:g,onConfirm:R}),I=d.useCallback(O=>{const B=O??T.find(U=>U.sessionId===v)??void 0;if(!B||f)return;if(!((B.clientCount??0)>0||B.hasActivePrompt===!0)){_(r("release.inactive"));return}if(B.sessionId===h){_(r("release.cannotCurrent"));return}u&&(p(!0),u(B.sessionId).then(()=>{e(B.sessionId),n()}).catch(U=>{t(U),p(!1)}))},[h,f,T,n,t,e,u,v,r]),A=T.find(O=>O.sessionId===v)??void 0,N=A&&((A.clientCount??0)>0||A.hasActivePrompt===!0),j=!f&&!l&&!!A&&A.sessionId!==h&&!!N;return a.jsxs("div",{className:Os("picker","picker-in-shell"),children:[a.jsxs("div",{className:Os("picker-search"),children:[a.jsxs("span",{className:Os("picker-search-label"),children:[r("resume.search"),":"," "]}),a.jsx("input",{ref:E,className:Os("picker-search-input"),"aria-label":r("resume.search"),role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":FK,"aria-activedescendant":m>=0&&m<T.length?e0e(m):void 0,...b,placeholder:""}),a.jsx("span",{className:Os("picker-search-hint"),children:x||(f?r("release.releasing"):l?r("common.loading"):y?r("release.matches",{count:T.length}):"")})]}),a.jsx("div",{className:Os("picker-sep")}),a.jsxs("div",{id:FK,role:"listbox",className:Os("picker-list",C?"picker-keyboard-only":void 0),ref:S,children:[l&&a.jsx("div",{className:Os("picker-empty"),children:r("common.loading")}),!l&&T.length===0&&a.jsx("div",{className:Os("picker-empty"),children:y?r("release.noMatch",{query:y}):r("release.none")}),!l&&T.map((O,B)=>{const D=O.sessionId===h,U=(O.clientCount??0)>0||O.hasActivePrompt===!0,V=D||!U;return a.jsx(xee,{session:O,optionId:e0e(B),active:B===m,confirmed:O.sessionId===v,ariaSelected:O.sessionId===v,current:!1,disabled:V,trailing:D?a.jsx("span",{className:Os("picker-item-badge"),children:r("resume.current")}):U?void 0:a.jsx("span",{className:Os("picker-item-badge"),children:r("release.inactiveBadge")}),onClick:()=>R(B),onActivate:()=>g(B)},O.sessionId)})]}),a.jsx("div",{className:Os("picker-sep")}),a.jsxs("div",{className:Os("dialog-footer-actions"),children:[a.jsx("button",{type:"button",className:Os("dialog-inline-button"),onClick:n,disabled:f,children:r("common.cancel")}),a.jsx("button",{type:"button",className:Os("dialog-danger-button"),onClick:()=>I(),disabled:!j,children:r(f?"release.releasing":"release.action")})]})]})}const WEn="_root_ieg2d_1",VEn="_list_ieg2d_8",GEn="_item_ieg2d_21",KEn="_itemCursor_ieg2d_42",YEn="_itemSelected_ieg2d_49",XEn="_prompt_ieg2d_61",ZEn="_keyboardOnly_ieg2d_68",QEn="_itemDisabled_ieg2d_77",JEn="_turn_ieg2d_91",eRn="_time_ieg2d_96",tRn="_footer_ieg2d_102",nRn="_footerMessage_ieg2d_112",sRn="_dangerButton_ieg2d_118",Af={root:WEn,list:VEn,item:GEn,itemCursor:KEn,itemSelected:YEn,prompt:XEn,keyboardOnly:ZEn,itemDisabled:QEn,turn:JEn,time:eRn,footer:tRn,footerMessage:nRn,dangerButton:sRn},rRn="rewind-snapshot-list",t0e=e=>`${rRn}-opt-${e}`;function iRn(e,t){let n=0;for(const s of e)if(s.kind==="user"){if(n===t)return s.text.trim();n+=1}return""}function oRn(e){const t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():e}function aRn({blocks:e,loadSnapshots:t,rewind:n,onError:s,onClose:r}){const{t:i}=mt(),[o,l]=d.useState([]),[c,u]=d.useState(!0),[h,f]=d.useState(null),[p,m]=d.useState(0),[g,v]=d.useState(null),[w,y]=d.useState(null);d.useEffect(()=>{let R=!0;return u(!0),t().then(C=>{R&&l(C.snapshots)}).catch(C=>{R&&s(C)}).finally(()=>{R&&u(!1)}),()=>{R=!1}},[t,s]);const b=d.useMemo(()=>o.map(R=>({snapshot:R,promptText:iRn(e,R.turnIndex)})).sort((R,C)=>R.snapshot.turnIndex-C.snapshot.turnIndex),[e,o]);d.useEffect(()=>{p>=b.length&&b.length>0&&m(b.length-1)},[b.length,p]);const x=d.useRef(null),_=h!==null,S=R=>{!R||h||(f(R),y(null),n(R).then(()=>{r()}).catch(C=>{s(C),y(i("rewind.failed",{reason:C instanceof Error?C.message:String(C)})),f(null)}))},E=R=>{const C=b[R];C&&(m(R),v(C.snapshot.promptId))},{keyboardMode:T}=B1({itemCount:b.length,activeIndex:p,onActiveIndexChange:m,onConfirm:E,enabled:!_});return d.useEffect(()=>{x.current?.children[p]?.scrollIntoView({block:"nearest"})},[p]),d.useEffect(()=>{if(c||b.length===0)return;document.activeElement?.getAttribute("role")==="dialog"&&x.current?.focus()},[c,b.length]),c?a.jsx("div",{className:Os("picker-empty"),children:i("rewind.loading")}):b.length===0?a.jsx("div",{className:Os("picker-empty"),children:i("rewind.empty")}):a.jsxs("div",{className:Af.root,children:[a.jsx("div",{className:`${Af.list} ${T?Af.keyboardOnly:""}`,ref:x,role:"listbox","aria-label":i("rewind.title"),tabIndex:0,"aria-activedescendant":b.length>0?t0e(p):void 0,children:b.map(({snapshot:R,promptText:C},I)=>{const A=I===p,N=g===R.promptId,j=C||i("rewind.promptFallback",{id:R.promptId.slice(-8)});return a.jsxs("div",{id:t0e(I),role:"option","aria-selected":N,"aria-disabled":_||void 0,className:`${Af.item} ${A?Af.itemCursor:""} ${N?Af.itemSelected:""} ${_?Af.itemDisabled:""}`,onClick:()=>{_||E(I)},onMouseMove:()=>m(I),children:[a.jsxs("div",{className:Af.prompt,title:j,children:[a.jsxs("span",{className:Af.turn,children:["#",R.turnIndex+1]})," ",j]}),a.jsx("div",{className:Af.time,children:oRn(R.timestamp)})]},R.promptId)})}),a.jsxs("div",{className:Af.footer,children:[w&&a.jsx("span",{className:Af.footerMessage,role:"alert",children:w}),a.jsx("button",{type:"button",className:Os("dialog-inline-button"),onClick:r,disabled:h!==null,children:i("common.cancel")}),a.jsx("button",{type:"button",className:`${Os("dialog-danger-button")} ${Af.dangerButton}`,onClick:()=>S(g),disabled:!g||h!==null,children:i(h?"rewind.rewinding":"rewind.confirm")})]})]})}const Uq="add-workspace-hint",n0e="add-workspace-display-name-hint",s0e="add-workspace-error",D8="add-workspace-suggestions",lRn=150;function r0e(e){return e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)}function cRn({onClose:e,onAdd:t,displayNameEnabled:n=!1,onSuggest:s,onPick:r,persistenceSupported:i=!0}){const{t:o}=mt(),[l,c]=d.useState(""),[u,h]=d.useState(""),[f,p]=d.useState(null),[m,g]=d.useState(!1),[v,w]=d.useState(!0),[y,b]=d.useState([]),[x,_]=d.useState(!1),[S,E]=d.useState(-1),[T,R]=d.useState("/"),[C,I]=d.useState(!1),A=d.useRef(null),N=d.useRef(!1);N.current=x&&y.length>0;const j=d.useRef(0),O=d.useRef(!1),B=d.useRef(void 0);d.useEffect(()=>{A.current?.focus()},[]);const D=d.useCallback(()=>{B.current!==void 0&&(clearTimeout(B.current),B.current=void 0)},[]);d.useEffect(()=>()=>D(),[D]);const U=d.useCallback(()=>{_(!1),E(-1)},[]);d.useEffect(()=>{if(!s)return;if(!r0e(l)){b([]),U();return}const P=++j.current,ce=!O.current;O.current=!1;const ae=setTimeout(()=>{s(l).then(pe=>{if(P!==j.current)return;b(pe.suggestions),R(pe.sep||"/"),E(-1);const q=A.current;q!==null&&$9(q)===q&&(ce||N.current)&&_(pe.suggestions.length>0)},()=>{P===j.current&&(b([]),U())})},lRn);return()=>clearTimeout(ae)},[l,s,U]),d.useEffect(()=>{const P=ce=>{ce.key!=="Escape"||!N.current||ce.isComposing||ce.keyCode===229||(ce.preventDefault(),U())};return window.addEventListener("keydown",P,{capture:!0}),()=>window.removeEventListener("keydown",P,{capture:!0})},[U]);const V=d.useCallback(P=>{O.current=!1,c(P.path+T),p(null),U(),A.current?.focus()},[T,U]),F=d.useCallback(async()=>{if(!r)return;A.current?.blur(),D(),U(),O.current=!0,I(!0),p(null);let P;try{P=await r(),P&&P!==l?(++j.current,c(P),b([])):(P&&++j.current,O.current=!1)}catch{O.current=!1,p(o("sidebar.addWorkspaceBrowseError"))}finally{I(!1)}},[r,l,U,D,o]),M=d.useCallback(P=>{const ce=x&&y.length>0;if(P.key==="ArrowDown"){if(P.preventDefault(),!ce){y.length>0&&_(!0);return}E(ae=>(ae+1)%y.length);return}if(P.key==="ArrowUp"){if(!ce)return;P.preventDefault(),E(ae=>(ae<=0?y.length:ae)-1);return}if(P.key==="Tab"&&ce&&!P.shiftKey){const ae=S>=0?y[S]:y.length===1?y[0]:void 0;ae&&(P.preventDefault(),V(ae));return}P.key==="Enter"&&ce&&S>=0&&(P.preventDefault(),V(y[S]))},[x,y,S,V]),X=d.useCallback(async P=>{P.preventDefault();const ce=l.trim();if(ce){if(!r0e(ce)){p(o("sidebar.addWorkspaceAbsError"));return}p(null),g(!0),U();try{const ae=i?v:!1,pe=n?u.trim():"";pe?await t(ce,ae,pe):await t(ce,ae),e()}catch(ae){p(ae instanceof Error?ae.message:o("sidebar.addWorkspaceError"))}finally{g(!1)}}},[l,u,n,v,i,t,e,U,o]),ee=x&&y.length>0;return a.jsx(ga,{title:o("sidebar.addWorkspaceTitle"),size:"md",onClose:e,children:a.jsxs("form",{className:"flex flex-col gap-6",onSubmit:X,children:[a.jsxs(Fb,{children:[a.jsxs(ka,{"data-invalid":f?!0:void 0,children:[a.jsx(nl,{htmlFor:"add-workspace-path",children:o("sidebar.addWorkspacePath")}),a.jsxs("div",{className:"relative",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsx(oi,{ref:A,id:"add-workspace-path",type:"text",placeholder:"/absolute/path/to/project",value:l,onChange:P=>{c(P.target.value),f&&p(null)},onKeyDown:M,onFocus:D,onBlur:()=>{D(),B.current=setTimeout(()=>{B.current=void 0,++j.current,b([]),U()},100)},disabled:m||C,autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1,role:"combobox","aria-expanded":ee,"aria-controls":ee?D8:void 0,"aria-activedescendant":ee&&S>=0?`${D8}-${S}`:void 0,"aria-describedby":f?`${s0e} ${Uq}`:Uq,"aria-invalid":f?!0:void 0}),r&&a.jsxs(Nt,{type:"button",variant:"outline",onMouseDown:P=>P.preventDefault(),onClick:()=>void F(),disabled:m||C,children:[a.jsx(c5,{"aria-hidden":"true"}),o("sidebar.addWorkspaceBrowse")]})]}),ee&&a.jsx("ul",{id:D8,role:"listbox","aria-label":o("sidebar.addWorkspaceSuggestions"),className:"absolute inset-x-0 top-full z-50 mt-1 max-h-56 overflow-y-auto rounded-md border bg-popover py-1 text-popover-foreground shadow-md",children:y.map((P,ce)=>a.jsxs("li",{id:`${D8}-${ce}`,role:"option","aria-selected":ce===S,className:`cursor-pointer truncate px-3 py-1.5 ${ce===S?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,onMouseDown:ae=>{ae.preventDefault(),V(P)},onMouseEnter:()=>E(ce),children:[P.name,a.jsx("span",{className:"text-muted-foreground",children:T})]},P.path))})]}),a.jsx(th,{id:Uq,children:o("sidebar.addWorkspaceHint")}),f&&a.jsx(Oin,{id:s0e,children:f})]}),n&&a.jsxs(ka,{children:[a.jsx(nl,{htmlFor:"add-workspace-display-name",children:o("sidebar.addWorkspaceDisplayName")}),a.jsx(oi,{id:"add-workspace-display-name",type:"text",value:u,onChange:P=>h(P.target.value),disabled:m,maxLength:256,autoComplete:"off","aria-describedby":n0e}),a.jsx(th,{id:n0e,children:o("sidebar.addWorkspaceDisplayNameHint")})]}),i&&a.jsxs(ka,{orientation:"horizontal",children:[a.jsxs(_ee,{children:[a.jsx(nl,{htmlFor:"add-workspace-persist",children:o("sidebar.addWorkspacePersist")}),a.jsx(th,{children:o("sidebar.addWorkspacePersistHint")})]}),a.jsx(ag,{id:"add-workspace-persist",checked:v,onCheckedChange:w,disabled:m})]})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Nt,{type:"button",variant:"outline",onClick:e,disabled:m,children:o("sidebar.addWorkspaceCancel")}),a.jsx(Nt,{type:"submit",disabled:m||!l.trim(),children:o(m?"sidebar.addWorkspaceAdding":"sidebar.addWorkspaceRegister")})]})]})})}const uRn=[{target:"mcp",Icon:VCe},{target:"skills",Icon:Ob},{target:"extensions",Icon:aZ},{target:"channels",Icon:A2},{target:"settings",Icon:YCe}];function dRn(e){return Object.values(e).some(Boolean)}function hRn({workspace:e,actions:t,overview:n,disabled:s=!1,triggerClassName:r,contentStyle:i,onOpenChange:o,onPointerDownOutside:l,onCloseAutoFocus:c}){const{t:u}=mt(),h=d.useRef(!1),f=d.useRef(o);if(f.current=o,d.useEffect(()=>()=>{h.current&&f.current?.(!1)},[]),!dRn(t))return null;const p=[],m=[];t.rename&&m.push(a.jsxs(Ni,{onSelect:t.rename,children:[a.jsx(sg,{}),u("sidebar.renameWorkspace")]},"rename")),t.copyPath&&m.push(a.jsxs(Ni,{onSelect:t.copyPath,children:[a.jsx(gk,{}),u("sidebar.copyWorkspacePath")]},"copy")),t.openFolder&&m.push(a.jsxs(Ni,{onSelect:t.openFolder,children:[a.jsx(c5,{}),u("sidebar.openWorkspaceFolder")]},"open-folder")),t.openTerminal&&m.push(a.jsxs(Ni,{onSelect:t.openTerminal,children:[a.jsx(nrt,{}),u("sidebar.openWorkspaceTerminal")]},"open-terminal")),t.newSession&&m.push(a.jsxs(Ni,{onSelect:t.newSession,children:[a.jsx(a9,{}),u("sidebar.newTask")]},"new")),t.newWorktreeSession&&m.push(a.jsxs(Ni,{onSelect:t.newWorktreeSession,children:[a.jsx(PE,{}),u("sidebar.newWorktreeTask")]},"worktree")),m.length>0&&p.push(m);const g=t.openManagement;return g&&p.push([a.jsx(Tje,{children:u("sidebar.manageWorkspace")},"manage-label"),...uRn.map(({target:v,Icon:w})=>{const y=v==="settings"?void 0:JRe(n,v);return a.jsxs(Ni,{onSelect:()=>g(v),children:[a.jsx(w,{}),u(`sidebar.overview.${v==="settings"?"settings":v}`),y!==void 0&&a.jsx("span",{className:"text-muted-foreground ml-auto pl-3 text-xs tabular-nums",children:y})]},v)})]),t.reload&&p.push([a.jsxs(Ni,{onSelect:t.reload,children:[a.jsx(af,{}),u("sidebar.reloadWorkspace")]},"reload")]),t.remove&&p.push([a.jsxs(Ni,{variant:"destructive","aria-label":`${u("sidebar.removeWorkspace")}: ${e.cwd}`,onSelect:t.remove,children:[a.jsx(ef,{}),u("sidebar.removeWorkspace")]},"remove")]),a.jsxs(gm,{onOpenChange:v=>{h.current=v,o?.(v)},children:[a.jsx(op,{asChild:!0,children:a.jsx("button",{className:r,type:"button","aria-label":u("sidebar.workspaceActions"),title:u("sidebar.workspaceActions"),disabled:s,children:a.jsx(Jb,{size:16,strokeWidth:1.2})})}),a.jsx(ap,{align:"end",className:"w-auto min-w-40",style:i,onPointerDownOutside:l,onCloseAutoFocus:c,children:p.map((v,w)=>a.jsxs(Nw,{children:[w>0&&a.jsx(Bb,{}),v]},w))})]})}const fRn=256,pRn=/[\u0000-\u001f\u007f]/;function mRn(e){return!pRn.test(e)}function gRn({workspace:e,busy:t,onSubmit:n,onClose:s}){const{t:r}=mt(),[i,o]=d.useState(e.displayName??""),l=i.trim(),c=l===(e.displayName?.trim()??""),u=!mRn(l);return a.jsx(ga,{title:r("sidebar.renameWorkspaceTitle"),subtitle:e.cwd,size:"sm",onClose:()=>{t||s()},children:a.jsxs("form",{className:ut.confirmContent,onSubmit:h=>{h.preventDefault(),!(t||c||u)&&n(l===""?null:l)},children:[a.jsx(Fb,{children:a.jsxs(ka,{children:[a.jsx(nl,{htmlFor:"workspace-display-name",children:r("sidebar.workspaceNamePrompt")}),a.jsx(oi,{id:"workspace-display-name",value:i,autoFocus:!0,maxLength:fRn,placeholder:xJ(e.cwd),disabled:t,onChange:h=>o(h.target.value)})]})}),a.jsx("p",{className:ut.confirmDescription,role:u?"alert":void 0,children:r(u?"sidebar.workspaceNameInvalid":"sidebar.workspaceNameHint")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Nt,{type:"button",variant:"outline",disabled:t,onClick:s,children:r("common.cancel")}),a.jsx(Nt,{type:"submit",disabled:t||c||u,children:r("common.save")})]})]})})}const Wq=50;function i0e(e){return e.displayName?.trim()||e.sessionId.slice(0,8)}function Vq(e){return e.filter(t=>!t.parentSessionId)}function o0e(e,t){const n=new Set(e.map(s=>s.sessionId));return[...e,...t.filter(s=>!n.has(s.sessionId))]}function vRn(e){const t=URL.createObjectURL(new Blob([e.content],{type:e.mimeType||"text/html"}));try{const n=document.createElement("a");n.href=t,n.download=e.filename,document.body.appendChild(n),n.click(),n.remove()}finally{URL.revokeObjectURL(t)}}function a0e({archiveState:e,currentSessionId:t,currentSessionReady:n=!1,refreshKey:s,searchQuery:r="",onNewSession:i,renderSession:o,onLoadSession:l,onRenameSession:c,onMutated:u,onStatusChange:h,onError:f,onNotice:p}){const m=vi(),g=Ra(),v=lT(),w=d.useRef(v),y=d.useRef(0),b=d.useRef(!1),x=d.useRef(s),_=d.useRef(void 0),S=d.useRef(0),E=d.useRef(void 0),{t:T}=mt(),[R,C]=d.useState([]),I=d.useRef(R);I.current=R;const[A,N]=d.useState(),[j,O]=d.useState(!0),[B,D]=d.useState(!1),[U,V]=d.useState(!1),[F,M]=d.useState(!1),[X,ee]=d.useState(),[P,ce]=d.useState(),[ae,pe]=d.useState(),[q,K]=d.useState(),[oe,W]=d.useState(""),[ge,le]=d.useState(),ye=m.capabilities?.features?.includes(l0)===!0,se=d.useCallback(async($=!1)=>{if(!ye)return;const Y=y.current+1;y.current=Y,M(!1),V(!0);try{const de=$?I.current.length:0;let we=await m.client.listStandaloneSessionsPage({archiveState:e,pageSize:Wq});if(y.current!==Y)return;let Re=Vq(we.sessions);for(;we.nextCursor&&Re.length<de;){if(we=await m.client.listStandaloneSessionsPage({archiveState:e,cursor:we.nextCursor,pageSize:Wq}),y.current!==Y)return;Re=o0e(Re,Vq(we.sessions))}b.current=!0,C(Re),N(we.nextCursor),ee(void 0)}catch(de){if(y.current!==Y)return;console.warn("[web-shell] standalone session list failed:",de),ee({})}finally{y.current===Y&&V(!1)}},[e,ye,m.client]);d.useEffect(()=>{pe($=>$?.kind==="open"?void 0:$),E.current!==t&&++S.current},[t]),d.useEffect(()=>{n&&pe($=>$?.kind==="open"&&$.sessionId===t?void 0:$)},[t,n]),d.useEffect(()=>{const $=x.current!==s;x.current=s,(!b.current||$)&&se(!0)},[se,s]),d.useEffect(()=>{const $=w.current;w.current=v,e==="active"&&g.sessionContext?.kind==="standalone"&&$!=="idle"&&v==="idle"&&se(!0)},[e,g.sessionContext?.kind,se,v]),d.useEffect(()=>{h?.({count:R.length,loading:U,error:!!X})},[X,U,h,R.length]),d.useEffect(()=>{j||D(!1)},[j]);const Se=d.useCallback(async()=>{if(!A||F)return;const $=y.current;M(!0);try{const Y=await m.client.listStandaloneSessionsPage({archiveState:e,cursor:A,pageSize:Wq});if(y.current!==$)return;C(de=>o0e(de,Vq(Y.sessions))),N(Y.nextCursor),ee(void 0)}catch(Y){y.current===$&&(console.warn("[web-shell] standalone session page failed:",Y),ee({cursor:A}))}finally{y.current===$&&M(!1)}},[e,A,F,m.client]),re=d.useCallback(async($,Y)=>{if(_.current)return!1;_.current=$,ce($),pe(void 0);try{return await Y(),!0}catch(de){return qM(Km(de))?(console.warn("[web-shell] standalone session action blocked by writer fence:",de),K(we=>we?.sessionId===$?void 0:we),le(we=>we?.sessionId===$?void 0:we),pe({sessionId:$,kind:"action",messageKey:"session.writerBlocked",retry:()=>{re($,Y)}})):f(de,T("sidebar.standaloneActionFailed")),!1}finally{_.current=void 0,ce(void 0)}},[f,T]),me=d.useCallback($=>{C(Y=>Y.filter(de=>de.sessionId!==$)),u?.()},[u]),Le=d.useCallback(async $=>{await re($.sessionId,async()=>{const Y=await m.client.archiveStandaloneSessions([$.sessionId]);if(Y.archived.includes($.sessionId)||Y.alreadyArchived.includes($.sessionId)||Y.notFound?.includes($.sessionId)){me($.sessionId);return}const de=Y.errors.find(we=>we.sessionId===$.sessionId);throw Object.assign(new Error(de?.message??T("sidebar.standaloneActionFailed")),{body:de})})},[me,re,T,m.client]),Pe=d.useCallback(async $=>{await re($.sessionId,async()=>{const Y=await m.client.unarchiveStandaloneSessions([$.sessionId]);if(Y.unarchived.includes($.sessionId)||Y.alreadyActive.includes($.sessionId)||Y.notFound?.includes($.sessionId)){me($.sessionId);return}const de=Y.errors.find(we=>we.sessionId===$.sessionId);throw Object.assign(new Error(de?.message??T("sidebar.standaloneActionFailed")),{body:de})})},[me,re,T,m.client]),st=d.useCallback(async $=>await re($.sessionId,async()=>{const de=await m.client.deleteStandaloneSessions([$.sessionId]);if(!de.removed.includes($.sessionId)&&!de.notFound.includes($.sessionId)){const we=de.errors.find(Re=>Re.sessionId===$.sessionId);throw Object.assign(new Error(we?.message??T("sidebar.standaloneActionFailed")),{body:we})}de.fileCleanupPending.includes($.sessionId)&&p(T("sidebar.standaloneCleanupPending")),me($.sessionId)}),[p,me,re,T,m.client]),He=d.useCallback(async $=>{const Y=++S.current;E.current=$,pe(void 0);try{await l($)}catch(de){if(Y!==S.current||qM(Km(de)))return;console.warn("[web-shell] standalone session load failed:",de),pe({sessionId:$,kind:"open",messageKey:"session.loadFailed",retry:()=>{He($)}})}},[l]);if(!ye||e==="archived"&&!X&&!ae&&!U&&R.length===0&&!A)return null;const Te=r.trim().toLowerCase(),Ke=Te?R.filter($=>i0e($).toLowerCase().includes(Te)||$.sessionId.toLowerCase().includes(Te)):R,H=!Te&&!B&&Ke.length>Kb,Z=H?Ke.slice(0,Kb):Ke;return a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:`${wl.section} mb-3`,"aria-label":e==="active"?T("sidebar.noWorkspaceSessions"):`${T("sidebar.archivedTitle")}: ${T("sidebar.noWorkspaceSessions")}`,"data-testid":`standalone-${e}-group`,children:[a.jsxs("div",{className:`${wl.headerRow} group`,children:[a.jsxs("button",{type:"button",className:wl.header,"aria-expanded":j,onClick:$=>{O(Y=>!Y),$.detail>0&&$.currentTarget.blur()},children:[a.jsx(jCe,{className:wl.folderIcon,size:14,strokeWidth:1.4,"aria-hidden":"true"}),a.jsx("span",{className:wl.headerContent,children:a.jsx("span",{className:wl.name,children:T("sidebar.noWorkspaceSessions")})})]}),e==="active"&&i&&a.jsx("div",{className:`${ut.workspaceHeaderActions} invisible group-hover:visible group-focus-within:visible`,children:a.jsx("button",{className:ut.workspaceHeaderAction,type:"button",title:T("sidebar.newTask"),"aria-label":T("sidebar.newTask"),onClick:i,children:a.jsx(a9,{size:16,strokeWidth:1.2})})})]}),ae&&a.jsxs("div",{role:"alert",className:"px-2 py-1 text-xs text-muted-foreground",children:[a.jsxs("span",{children:[ae.sessionId.slice(0,8),": ",T(ae.messageKey)]}),a.jsx(Nt,{variant:"ghost",size:"sm",disabled:!!P,onClick:ae.retry,children:T("common.retry")})]}),X&&a.jsxs("div",{role:"alert",className:"px-2 py-1 text-xs text-muted-foreground",children:[T("sidebar.standaloneLoadFailed"),a.jsx(Nt,{variant:"ghost",size:"sm",disabled:U||F,onClick:()=>{X.cursor?Se():se(!0)},children:T("common.retry")})]}),(j||!!Te)&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[Z.map($=>{const Y=$.sessionId===t;return o($,{active:Y,busy:P===$.sessionId,isArchived:e==="archived",onOpen:()=>void He($.sessionId),onRename:()=>{K($),W(i0e($))},onExport:()=>{re($.sessionId,async()=>{vRn(await m.client.exportStandaloneSession($.sessionId,{format:"html"}))})},onArchive:e==="active"?()=>void Le($):void 0,onUnarchive:e==="archived"?()=>void Pe($):void 0,onDelete:()=>le($)})}),!U&&!X&&Ke.length===0&&a.jsx("div",{className:wl.empty,children:T(e==="active"?"sidebar.noSessions":"sidebar.archivedEmpty")}),H&&a.jsx("button",{type:"button",className:ut.showAllSessions,onClick:()=>D(!0),children:T("sidebar.showAllSessions")}),A&&!H&&a.jsx(Nt,{type:"button",variant:"ghost",size:"sm",className:"w-full",disabled:F,onClick:()=>void Se(),children:T("sidebar.showAllSessions")})]})]}),q&&a.jsx(ga,{title:T("sidebar.rename"),size:"sm",onClose:()=>K(void 0),children:a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:$=>{$.preventDefault();const Y=oe.trim();Y&&re(q.sessionId,async()=>{await m.client.renameStandaloneSession(q.sessionId,Y),C(de=>de.map(we=>we.sessionId===q.sessionId?{...we,displayName:Y}:we)),c?.(q.sessionId,Y)}).then(de=>{de&&K(void 0)})},children:[a.jsx(oi,{autoFocus:!0,value:oe,onChange:$=>W($.target.value)}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Nt,{type:"button",variant:"outline",onClick:()=>K(void 0),children:T("common.cancel")}),a.jsx(Nt,{type:"submit",disabled:!oe.trim(),children:T("common.save")})]})]})}),ge&&a.jsx(ga,{title:T("sidebar.delete"),size:"sm",onClose:()=>le(void 0),children:a.jsxs("div",{className:"flex flex-col gap-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:T("sidebar.standaloneDeleteConfirm")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Nt,{type:"button",variant:"outline",onClick:()=>le(void 0),children:T("common.cancel")}),a.jsx(Nt,{type:"button",variant:"destructive",onClick:()=>{st(ge).then($=>{$&&le(void 0)})},children:T("sidebar.delete")})]})]})})]})}class yl extends Error{constructor(t,n){super(n),this.code=t,this.name="LocalDirectoryError"}}const wRn={maxListEntries:500,maxReadBytes:1e6,maxWriteBytes:1e7,maxSearchFiles:2e3,maxSearchBytes:2e7,maxSearchHits:200,maxSearchDirs:1e4},l0e=400;function c0e(e){return e?.kind==="directory"}function u0e(e){return e?.kind==="file"}function O8(e){if(typeof e!="string")throw new yl("invalid_path","`path` must be a string.");const t=e;if(t===""||t===".")return[];if(t.includes("\\"))throw new yl("invalid_path","Backslashes are not allowed; use forward slashes.");if(t.startsWith("/"))throw new yl("invalid_path","Absolute paths are not allowed; paths are relative to the granted directory.");if(/^[a-zA-Z]:[\\/]/.test(t))throw new yl("invalid_path","Windows drive paths are not allowed; paths are relative to the granted directory.");const n=[];for(const s of t.split("/"))if(!(s===""||s===".")){if(s==="..")throw new yl("invalid_path","`..` is not allowed; paths must stay inside the granted directory.");if(/[\u0000-\u001f]/.test(s))throw new yl("invalid_path","C0 control characters (U+0000-U+001F) are not allowed in a path.");n.push(s)}return n}function h3(e,t){if(e instanceof yl)return e;const n=e?.name,s=e instanceof Error?e.message:String(e);return n==="NotFoundError"?new yl("not_found",`No such file or directory: ${t}`):n==="NotAllowedError"||n==="SecurityError"?new yl("permission_denied",`Permission denied for ${t} (${s}). The directory grant may have been revoked; reconnect it.`):n==="TypeMismatchError"?new yl("not_a_directory",`Not a directory: ${t}`):new yl("failed",`${t}: ${s}`)}function d0e(e,t){return e?.name==="TypeMismatchError"?new yl("not_a_file",`${t} is a directory, not a file.`):h3(e,t)}class yRn{constructor(t,n=wRn){this.root=t,this.limits=n}get name(){return this.root.name}async resolveDirectory(t,n,s){let r=this.root;for(const i of t)try{r=await r.getDirectoryHandle(i,{create:s})}catch(o){throw h3(o,n)}return r}async list(t,n){const s=O8(t),r=await this.resolveDirectory(s,t,!1),i=typeof n=="number"&&Number.isFinite(n)&&n>0?Math.max(1,Math.trunc(n)):this.limits.maxListEntries,o=Math.min(i,this.limits.maxListEntries),l=[];let c=!1;try{for await(const u of r.values()){if(l.length>=o){c=!0;break}if(c0e(u))l.push({name:u.name,path:Gq(s,u.name),kind:"directory"});else if(u0e(u)){const h=Gq(s,u.name);try{const f=await u.getFile();l.push({name:u.name,path:h,kind:"file",size:f.size,lastModified:f.lastModified})}catch{l.push({name:u.name,path:h,kind:"file"})}}}}catch(u){throw h3(u,t)}return l.sort((u,h)=>u.path<h.path?-1:u.path>h.path?1:0),{entries:l,truncated:c,limit:o}}async read(t,n=0,s){const r=O8(t);if(r.length===0)throw new yl("invalid_path","`path` must name a file.");const i=r[r.length-1],o=await this.resolveDirectory(r.slice(0,-1),h0e(t),!1);let l;try{l=await(await o.getFileHandle(i)).getFile()}catch(m){throw d0e(m,t)}if(l.size>this.limits.maxReadBytes)throw new yl("too_large",`${t} is ${l.size} bytes, over the ${this.limits.maxReadBytes}-byte read limit. Narrow the request or handle this file another way.`);let c;try{c=new TextDecoder("utf-8",{fatal:!0}).decode(await l.arrayBuffer())}catch(m){throw m instanceof TypeError?new yl("binary_content",`${t} is not valid UTF-8 text; it cannot be returned as text.`):h3(m,t)}if(c.includes("\0"))throw new yl("binary_content",`${t} looks like a binary file (NUL byte); it cannot be returned as text.`);const u=c.split(`
|
|
2172
|
+
`)}function yMe(e,t){const n=e.defaultView?.CSSStyleSheet;if(!n||typeof n.prototype.replaceSync!="function")return null;const s=new n;return s.replaceSync(t),s}function y3n(e,t){const n=Xge.get(e);if(n?.css===t)return n.sheet;const s=yMe(e,t);return s&&Xge.set(e,{css:t,sheet:s}),s}function bMe(e,t){const n=w3n(e.ownerDocument),s=[n,t].filter(i=>!!i);try{const i=n?y3n(e.ownerDocument,n):null,o=t?yMe(e.ownerDocument,t):null,l=[i,o].filter(c=>!!c);if(l.length===s.length&&l.length>0)return e.adoptedStyleSheets=[...e.adoptedStyleSheets,...l],()=>{e.adoptedStyleSheets=e.adoptedStyleSheets.filter(c=>!l.includes(c))}}catch{}const r=s.map(i=>{const o=e.ownerDocument.createElement("style");return o.dataset.qwenWebShellShadow="",o.textContent=i,e.appendChild(o),o});return()=>{for(const i of r)i.remove()}}function b3n({children:e,enabled:t,language:n,themeClassName:s,styles:r,initialFocusRef:i}){const o=d.useRef(null),[l,c]=d.useState(null);return d.useLayoutEffect(()=>{if(!t||!o.current)return;o.current.style.setProperty("all","initial","important"),o.current.style.setProperty("display","block","important"),o.current.style.setProperty("min-width","0","important"),o.current.style.setProperty("width","100%","important");const u=o.current.shadowRoot??o.current.attachShadow({mode:"open"}),h=u.ownerDocument.createElement("div");h.dataset.webShellRoot="",h.dataset.webShellShadcn="",h.dataset.webShellShadowRoot="plugins";const f=bMe(u,r);return u.appendChild(h),c(h),()=>{h.remove(),f(),c(null)}},[t,r]),d.useLayoutEffect(()=>{l&&(l.className=s,l.lang=n)},[n,l,s]),d.useLayoutEffect(()=>{l&&i?.current?.focus()},[i,l]),t?a.jsx("div",{ref:o,"data-web-shell-shadow-host":"plugins",children:l?cp.createPortal(e,l):null}):e}const x3n={ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",Backspace:"Backspace",Delete:"Delete",End:"End",Enter:"Enter",Home:"Home",PageDown:"PageDown",PageUp:"PageUp",Space:"Space",Tab:"Tab"},_3n={Backquote:"`",Backslash:"\\",BracketLeft:"[",BracketRight:"]",Comma:",",Equal:"=",Minus:"-",Period:".",Quote:"'",Semicolon:";",Slash:"/"};function k3n(e){return/^Key[A-Z]$/.test(e.code)?e.code.slice(3):/^Digit[0-9]$/.test(e.code)?e.code.slice(5):/^F(?:[1-9]|1[0-9]|2[0-4])$/.test(e.code)?e.code:x3n[e.key]??_3n[e.code]??null}function S3n(e){const t=k3n(e);if(!t)return null;const n=[];return e.metaKey&&n.push("Command"),e.ctrlKey&&n.push("Control"),e.altKey&&n.push("Alt"),e.shiftKey&&n.push("Shift"),n.push(t),n.join("+")}function C3n(e){return e?e.split("+").map(t=>t==="Command"?"⌘":t==="Control"?"⌃":t==="Alt"?"⌥":t==="Shift"?"⇧":t==="Space"?"Space":t).join(""):""}function T3n({accelerator:e,disabled:t,captureLabel:n,clearLabel:s,offLabel:r,onChange:i}){const[o,l]=d.useState(!1),[c,u]=d.useState(),[h,f]=d.useState(!1),p=d.useRef(null);d.useEffect(()=>{o&&p.current?.focus()},[o]);const m=async g=>{l(!1),u(void 0),f(!0);try{await i(g)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}};return a.jsxs("div",{className:"flex min-w-0 flex-col items-end gap-1 max-md:items-start",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[o?a.jsx(oi,{ref:p,readOnly:!0,"aria-label":n,value:n,className:"w-40",onBlur:()=>l(!1),onKeyDown:g=>{if(g.preventDefault(),g.stopPropagation(),g.key==="Escape"){l(!1);return}if(g.repeat)return;const v=S3n(g);v&&m(v)}}):a.jsx(Nt,{type:"button",variant:"outline",size:"sm",disabled:t||h,"aria-label":n,onClick:()=>{u(void 0),l(!0)},children:e?C3n(e):r}),e&&!o?a.jsx(Nt,{type:"button",variant:"ghost",size:"sm",disabled:t||h,onClick:()=>void m(""),children:s}):null]}),c?a.jsx("span",{className:"max-w-72 text-right text-xs text-destructive max-md:text-left",children:c}):null]})}function Zge({state:e}){const{t}=mt(),n=e??"checking";return a.jsx(zi,{variant:n==="ready"?"secondary":n==="denied"||n==="unavailable"?"destructive":"outline",children:t(`settings.liveSetup.requirement.${n}`)})}function I3n({setup:e}){const{t}=mt(),[n,s]=d.useState(""),[r,i]=d.useState(!1),o=e.status,l=o?.enabled===!0,c=e.mutating||e.loading,u=o!==void 0&&r5e.has(o.install.state),h=o?.live.requirements,f=async()=>{const w=n.trim();if(w)try{await e.update({apiKey:{operation:"replace",value:w}}),s("")}catch{}},p=async()=>{try{await e.update({apiKey:{operation:"clear"}}),s("")}catch{}},m=async w=>{if(w){i(!0);return}try{await e.update({enabled:!1})}catch{}},g=()=>{e.update({enabled:!0}).catch(()=>{})},v=()=>{(o?.install.state==="error"?e.retryInstall():e.launchHost()).catch(()=>{})};return a.jsxs("div",{className:"space-y-5 p-5 max-md:p-4",children:[a.jsxs("div",{className:"flex items-start justify-between gap-6",children:[a.jsxs("div",{className:"min-w-0 space-y-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"font-medium",children:t("settings.liveSetup.title")}),a.jsx(zi,{variant:"outline",children:t("settings.liveSetup.experimental")})]}),a.jsx("p",{className:"max-w-3xl text-sm text-muted-foreground",children:t("settings.liveSetup.description")})]}),e.loading&&!o?a.jsx(Lr,{}):a.jsx(ag,{checked:l,disabled:c||!l&&o?.keyConfigured!==!0,"aria-label":t("settings.liveSetup.enable"),onCheckedChange:w=>void m(w)})]}),a.jsx(TR,{}),a.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("label",{htmlFor:"live-realtime-key",className:"text-sm font-medium",children:t("settings.liveSetup.apiKey")}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(zi,{variant:o?.keyConfigured?"secondary":"outline",children:t(o?.keyConfigured?"settings.liveSetup.configured":"settings.liveSetup.notConfigured")}),o?.keyConfigured&&!l?a.jsx(Nt,{type:"button",size:"xs",variant:"ghost",disabled:e.mutating,onClick:()=>void p(),children:t("settings.liveSetup.removeKey")}):null]})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(oi,{id:"live-realtime-key",type:"password",autoComplete:"off",value:n,disabled:e.mutating,placeholder:o?.keyConfigured?t("settings.liveSetup.apiKeyReplace"):t("settings.liveSetup.apiKeyPlaceholder"),onChange:w=>s(w.target.value),onKeyDown:w=>{w.key==="Enter"&&f()}}),a.jsx(Nt,{type:"button",size:"sm",variant:"outline",disabled:!n.trim()||e.mutating,onClick:()=>void f(),children:e.mutating?a.jsx(Lr,{}):t("settings.liveSetup.save")})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:o?.model??"qwen3.5-omni-plus-realtime"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"text-sm font-medium",children:t("settings.liveSetup.shortcut")}),a.jsx(T3n,{accelerator:o?.shortcut??"Command+E",disabled:e.mutating,captureLabel:t("settings.liveShortcut.capture"),clearLabel:t("settings.liveShortcut.clear"),offLabel:t("settings.liveShortcut.off"),onChange:async w=>e.update({shortcut:w})})]})]}),l&&o?a.jsxs(a.Fragment,{children:[a.jsx(TR,{}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-sm font-medium",children:t("settings.liveSetup.host")}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[t(`settings.liveSetup.install.${o.install.state}`),o.install.version?` · ${o.install.version}`:""]})]}),u?a.jsx(Lr,{}):o.install.state==="error"||o.install.state==="installed"&&h?.host!=="ready"?a.jsx(Nt,{type:"button",size:"sm",variant:"outline",disabled:e.mutating,onClick:v,children:o.install.state==="error"?t("settings.liveSetup.retry"):t("settings.liveSetup.openHost")}):a.jsx(Zge,{state:h?.host})]}),typeof o.install.progress=="number"&&u?a.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted",children:a.jsx("div",{className:"h-full rounded-full bg-primary transition-[width]",style:{width:`${Math.round(o.install.progress*100)}%`}})}):null,a.jsx("div",{className:"grid gap-2 sm:grid-cols-3",children:[["microphone",h?.microphone],["accessibility",h?.accessibility],["screenRecording",h?.screenRecording]].map(([w,y])=>a.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-border px-3 py-2",children:[a.jsx("span",{className:"text-xs",children:t(`settings.liveSetup.permission.${w}`)}),a.jsx(Zge,{state:y})]},w))}),a.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.liveSetup.permissionHint")})]})]}):null,(e.error||l&&o?.install.message)&&a.jsx("p",{className:"text-sm text-destructive",role:"alert",children:e.error?.message??o?.install.message}),a.jsx(Mw,{open:r,onOpenChange:i,children:a.jsxs(Pw,{children:[a.jsxs(Lw,{children:[a.jsx(Qin,{children:a.jsx(FCe,{})}),a.jsx(Ow,{children:t("settings.liveSetup.confirmTitle")}),a.jsx($w,{children:t("settings.liveSetup.confirmDescription")})]}),a.jsxs(Dw,{children:[a.jsx(Bw,{children:t("settings.liveSetup.cancel")}),a.jsx(tk,{onClick:g,children:t("settings.liveSetup.confirm")})]})]})})]})}const E3n="_section_iwuxi_1",R3n="_header_iwuxi_12",A3n="_title_iwuxi_19",j3n="_addButton_iwuxi_24",N3n="_hint_iwuxi_38",M3n="_empty_iwuxi_39",P3n="_provider_iwuxi_45",L3n="_providerName_iwuxi_51",D3n="_modelRow_iwuxi_59",O3n="_modelInfo_iwuxi_70",$3n="_modelName_iwuxi_78",B3n="_modelBaseUrl_iwuxi_84",F3n="_modelId_iwuxi_91",z3n="_modelDescription_iwuxi_98",q3n="_modelDetails_iwuxi_99",H3n="_capability_iwuxi_113",U3n="_currentBadge_iwuxi_119",W3n="_runtimeBadge_iwuxi_127",V3n="_modelActions_iwuxi_135",G3n="_actionButton_iwuxi_142",K3n="_deleteButton_iwuxi_143",Y3n="_confirmButton_iwuxi_144",La={section:E3n,header:R3n,title:A3n,addButton:j3n,hint:N3n,empty:M3n,provider:P3n,providerName:L3n,modelRow:D3n,modelInfo:O3n,modelName:$3n,modelBaseUrl:B3n,modelId:F3n,modelDescription:z3n,modelDetails:q3n,capability:H3n,currentBadge:U3n,runtimeBadge:W3n,modelActions:V3n,actionButton:G3n,deleteButton:K3n,confirmButton:Y3n};function nM(e,t){return`${e.authType}:${t.modelId}:${t.baseUrl??""}`}function X3n(e,t){const n=e.flatMap(r=>r.models.map(i=>({provider:r,model:i})));if(t){const r=n.find(({model:o})=>o.modelId===t);if(r)return nM(r.provider,r.model);const i=n.filter(({model:o})=>o.baseModelId===t);if(i.length===1)return nM(i[0].provider,i[0].model)}const s=n.find(({model:r})=>r.isCurrent);return s?nM(s.provider,s.model):void 0}function Z3n({providers:e,configurations:t=[],onUpdateContextWindow:n,currentModelId:s,loading:r,error:i,busy:o,onSelectModel:l,onDeleteModel:c,onAddModel:u}){const{t:h}=mt(),[f,p]=d.useState(null);d.useEffect(()=>{if(f===null)return;const b=x=>{x.key==="Escape"&&p(null)};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[f]);const m=e.map(b=>({...b,models:[...b.models]})),v=[...new Map(t.map(b=>[b.key,b])).values()].filter(b=>!e.some(x=>x.models.some(_=>_.configurationKey===b.key)));for(const b of v){let x=m.find(_=>_.authType===b.authType);x||(x={kind:"model_provider",status:"ok",authType:b.authType,current:!1,models:[]},m.push(x)),x.models.push({configurationKey:b.key,modelId:b.key,baseModelId:b.modelId,name:b.name||b.modelId,baseUrl:b.baseUrl,envKey:b.envKey,contextLimit:b.contextWindowSize,isCurrent:!1,isRuntime:!1})}const w=m.some(b=>b.models.length>0),y=X3n(e,s);return a.jsxs("div",{className:La.section,"data-testid":"model-management",children:[a.jsxs("div",{className:La.header,children:[a.jsx("span",{className:La.title,children:h("settings.models.title")}),a.jsx("button",{type:"button",className:La.addButton,disabled:o,onClick:u,children:h("settings.models.add")})]}),i&&a.jsx("div",{className:La.hint,children:i.message}),r&&!w&&a.jsx("div",{className:La.hint,children:h("settings.models.loading")}),!r&&!w&&!i&&a.jsx("div",{className:La.empty,children:h("settings.models.empty")}),m.map((b,x)=>b.models.length===0?null:a.jsxs("div",{className:La.provider,children:[a.jsx("div",{className:La.providerName,children:b.authType}),b.models.map(_=>{const S=t.filter(N=>N.key===_.configurationKey),E=S.length===1?S[0]:void 0,T=e.some(N=>N.models.includes(_)),R=nM(b,_),C=R===y,I=f===R,A=_.name||_.baseModelId;return a.jsxs("div",{className:La.modelRow,children:[a.jsxs("div",{className:La.modelInfo,children:[a.jsx("span",{className:La.modelName,children:_.name||_.baseModelId}),C&&a.jsx("span",{className:La.currentBadge,children:h("settings.models.current")}),_.isRuntime&&a.jsx("span",{className:La.runtimeBadge,children:h("settings.models.runtime")}),!T&&a.jsx("span",{className:La.runtimeBadge,children:h("settings.models.savedConfiguration")}),_.name&&_.name!==_.baseModelId&&a.jsx("span",{className:La.modelId,children:_.baseModelId}),_.description&&a.jsx("div",{className:La.modelDescription,children:_.description}),_.baseUrl&&a.jsx("span",{className:La.modelBaseUrl,children:_.baseUrl.split(/[?#]/)[0]}),(_.contextLimit||_.modalities||_.envKey)&&a.jsxs("div",{className:La.modelDetails,children:[_.contextLimit!==void 0&&_.contextLimit>0&&a.jsx("span",{children:h("settings.models.context",{tokens:_.contextLimit.toLocaleString()})}),[["image","auth.advanced.modalityImage"],["video","auth.advanced.modalityVideo"],["audio","auth.advanced.modalityAudio"],["pdf","auth.advanced.modalityPdf"]].map(([N,j])=>_.modalities?.[N]?a.jsx("span",{className:La.capability,children:h(j)},N):null),_.envKey&&a.jsxs("span",{children:[h("settings.models.credentialEnv"),":"," ",a.jsx("code",{children:_.envKey})]})]}),E&&a.jsxs(a.Fragment,{children:[E.purpose!=="chat"&&a.jsx("span",{className:La.capability,children:h(`auth.purpose.${E.purpose}`)}),E.canEditContextWindow===!1&&a.jsx("div",{className:La.modelDescription,children:h("settings.models.ambiguousWindow")}),n&&E.canEditContextWindow!==!1&&a.jsx(Q3n,{configuration:E,busy:o,onSave:n})]})]}),a.jsxs("div",{className:La.modelActions,children:[!C&&T&&a.jsx("button",{type:"button",className:La.actionButton,disabled:o,"aria-label":`${h("settings.models.setCurrent")} ${A}`,onClick:()=>l(_.modelId),children:h("settings.models.setCurrent")}),!_.isRuntime&&(I?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:La.confirmButton,disabled:o,"aria-label":`${h("settings.models.confirmDelete")} ${A}`,onClick:()=>{p(null),c({..._.configurationKey?{key:_.configurationKey}:{},authType:b.authType,modelId:_.baseModelId,..._.baseUrl?{baseUrl:_.baseUrl}:{}})},children:h("settings.models.confirmDelete")}),a.jsx("button",{type:"button",className:La.actionButton,disabled:o,"aria-label":`${h("settings.models.cancel")} ${A}`,onClick:()=>p(null),children:h("settings.models.cancel")})]}):a.jsx("button",{type:"button",className:La.deleteButton,disabled:o,"aria-label":`${h("settings.models.delete")} ${A}`,onClick:()=>p(R),children:h("settings.models.delete")}))]})]},R)})]},`${b.authType}:${x}`))]})}function Q3n({configuration:e,busy:t,onSave:n}){const{t:s}=mt(),r=d.useId(),[i,o]=d.useState(!1),[l,c]=d.useState(""),[u,h]=d.useState(!1),[f,p]=d.useState(""),[m,g]=d.useState(""),v=!l.trim()||/^\d+$/.test(l.trim())&&Number(l)>=1&&Number(l)<=1e7;return i?a.jsxs("form",{className:"mt-3 flex max-w-md flex-col gap-2",onSubmit:w=>{w.preventDefault(),!(!v||u||t)&&(h(!0),p(""),n(e.key,l.trim()?Number(l):null).then(y=>{o(!1),g(y.runtimeSync?.status==="failed"?s("settings.models.runtimeSyncFailed"):y.requiresRestart?s("settings.models.windowSaved"):s("settings.models.saved"))}).catch(y=>p(y instanceof Error?y.message:String(y))).finally(()=>h(!1)))},children:[a.jsxs(ka,{children:[a.jsx(nl,{htmlFor:r,children:s("auth.advanced.contextWindow")}),a.jsx(oi,{id:r,value:l,inputMode:"numeric",placeholder:s("common.auto"),disabled:u||t,"aria-invalid":!v,"aria-describedby":`${r}-hint`,onChange:w=>c(w.target.value)}),a.jsx(th,{id:`${r}-hint`,children:v?s("settings.models.windowHint"):s("auth.advanced.tokenLimitInvalid",{field:s("auth.advanced.contextWindow")})})]}),f&&a.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Nt,{type:"submit",size:"sm","aria-label":`${s("common.save")} ${e.name||e.modelId}`,disabled:!v||u||t,children:s("common.save")}),a.jsx(Nt,{type:"button",variant:"outline",size:"sm",disabled:u||t,"aria-label":`${s("settings.models.cancel")} ${e.name||e.modelId}`,onClick:()=>o(!1),children:s("settings.models.cancel")})]})]}):a.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[a.jsx(Nt,{size:"sm",variant:"outline",disabled:t,"aria-label":`${s("settings.models.editWindow")} ${e.name||e.modelId}`,onClick:()=>{c(e.contextWindowSize?.toString()??""),p(""),g(""),o(!0)},children:s("settings.models.editWindow")}),m&&a.jsx("span",{role:"status",className:"text-xs text-muted-foreground",children:m})]})}function J3n(){const e=new URL(window.location.href);return e.searchParams.delete("daemon"),e.searchParams.delete("token"),`${e.pathname}${e.search}`}function qq(e,t){return e?e.length===1?e[0].address:t&&!e.some(n=>n.address===t)?"":t:t}function eEn(){const{t:e}=mt(),{baseUrl:t,token:n}=vi(),[s,r]=d.useState(),[i,o]=d.useState(""),[l,c]=d.useState(!1),[u,h]=d.useState("");d.useEffect(()=>{let m=!1;return h(""),QU(t,n,"GET","/workspace/local-control").then(g=>{m||(r(g),o(v=>qq(g.interfaces,v)))}).catch(g=>{m||h(g instanceof Error?g.message:String(g))}),()=>{m=!0}},[t,n]);const f=async()=>{if(s){c(!0),h("");try{const m=s.active?"/workspace/local-control/disable":"/workspace/local-control/enable",g=s.active?void 0:{address:i||void 0,target:J3n()},v=await QU(t,n,"POST",m,g);r(v),o(w=>qq(v.interfaces,w))}catch(m){h(m instanceof Error?m.message:String(m));const g=m instanceof e2e?m.payload?.interfaces:void 0;g&&(r(v=>v&&{...v,interfaces:g}),o(v=>qq(g,v)))}finally{c(!1)}}},p=(s?.interfaces?.length??0)>1;return a.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4 max-md:px-4","aria-live":"polite",children:[a.jsxs("div",{className:"flex items-start justify-between gap-4",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[a.jsx(frt,{className:"size-4","aria-hidden":"true"}),e("settings.localControl.title"),a.jsx(zi,{variant:s?.active?"default":"secondary",children:s?.active?e("settings.localControl.on"):e("settings.localControl.off")})]}),a.jsx("p",{className:"mt-1 max-w-3xl text-sm text-muted-foreground",children:e("settings.localControl.description")})]}),!s&&!u&&a.jsx(Lr,{})]}),!s?.active&&p&&a.jsxs(sc,{value:i,onValueChange:o,children:[a.jsx(ic,{className:"w-full max-w-sm","aria-label":e("settings.localControl.network"),children:a.jsx(rc,{placeholder:e("settings.localControl.selectNetwork")})}),a.jsx(oc,{children:(s?.interfaces??[]).map(m=>a.jsxs(Ho,{value:m.address,children:[m.interfaceName," · ",m.address]},m.address))})]}),s?.active&&s.url&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[s.qrText&&a.jsx("pre",{"aria-label":e("settings.localControl.qr"),className:"w-fit overflow-hidden rounded-lg bg-white p-3 font-mono text-[7px] leading-[7px] tracking-normal text-black select-none",children:s.qrText}),a.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[a.jsx("div",{className:"break-all rounded-md bg-muted px-3 py-2 font-mono text-xs",children:s.url}),a.jsxs(Nt,{type:"button",variant:"outline",size:"sm",onClick:()=>void tf(s.url).catch(rg),children:[a.jsx(gk,{"aria-hidden":"true"}),e("common.copy")]}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.encrypted?e("settings.localControl.encrypted"):e("settings.localControl.unencrypted")," ","·"," ",s.sleepInhibited?e("settings.localControl.awake"):e("settings.localControl.maySleep")]})]})]}),s?.active&&!s.url&&s.urlRedacted&&a.jsx("p",{className:"max-w-3xl text-sm text-muted-foreground",children:e("settings.localControl.urlRedacted")}),u&&a.jsx("p",{className:"text-sm text-destructive",role:"alert",children:u}),a.jsxs(Nt,{type:"button",variant:s?.active?"destructive":"default",className:"w-fit",disabled:l||!s||!s.active&&p&&!i,onClick:f,children:[l&&a.jsx(Lr,{}),s?.active?e("settings.localControl.disable"):e("settings.localControl.enable")]})]})}const tEn=new Set(["advisorModel","imageModel","fastModel","visionModel","voiceModel","modelFallbacks"]),nEn=new Set(["ui.hideTips","ui.enableUserFeedback","ui.compactMode","mcpServers","model.reasoningEffort"]),sEn=new Set(["experimental.liveVoice.enabled","experimental.liveVoice.shortcut"]);function AD(e,t,n){const s=e(t);return s===t?n:s}function L8(e,t){return AD(t,`settings.category.${e}`,e)}function US(e,t){return AD(t,`settings.label.${e.key}`,e.label)}function rEn(e,t){if(e.description)return AD(t,`settings.description.${e.key}`,e.description)}function xMe(e,t,n,s){return AD(s,`settings.option.${e.key}.${String(t)}`,n)}function iEn(e,t,n){const s=kMe(e,t);if(s==null)return"";if(e.key==="advisorModel"&&s==="")return n("model.useMain");if(e.key==="imageModel"&&s==="")return n("model.disabled");if(e.key===f_){const i=kX(s,ua.Dark);return n(`theme.${i}`)}if(e.key===YM){const i=bX(s);return i?xX(i):String(s)}if(e.type==="boolean")return n(s===!0?"settings.value.on":"settings.value.off");if(e.type==="enum"&&e.options){const i=e.options.find(o=>o.value===s);return i?xMe(e,i.value,i.label,n):String(s)}const r=String(s).replaceAll("\0"," · ");return r.length>24?`${r.slice(0,21)}…`:r}function _Me(e,t){return(t==="user"?e.values.user:e.values.workspace)!==void 0}function oEn(e,t){if(t==="workspace"?e.values.user!==void 0:e.values.workspace!==void 0)return _Me(e,t)?"settings.alsoModifiedIn":"settings.modifiedIn"}function kMe(e,t){const n=t==="user"?e.values.user:e.values.workspace;return n!==void 0?n:e.values.effective}function aEn(e){const t=new Map;for(const n of e){let s=t.get(n.category);s||(s=[],t.set(n.category,s)),s.push(n)}return Array.from(t.entries()).map(([n,s])=>({category:n,items:s}))}function Qge({category:e}){const t=e.toLowerCase(),n=t.includes("ui")?ist:t.includes("tool")?XU:t.includes("context")?YU:t.includes("privacy")?Lst:t.includes("model")?Db:t.includes("daemon")?L3:t.includes("advanced")?Fst:t.includes("experimental")?FCe:KCe;return a.jsx(n,{"data-icon":"inline-start","aria-hidden":"true"})}function Hq({title:e,description:t,metadata:n,control:s}){return a.jsxs(ka,{orientation:"responsive",className:"min-h-20 gap-6 px-5 py-4 max-md:px-4",children:[a.jsxs(_ee,{className:"min-w-0",children:[a.jsxs(Din,{children:[e,n]}),t&&a.jsx(th,{className:"max-w-3xl",children:t})]}),a.jsx("div",{className:"flex min-w-0 justify-end max-md:justify-start",children:s})]})}function lEn({name:e,label:t,type:n,value:s,disabled:r,onCommit:i,onInvalid:o}){const l=String(s??""),[c,u]=d.useState(l);d.useEffect(()=>u(l),[l]);const h=()=>{if(n==="number"){const f=c.trim(),p=Number(f);if(!f||!Number.isFinite(p)){u(l),o();return}p!==s&&i(p);return}c!==l&&i(c)};return a.jsx(oi,{type:n,name:e,autoComplete:"off","aria-label":t,value:c,disabled:r,className:"w-[min(80px,50vw)] max-md:w-full",onChange:f=>u(f.target.value),onBlur:h,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur(),f.key==="Escape"&&(u(l),f.currentTarget.blur())}})}function cEn({settingsState:e,onLanguageChange:t,onSubDialog:n,onThemeChange:s,chatWidthMode:r,onChatWidthModeChange:i,modelManagement:o,embedded:l=!1,initialCategory:c}){const{language:u,t:h}=mt(),f=zw(),p=uxe(),m=p?.refreshPermission;d.useEffect(()=>{m?.()},[m]);const{status:g,settings:v,loading:w,error:y,reload:b,setValue:x,liveSetup:_}=e,[S,E]=d.useState("workspace"),[T,R]=d.useState(""),[C,I]=d.useState(null),[A,N]=d.useState(null),[j,O]=d.useState(!1),B=p!==void 0,D=w&&!g,U=d.useMemo(()=>{const P=v.filter(K=>!nEn.has(K.key)&&!sEn.has(K.key)),ce=aEn(P).map(K=>({id:K.category,label:L8(K.category,h),items:K.items.map(oe=>({type:"setting",setting:oe}))})),ae={type:"local",localKey:"chatWidth"},pe=ce.find(K=>K.items.some(oe=>oe.type==="setting"&&oe.setting.key===f_));if(pe){const K=pe.items.findIndex(oe=>oe.type==="setting"&&oe.setting.key===f_);pe.items.splice(K+1,0,ae)}else ce.push({id:"UI",label:L8("UI",h),items:[ae]});if(B&&ce.find(oe=>oe.items.includes(ae))?.items.push({type:"local",localKey:"browserNotifications"}),_?.supported){const K=ce.find(oe=>oe.id==="Experimental");K?K.items.unshift({type:"live"}):ce.push({id:"Experimental",label:L8("Experimental",h),items:[{type:"live"}]})}const q=ce.find(K=>K.id==="Daemon");return q?q.items.unshift({type:"local-control"}):ce.push({id:"Daemon",label:L8("Daemon",h),items:[{type:"local-control"}]}),ce},[_,v,h,B]);d.useEffect(()=>{if(U.length!==0&&!U.some(P=>P.id===T)){const P=c&&U.some(ce=>ce.id===c)?c:U[0].id;R(P)}},[T,U,c]),d.useEffect(()=>{y?N(y.message):g?.warnings?.length?N(g.warnings.map(P=>h("settings.corrupted",{recovered:P.recovered?"true":"false"})).join("; ")):v.length>0&&N(null)},[y,v,g,h]);const V=d.useCallback((P,ce)=>{j||N(null),I(P),x(S,P,ce).then(async ae=>{try{await b()}catch{}ae?.requiresRestart&&P!==YM&&O(!0)}).catch(ae=>{N(ae instanceof Error?ae.message:String(ae))}).finally(()=>I(null))},[b,j,S,x]),F=U.find(P=>P.id===T)??U[0],M=F?.items.some(P=>P.type==="setting"&&P.setting.category==="Model"),X=(P,ce,ae,pe,q=!1)=>a.jsxs(sc,{value:P,disabled:q,onValueChange:ce,children:[a.jsx(ic,{size:"sm","aria-label":pe,className:"w-[min(160px,50vw)] bg-background max-md:w-full",children:a.jsx(rc,{})}),a.jsx(oc,{position:"popper",align:"end",children:a.jsx(jIe,{children:ae.map(K=>a.jsx(Ho,{value:K.value,children:K.label},K.value))})})]}),ee=P=>{const ce=kMe(P,S),pe=C===P.key;if(P.key===f_)return X(kX(ce)??f,q=>{const K=q;s(K),V(f_,yxe(K))},vxe.map(q=>({value:q,label:h(`theme.${q}`)})),US(P,h),pe);if(P.key===YM)return X(bX(ce)??u,q=>t(q,S),DUe.map(q=>({value:q,label:xX(q)})),US(P,h),pe);if(tEn.has(P.key))return a.jsx(Nt,{type:"button",variant:"outline",size:"sm",disabled:pe,className:"max-w-[260px] truncate",onClick:()=>n(P.key,S),children:iEn(P,S,h)||h("settings.action.select")});if(P.type==="boolean"){const q=ce===!0;return a.jsx(ag,{checked:q,disabled:pe,onCheckedChange:K=>V(P.key,K),"aria-label":US(P,h)})}if(P.type==="enum"&&P.options?.length){const q=P.options.findIndex(K=>K.value===ce);return X(q>=0?String(q):"",K=>{const oe=P.options?.[Number(K)];oe&&V(P.key,oe.value)},P.options.map((K,oe)=>({value:String(oe),label:xMe(P,K.value,K.label,h)})),US(P,h),pe)}return a.jsx(lEn,{name:P.key,label:US(P,h),type:P.type==="number"||P.type==="integer"?"number":"text",value:ce,disabled:pe,onCommit:q=>V(P.key,q),onInvalid:()=>N(h("settings.invalidNumber"))})};return a.jsxs("div",{className:l?"flex min-h-0 flex-1 flex-col text-sm text-foreground":"flex max-w-[min(var(--chat-regular-content-width,1000px),calc(100vw-64px))] flex-col overflow-hidden rounded-xl border border-border bg-background text-sm text-foreground","data-keyboard-scope":!0,children:[!l&&a.jsx("div",{className:"flex items-center justify-between border-b border-border px-5 py-4",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-base font-semibold text-balance",children:h("settings.title")}),a.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:h("settings.scope.workspace")})]})}),(A||D)&&a.jsxs(ol,{className:"mx-4 mt-3 w-auto",children:[D&&a.jsx(Lr,{}),a.jsx(al,{children:A||h("settings.loading")})]}),a.jsxs(fg,{value:S,className:"flex min-h-0 flex-1 flex-col gap-0",onValueChange:P=>{E(P)},children:[a.jsxs("div",{className:"flex items-center justify-between gap-4 border-b border-border px-3 py-2",children:[a.jsxs(pg,{className:"p-0",children:[a.jsx(io,{value:"workspace",children:h("settings.scope.workspace")}),a.jsx(io,{value:"user",children:h("settings.scope.user")})]}),j&&a.jsx(zi,{variant:"secondary",children:h("settings.requiresRestart")})]}),a.jsxs(Zo,{value:S,forceMount:!0,className:"grid min-h-0 flex-1 grid-cols-[190px_minmax(0,1fr)] outline-none max-md:grid-cols-1",children:[a.jsx("nav",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto border-r border-border bg-muted/20 p-3 max-md:flex-row max-md:overflow-x-auto max-md:border-r-0 max-md:border-b","aria-label":h("settings.title"),children:U.map(P=>a.jsxs(Nt,{type:"button",variant:P.id===T?"secondary":"ghost",size:"sm","aria-current":P.id===T?"page":void 0,className:"w-full justify-start gap-2 px-2.5 max-md:w-auto max-md:shrink-0",onClick:()=>R(P.id),children:[a.jsx(Qge,{category:P.id}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:P.label}),a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:P.items.length})]},P.id))}),a.jsxs("section",{className:"min-h-0 min-w-0 overflow-y-auto bg-background p-5 max-md:p-3",children:[!w&&!F&&a.jsx(C0,{className:"min-h-60",children:a.jsxs(T0,{children:[a.jsx(I0,{variant:"icon",children:a.jsx(KCe,{})}),a.jsx(E0,{children:h("settings.empty")}),a.jsx(X5,{children:h("settings.empty")})]})}),F&&a.jsxs("div",{className:"mx-auto w-full max-w-5xl",children:[a.jsxs(_c,{children:[a.jsx(jd,{children:a.jsxs(Nd,{className:"flex items-center gap-2",children:[a.jsx(Qge,{category:F.id}),F.label]})}),a.jsx(ih,{className:"-mb-(--card-spacing) p-0",children:a.jsx(Fb,{className:"gap-0",children:F.items.map((P,ce)=>{const ae=ce>0&&a.jsx(TR,{className:"mx-5 w-auto max-md:mx-4"});if(P.type==="local"&&P.localKey==="browserNotifications"&&p){const ge=p.permission==="unavailable",le=ge?"unavailable":p.pending?"requesting":p.permission==="denied"?"denied":p.error?"error":p.enabled?p.permission==="granted"?"enabled":"waiting":"disabled";return a.jsxs("div",{children:[ae,a.jsx(Hq,{title:h("browserNotifications.label"),description:[h("browserNotifications.description"),h(`browserNotifications.${le}`),...p.persistent?[]:[h("browserNotifications.temporary")]].join(" "),control:a.jsxs("div",{className:"flex items-center gap-2",children:[p.enabled&&p.permission==="default"&&a.jsx(Nt,{variant:"outline",size:"sm",disabled:p.pending,onClick:()=>void p.setEnabled(!0),children:h("browserNotifications.allow")}),a.jsx(ag,{"aria-label":h("browserNotifications.label"),checked:p.enabled,disabled:p.pending||ge&&!p.enabled,onCheckedChange:ye=>void p.setEnabled(ye)})]})})]},P.localKey)}if(P.type==="local")return a.jsxs("div",{children:[ae,a.jsx(Hq,{title:h("settings.label.ui.chatWidth"),description:h("settings.description.ui.chatWidth"),control:X(r,ge=>i(ge),[{value:"1000",label:h("settings.option.ui.chatWidth.1000")},{value:"wide",label:h("settings.option.ui.chatWidth.wide")}],h("settings.label.ui.chatWidth"),!1)})]},P.localKey);if(P.type==="live")return _?a.jsxs("div",{children:[ae,a.jsx(I3n,{setup:_})]},"live-voice-setup"):null;if(P.type==="local-control")return a.jsxs("div",{children:[ae,a.jsx(eEn,{})]},"local-control");const pe=P.setting,q=rEn(pe,h),K=oEn(pe,S),oe=_Me(pe,S),W=K?h(K,{scope:h(S==="workspace"?"settings.scope.user":"settings.scope.workspace")}):void 0;return a.jsxs("div",{children:[ae,a.jsx(Hq,{title:US(pe,h),description:[q,W].filter(Boolean).join(" · ")||void 0,metadata:oe?a.jsx(zi,{variant:"secondary",children:h(S==="workspace"?"settings.scope.workspace":"settings.scope.user")}):void 0,control:C===pe.key?a.jsx(Lr,{}):ee(pe)})]},pe.key)})})})]}),M&&o&&a.jsx("div",{className:"mt-4",children:a.jsx(Z3n,{...o})})]})]})]})]}),!l&&a.jsx("div",{className:"border-t border-border px-5 py-3 text-xs text-muted-foreground",children:h("settings.footer")})]})}const uEn="_dialog_1ymqd_1",dEn="_toolbar_1ymqd_12",hEn="_tabs_1ymqd_21",fEn="_tab_1ymqd_21",pEn="_tabActive_1ymqd_39",mEn="_search_1ymqd_48",gEn="_general_1ymqd_60",vEn="_shortcuts_1ymqd_67",wEn="_shortcut_1ymqd_67",yEn="_shortcutKey_1ymqd_87",bEn="_shortcutDesc_1ymqd_95",xEn="_commandList_1ymqd_101",_En="_commandCard_1ymqd_108",kEn="_commandCardExpanded_1ymqd_115",SEn="_commandRow_1ymqd_119",CEn="_commandName_1ymqd_135",TEn="_commandTag_1ymqd_142",IEn="_chevron_1ymqd_152",EEn="_chevronExpanded_1ymqd_160",REn="_commandDetail_1ymqd_164",AEn="_commandDescription_1ymqd_174",jEn="_commandSubcommands_1ymqd_175",NEn="_empty_1ymqd_182",Fl={dialog:uEn,toolbar:dEn,tabs:hEn,tab:fEn,tabActive:pEn,search:mEn,general:gEn,shortcuts:vEn,shortcut:wEn,shortcutKey:yEn,shortcutDesc:bEn,commandList:xEn,commandCard:_En,commandCardExpanded:kEn,commandRow:SEn,commandName:CEn,commandTag:TEn,chevron:IEn,chevronExpanded:EEn,commandDetail:REn,commandDescription:AEn,commandSubcommands:jEn,empty:NEn},MEn=[{id:"general",labelKey:"help.tab.general"},{id:"commands",labelKey:"help.tab.commands"},{id:"custom-commands",labelKey:"help.tab.custom"}],PEn=new Set(["about","agents","approval-mode","arena","auth","branch","btw","bug","clear","compress","context","copy","release","diff","directory","docs","doctor","dream","editor","export","extensions","forget","goal","help","hooks","ide","init","insight","language","lsp","mcp","memory","model","new","permissions","plan","quit","recap","remember","rename","reset","restore","resume","rewind","settings","setup-github","skills","stats","status","statusline","summary","tasks","terminal-setup","theme","tools","trust","vim"]),LEn=[["@","help.shortcut.addContext"],["!","help.shortcut.shell"],["/","help.shortcut.commandMenu"],["Tab","help.shortcut.completion"],["Esc","help.shortcut.cancel"],["Ctrl+J","help.shortcut.newline"],["Ctrl+L","help.shortcut.clear"],["Ctrl+Y","help.shortcut.retry"],["Shift+Tab","help.shortcut.approvals"],["Alt+Left/Right","help.shortcut.altWords"],["Up/Down","help.shortcut.history"]];function DEn(e){return[`/${e.name}`,e.argumentHint].filter(Boolean).join(" ")}function $K(e){return!PEn.has(e.name)}function OEn(e,t){return $K(e)?t("help.commandMeta.custom"):t("help.commandMeta.builtIn")}function $En(e,t,n){const s=n.trim().toLowerCase();return e.filter(r=>r.name&&r.description!==void 0).filter(r=>t==="commands"?!$K(r):t==="custom-commands"?$K(r):!0).filter(r=>s?r.name.toLowerCase().includes(s)||(r.description??"").toLowerCase().includes(s)||(r.argumentHint??"").toLowerCase().includes(s):!0).sort((r,i)=>r.name.localeCompare(i.name))}function BEn(){const{t:e}=mt();return a.jsx("div",{className:Fl.general,children:a.jsx("div",{className:Fl.shortcuts,children:LEn.map(([t,n])=>a.jsxs("div",{className:Fl.shortcut,children:[a.jsx("span",{className:Fl.shortcutDesc,children:e(n)}),a.jsx("span",{className:Fl.shortcutKey,children:t})]},t))})})}function FEn({commands:e,tab:t,query:n}){const{t:s}=mt(),[r,i]=d.useState(null),o=d.useMemo(()=>$En(e,t,n),[e,n,t]);return o.length===0?a.jsx("div",{className:Fl.empty,children:s(t==="custom-commands"?"help.emptyCustom":"help.empty")}):a.jsx("div",{className:Fl.commandList,children:o.map(l=>{const c=r===l.name;return a.jsxs("article",{className:`${Fl.commandCard} ${c?Fl.commandCardExpanded:""}`,children:[a.jsxs("button",{type:"button",className:Fl.commandRow,onClick:()=>i(c?null:l.name),"aria-expanded":c,children:[a.jsx("span",{className:Fl.commandName,children:DEn(l)}),a.jsx("span",{className:Fl.commandTag,children:OEn(l,s)}),a.jsx("svg",{className:`${Fl.chevron} ${c?Fl.chevronExpanded:""}`,viewBox:"0 0 16 16","aria-hidden":"true",children:a.jsx("path",{d:"M6 4.5 9.5 8 6 11.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})})]}),c&&a.jsxs("div",{className:Fl.commandDetail,children:[l.description&&a.jsx("div",{className:Fl.commandDescription,children:l.description}),!!l.subcommands?.length&&a.jsxs("div",{className:Fl.commandSubcommands,children:[s("help.subcommands"),": ",l.subcommands.join(", ")]})]})]},l.name)})})}function zEn({commands:e}){const{t}=mt(),[n,s]=d.useState("general"),{filterValue:r,inputProps:i}=bD(),o=n!=="general";return a.jsxs("div",{className:Fl.dialog,children:[a.jsxs("div",{className:Fl.toolbar,children:[a.jsx("div",{className:Fl.tabs,children:MEn.map(l=>a.jsx("button",{type:"button",className:`${Fl.tab} ${l.id===n?Fl.tabActive:""}`,onClick:()=>s(l.id),children:t(l.labelKey)},l.id))}),o&&a.jsx("input",{className:Fl.search,...i,placeholder:t("help.search")})]}),n==="general"?a.jsx(BEn,{}):a.jsx(FEn,{commands:e,tab:n,query:r})]})}function qEn({currentTheme:e,onSelect:t,onClose:n}){const{t:s}=mt(),r=vxe.map(h=>({id:h,label:s(`theme.${h}`),description:s(`theme.${h}.desc`)})),[i,o]=d.useState(()=>{const h=r.findIndex(f=>f.id===e);return h>=0?h:0}),l=d.useRef(null),c=h=>{const f=r[h];f&&(t(f.id),n())},{keyboardMode:u}=B1({itemCount:r.length,activeIndex:i,onActiveIndexChange:o,onConfirm:c});return d.useEffect(()=>{l.current?.children[i]?.scrollIntoView({block:"nearest"})},[i]),a.jsx("div",{className:Os("picker-list","picker-list-compact",u?"picker-keyboard-only":void 0),ref:l,role:"listbox","aria-label":s("theme.title"),tabIndex:0,"aria-activedescendant":r.length>0?`theme-opt-${i}`:void 0,"data-web-shell-theme-dialog":!0,children:r.map((h,f)=>{const p=h.id===e;return a.jsxs("div",{id:`theme-opt-${f}`,role:"option","aria-selected":p,className:Os("picker-item","picker-session-item",f===i?"selected":void 0,p?"dialog-current":void 0),"data-web-shell-theme-option":!0,"data-theme-id":h.id,onClick:()=>c(f),onMouseMove:()=>o(f),children:[a.jsx("div",{className:Os("picker-item-row"),children:a.jsx("span",{className:Os("picker-item-title"),children:h.label})}),a.jsx("div",{className:Os("picker-item-meta"),children:h.description})]},h.id)})})}const BK="delete-session-list",Jge=e=>`${BK}-opt-${e}`;function HEn({onDeleted:e,onError:t,onClose:n,workspaceCwd:s}){const{t:r}=mt(),i=Ra(),{sessions:o,loading:l,error:c,deleteSession:u,deleteSessions:h}=Y5(s,{autoLoad:!0,maxAgeMs:1e3}),f=i.sessionId,[p,m]=d.useState(!1),[g,v]=d.useState(-1),[w,y]=d.useState(new Set),{filterValue:b,inputProps:x}=bD(()=>{v(-1),y(new Set)}),[_,S]=d.useState(null),E=d.useRef(null),T=d.useRef(null);d.useEffect(()=>{c&&S(c.message)},[c]);const R=d.useMemo(()=>b?o.filter(O=>{const B=b.toLowerCase();return(O.displayName||"").toLowerCase().includes(B)||O.sessionId.toLowerCase().includes(B)||B5(O,B)}):o,[o,b]),C=d.useCallback(O=>{O!==f&&y(B=>{const D=new Set(B);return D.has(O)?D.delete(O):D.add(O),D})},[f]);d.useEffect(()=>{if(w.size===0)return;const O=new Set(R.map(B=>B.sessionId));y(B=>{const D=new Set([...B].filter(U=>O.has(U)));return D.size===B.size?B:D})},[R,w.size]),d.useEffect(()=>{g>=R.length&&R.length>0&&v(R.length-1)},[R.length,g]),d.useEffect(()=>{E.current?.children[g]?.scrollIntoView({block:"nearest"})},[g]),d.useEffect(()=>{T.current?.focus()},[]);const{keyboardMode:I}=B1({itemCount:R.length,activeIndex:g,onActiveIndexChange:v,onConfirm:O=>{const B=R[O];B&&C(B.sessionId)}}),A=d.useCallback(()=>{if(p)return;if(w.size>0){const B=new Set(R.map(U=>U.sessionId)),D=Array.from(w).filter(U=>B.has(U));if(D.length===0)return;m(!0),h(D).then(U=>{const V=U.removed.length+U.notFound.length,F=U.errors.length;if(F>0&&V>0){t(new Error(r("delete.partialFail",{removed:V,failed:F,detail:U.errors[0].error}))),n();return}if(F>0){S(r("delete.allFailed",{count:F,reason:U.errors[0].error})),m(!1),y(new Set);return}if(V===0){S(r("delete.nonRemoved")),m(!1),y(new Set);return}e([...U.removed,...U.notFound]),n()}).catch(U=>{t(U),m(!1)});return}const O=R[g];if(O){if(O.sessionId===f){S(r("delete.cannotCurrent"));return}m(!0),u(O.sessionId).then(B=>{if(!B){S(r("delete.notFound")),m(!1);return}e([O.sessionId]),n()}).catch(B=>{t(B),m(!1)})}},[f,u,h,p,R,n,e,t,g,w,r]),N=w.size>0,j=!p&&!l&&N;return a.jsxs("div",{className:Os("picker","picker-in-shell"),children:[a.jsxs("div",{className:Os("picker-search"),children:[a.jsxs("span",{className:Os("picker-search-label"),children:[r("resume.search"),":"," "]}),a.jsx("input",{ref:T,className:Os("picker-search-input"),"aria-label":r("resume.search"),role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":BK,"aria-activedescendant":g>=0&&g<R.length?Jge(g):void 0,...x,placeholder:""}),a.jsx("span",{className:Os("picker-search-hint"),children:_||(p?r("delete.deleting"):l?r("common.loading"):N?r("delete.selected",{count:w.size}):b?r("delete.matches",{count:R.length}):"")})]}),a.jsx("div",{className:Os("picker-sep")}),a.jsxs("div",{id:BK,role:"listbox","aria-multiselectable":"true",className:Os("picker-list",I?"picker-keyboard-only":void 0),ref:E,children:[l&&a.jsx("div",{className:Os("picker-empty"),children:r("common.loading")}),!l&&c&&a.jsx("div",{className:Os("picker-empty"),children:c.message}),!l&&!c&&R.length===0&&a.jsx("div",{className:Os("picker-empty"),children:b?r("delete.noMatch",{query:b}):r("delete.none")}),!l&&R.map((O,B)=>{const D=O.sessionId===f,U=w.has(O.sessionId);return a.jsx(xee,{session:O,optionId:Jge(B),active:B===g,ariaSelected:U,current:!1,disabled:D,leading:a.jsx("span",{className:Os("picker-item-checkbox",U?"picker-item-checkbox-checked":void 0),children:U?"[x] ":"[ ] "}),trailing:D?a.jsx("span",{className:Os("picker-item-badge"),children:r("resume.current")}):void 0,onClick:()=>{v(B),D||C(O.sessionId)},onActivate:()=>v(B)},O.sessionId)})]}),a.jsx("div",{className:Os("picker-sep")}),a.jsxs("div",{className:Os("dialog-footer-actions"),children:[a.jsx("button",{type:"button",className:Os("dialog-inline-button"),onClick:n,disabled:p,children:r("common.cancel")}),a.jsx("button",{type:"button",className:Os("dialog-danger-button"),onClick:A,disabled:!j,children:r(p?"delete.deleting":"delete.action")})]})]})}const FK="release-session-list",e0e=e=>`${FK}-opt-${e}`;function UEn({onReleased:e,onError:t,onClose:n,workspaceCwd:s}){const{t:r}=mt(),i=Ra(),{sessions:o,loading:l,error:c,releaseSession:u}=Y5(s,{autoLoad:!0,maxAgeMs:1e3}),h=i.sessionId,[f,p]=d.useState(!1),[m,g]=d.useState(-1),[v,w]=d.useState(null),{filterValue:y,inputProps:b}=bD(()=>{g(-1),w(null)}),[x,_]=d.useState(null),S=d.useRef(null),E=d.useRef(null);d.useEffect(()=>{c&&_(c.message)},[c]);const T=y?o.filter(O=>{const B=y.toLowerCase();return(O.displayName||"").toLowerCase().includes(B)||O.sessionId.toLowerCase().includes(B)||B5(O,B)}):o,R=O=>{const B=T[O];if(!B)return;const D=B.sessionId===h,U=(B.clientCount??0)>0||B.hasActivePrompt===!0;D||!U||(g(O),w(B.sessionId))};d.useEffect(()=>{m>=T.length&&T.length>0&&g(T.length-1)},[T.length,m]),d.useEffect(()=>{S.current?.children[m]?.scrollIntoView({block:"nearest"})},[m]),d.useEffect(()=>{E.current?.focus()},[]);const{keyboardMode:C}=B1({itemCount:T.length,activeIndex:m,onActiveIndexChange:g,onConfirm:R}),I=d.useCallback(O=>{const B=O??T.find(U=>U.sessionId===v)??void 0;if(!B||f)return;if(!((B.clientCount??0)>0||B.hasActivePrompt===!0)){_(r("release.inactive"));return}if(B.sessionId===h){_(r("release.cannotCurrent"));return}u&&(p(!0),u(B.sessionId).then(()=>{e(B.sessionId),n()}).catch(U=>{t(U),p(!1)}))},[h,f,T,n,t,e,u,v,r]),A=T.find(O=>O.sessionId===v)??void 0,N=A&&((A.clientCount??0)>0||A.hasActivePrompt===!0),j=!f&&!l&&!!A&&A.sessionId!==h&&!!N;return a.jsxs("div",{className:Os("picker","picker-in-shell"),children:[a.jsxs("div",{className:Os("picker-search"),children:[a.jsxs("span",{className:Os("picker-search-label"),children:[r("resume.search"),":"," "]}),a.jsx("input",{ref:E,className:Os("picker-search-input"),"aria-label":r("resume.search"),role:"combobox","aria-autocomplete":"list","aria-expanded":"true","aria-controls":FK,"aria-activedescendant":m>=0&&m<T.length?e0e(m):void 0,...b,placeholder:""}),a.jsx("span",{className:Os("picker-search-hint"),children:x||(f?r("release.releasing"):l?r("common.loading"):y?r("release.matches",{count:T.length}):"")})]}),a.jsx("div",{className:Os("picker-sep")}),a.jsxs("div",{id:FK,role:"listbox",className:Os("picker-list",C?"picker-keyboard-only":void 0),ref:S,children:[l&&a.jsx("div",{className:Os("picker-empty"),children:r("common.loading")}),!l&&T.length===0&&a.jsx("div",{className:Os("picker-empty"),children:y?r("release.noMatch",{query:y}):r("release.none")}),!l&&T.map((O,B)=>{const D=O.sessionId===h,U=(O.clientCount??0)>0||O.hasActivePrompt===!0,V=D||!U;return a.jsx(xee,{session:O,optionId:e0e(B),active:B===m,confirmed:O.sessionId===v,ariaSelected:O.sessionId===v,current:!1,disabled:V,trailing:D?a.jsx("span",{className:Os("picker-item-badge"),children:r("resume.current")}):U?void 0:a.jsx("span",{className:Os("picker-item-badge"),children:r("release.inactiveBadge")}),onClick:()=>R(B),onActivate:()=>g(B)},O.sessionId)})]}),a.jsx("div",{className:Os("picker-sep")}),a.jsxs("div",{className:Os("dialog-footer-actions"),children:[a.jsx("button",{type:"button",className:Os("dialog-inline-button"),onClick:n,disabled:f,children:r("common.cancel")}),a.jsx("button",{type:"button",className:Os("dialog-danger-button"),onClick:()=>I(),disabled:!j,children:r(f?"release.releasing":"release.action")})]})]})}const WEn="_root_ieg2d_1",VEn="_list_ieg2d_8",GEn="_item_ieg2d_21",KEn="_itemCursor_ieg2d_42",YEn="_itemSelected_ieg2d_49",XEn="_prompt_ieg2d_61",ZEn="_keyboardOnly_ieg2d_68",QEn="_itemDisabled_ieg2d_77",JEn="_turn_ieg2d_91",eRn="_time_ieg2d_96",tRn="_footer_ieg2d_102",nRn="_footerMessage_ieg2d_112",sRn="_dangerButton_ieg2d_118",Af={root:WEn,list:VEn,item:GEn,itemCursor:KEn,itemSelected:YEn,prompt:XEn,keyboardOnly:ZEn,itemDisabled:QEn,turn:JEn,time:eRn,footer:tRn,footerMessage:nRn,dangerButton:sRn},rRn="rewind-snapshot-list",t0e=e=>`${rRn}-opt-${e}`;function iRn(e,t){let n=0;for(const s of e)if(s.kind==="user"){if(n===t)return s.text.trim();n+=1}return""}function oRn(e){const t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():e}function aRn({blocks:e,loadSnapshots:t,rewind:n,onError:s,onClose:r}){const{t:i}=mt(),[o,l]=d.useState([]),[c,u]=d.useState(!0),[h,f]=d.useState(null),[p,m]=d.useState(0),[g,v]=d.useState(null),[w,y]=d.useState(null);d.useEffect(()=>{let R=!0;return u(!0),t().then(C=>{R&&l(C.snapshots)}).catch(C=>{R&&s(C)}).finally(()=>{R&&u(!1)}),()=>{R=!1}},[t,s]);const b=d.useMemo(()=>o.map(R=>({snapshot:R,promptText:iRn(e,R.turnIndex)})).sort((R,C)=>R.snapshot.turnIndex-C.snapshot.turnIndex),[e,o]);d.useEffect(()=>{p>=b.length&&b.length>0&&m(b.length-1)},[b.length,p]);const x=d.useRef(null),_=h!==null,S=R=>{!R||h||(f(R),y(null),n(R).then(()=>{r()}).catch(C=>{s(C),y(i("rewind.failed",{reason:C instanceof Error?C.message:String(C)})),f(null)}))},E=R=>{const C=b[R];C&&(m(R),v(C.snapshot.promptId))},{keyboardMode:T}=B1({itemCount:b.length,activeIndex:p,onActiveIndexChange:m,onConfirm:E,enabled:!_});return d.useEffect(()=>{x.current?.children[p]?.scrollIntoView({block:"nearest"})},[p]),d.useEffect(()=>{if(c||b.length===0)return;document.activeElement?.getAttribute("role")==="dialog"&&x.current?.focus()},[c,b.length]),c?a.jsx("div",{className:Os("picker-empty"),children:i("rewind.loading")}):b.length===0?a.jsx("div",{className:Os("picker-empty"),children:i("rewind.empty")}):a.jsxs("div",{className:Af.root,children:[a.jsx("div",{className:`${Af.list} ${T?Af.keyboardOnly:""}`,ref:x,role:"listbox","aria-label":i("rewind.title"),tabIndex:0,"aria-activedescendant":b.length>0?t0e(p):void 0,children:b.map(({snapshot:R,promptText:C},I)=>{const A=I===p,N=g===R.promptId,j=C||i("rewind.promptFallback",{id:R.promptId.slice(-8)});return a.jsxs("div",{id:t0e(I),role:"option","aria-selected":N,"aria-disabled":_||void 0,className:`${Af.item} ${A?Af.itemCursor:""} ${N?Af.itemSelected:""} ${_?Af.itemDisabled:""}`,onClick:()=>{_||E(I)},onMouseMove:()=>m(I),children:[a.jsxs("div",{className:Af.prompt,title:j,children:[a.jsxs("span",{className:Af.turn,children:["#",R.turnIndex+1]})," ",j]}),a.jsx("div",{className:Af.time,children:oRn(R.timestamp)})]},R.promptId)})}),a.jsxs("div",{className:Af.footer,children:[w&&a.jsx("span",{className:Af.footerMessage,role:"alert",children:w}),a.jsx("button",{type:"button",className:Os("dialog-inline-button"),onClick:r,disabled:h!==null,children:i("common.cancel")}),a.jsx("button",{type:"button",className:`${Os("dialog-danger-button")} ${Af.dangerButton}`,onClick:()=>S(g),disabled:!g||h!==null,children:i(h?"rewind.rewinding":"rewind.confirm")})]})]})}const Uq="add-workspace-hint",n0e="add-workspace-display-name-hint",s0e="add-workspace-error",D8="add-workspace-suggestions",lRn=150;function r0e(e){return e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)}function cRn({onClose:e,onAdd:t,displayNameEnabled:n=!1,onSuggest:s,onPick:r,persistenceSupported:i=!0}){const{t:o}=mt(),[l,c]=d.useState(""),[u,h]=d.useState(""),[f,p]=d.useState(null),[m,g]=d.useState(!1),[v,w]=d.useState(!0),[y,b]=d.useState([]),[x,_]=d.useState(!1),[S,E]=d.useState(-1),[T,R]=d.useState("/"),[C,I]=d.useState(!1),A=d.useRef(null),N=d.useRef(!1);N.current=x&&y.length>0;const j=d.useRef(0),O=d.useRef(!1),B=d.useRef(void 0);d.useEffect(()=>{A.current?.focus()},[]);const D=d.useCallback(()=>{B.current!==void 0&&(clearTimeout(B.current),B.current=void 0)},[]);d.useEffect(()=>()=>D(),[D]);const U=d.useCallback(()=>{_(!1),E(-1)},[]);d.useEffect(()=>{if(!s)return;if(!r0e(l)){b([]),U();return}const P=++j.current,ce=!O.current;O.current=!1;const ae=setTimeout(()=>{s(l).then(pe=>{if(P!==j.current)return;b(pe.suggestions),R(pe.sep||"/"),E(-1);const q=A.current;q!==null&&$9(q)===q&&(ce||N.current)&&_(pe.suggestions.length>0)},()=>{P===j.current&&(b([]),U())})},lRn);return()=>clearTimeout(ae)},[l,s,U]),d.useEffect(()=>{const P=ce=>{ce.key!=="Escape"||!N.current||ce.isComposing||ce.keyCode===229||(ce.preventDefault(),U())};return window.addEventListener("keydown",P,{capture:!0}),()=>window.removeEventListener("keydown",P,{capture:!0})},[U]);const V=d.useCallback(P=>{O.current=!1,c(P.path+T),p(null),U(),A.current?.focus()},[T,U]),F=d.useCallback(async()=>{if(!r)return;A.current?.blur(),D(),U(),O.current=!0,I(!0),p(null);let P;try{P=await r(),P&&P!==l?(++j.current,c(P),b([])):(P&&++j.current,O.current=!1)}catch{O.current=!1,p(o("sidebar.addWorkspaceBrowseError"))}finally{I(!1)}},[r,l,U,D,o]),M=d.useCallback(P=>{const ce=x&&y.length>0;if(P.key==="ArrowDown"){if(P.preventDefault(),!ce){y.length>0&&_(!0);return}E(ae=>(ae+1)%y.length);return}if(P.key==="ArrowUp"){if(!ce)return;P.preventDefault(),E(ae=>(ae<=0?y.length:ae)-1);return}if(P.key==="Tab"&&ce&&!P.shiftKey){const ae=S>=0?y[S]:y.length===1?y[0]:void 0;ae&&(P.preventDefault(),V(ae));return}P.key==="Enter"&&ce&&S>=0&&(P.preventDefault(),V(y[S]))},[x,y,S,V]),X=d.useCallback(async P=>{P.preventDefault();const ce=l.trim();if(ce){if(!r0e(ce)){p(o("sidebar.addWorkspaceAbsError"));return}p(null),g(!0),U();try{const ae=i?v:!1,pe=n?u.trim():"";pe?await t(ce,ae,pe):await t(ce,ae),e()}catch(ae){p(ae instanceof Error?ae.message:o("sidebar.addWorkspaceError"))}finally{g(!1)}}},[l,u,n,v,i,t,e,U,o]),ee=x&&y.length>0;return a.jsx(ga,{title:o("sidebar.addWorkspaceTitle"),size:"md",onClose:e,children:a.jsxs("form",{className:"flex flex-col gap-6",onSubmit:X,children:[a.jsxs(Fb,{children:[a.jsxs(ka,{"data-invalid":f?!0:void 0,children:[a.jsx(nl,{htmlFor:"add-workspace-path",children:o("sidebar.addWorkspacePath")}),a.jsxs("div",{className:"relative",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsx(oi,{ref:A,id:"add-workspace-path",type:"text",placeholder:"/absolute/path/to/project",value:l,onChange:P=>{c(P.target.value),f&&p(null)},onKeyDown:M,onFocus:D,onBlur:()=>{D(),B.current=setTimeout(()=>{B.current=void 0,++j.current,b([]),U()},100)},disabled:m||C,autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",spellCheck:!1,role:"combobox","aria-expanded":ee,"aria-controls":ee?D8:void 0,"aria-activedescendant":ee&&S>=0?`${D8}-${S}`:void 0,"aria-describedby":f?`${s0e} ${Uq}`:Uq,"aria-invalid":f?!0:void 0}),r&&a.jsxs(Nt,{type:"button",variant:"outline",onMouseDown:P=>P.preventDefault(),onClick:()=>void F(),disabled:m||C,children:[a.jsx(c5,{"aria-hidden":"true"}),o("sidebar.addWorkspaceBrowse")]})]}),ee&&a.jsx("ul",{id:D8,role:"listbox","aria-label":o("sidebar.addWorkspaceSuggestions"),className:"absolute inset-x-0 top-full z-50 mt-1 max-h-56 overflow-y-auto rounded-md border bg-popover py-1 text-popover-foreground shadow-md",children:y.map((P,ce)=>a.jsxs("li",{id:`${D8}-${ce}`,role:"option","aria-selected":ce===S,className:`cursor-pointer truncate px-3 py-1.5 ${ce===S?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,onMouseDown:ae=>{ae.preventDefault(),V(P)},onMouseEnter:()=>E(ce),children:[P.name,a.jsx("span",{className:"text-muted-foreground",children:T})]},P.path))})]}),a.jsx(th,{id:Uq,children:o("sidebar.addWorkspaceHint")}),f&&a.jsx(Oin,{id:s0e,children:f})]}),n&&a.jsxs(ka,{children:[a.jsx(nl,{htmlFor:"add-workspace-display-name",children:o("sidebar.addWorkspaceDisplayName")}),a.jsx(oi,{id:"add-workspace-display-name",type:"text",value:u,onChange:P=>h(P.target.value),disabled:m,maxLength:256,autoComplete:"off","aria-describedby":n0e}),a.jsx(th,{id:n0e,children:o("sidebar.addWorkspaceDisplayNameHint")})]}),i&&a.jsxs(ka,{orientation:"horizontal",children:[a.jsxs(_ee,{children:[a.jsx(nl,{htmlFor:"add-workspace-persist",children:o("sidebar.addWorkspacePersist")}),a.jsx(th,{children:o("sidebar.addWorkspacePersistHint")})]}),a.jsx(ag,{id:"add-workspace-persist",checked:v,onCheckedChange:w,disabled:m})]})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Nt,{type:"button",variant:"outline",onClick:e,disabled:m,children:o("sidebar.addWorkspaceCancel")}),a.jsx(Nt,{type:"submit",disabled:m||!l.trim(),children:o(m?"sidebar.addWorkspaceAdding":"sidebar.addWorkspaceRegister")})]})]})})}const uRn=[{target:"mcp",Icon:VCe},{target:"skills",Icon:Ob},{target:"extensions",Icon:aZ},{target:"channels",Icon:A2},{target:"settings",Icon:YCe}];function dRn(e){return Object.values(e).some(Boolean)}function hRn({workspace:e,actions:t,overview:n,disabled:s=!1,triggerClassName:r,contentStyle:i,onOpenChange:o,onPointerDownOutside:l,onCloseAutoFocus:c}){const{t:u}=mt(),h=d.useRef(!1),f=d.useRef(o);if(f.current=o,d.useEffect(()=>()=>{h.current&&f.current?.(!1)},[]),!dRn(t))return null;const p=[],m=[];t.rename&&m.push(a.jsxs(Ni,{onSelect:t.rename,children:[a.jsx(sg,{}),u("sidebar.renameWorkspace")]},"rename")),t.copyPath&&m.push(a.jsxs(Ni,{onSelect:t.copyPath,children:[a.jsx(gk,{}),u("sidebar.copyWorkspacePath")]},"copy")),t.openFolder&&m.push(a.jsxs(Ni,{onSelect:t.openFolder,children:[a.jsx(c5,{}),u("sidebar.openWorkspaceFolder")]},"open-folder")),t.openTerminal&&m.push(a.jsxs(Ni,{onSelect:t.openTerminal,children:[a.jsx(nrt,{}),u("sidebar.openWorkspaceTerminal")]},"open-terminal")),t.newSession&&m.push(a.jsxs(Ni,{onSelect:t.newSession,children:[a.jsx(a9,{}),u("sidebar.newTask")]},"new")),t.newWorktreeSession&&m.push(a.jsxs(Ni,{onSelect:t.newWorktreeSession,children:[a.jsx(PE,{}),u("sidebar.newWorktreeTask")]},"worktree")),m.length>0&&p.push(m);const g=t.openManagement;return g&&p.push([a.jsx(Tje,{children:u("sidebar.manageWorkspace")},"manage-label"),...uRn.map(({target:v,Icon:w})=>{const y=v==="settings"?void 0:JRe(n,v);return a.jsxs(Ni,{onSelect:()=>g(v),children:[a.jsx(w,{}),u(`sidebar.overview.${v==="settings"?"settings":v}`),y!==void 0&&a.jsx("span",{className:"text-muted-foreground ml-auto pl-3 text-xs tabular-nums",children:y})]},v)})]),t.reload&&p.push([a.jsxs(Ni,{onSelect:t.reload,children:[a.jsx(af,{}),u("sidebar.reloadWorkspace")]},"reload")]),t.remove&&p.push([a.jsxs(Ni,{variant:"destructive","aria-label":`${u("sidebar.removeWorkspace")}: ${e.cwd}`,onSelect:t.remove,children:[a.jsx(ef,{}),u("sidebar.removeWorkspace")]},"remove")]),a.jsxs(gm,{onOpenChange:v=>{h.current=v,o?.(v)},children:[a.jsx(op,{asChild:!0,children:a.jsx("button",{className:r,type:"button","aria-label":u("sidebar.workspaceActions"),title:u("sidebar.workspaceActions"),disabled:s,children:a.jsx(Jb,{size:16,strokeWidth:1.2})})}),a.jsx(ap,{align:"end",className:"w-auto min-w-40",style:i,onPointerDownOutside:l,onCloseAutoFocus:c,children:p.map((v,w)=>a.jsxs(Nw,{children:[w>0&&a.jsx(Bb,{}),v]},w))})]})}const fRn=256,pRn=/[\u0000-\u001f\u007f]/;function mRn(e){return!pRn.test(e)}function gRn({workspace:e,busy:t,onSubmit:n,onClose:s}){const{t:r}=mt(),[i,o]=d.useState(e.displayName??""),l=i.trim(),c=l===(e.displayName?.trim()??""),u=!mRn(l);return a.jsx(ga,{title:r("sidebar.renameWorkspaceTitle"),subtitle:e.cwd,size:"sm",onClose:()=>{t||s()},children:a.jsxs("form",{className:ut.confirmContent,onSubmit:h=>{h.preventDefault(),!(t||c||u)&&n(l===""?null:l)},children:[a.jsx(Fb,{children:a.jsxs(ka,{children:[a.jsx(nl,{htmlFor:"workspace-display-name",children:r("sidebar.workspaceNamePrompt")}),a.jsx(oi,{id:"workspace-display-name",value:i,autoFocus:!0,maxLength:fRn,placeholder:xJ(e.cwd),disabled:t,onChange:h=>o(h.target.value)})]})}),a.jsx("p",{className:ut.confirmDescription,role:u?"alert":void 0,children:r(u?"sidebar.workspaceNameInvalid":"sidebar.workspaceNameHint")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Nt,{type:"button",variant:"outline",disabled:t,onClick:s,children:r("common.cancel")}),a.jsx(Nt,{type:"submit",disabled:t||c||u,children:r("common.save")})]})]})})}const Wq=50;function i0e(e){return e.displayName?.trim()||e.sessionId.slice(0,8)}function Vq(e){return e.filter(t=>!t.parentSessionId)}function o0e(e,t){const n=new Set(e.map(s=>s.sessionId));return[...e,...t.filter(s=>!n.has(s.sessionId))]}function vRn(e){const t=URL.createObjectURL(new Blob([e.content],{type:e.mimeType||"text/html"}));try{const n=document.createElement("a");n.href=t,n.download=e.filename,document.body.appendChild(n),n.click(),n.remove()}finally{URL.revokeObjectURL(t)}}function a0e({archiveState:e,currentSessionId:t,currentSessionReady:n=!1,refreshKey:s,searchQuery:r="",onNewSession:i,renderSession:o,onLoadSession:l,onRenameSession:c,onMutated:u,onStatusChange:h,onError:f,onNotice:p}){const m=vi(),g=Ra(),v=lT(),w=d.useRef(v),y=d.useRef(0),b=d.useRef(!1),x=d.useRef(s),_=d.useRef(void 0),S=d.useRef(0),E=d.useRef(void 0),{t:T}=mt(),[R,C]=d.useState([]),I=d.useRef(R);I.current=R;const[A,N]=d.useState(),[j,O]=d.useState(!0),[B,D]=d.useState(!1),[U,V]=d.useState(!1),[F,M]=d.useState(!1),[X,ee]=d.useState(),[P,ce]=d.useState(),[ae,pe]=d.useState(),[q,K]=d.useState(),[oe,W]=d.useState(""),[ge,le]=d.useState(),ye=m.capabilities?.features?.includes(l0)===!0,se=d.useCallback(async($=!1)=>{if(!ye)return;const Y=y.current+1;y.current=Y,M(!1),V(!0);try{const de=$?I.current.length:0;let we=await m.client.listStandaloneSessionsPage({archiveState:e,pageSize:Wq});if(y.current!==Y)return;let Re=Vq(we.sessions);for(;we.nextCursor&&Re.length<de;){if(we=await m.client.listStandaloneSessionsPage({archiveState:e,cursor:we.nextCursor,pageSize:Wq}),y.current!==Y)return;Re=o0e(Re,Vq(we.sessions))}b.current=!0,C(Re),N(we.nextCursor),ee(void 0)}catch(de){if(y.current!==Y)return;console.warn("[web-shell] standalone session list failed:",de),ee({})}finally{y.current===Y&&V(!1)}},[e,ye,m.client]);d.useEffect(()=>{pe($=>$?.kind==="open"?void 0:$),E.current!==t&&++S.current},[t]),d.useEffect(()=>{n&&pe($=>$?.kind==="open"&&$.sessionId===t?void 0:$)},[t,n]),d.useEffect(()=>{const $=x.current!==s;x.current=s,(!b.current||$)&&se(!0)},[se,s]),d.useEffect(()=>{const $=w.current;w.current=v,e==="active"&&g.sessionContext?.kind==="standalone"&&$!=="idle"&&v==="idle"&&se(!0)},[e,g.sessionContext?.kind,se,v]),d.useEffect(()=>{h?.({count:R.length,loading:U,error:!!X})},[X,U,h,R.length]),d.useEffect(()=>{j||D(!1)},[j]);const Se=d.useCallback(async()=>{if(!A||F)return;const $=y.current;M(!0);try{const Y=await m.client.listStandaloneSessionsPage({archiveState:e,cursor:A,pageSize:Wq});if(y.current!==$)return;C(de=>o0e(de,Vq(Y.sessions))),N(Y.nextCursor),ee(void 0)}catch(Y){y.current===$&&(console.warn("[web-shell] standalone session page failed:",Y),ee({cursor:A}))}finally{y.current===$&&M(!1)}},[e,A,F,m.client]),re=d.useCallback(async($,Y)=>{if(_.current)return!1;_.current=$,ce($),pe(void 0);try{return await Y(),!0}catch(de){return qM(Km(de))?(console.warn("[web-shell] standalone session action blocked by writer fence:",de),K(we=>we?.sessionId===$?void 0:we),le(we=>we?.sessionId===$?void 0:we),pe({sessionId:$,kind:"action",messageKey:"session.writerBlocked",retry:()=>{re($,Y)}})):f(de,T("sidebar.standaloneActionFailed")),!1}finally{_.current=void 0,ce(void 0)}},[f,T]),me=d.useCallback($=>{C(Y=>Y.filter(de=>de.sessionId!==$)),u?.()},[u]),Le=d.useCallback(async $=>{await re($.sessionId,async()=>{const Y=await m.client.archiveStandaloneSessions([$.sessionId]);if(Y.archived.includes($.sessionId)||Y.alreadyArchived.includes($.sessionId)||Y.notFound?.includes($.sessionId)){me($.sessionId);return}const de=Y.errors.find(we=>we.sessionId===$.sessionId);throw Object.assign(new Error(de?.message??T("sidebar.standaloneActionFailed")),{body:de})})},[me,re,T,m.client]),Pe=d.useCallback(async $=>{await re($.sessionId,async()=>{const Y=await m.client.unarchiveStandaloneSessions([$.sessionId]);if(Y.unarchived.includes($.sessionId)||Y.alreadyActive.includes($.sessionId)||Y.notFound?.includes($.sessionId)){me($.sessionId);return}const de=Y.errors.find(we=>we.sessionId===$.sessionId);throw Object.assign(new Error(de?.message??T("sidebar.standaloneActionFailed")),{body:de})})},[me,re,T,m.client]),st=d.useCallback(async $=>await re($.sessionId,async()=>{const de=await m.client.deleteStandaloneSessions([$.sessionId]);if(!de.removed.includes($.sessionId)&&!de.notFound.includes($.sessionId)){const we=de.errors.find(Re=>Re.sessionId===$.sessionId);throw Object.assign(new Error(we?.message??T("sidebar.standaloneActionFailed")),{body:we})}de.fileCleanupPending.includes($.sessionId)&&p(T("sidebar.standaloneCleanupPending")),me($.sessionId)}),[p,me,re,T,m.client]),He=d.useCallback(async $=>{const Y=++S.current;E.current=$,pe(void 0);try{await l($)}catch(de){if(Y!==S.current||qM(Km(de)))return;console.warn("[web-shell] standalone session load failed:",de),pe({sessionId:$,kind:"open",messageKey:"session.loadFailed",retry:()=>{He($)}})}},[l]);if(!ye||e==="archived"&&!X&&!ae&&!U&&R.length===0&&!A)return null;const Te=r.trim().toLowerCase(),Ke=Te?R.filter($=>i0e($).toLowerCase().includes(Te)||$.sessionId.toLowerCase().includes(Te)):R,H=!Te&&!B&&Ke.length>Kb,Z=H?Ke.slice(0,Kb):Ke;return a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:`${wl.section} mb-3`,"aria-label":e==="active"?T("sidebar.noWorkspaceSessions"):`${T("sidebar.archivedTitle")}: ${T("sidebar.noWorkspaceSessions")}`,"data-testid":`standalone-${e}-group`,children:[a.jsxs("div",{className:`${wl.headerRow} group`,children:[a.jsxs("button",{type:"button",className:wl.header,"aria-expanded":j,onClick:$=>{O(Y=>!Y),$.detail>0&&$.currentTarget.blur()},children:[a.jsx(jCe,{className:wl.folderIcon,size:14,strokeWidth:1.4,"aria-hidden":"true"}),a.jsx("span",{className:wl.headerContent,children:a.jsx("span",{className:wl.name,children:T("sidebar.noWorkspaceSessions")})})]}),e==="active"&&i&&a.jsx("div",{className:`${ut.workspaceHeaderActions} invisible group-hover:visible group-focus-within:visible`,children:a.jsx("button",{className:ut.workspaceHeaderAction,type:"button",title:T("sidebar.newTask"),"aria-label":T("sidebar.newTask"),onClick:i,children:a.jsx(a9,{size:16,strokeWidth:1.2})})})]}),ae&&a.jsxs("div",{role:"alert",className:"px-2 py-1 text-xs text-muted-foreground",children:[a.jsxs("span",{children:[ae.sessionId.slice(0,8),": ",T(ae.messageKey)]}),a.jsx(Nt,{variant:"ghost",size:"sm",disabled:!!P,onClick:ae.retry,children:T("common.retry")})]}),X&&a.jsxs("div",{role:"alert",className:"px-2 py-1 text-xs text-muted-foreground",children:[T("sidebar.standaloneLoadFailed"),a.jsx(Nt,{variant:"ghost",size:"sm",disabled:U||F,onClick:()=>{X.cursor?Se():se(!0)},children:T("common.retry")})]}),(j||!!Te)&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[Z.map($=>{const Y=$.sessionId===t;return o($,{active:Y,busy:P===$.sessionId,isArchived:e==="archived",onOpen:()=>void He($.sessionId),onRename:()=>{K($),W(i0e($))},onExport:()=>{re($.sessionId,async()=>{vRn(await m.client.exportStandaloneSession($.sessionId,{format:"html"}))})},onArchive:e==="active"?()=>void Le($):void 0,onUnarchive:e==="archived"?()=>void Pe($):void 0,onDelete:()=>le($)})}),!U&&!X&&Ke.length===0&&a.jsx("div",{className:wl.empty,children:T(e==="active"?"sidebar.noSessions":"sidebar.archivedEmpty")}),H&&a.jsx("button",{type:"button",className:ut.showAllSessions,onClick:()=>D(!0),children:T("sidebar.showAllSessions")}),A&&!H&&a.jsx(Nt,{type:"button",variant:"ghost",size:"sm",className:"w-full",disabled:F,onClick:()=>void Se(),children:T("sidebar.showAllSessions")})]})]}),q&&a.jsx(ga,{title:T("sidebar.rename"),size:"sm",onClose:()=>K(void 0),children:a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:$=>{$.preventDefault();const Y=oe.trim();Y&&re(q.sessionId,async()=>{await m.client.renameStandaloneSession(q.sessionId,Y),C(de=>de.map(we=>we.sessionId===q.sessionId?{...we,displayName:Y}:we)),c?.(q.sessionId,Y)}).then(de=>{de&&K(void 0)})},children:[a.jsx(oi,{autoFocus:!0,value:oe,onChange:$=>W($.target.value)}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Nt,{type:"button",variant:"outline",onClick:()=>K(void 0),children:T("common.cancel")}),a.jsx(Nt,{type:"submit",disabled:!oe.trim(),children:T("common.save")})]})]})}),ge&&a.jsx(ga,{title:T("sidebar.delete"),size:"sm",onClose:()=>le(void 0),children:a.jsxs("div",{className:"flex flex-col gap-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:T("sidebar.standaloneDeleteConfirm")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Nt,{type:"button",variant:"outline",onClick:()=>le(void 0),children:T("common.cancel")}),a.jsx(Nt,{type:"button",variant:"destructive",onClick:()=>{st(ge).then($=>{$&&le(void 0)})},children:T("sidebar.delete")})]})]})})]})}class yl extends Error{constructor(t,n){super(n),this.code=t,this.name="LocalDirectoryError"}}const wRn={maxListEntries:500,maxReadBytes:1e6,maxWriteBytes:1e7,maxSearchFiles:2e3,maxSearchBytes:2e7,maxSearchHits:200,maxSearchDirs:1e4},l0e=400;function c0e(e){return e?.kind==="directory"}function u0e(e){return e?.kind==="file"}function O8(e){if(typeof e!="string")throw new yl("invalid_path","`path` must be a string.");const t=e;if(t===""||t===".")return[];if(t.includes("\\"))throw new yl("invalid_path","Backslashes are not allowed; use forward slashes.");if(t.startsWith("/"))throw new yl("invalid_path","Absolute paths are not allowed; paths are relative to the granted directory.");if(/^[a-zA-Z]:[\\/]/.test(t))throw new yl("invalid_path","Windows drive paths are not allowed; paths are relative to the granted directory.");const n=[];for(const s of t.split("/"))if(!(s===""||s===".")){if(s==="..")throw new yl("invalid_path","`..` is not allowed; paths must stay inside the granted directory.");if(/[\u0000-\u001f]/.test(s))throw new yl("invalid_path","C0 control characters (U+0000-U+001F) are not allowed in a path.");n.push(s)}return n}function h3(e,t){if(e instanceof yl)return e;const n=e?.name,s=e instanceof Error?e.message:String(e);return n==="NotFoundError"?new yl("not_found",`No such file or directory: ${t}`):n==="NotAllowedError"||n==="SecurityError"?new yl("permission_denied",`Permission denied for ${t} (${s}). The directory grant may have been revoked; reconnect it.`):n==="TypeMismatchError"?new yl("not_a_directory",`Not a directory: ${t}`):new yl("failed",`${t}: ${s}`)}function d0e(e,t){return e?.name==="TypeMismatchError"?new yl("not_a_file",`${t} is a directory, not a file.`):h3(e,t)}class yRn{constructor(t,n=wRn){this.root=t,this.limits=n}get name(){return this.root.name}async resolveDirectory(t,n,s){let r=this.root;for(const i of t)try{r=await r.getDirectoryHandle(i,{create:s})}catch(o){throw h3(o,n)}return r}async list(t,n){const s=O8(t),r=await this.resolveDirectory(s,t,!1),i=typeof n=="number"&&Number.isFinite(n)&&n>0?Math.max(1,Math.trunc(n)):this.limits.maxListEntries,o=Math.min(i,this.limits.maxListEntries),l=[];let c=!1;try{for await(const u of r.values()){if(l.length>=o){c=!0;break}if(c0e(u))l.push({name:u.name,path:Gq(s,u.name),kind:"directory"});else if(u0e(u)){const h=Gq(s,u.name);try{const f=await u.getFile();l.push({name:u.name,path:h,kind:"file",size:f.size,lastModified:f.lastModified})}catch{l.push({name:u.name,path:h,kind:"file"})}}}}catch(u){throw h3(u,t)}return l.sort((u,h)=>u.path<h.path?-1:u.path>h.path?1:0),{entries:l,truncated:c,limit:o}}async read(t,n=0,s){const r=O8(t);if(r.length===0)throw new yl("invalid_path","`path` must name a file.");const i=r[r.length-1],o=await this.resolveDirectory(r.slice(0,-1),h0e(t),!1);let l;try{l=await(await o.getFileHandle(i)).getFile()}catch(m){throw d0e(m,t)}if(l.size>this.limits.maxReadBytes)throw new yl("too_large",`${t} is ${l.size} bytes, over the ${this.limits.maxReadBytes}-byte read limit. Narrow the request or handle this file another way.`);let c;try{c=new TextDecoder("utf-8",{fatal:!0}).decode(await l.arrayBuffer())}catch(m){throw m instanceof TypeError?new yl("binary_content",`${t} is not valid UTF-8 text; it cannot be returned as text.`):h3(m,t)}if(c.includes("\0"))throw new yl("binary_content",`${t} looks like a binary file (NUL byte); it cannot be returned as text.`);const u=c.split(`
|
|
2173
2173
|
`),h=Math.max(0,Math.trunc(n)||0),f=s===void 0||!Number.isFinite(s)||s<=0?u.length:Math.max(1,Math.trunc(s)),p=u.slice(h,h+f);return{path:t,content:p.join(`
|
|
2174
2174
|
`),totalLines:u.length,returnedLines:p.length,truncated:h+p.length<u.length}}async write(t,n){const s=O8(t);if(s.length===0)throw new yl("invalid_path","`path` must name a file.");if(typeof n!="string")throw new yl("invalid_path","`content` must be a string.");const r=new TextEncoder().encode(n);if(new TextDecoder("utf-8",{fatal:!0}).decode(r)!==n)throw new yl("invalid_path",`${t} content contains unpaired surrogates; it cannot be written as UTF-8 text.`);const i=r.length;if(i>this.limits.maxWriteBytes)throw new yl("too_large",`${t} would write ${i} bytes, over the ${this.limits.maxWriteBytes}-byte write limit.`);const o=s[s.length-1],l=await this.resolveDirectory(s.slice(0,-1),h0e(t),!0);let c=!0;try{await l.getFileHandle(o),c=!1}catch{}let u;try{return u=await(await l.getFileHandle(o,{create:!0})).createWritable(),await u.write(n),await u.close(),u=void 0,{path:t,bytes:i,created:c}}catch(h){throw d0e(h,t)}finally{await u?.close().catch(()=>{})}}async search(t,n={}){if(typeof t!="string"||t==="")throw new yl("invalid_path","`pattern` must be a non-empty string.");if(t.includes(`
|
|
2175
2175
|
`)||t.includes("\0"))throw new yl("invalid_path","Multi-line or NUL-bearing patterns are not supported: search matches one line at a time and never opens binary files.");const s=O8(n.path??""),r=await this.resolveDirectory(s,n.path??"",!1),i=Math.min(n.maxFiles??this.limits.maxSearchFiles,this.limits.maxSearchFiles),o=Math.min(n.maxBytes??this.limits.maxSearchBytes,this.limits.maxSearchBytes),l=[];let c=0,u=0,h=0,f=0,p=0,m=null;const g=[{dir:r,prefix:s}];try{for(;g.length>0&&m===null;){const{dir:v,prefix:w}=g.shift();for await(const y of v.values()){if(m!==null)break;if(c0e(y)){if(h>=this.limits.maxSearchDirs){m="directories";break}h+=1,g.push({dir:y,prefix:[...w,y.name]});continue}if(!u0e(y))continue;if(u>=i){m="files";break}const b=Gq(w,y.name);u+=1;let x;try{x=await y.getFile()}catch{p+=1;continue}if(x.size>this.limits.maxReadBytes){p+=1;continue}if(f+x.size>o){m="bytes";break}f+=x.size;let _;try{_=new TextDecoder("utf-8",{fatal:!0}).decode(await x.arrayBuffer())}catch{p+=1;continue}if(_.includes("\0")){p+=1;continue}c+=1;const S=_.split(`
|