@xopcai/xopc 0.0.128 → 0.0.129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Dx3HQkOk.js → agent-avatar-dicebear-DHzfg5D-.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agents-Ceb_WmSZ.js → agents-CMxKKFQD.js} +1 -1
  5. package/dist/gateway/static/root/assets/{app-management-settings-panel-DGtoXVvI.js → app-management-settings-panel-ptk9c5BN.js} +1 -1
  6. package/dist/gateway/static/root/assets/{appearance-settings-BQQf_iLu.js → appearance-settings-bYeEj3IW.js} +1 -1
  7. package/dist/gateway/static/root/assets/{apps-page-D05daQF8.js → apps-page-DdZvDf5B.js} +1 -1
  8. package/dist/gateway/static/root/assets/{archive-plugin-HuCFa2UL.js → archive-plugin-Dy6lsTHw.js} +1 -1
  9. package/dist/gateway/static/root/assets/{attachment-load-N3csiRso.js → attachment-load-qOtBYR6Y.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automation-suggestion-card-DeYEW2YQ.js → automation-suggestion-card-BFH-RfaV.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-page-Dxn5-hGx.js → automations-page-B8JTjkCr.js} +1 -1
  12. package/dist/gateway/static/root/assets/{binary-plugins-DnJO0VG7.js → binary-plugins-DJvi_thc.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-DOAZkqfs.js → block-editor-DlMnizlt.js} +1 -1
  14. package/dist/gateway/static/root/assets/{browser-settings-page-DSB-ZKIX.js → browser-settings-page-slHLiZgi.js} +1 -1
  15. package/dist/gateway/static/root/assets/{capability-presets-api-DRCu-s6d.js → capability-presets-api-D4q7vHVJ.js} +1 -1
  16. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-M7jOJxZX.js → capability-presets-settings-panel-Dng8Grpv.js} +1 -1
  17. package/dist/gateway/static/root/assets/{channels-settings-C1iggCG3.js → channels-settings-KIsISXw0.js} +1 -1
  18. package/dist/gateway/static/root/assets/{connectors-page-Df0TJNgv.js → connectors-page-C5fx4Qs9.js} +1 -1
  19. package/dist/gateway/static/root/assets/{desktop-pet-MnqKnEgd.js → desktop-pet-Jmdn6q47.js} +1 -1
  20. package/dist/gateway/static/root/assets/{desktop-pet-settings-PRnTI9no.js → desktop-pet-settings-B-u63N4e.js} +1 -1
  21. package/dist/gateway/static/root/assets/{directory-picker-path-field-DJNFtSWq.js → directory-picker-path-field-8p1ehIHn.js} +1 -1
  22. package/dist/gateway/static/root/assets/{dreaming-settings-D0_2JavX.js → dreaming-settings-CCkKP-I4.js} +1 -1
  23. package/dist/gateway/static/root/assets/{extension-debug-page-C4sQuETO.js → extension-debug-page-DJ1ABK95.js} +1 -1
  24. package/dist/gateway/static/root/assets/{extension-page-DhnpWAUJ.js → extension-page-CP9P2lGM.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-settings-page-D7JDxFGh.js → extension-settings-page-DnhU-tx0.js} +1 -1
  26. package/dist/gateway/static/root/assets/{gateway-config-api-B_VyPdKh.js → gateway-config-api-CjxDn46s.js} +1 -1
  27. package/dist/gateway/static/root/assets/{gateway-settings-C0TutwM5.js → gateway-settings-TING7224.js} +1 -1
  28. package/dist/gateway/static/root/assets/{goal-create-dialog-DrDGK2L5.js → goal-create-dialog-2lPbGfp3.js} +1 -1
  29. package/dist/gateway/static/root/assets/{goal-detail-page-aaIMRRor.js → goal-detail-page-DHWVRafk.js} +1 -1
  30. package/dist/gateway/static/root/assets/{goals-config-api-CzTu01a1.js → goals-config-api-BqhuxG8P.js} +1 -1
  31. package/dist/gateway/static/root/assets/{goals-page-CBfCPiNK.js → goals-page-CMk-9ZYN.js} +1 -1
  32. package/dist/gateway/static/root/assets/{goals-settings-4rKUC3EH.js → goals-settings-BHzOAU_l.js} +1 -1
  33. package/dist/gateway/static/root/assets/{heartbeat-settings-DqJBKlza.js → heartbeat-settings-BQIm0P3V.js} +1 -1
  34. package/dist/gateway/static/root/assets/{index-38TSE7ng.js → index-C4k6QSXw.js} +6 -6
  35. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-ClVhEihC.js → keyboard-shortcuts-settings-BrENZzM7.js} +1 -1
  36. package/dist/gateway/static/root/assets/{logs-page-J8fw1O8x.js → logs-page-BiL302Ve.js} +1 -1
  37. package/dist/gateway/static/root/assets/{markdown-split-DQYDAL4r.js → markdown-split-BYF4ReGM.js} +1 -1
  38. package/dist/gateway/static/root/assets/{media-plugins-o5fchHfb.js → media-plugins-CpQDz-QJ.js} +1 -1
  39. package/dist/gateway/static/root/assets/{models-hub-panel-D9csuY5T.js → models-hub-panel-CFPpl3Cq.js} +1 -1
  40. package/dist/gateway/static/root/assets/{notes-page-CeWoUGI-.js → notes-page-BurgcdVZ.js} +1 -1
  41. package/dist/gateway/static/root/assets/{notes-workbench-D_oaF0Pq.js → notes-workbench-BAELRM_O.js} +2 -2
  42. package/dist/gateway/static/root/assets/{page-tabs-u0u41Gxz.js → page-tabs-RnYYOIWO.js} +1 -1
  43. package/dist/gateway/static/root/assets/{preview-open-alternatives-BaYRX55y.js → preview-open-alternatives-CTRt06Ri.js} +1 -1
  44. package/dist/gateway/static/root/assets/{project-detail-page-dkHzwhDL.js → project-detail-page-iXX1Ceo2.js} +1 -1
  45. package/dist/gateway/static/root/assets/{projects-page-DBp2WExF.js → projects-page-GDVTFAY7.js} +1 -1
  46. package/dist/gateway/static/root/assets/{remote-access-hub-Cgzg4pNN.js → remote-access-hub-BUrbUnwv.js} +1 -1
  47. package/dist/gateway/static/root/assets/{save-bar-controls-8ebg7PIX.js → save-bar-controls-c4pZeikq.js} +1 -1
  48. package/dist/gateway/static/root/assets/{schedule-field-Cd7FPvsJ.js → schedule-field-Cb6R7iuP.js} +1 -1
  49. package/dist/gateway/static/root/assets/{schema-form-Bq9iqPeA.js → schema-form-BqET_hEP.js} +1 -1
  50. package/dist/gateway/static/root/assets/{sessions-page-vkORZvUB.js → sessions-page-CiOreA2k.js} +1 -1
  51. package/dist/gateway/static/root/assets/settings-advanced-gate-C-qvptlu.js +1 -0
  52. package/dist/gateway/static/root/assets/{settings-collapsible-section-DaVKl6I7.js → settings-collapsible-section-DuOvqNsI.js} +1 -1
  53. package/dist/gateway/static/root/assets/{settings-form-section-C92Shabe.js → settings-form-section-DptSsbWd.js} +1 -1
  54. package/dist/gateway/static/root/assets/{settings-loading-skeleton-EJwzElLr.js → settings-loading-skeleton-BlVfBCb9.js} +1 -1
  55. package/dist/gateway/static/root/assets/{settings-page-layout-dTbdUfAB.js → settings-page-layout-DVt69dJJ.js} +1 -1
  56. package/dist/gateway/static/root/assets/{settings-page-BLY6onMK.js → settings-page-xQx2Pkg5.js} +1 -1
  57. package/dist/gateway/static/root/assets/{setup-status-panel-BU0JUWIA.js → setup-status-panel-DWB8VdLK.js} +1 -1
  58. package/dist/gateway/static/root/assets/{share-preview-page-SgKIyNQ7.js → share-preview-page-8m_ACH0z.js} +1 -1
  59. package/dist/gateway/static/root/assets/{shares-settings-aiY_QGsl.js → shares-settings-CgxfhNxI.js} +1 -1
  60. package/dist/gateway/static/root/assets/{skill-reload-api-C44tGvK7.js → skill-reload-api-BBFUOxmf.js} +1 -1
  61. package/dist/gateway/static/root/assets/{skills-page-C1re61FQ.js → skills-page-bo695odu.js} +1 -1
  62. package/dist/gateway/static/root/assets/{system-settings-panel-CntJCZEg.js → system-settings-panel-CW22OkZ4.js} +1 -1
  63. package/dist/gateway/static/root/assets/{typed-models-lib-CjULd6SF.js → typed-models-lib-BqpGAKxV.js} +1 -1
  64. package/dist/gateway/static/root/assets/{user-profile-settings-panel-DBgcbZfp.js → user-profile-settings-panel-CERVLuaW.js} +1 -1
  65. package/dist/gateway/static/root/assets/{utils-icmWvHl6.js → utils-BnmysurA.js} +1 -1
  66. package/dist/gateway/static/root/assets/{voice-api-key-field-BfvNUIWI.js → voice-api-key-field-Jr3jvPcB.js} +1 -1
  67. package/dist/gateway/static/root/assets/{work-item-detail-page-BYvZjBuJ.js → work-item-detail-page-B-8rex4u.js} +1 -1
  68. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DMXd1znx.js → workflow-run-setup-panel-Ci9GSPnS.js} +1 -1
  69. package/dist/gateway/static/root/assets/{workflow-start-dialog-Dff4IHzz.js → workflow-start-dialog-BhDj8pqH.js} +1 -1
  70. package/dist/gateway/static/root/assets/{workflows-page-0-640fQi.js → workflows-page-Brb3UGvs.js} +1 -1
  71. package/dist/gateway/static/root/index.html +1 -1
  72. package/dist/package.js +1 -1
  73. package/dist/src/mcp/channel-bridge.js +1 -1
  74. package/package.json +1 -1
  75. package/dist/gateway/static/root/assets/settings-advanced-gate-BFJsnSvx.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/settings-page-BLY6onMK.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/locale-store-Ba72bFmP.js","assets/messages-YzjnURPJ.js","assets/sessions-page-vkORZvUB.js","assets/vendor-swr-BIWyz7Rc.js","assets/cn-BQ_8x0bT.js","assets/page-tabs-u0u41Gxz.js","assets/segmented-styles-BL8oLBEp.js","assets/settings-form-section-C92Shabe.js","assets/fetch-BMjlW0g1.js","assets/url-DFGNSBNT.js","assets/logs-page-J8fw1O8x.js","assets/automations-page-Dxn5-hGx.js","assets/workflow-run-setup-panel-DMXd1znx.js","assets/format-cron-label-arqgGlVV.js","assets/cron-expression-B3B1eqnr.js","assets/toast-z0toXu32.js","assets/skills-page-C1re61FQ.js","assets/preload-helper-zJ_50EbN.js","assets/config-reload-event-Bjh2zoKp.js","assets/skill-reload-api-C44tGvK7.js","assets/projects-page-DBp2WExF.js","assets/directory-picker-path-field-DJNFtSWq.js","assets/project-detail-page-dkHzwhDL.js","assets/goal-create-dialog-DrDGK2L5.js","assets/notes-workbench-D_oaF0Pq.js","assets/automation-suggestion-card-DeYEW2YQ.js","assets/theme-store-Bt6vAkSB.js","assets/middleware-Pd0e8Igk.js","assets/goals-config-api-CzTu01a1.js","assets/workflow-start-dialog-Dff4IHzz.js","assets/work-item-detail-page-BYvZjBuJ.js","assets/goals-page-CBfCPiNK.js","assets/goal-detail-page-aaIMRRor.js","assets/notes-page-CeWoUGI-.js","assets/workflows-page-0-640fQi.js","assets/connectors-page-Df0TJNgv.js","assets/agents-Ceb_WmSZ.js","assets/agent-avatar-dicebear-Dx3HQkOk.js","assets/markdown-editor-jD1LPiP-.js","assets/vendor-codemirror-C1WKjCk5.js","assets/code-editor--tMO38Tr.js","assets/capability-presets-api-DRCu-s6d.js","assets/typed-models-lib-CjULd6SF.js","assets/utils-icmWvHl6.js","assets/channel-recipient-api-BrW5Kcgc.js","assets/settings-loading-skeleton-EJwzElLr.js","assets/settings-page-layout-dTbdUfAB.js","assets/browser-settings-page-DSB-ZKIX.js","assets/gateway-config-api-B_VyPdKh.js","assets/settings-advanced-gate-BFJsnSvx.js","assets/channels-settings-C1iggCG3.js","assets/browser-BLJWD7WI.js","assets/schema-form-Bq9iqPeA.js","assets/use-channel-catalog-CPdJ0o0i.js","assets/apps-page-D05daQF8.js","assets/extension-page-DhnpWAUJ.js","assets/extension-settings-page-D7JDxFGh.js","assets/voice-api-key-field-BfvNUIWI.js","assets/extension-debug-page-C4sQuETO.js","assets/share-preview-page-SgKIyNQ7.js","assets/setup-status-panel-BU0JUWIA.js","assets/appearance-settings-BQQf_iLu.js","assets/keyboard-shortcuts-settings-ClVhEihC.js","assets/user-profile-settings-panel-DBgcbZfp.js","assets/system-settings-panel-CntJCZEg.js","assets/desktop-pet-settings-PRnTI9no.js","assets/desktop-pet-sprite-DqZ6fbIj.js","assets/app-management-settings-panel-DGtoXVvI.js","assets/models-hub-panel-D9csuY5T.js","assets/save-bar-controls-8ebg7PIX.js","assets/settings-collapsible-section-DaVKl6I7.js","assets/gateway-settings-C0TutwM5.js","assets/heartbeat-settings-DqJBKlza.js","assets/schedule-field-Cd7FPvsJ.js","assets/remote-access-hub-Cgzg4pNN.js","assets/shares-settings-aiY_QGsl.js","assets/dreaming-settings-D0_2JavX.js","assets/goals-settings-4rKUC3EH.js","assets/capability-presets-settings-panel-M7jOJxZX.js","assets/mermaid-render-BbqDc_LQ.js","assets/markdown-split-DQYDAL4r.js","assets/html-workspace-editor-COqmtESs.js","assets/binary-plugins-DnJO0VG7.js","assets/use-blob-object-url-D4BFuzZB.js","assets/preview-open-alternatives-BaYRX55y.js","assets/media-plugins-o5fchHfb.js","assets/archive-plugin-HuCFa2UL.js","assets/jszip.min-DT31yWkU.js","assets/attachment-process-heavy-RnGYy9bC.js","assets/excel-worksheet-utils-EyvwNT4X.js","assets/attachment-load-N3csiRso.js","assets/desktop-pet-MnqKnEgd.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/settings-page-xQx2Pkg5.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js","assets/locale-store-Ba72bFmP.js","assets/messages-YzjnURPJ.js","assets/sessions-page-CiOreA2k.js","assets/vendor-swr-BIWyz7Rc.js","assets/cn-BQ_8x0bT.js","assets/page-tabs-RnYYOIWO.js","assets/segmented-styles-BL8oLBEp.js","assets/settings-form-section-DptSsbWd.js","assets/fetch-BMjlW0g1.js","assets/url-DFGNSBNT.js","assets/logs-page-BiL302Ve.js","assets/automations-page-B8JTjkCr.js","assets/workflow-run-setup-panel-Ci9GSPnS.js","assets/format-cron-label-arqgGlVV.js","assets/cron-expression-B3B1eqnr.js","assets/toast-z0toXu32.js","assets/skills-page-bo695odu.js","assets/preload-helper-zJ_50EbN.js","assets/config-reload-event-Bjh2zoKp.js","assets/skill-reload-api-BBFUOxmf.js","assets/projects-page-GDVTFAY7.js","assets/directory-picker-path-field-8p1ehIHn.js","assets/project-detail-page-iXX1Ceo2.js","assets/goal-create-dialog-2lPbGfp3.js","assets/notes-workbench-BAELRM_O.js","assets/automation-suggestion-card-BFH-RfaV.js","assets/theme-store-Bt6vAkSB.js","assets/middleware-Pd0e8Igk.js","assets/goals-config-api-BqhuxG8P.js","assets/workflow-start-dialog-BhDj8pqH.js","assets/work-item-detail-page-B-8rex4u.js","assets/goals-page-CMk-9ZYN.js","assets/goal-detail-page-DHWVRafk.js","assets/notes-page-BurgcdVZ.js","assets/workflows-page-Brb3UGvs.js","assets/connectors-page-C5fx4Qs9.js","assets/agents-CMxKKFQD.js","assets/agent-avatar-dicebear-DHzfg5D-.js","assets/markdown-editor-jD1LPiP-.js","assets/vendor-codemirror-C1WKjCk5.js","assets/code-editor--tMO38Tr.js","assets/capability-presets-api-D4q7vHVJ.js","assets/typed-models-lib-BqpGAKxV.js","assets/utils-BnmysurA.js","assets/channel-recipient-api-BrW5Kcgc.js","assets/settings-loading-skeleton-BlVfBCb9.js","assets/settings-page-layout-DVt69dJJ.js","assets/browser-settings-page-slHLiZgi.js","assets/gateway-config-api-CjxDn46s.js","assets/settings-advanced-gate-C-qvptlu.js","assets/channels-settings-KIsISXw0.js","assets/browser-BLJWD7WI.js","assets/schema-form-BqET_hEP.js","assets/use-channel-catalog-CPdJ0o0i.js","assets/apps-page-DdZvDf5B.js","assets/extension-page-CP9P2lGM.js","assets/extension-settings-page-DnhU-tx0.js","assets/voice-api-key-field-Jr3jvPcB.js","assets/extension-debug-page-DJ1ABK95.js","assets/share-preview-page-8m_ACH0z.js","assets/setup-status-panel-DWB8VdLK.js","assets/appearance-settings-bYeEj3IW.js","assets/keyboard-shortcuts-settings-BrENZzM7.js","assets/user-profile-settings-panel-CERVLuaW.js","assets/system-settings-panel-CW22OkZ4.js","assets/desktop-pet-settings-B-u63N4e.js","assets/desktop-pet-sprite-DqZ6fbIj.js","assets/app-management-settings-panel-ptk9c5BN.js","assets/models-hub-panel-CFPpl3Cq.js","assets/save-bar-controls-c4pZeikq.js","assets/settings-collapsible-section-DuOvqNsI.js","assets/gateway-settings-TING7224.js","assets/heartbeat-settings-BQIm0P3V.js","assets/schedule-field-Cb6R7iuP.js","assets/remote-access-hub-BUrbUnwv.js","assets/shares-settings-CgxfhNxI.js","assets/dreaming-settings-CCkKP-I4.js","assets/goals-settings-BHzOAU_l.js","assets/capability-presets-settings-panel-Dng8Grpv.js","assets/mermaid-render-BbqDc_LQ.js","assets/markdown-split-BYF4ReGM.js","assets/html-workspace-editor-COqmtESs.js","assets/binary-plugins-DJvi_thc.js","assets/use-blob-object-url-D4BFuzZB.js","assets/preview-open-alternatives-CTRt06Ri.js","assets/media-plugins-CpQDz-QJ.js","assets/archive-plugin-Dy6lsTHw.js","assets/jszip.min-DT31yWkU.js","assets/attachment-process-heavy-RnGYy9bC.js","assets/excel-worksheet-utils-EyvwNT4X.js","assets/attachment-load-qOtBYR6Y.js","assets/desktop-pet-Jmdn6q47.js"])))=>i.map(i=>d[i]);
2
2
  import{i as e,n as t,t as n}from"./rolldown-runtime-aKtaBQYM.js";import{a as r,i,n as a,r as o,t as s}from"./vendor-react-BOUWij0V.js";import{t as c}from"./preload-helper-zJ_50EbN.js";import{n as l,t as u}from"./cn-BQ_8x0bT.js";import{n as d,t as f}from"./dist-DokQNVMQ.js";import{n as p,t as m}from"./messages-YzjnURPJ.js";import{c as h,i as g,n as _,s as v,t as y}from"./locale-store-Ba72bFmP.js";import{t as b}from"./middleware-Pd0e8Igk.js";import{i as x,n as S,r as C,t as w}from"./theme-store-Bt6vAkSB.js";import{_ as T,a as E,c as D,d as O,f as k,g as A,h as j,i as M,l as N,m as P,n as F,o as I,p as L,r as R,t as z,u as B,v as V}from"./Combination-BzaXOLd9.js";import{a as H,i as U,n as W,r as G,t as K}from"./dist-CkobR7mk.js";import{a as q,i as ee,n as J,r as te,t as Y}from"./fetch-BMjlW0g1.js";import{n as ne,r as re}from"./toast-z0toXu32.js";import{t as X}from"./url-DFGNSBNT.js";import{i as ie,n as ae,o as oe,t as se}from"./vendor-swr-BIWyz7Rc.js";import{n as ce,t as le}from"./config-reload-event-Bjh2zoKp.js";import{t as ue}from"./gateway-startup-retry-CY5W2Pp4.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Z=e(r(),1),de=e=>{throw TypeError(e)},fe=(e,t,n)=>t.has(e)||de(`Cannot `+n),pe=(e,t,n)=>(fe(e,t,`read from private field`),n?n.call(e):t.get(e)),me=(e,t,n)=>t.has(e)?de(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),he=(e,t,n,r)=>(fe(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),ge=`popstate`;function _e(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function ve(e={}){function t(e,t){let{pathname:n=`/`,search:r=``,hash:i=``}=Te(e.location.hash.substring(1));return!n.startsWith(`/`)&&!n.startsWith(`.`)&&(n=`/`+n),Ce(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){let n=e.document.querySelector(`base`),r=``;if(n&&n.getAttribute(`href`)){let t=e.location.href,n=t.indexOf(`#`);r=n===-1?t:t.slice(0,n)}return r+`#`+(typeof t==`string`?t:we(t))}function r(e,t){be(e.pathname.charAt(0)===`/`,`relative pathnames are not supported in hash history.push(${JSON.stringify(t)})`)}return Ee(t,n,r,e)}function ye(e,t){if(e===!1||e==null)throw Error(t)}function be(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function xe(){return Math.random().toString(36).substring(2,10)}function Se(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Ce(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?Te(t):t,state:n,key:t&&t.key||r||xe(),mask:i}}function we({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function Te(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Ee(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=_e(e)?e:Ce(h.location,e,t);n&&n(r,e),l=u()+1;let d=Se(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=_e(e)?e:Ce(h.location,e,t);n&&n(r,e),l=u();let i=Se(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return De(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(ge,d),c=e,()=>{i.removeEventListener(ge,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function De(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),ye(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:we(t);return i=i.replace(/ $/,`%20`),!n&&i.startsWith(`//`)&&(i=r+i),new URL(i,r)}var Oe,ke=class{constructor(e){if(me(this,Oe,new Map),e)for(let[t,n]of e)this.set(t,n)}get(e){if(pe(this,Oe).has(e))return pe(this,Oe).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw Error(`No value found for context`)}set(e,t){pe(this,Oe).set(e,t)}};Oe=new WeakMap;var Ae=new Set([`lazy`,`caseSensitive`,`path`,`id`,`index`,`children`]);function je(e){return Ae.has(e)}var Me=new Set([`lazy`,`caseSensitive`,`path`,`id`,`index`,`middleware`,`children`]);function Ne(e){return Me.has(e)}function Pe(e){return e.index===!0}function Fe(e,t,n=[],r={},i=!1){return e.map((e,a)=>{let o=[...n,String(a)],s=typeof e.id==`string`?e.id:o.join(`-`);if(ye(e.index!==!0||!e.children,`Cannot specify children on an index route`),ye(i||!r[s],`Found a route id collision on id "${s}". Route id's must be globally unique within Data Router usages`),Pe(e)){let n={...e,id:s};return r[s]=Ie(n,t(n)),n}else{let n={...e,id:s,children:void 0};return r[s]=Ie(n,t(n)),e.children&&(n.children=Fe(e.children,t,o,r,i)),n}})}function Ie(e,t){return Object.assign(e,{...t,...typeof t.lazy==`object`&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function Le(e,t,n=`/`){return Re(e,t,n,!1)}function Re(e,t,n,r,i){let a=rt((typeof t==`string`?Te(t):t).pathname||`/`,n);if(a==null)return null;let o=i??Be(e),s=null,c=nt(a);for(let e=0;s==null&&e<o.length;++e)s=$e(o[e],c,r);return s}function ze(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function Be(e){let t=Ve(e);return Ue(t),t}function Ve(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;ye(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=mt([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(ye(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Ve(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Ze(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of He(e.path))a(e,t,!0,n)}),t}function He(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=He(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function Ue(e){e.sort((e,t)=>e.score===t.score?Qe(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var We=/^:[\w-]+$/,Ge=3,Ke=2,qe=1,Je=10,Ye=-2,Xe=e=>e===`*`;function Ze(e,t){let n=e.split(`/`),r=n.length;return n.some(Xe)&&(r+=Ye),t&&(r+=Ke),n.filter(e=>!Xe(e)).reduce((e,t)=>e+(We.test(t)?Ge:t===``?qe:Je),r)}function Qe(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function $e(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=et({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=et({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:mt([a,u.pathname]),pathnameBase:gt(mt([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=mt([a,u.pathnameBase]))}return o}function et(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=tt(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function tt(e,t=!1,n=!0){be(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function nt(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return be(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function rt(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function it({basename:e,pathname:t}){return t===`/`?e:mt([e,t])}var at=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ot=e=>at.test(e);function st(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?Te(e):e,a;return n?(n=pt(n),a=n.startsWith(`/`)?ct(n.substring(1),`/`):ct(n,t)):a=t,{pathname:a,search:_t(r),hash:vt(i)}}function ct(e,t){let n=ht(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function lt(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ut(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function dt(e){let t=ut(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function ft(e,t,n,r=!1){let i;typeof e==`string`?i=Te(e):(i={...e},ye(!i.pathname||!i.pathname.includes(`?`),lt(`?`,`pathname`,`search`,i)),ye(!i.pathname||!i.pathname.includes(`#`),lt(`#`,`pathname`,`hash`,i)),ye(!i.search||!i.search.includes(`#`),lt(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=st(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var pt=e=>e.replace(/\/\/+/g,`/`),mt=e=>pt(e.join(`/`)),ht=e=>e.replace(/\/+$/,``),gt=e=>ht(e).replace(/^\/*/,`/`),_t=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,vt=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,yt=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function bt(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function xt(e){return mt(e.map(e=>e.route.path).filter(Boolean))||`/`}var St=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Ct(e,t){let n=e;if(typeof n!=`string`||!at.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(St)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=rt(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{be(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}var wt=Symbol(`Uninstrumented`);function Tt(e,t){let n={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(e=>e({id:t.id,index:t.index,path:t.path,instrument(e){let t=Object.keys(n);for(let r of t)e[r]&&n[r].push(e[r])}}));let r={};if(typeof t.lazy==`function`&&n.lazy.length>0){let e=Dt(n.lazy,t.lazy,()=>void 0);e&&(r.lazy=e)}if(typeof t.lazy==`object`){let e=t.lazy;[`middleware`,`loader`,`action`].forEach(t=>{let i=e[t],a=n[`lazy.${t}`];if(typeof i==`function`&&a.length>0){let e=Dt(a,i,()=>void 0);e&&(r.lazy=Object.assign(r.lazy||{},{[t]:e}))}})}return[`loader`,`action`].forEach(e=>{let i=t[e];if(typeof i==`function`&&n[e].length>0){let t=i[wt]??i,a=Dt(n[e],t,(...e)=>kt(e[0]));a&&(e===`loader`&&t.hydrate===!0&&(a.hydrate=!0),a[wt]=t,r[e]=a)}}),t.middleware&&t.middleware.length>0&&n.middleware.length>0&&(r.middleware=t.middleware.map(e=>{let t=e[wt]??e,r=Dt(n.middleware,t,(...e)=>kt(e[0]));return r?(r[wt]=t,r):e})),r}function Et(e,t){let n={navigate:[],fetch:[]};if(t.forEach(e=>e({instrument(e){let t=Object.keys(e);for(let r of t)e[r]&&n[r].push(e[r])}})),n.navigate.length>0){let t=e.navigate[wt]??e.navigate,r=Dt(n.navigate,t,(...t)=>{let[n,r]=t;return{to:typeof n==`number`||typeof n==`string`?n:n?we(n):`.`,...At(e,r??{})}});r&&(r[wt]=t,e.navigate=r)}if(n.fetch.length>0){let t=e.fetch[wt]??e.fetch,r=Dt(n.fetch,t,(...t)=>{let[n,,r,i]=t;return{href:r??`.`,fetcherKey:n,...At(e,i??{})}});r&&(r[wt]=t,e.fetch=r)}return e}function Dt(e,t,n){return e.length===0?null:async(...r)=>{let i=await Ot(e,n(...r),()=>t(...r),e.length-1);if(i.type===`error`)throw i.value;return i.value}}async function Ot(e,t,n,r){let i=e[r],a;if(i){let o,s=async()=>(o?console.error(`You cannot call instrumented handlers more than once`):o=Ot(e,t,n,r-1),a=await o,ye(a,`Expected a result`),a.type===`error`&&a.value instanceof Error?{status:`error`,error:a.value}:{status:`success`,error:void 0});try{await i(s,t)}catch(e){console.error(`An instrumentation function threw an error:`,e)}o||await s(),await o}else try{a={type:`success`,value:await n()}}catch(e){a={type:`error`,value:e}}return a||{type:`error`,value:Error(`No result assigned in instrumentation chain.`)}}function kt(e){let{request:t,context:n,params:r,pattern:i}=e;return{request:jt(t),params:{...r},pattern:i,context:Mt(n)}}function At(e,t){return{currentUrl:we(e.state.location),...`formMethod`in t?{formMethod:t.formMethod}:{},...`formEncType`in t?{formEncType:t.formEncType}:{},...`formData`in t?{formData:t.formData}:{},...`body`in t?{body:t.body}:{}}}function jt(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function Mt(e){if(Pt(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var Nt=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function Pt(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===Nt}var Ft=[`POST`,`PUT`,`PATCH`,`DELETE`],It=new Set(Ft),Lt=[`GET`,...Ft],Rt=new Set(Lt),zt=new Set([301,302,303,307,308]),Bt=new Set([307,308]),Vt={state:`idle`,location:void 0,matches:void 0,historyAction:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Ht={state:`idle`,data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Ut={state:`unblocked`,proceed:void 0,reset:void 0,location:void 0},Wt=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),Gt=`remix-router-transitions`,Kt=Symbol(`ResetLoaderData`),qt,Jt,Yt,Xt,Zt=class{constructor(e){me(this,qt),me(this,Jt),me(this,Yt),me(this,Xt),he(this,qt,e),he(this,Jt,Be(e))}get stableRoutes(){return pe(this,qt)}get activeRoutes(){return pe(this,Yt)??pe(this,qt)}get branches(){return pe(this,Xt)??pe(this,Jt)}get hasHMRRoutes(){return pe(this,Yt)!=null}setRoutes(e){he(this,qt,e),he(this,Jt,Be(e))}setHmrRoutes(e){he(this,Yt,e),he(this,Xt,Be(e))}commitHmrRoutes(){pe(this,Yt)&&(he(this,qt,pe(this,Yt)),he(this,Jt,pe(this,Xt)),he(this,Yt,void 0),he(this,Xt,void 0))}};qt=new WeakMap,Jt=new WeakMap,Yt=new WeakMap,Xt=new WeakMap;function eee(e){let t=e.window?e.window:typeof window<`u`?window:void 0,n=t!==void 0&&t.document!==void 0&&t.document.createElement!==void 0;ye(e.routes.length>0,`You must provide a non-empty routes array to createRouter`);let r=e.hydrationRouteProperties||[],i=e.mapRouteProperties||Wt,a=i;if(e.instrumentations){let t=e.instrumentations;a=e=>({...i(e),...Tt(t.map(e=>e.route).filter(Boolean),e)})}let o={},s=new Zt(Fe(e.routes,a,void 0,o)),c=e.basename||`/`;c.startsWith(`/`)||(c=`/${c}`);let l=e.dataStrategy||ree,u={...e.future},d=null,f=new Set,p=null,m=null,h=null,g=null,_=e.hydrationData!=null,v=Re(s.activeRoutes,e.history.location,c,!1,s.branches),y=!1,b=null,x,S;if(v==null&&!e.patchRoutesOnNavigation){let t=Fn(404,{pathname:e.history.location.pathname}),{matches:n,route:r}=Pn(s.activeRoutes);x=!0,S=!x,v=n,b={[r.id]:t}}else if(v&&!e.hydrationData&&Ve(v,s.activeRoutes,e.history.location.pathname).active&&(v=null),!v){x=!1,S=!x,v=[];let t=Ve(null,s.activeRoutes,e.history.location.pathname);t.active&&t.matches&&(y=!0,v=t.matches)}else if(v.some(e=>e.route.lazy))x=!1,S=!x;else if(!v.some(e=>tn(e.route)))x=!0,S=!x;else{let t=e.hydrationData?e.hydrationData.loaderData:null,n=e.hydrationData?e.hydrationData.errors:null,r=v;if(n){let e=v.findIndex(e=>n[e.route.id]!==void 0);r=r.slice(0,e+1)}S=!1,x=!0,r.forEach(e=>{let r=nn(e.route,t,n);S||=r.renderFallback,x&&=!r.shouldLoad})}let C,w={historyAction:e.history.action,location:e.history.location,matches:v,initialized:x,renderFallback:S,navigation:Vt,restoreScrollPosition:e.hydrationData==null?null:!1,preventScrollReset:!1,revalidation:`idle`,loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||b,fetchers:new Map,blockers:new Map},T=`POP`,E=null,D=!1,O,k=!1,A=new Map,j=null,M=!1,N=!1,P=new Set,F=new Map,I=0,L=-1,R=new Map,z=new Set,B=new Map,V=new Map,H=new Set,U=new Map,W,G=null;function K(){if(d=e.history.listen(({action:t,location:n,delta:r})=>{if(W){W(),W=void 0;return}be(U.size===0||r!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let i=Me({currentLocation:w.location,nextLocation:n,historyAction:t});if(i&&r!=null){let t=new Promise(e=>{W=e});e.history.go(r*-1),je(i,{state:`blocked`,location:n,proceed(){je(i,{state:`proceeding`,proceed:void 0,reset:void 0,location:n}),t.then(()=>e.history.go(r))},reset(){let e=new Map(w.blockers);e.set(i,Ut),J({blockers:e})}}),E?.resolve(),E=null;return}return re(t,n)}),n){tr(t,A);let e=()=>nr(t,A);t.addEventListener(`pagehide`,e),j=()=>t.removeEventListener(`pagehide`,e)}return w.initialized||re(`POP`,w.location,{initialHydration:!0}),C}function q(){d&&d(),j&&j(),f.clear(),O&&O.abort(),w.fetchers.forEach((e,t)=>_e(w.fetchers,t)),w.blockers.forEach((e,t)=>Ae(t))}function ee(e){if(f.add(e),p){let{newErrors:t}=p;p=null,e(w,{deletedFetchers:[],newErrors:t,viewTransitionOpts:void 0,flushSync:!1})}return()=>f.delete(e)}function J(e,t={}){e.matches&&=e.matches.map(e=>{let t=o[e.route.id],n=e.route;return n.element!==t.element||n.errorElement!==t.errorElement||n.hydrateFallbackElement!==t.hydrateFallbackElement?{...e,route:t}:e}),w={...w,...e};let n=[],r=[];w.fetchers.forEach((e,t)=>{e.state===`idle`&&(H.has(t)?n.push(t):r.push(t))}),H.forEach(e=>{!w.fetchers.has(e)&&!F.has(e)&&n.push(e)}),f.size===0&&(p={newErrors:e.errors??null}),[...f].forEach(r=>r(w,{deletedFetchers:n,newErrors:e.errors??null,viewTransitionOpts:t.viewTransitionOpts,flushSync:t.flushSync===!0})),n.forEach(e=>_e(w.fetchers,e)),r.forEach(e=>w.fetchers.delete(e))}function te(t,n,{flushSync:r}={}){let i=w.actionData!=null&&w.navigation.formMethod!=null&&Kn(w.navigation.formMethod)&&w.navigation.state===`loading`&&t.state?._isRedirect!==!0,a;a=n.actionData?Object.keys(n.actionData).length>0?n.actionData:null:i?w.actionData:null;let o=n.loaderData?jn(w.loaderData,n.loaderData,n.matches||[],n.errors):w.loaderData,c=w.blockers;c.size>0&&(c=new Map(c),c.forEach((e,t)=>c.set(t,Ut)));let l=M?!1:Be(t,n.matches||w.matches),u=D===!0||w.navigation.formMethod!=null&&Kn(w.navigation.formMethod)&&t.state?._isRedirect!==!0;s.commitHmrRoutes(),M||T===`POP`||(T===`PUSH`?e.history.push(t,t.state):T===`REPLACE`&&e.history.replace(t,t.state));let d;if(T===`POP`){let e=A.get(w.location.pathname);e&&e.has(t.pathname)?d={currentLocation:w.location,nextLocation:t}:A.has(t.pathname)&&(d={currentLocation:t,nextLocation:w.location})}else if(k){let e=A.get(w.location.pathname);e?e.add(t.pathname):(e=new Set([t.pathname]),A.set(w.location.pathname,e)),d={currentLocation:w.location,nextLocation:t}}J({...n,actionData:a,loaderData:o,historyAction:T,location:t,initialized:!0,renderFallback:!1,navigation:Vt,revalidation:`idle`,restoreScrollPosition:l,preventScrollReset:u,blockers:c},{viewTransitionOpts:d,flushSync:r===!0}),T=`POP`,D=!1,k=!1,M=!1,N=!1,E?.resolve(),E=null,G?.resolve(),G=null}async function Y(t,n){if(E?.resolve(),E=null,typeof t==`number`){E||=rr();let n=E.promise;return e.history.go(t),n}let{path:r,submission:i,error:a}=$t(!1,Qt(w.location,w.matches,c,t,n?.fromRouteId,n?.relative),n),o;n?.mask&&(o={pathname:``,search:``,hash:``,...typeof n.mask==`string`?Te(n.mask):{...w.location.mask,...n.mask}});let s=w.location,l=Ce(s,r,n&&n.state,void 0,o);l={...l,...e.history.encodeLocation(l)};let u=n&&n.replace!=null?n.replace:void 0,d=`PUSH`;u===!0?d=`REPLACE`:u===!1||i!=null&&Kn(i.formMethod)&&i.formAction===w.location.pathname+w.location.search&&(d=`REPLACE`);let f=n&&`preventScrollReset`in n?n.preventScrollReset===!0:void 0,p=(n&&n.flushSync)===!0,m=Me({currentLocation:s,nextLocation:l,historyAction:d});if(m){je(m,{state:`blocked`,location:l,proceed(){je(m,{state:`proceeding`,proceed:void 0,reset:void 0,location:l}),Y(t,n)},reset(){let e=new Map(w.blockers);e.set(m,Ut),J({blockers:e})}});return}await re(d,l,{submission:i,pendingError:a,preventScrollReset:f,replace:n&&n.replace,enableViewTransition:n&&n.viewTransition,flushSync:p,callSiteDefaultShouldRevalidate:n&&n.defaultShouldRevalidate})}function ne(){G||=rr(),fe(),J({revalidation:`loading`});let e=G.promise;return w.navigation.state===`submitting`?e:w.navigation.state===`idle`?(re(w.historyAction,w.location,{startUninterruptedRevalidation:!0}),e):(re(T||w.historyAction,w.navigation.location,{overrideNavigation:w.navigation,enableViewTransition:k===!0}),e)}async function re(t,n,r){O&&O.abort(),O=null,T=t,M=(r&&r.startUninterruptedRevalidation)===!0,Le(w.location,w.matches),D=(r&&r.preventScrollReset)===!0,k=(r&&r.enableViewTransition)===!0;let i=s.activeRoutes,a=r?.initialHydration&&w.matches&&w.matches.length>0&&!y?w.matches:Re(i,n,c,!1,s.branches),o=(r&&r.flushSync)===!0;if(a&&w.initialized&&!N&&aee(w.location,n)&&!(r&&r.submission&&Kn(r.submission.formMethod))){te(n,{matches:a},{flushSync:o});return}let l=Ve(a,i,n.pathname);if(l.active&&l.matches&&(a=l.matches),!a){let{error:e,notFoundMatches:t,route:r}=Ne(n.pathname);te(n,{matches:t,loaderData:{},errors:{[r.id]:e}},{flushSync:o});return}let u=r&&r.overrideNavigation?{...r.overrideNavigation,matches:a,historyAction:t}:void 0;O=new AbortController;let d=Tn(e.history,n,O.signal,r&&r.submission),f=e.getContext?await e.getContext():new ke,p;if(r&&r.pendingError)p=[Nn(a).route.id,{type:`error`,error:r.pendingError}];else if(r&&r.submission&&Kn(r.submission.formMethod)){let i=await X(d,n,r.submission,a,t,f,l.active,r&&r.initialHydration===!0,{replace:r.replace,flushSync:o});if(i.shortCircuited)return;if(i.pendingActionResult){let[e,t]=i.pendingActionResult;if(zn(t)&&bt(t.error)&&t.error.status===404){O=null,te(n,{matches:i.matches,loaderData:{},errors:{[e]:t.error}});return}}a=i.matches||a,p=i.pendingActionResult,u=Xn(n,a,t,r.submission),o=!1,l.active=!1,d=Tn(e.history,d.url,d.signal)}let{shortCircuited:m,matches:h,loaderData:g,errors:_,workingFetchers:v}=await ie(d,n,a,t,f,l.active,u,r&&r.submission,r&&r.fetcherSubmission,r&&r.replace,r&&r.initialHydration===!0,o,p,r&&r.callSiteDefaultShouldRevalidate);m||(O=null,te(n,{matches:h||a,...Mn(p),loaderData:g,errors:_,...v?{fetchers:v}:{}}))}async function X(t,n,i,l,u,d,f,p,m={}){if(fe(),J({navigation:Zn(n,l,u,i)},{flushSync:m.flushSync===!0}),f){let e=await He(l,n.pathname,t.signal);if(e.type===`aborted`)return{shortCircuited:!0};if(e.type===`error`){if(e.partialMatches.length===0){let{matches:t,route:n}=Pn(s.activeRoutes);return{matches:t,pendingActionResult:[n.id,{type:`error`,error:e.error}]}}let t=Nn(e.partialMatches).route.id;return{matches:e.partialMatches,pendingActionResult:[t,{type:`error`,error:e.error}]}}else if(e.matches)l=e.matches;else{let{notFoundMatches:e,error:t,route:r}=Ne(n.pathname);return{matches:e,pendingActionResult:[r.id,{type:`error`,error:t}]}}}let h,g=Jn(l,n);if(!g.route.action&&!g.route.lazy)h={type:`error`,error:Fn(405,{method:t.method,pathname:n.pathname,routeId:g.route.id})};else{let e=await Z(t,n,_n(a,o,t,n,l,g,p?[]:r,d),d,null);if(h=e[g.route.id],!h){for(let t of l)if(e[t.route.id]){h=e[t.route.id];break}}if(t.signal.aborted)return{shortCircuited:!0}}if(Bn(h)){let n;return n=m&&m.replace!=null?m.replace:wn(h.response.headers.get(`Location`),new URL(t.url),c,e.history)===w.location.pathname+w.location.search,await ue(t,h,!0,{submission:i,replace:n}),{shortCircuited:!0}}if(zn(h)){let e=Nn(l,g.route.id);return(m&&m.replace)!==!0&&(T=`PUSH`),{matches:l,pendingActionResult:[e.route.id,h,g.route.id]}}return{matches:l,pendingActionResult:[g.route.id,h]}}async function ie(t,n,i,l,u,d,f,p,m,h,g,_,v,y){let b=f||Xn(n,i,l,p),x=p||m||Yn(b),S=!M&&!g;if(d){if(S){let e=ae(v);J({navigation:b,...e===void 0?{}:{actionData:e}},{flushSync:_})}let e=await He(i,n.pathname,t.signal);if(e.type===`aborted`)return{shortCircuited:!0};if(e.type===`error`){if(e.partialMatches.length===0){let{matches:t,route:n}=Pn(s.activeRoutes);return{matches:t,loaderData:{},errors:{[n.id]:e.error}}}let t=Nn(e.partialMatches).route.id;return{matches:e.partialMatches,loaderData:{},errors:{[t]:e.error}}}else if(e.matches)i=e.matches;else{let{error:e,notFoundMatches:t,route:r}=Ne(n.pathname);return{matches:t,loaderData:{},errors:{[r.id]:e}}}}let C=s.activeRoutes,{dsMatches:T,revalidatingFetchers:E}=en(t,u,a,o,e.history,w,i,x,n,g?[]:r,g===!0,N,P,H,B,z,C,c,e.patchRoutesOnNavigation!=null,s.branches,v,y);if(L=++I,!e.dataStrategy&&!T.some(e=>e.shouldLoad)&&!T.some(e=>e.route.middleware&&e.route.middleware.length>0)&&E.length===0){let e=new Map(w.fetchers),t=we(e);return te(n,{matches:i,loaderData:{},errors:v&&zn(v[1])?{[v[0]]:v[1].error}:null,...Mn(v),...t?{fetchers:e}:{}},{flushSync:_}),{shortCircuited:!0}}if(S){let e={};if(!d){e.navigation=b;let t=ae(v);t!==void 0&&(e.actionData=t)}E.length>0&&(e.fetchers=oe(E)),J(e,{flushSync:_})}E.forEach(e=>{xe(e.key),e.controller&&F.set(e.key,e.controller)});let D=()=>E.forEach(e=>xe(e.key));O&&O.signal.addEventListener(`abort`,D);let{loaderResults:k,fetcherResults:A}=await de(T,E,t,n,u);if(t.signal.aborted)return{shortCircuited:!0};O&&O.signal.removeEventListener(`abort`,D),E.forEach(e=>F.delete(e.key));let j=In(k);if(j)return await ue(t,j.result,!0,{replace:h}),{shortCircuited:!0};if(j=In(A),j)return z.add(j.key),await ue(t,j.result,!0,{replace:h}),{shortCircuited:!0};let R=new Map(w.fetchers),{loaderData:V,errors:U}=An(w,i,k,v,E,A,R);g&&w.errors&&(U={...w.errors,...U});let W=we(R),G=Ee(L,R),K=W||G||E.length>0;return{matches:i,loaderData:V,errors:U,...K?{workingFetchers:R}:{}}}function ae(e){if(e&&!zn(e[1]))return{[e[0]]:e[1].data};if(w.actionData)return Object.keys(w.actionData).length===0?null:w.actionData}function oe(e){let t=new Map(w.fetchers);return e.forEach(e=>{let n=t.get(e.key),r=Qn(void 0,n?n.data:void 0);t.set(e.key,r)}),t}async function se(t,n,r,i){xe(t);let a=(i&&i.flushSync)===!0,o=s.activeRoutes,l=Qt(w.location,w.matches,c,r,n,i?.relative),u=Re(o,l,c,!1,s.branches),d=Ve(u,o,l);if(d.active&&d.matches&&(u=d.matches),!u){me(t,n,Fn(404,{pathname:l}),{flushSync:a});return}let{path:f,submission:p,error:m}=$t(!0,l,i);if(m){me(t,n,m,{flushSync:a});return}let h=e.getContext?await e.getContext():new ke,g=(i&&i.preventScrollReset)===!0;if(p&&Kn(p.formMethod)){await ce(t,n,f,u,h,d.active,a,g,p,i&&i.defaultShouldRevalidate);return}B.set(t,{routeId:n,path:f}),await le(t,n,f,u,h,d.active,a,g,p)}async function ce(t,n,i,l,u,d,f,p,m,h){fe(),B.delete(t),pe(t,$n(m,w.fetchers.get(t)),{flushSync:f});let g=new AbortController,_=Tn(e.history,i,g.signal,m);if(d){let e=await He(l,new URL(_.url).pathname,_.signal,t);if(e.type===`aborted`)return;if(e.type===`error`){me(t,n,e.error,{flushSync:f});return}else if(e.matches)l=e.matches;else{me(t,n,Fn(404,{pathname:i}),{flushSync:f});return}}let v=Jn(l,i);if(!v.route.action&&!v.route.lazy){me(t,n,Fn(405,{method:m.formMethod,pathname:i,routeId:n}),{flushSync:f});return}F.set(t,g);let y=I,b=_n(a,o,_,i,l,v,r,u),x=await Z(_,i,b,u,t),S=x[v.route.id];if(!S){for(let e of b)if(x[e.route.id]){S=x[e.route.id];break}}if(_.signal.aborted){F.get(t)===g&&F.delete(t);return}if(H.has(t)){if(Bn(S)||zn(S)){pe(t,er(void 0));return}}else{if(Bn(S))if(F.delete(t),L>y){pe(t,er(void 0));return}else return z.add(t),pe(t,Qn(m)),ue(_,S,!1,{fetcherSubmission:m,preventScrollReset:p});if(zn(S)){me(t,n,S.error);return}}let C=w.navigation.location||w.location,E=Tn(e.history,C,g.signal),D=s.activeRoutes,k=w.navigation.state===`idle`?w.matches:Re(D,w.navigation.location,c,!1,s.branches);ye(k,`Didn't find any matches after fetcher action`);let A=++I;R.set(t,A);let{dsMatches:j,revalidatingFetchers:M}=en(E,u,a,o,e.history,w,k,m,C,r,!1,N,P,H,B,z,D,c,e.patchRoutesOnNavigation!=null,s.branches,[v.route.id,S],h),V=Qn(m,S.data),U=new Map(w.fetchers);U.set(t,V),M.filter(e=>e.key!==t).forEach(e=>{let t=e.key,n=U.get(t),r=Qn(void 0,n?n.data:void 0);U.set(t,r),xe(t),e.controller&&F.set(t,e.controller)}),J({fetchers:U});let W=()=>M.forEach(e=>xe(e.key));g.signal.addEventListener(`abort`,W);let{loaderResults:G,fetcherResults:K}=await de(j,M,E,C,u);if(g.signal.aborted)return;g.signal.removeEventListener(`abort`,W),R.delete(t),F.delete(t),M.forEach(e=>F.delete(e.key));let q=w.fetchers.has(t),ee=e=>{if(!q)return e;let n=new Map(e.fetchers);return n.set(t,er(S.data)),{...e,fetchers:n}},Y=In(G);if(Y)return w=ee(w),ue(E,Y.result,!1,{preventScrollReset:p});if(Y=In(K),Y)return z.add(Y.key),w=ee(w),ue(E,Y.result,!1,{preventScrollReset:p});let ne=new Map(w.fetchers);q&&ne.set(t,er(S.data));let{loaderData:re,errors:X}=An(w,k,G,void 0,M,K,ne);Ee(A,ne),w.navigation.state===`loading`&&A>L?(ye(T,`Expected pending action`),O&&O.abort(),te(w.navigation.location,{matches:k,loaderData:re,errors:X,fetchers:ne})):(J({errors:X,loaderData:jn(w.loaderData,re,k,X),fetchers:ne}),N=!1)}async function le(t,n,i,s,c,l,u,d,f){let p=w.fetchers.get(t);pe(t,Qn(f,p?p.data:void 0),{flushSync:u});let m=new AbortController,h=Tn(e.history,i,m.signal);if(l){let e=await He(s,new URL(h.url).pathname,h.signal,t);if(e.type===`aborted`)return;if(e.type===`error`){me(t,n,e.error,{flushSync:u});return}else if(e.matches)s=e.matches;else{me(t,n,Fn(404,{pathname:i}),{flushSync:u});return}}let g=Jn(s,i);F.set(t,m);let _=I,v=await Z(h,i,_n(a,o,h,i,s,g,r,c),c,t),y=v[g.route.id];if(!y){for(let e of s)if(v[e.route.id]){y=v[e.route.id];break}}if(F.get(t)===m&&F.delete(t),!h.signal.aborted){if(H.has(t)){pe(t,er(void 0));return}if(Bn(y))if(L>_){pe(t,er(void 0));return}else{z.add(t),await ue(h,y,!1,{preventScrollReset:d});return}if(zn(y)){me(t,n,y.error);return}pe(t,er(y.data))}}async function ue(r,i,a,{submission:o,fetcherSubmission:s,preventScrollReset:l,replace:u}={}){a||(E?.resolve(),E=null),i.response.headers.has(`X-Remix-Revalidate`)&&(N=!0);let d=i.response.headers.get(`Location`);ye(d,`Expected a Location header on the redirect Response`),d=wn(d,new URL(r.url),c,e.history);let f=Ce(w.location,d,{_isRedirect:!0});if(n){let e=!1;if(i.response.headers.has(`X-Remix-Reload-Document`))e=!0;else if(ot(d)){let n=De(t,d,!0);e=n.origin!==t.location.origin||rt(n.pathname,c)==null}if(e){u?t.location.replace(d):t.location.assign(d);return}}O=null;let p=u===!0||i.response.headers.has(`X-Remix-Replace`)?`REPLACE`:`PUSH`,{formMethod:m,formAction:h,formEncType:g}=w.navigation;!o&&!s&&m&&h&&g&&(o=Yn(w.navigation));let _=o||s;Bt.has(i.response.status)&&_&&Kn(_.formMethod)?await re(p,f,{submission:{..._,formAction:d},preventScrollReset:l||D,enableViewTransition:a?k:void 0}):await re(p,f,{overrideNavigation:Xn(f,[],p,o),fetcherSubmission:s,preventScrollReset:l||D,enableViewTransition:a?k:void 0})}async function Z(e,t,n,r,i){let a,o={};try{a=await vn(l,e,t,n,i,r,!1)}catch(e){return n.filter(e=>e.shouldLoad).forEach(t=>{o[t.route.id]={type:`error`,error:e}}),o}if(e.signal.aborted)return o;if(!Kn(e.method))for(let e of n){if(a[e.route.id]?.type===`error`)break;!a.hasOwnProperty(e.route.id)&&!w.loaderData.hasOwnProperty(e.route.id)&&(!w.errors||!w.errors.hasOwnProperty(e.route.id))&&e.shouldCallHandler()&&(a[e.route.id]={type:`error`,result:Error(`No result returned from dataStrategy for route ${e.route.id}`)})}for(let[t,r]of Object.entries(a))if(Rn(r)){let i=r.result;o[t]={type:`redirect`,response:Sn(i,e,t,n,c)}}else o[t]=await xn(r);return o}async function de(e,t,n,r,i){let a=Z(n,r,e,i,null),o=Promise.all(t.map(async e=>{if(e.matches&&e.match&&e.request&&e.controller){let t=(await Z(e.request,e.path,e.matches,i,e.key))[e.match.route.id];return{[e.key]:t}}else return Promise.resolve({[e.key]:{type:`error`,error:Fn(404,{pathname:e.path})}})}));return{loaderResults:await a,fetcherResults:(await o).reduce((e,t)=>Object.assign(e,t),{})}}function fe(){N=!0,B.forEach((e,t)=>{F.has(t)&&P.add(t),xe(t)})}function pe(e,t,n={}){let r=new Map(w.fetchers);r.set(e,t),J({fetchers:r},{flushSync:(n&&n.flushSync)===!0})}function me(e,t,n,r={}){let i=Nn(w.matches,t),a=new Map(w.fetchers);_e(a,e),J({errors:{[i.route.id]:n},fetchers:a},{flushSync:(r&&r.flushSync)===!0})}function he(e){return V.set(e,(V.get(e)||0)+1),H.has(e)&&H.delete(e),w.fetchers.get(e)||Ht}function ge(e,t){xe(e,t?.reason),pe(e,er(null))}function _e(e,t){let n=w.fetchers.get(t);F.has(t)&&!(n&&n.state===`loading`&&R.has(t))&&xe(t),B.delete(t),R.delete(t),z.delete(t),H.delete(t),P.delete(t),e.delete(t)}function ve(e){let t=(V.get(e)||0)-1;t<=0?(V.delete(e),H.add(e)):V.set(e,t),J({fetchers:new Map(w.fetchers)})}function xe(e,t){let n=F.get(e);n&&(n.abort(t),F.delete(e))}function Se(e,t){for(let n of e){let e=t.get(n);ye(e,`Expected fetcher: ${n}`);let r=er(e.data);t.set(n,r)}}function we(e){let t=[],n=!1;for(let r of z){let i=e.get(r);ye(i,`Expected fetcher: ${r}`),i.state===`loading`&&(z.delete(r),t.push(r),n=!0)}return Se(t,e),n}function Ee(e,t){let n=[];for(let[r,i]of R)if(i<e){let e=t.get(r);ye(e,`Expected fetcher: ${r}`),e.state===`loading`&&(xe(r),R.delete(r),n.push(r))}return Se(n,t),n.length>0}function Oe(e,t){let n=w.blockers.get(e)||Ut;return U.get(e)!==t&&U.set(e,t),n}function Ae(e){w.blockers.delete(e),U.delete(e)}function je(e,t){let n=w.blockers.get(e)||Ut;ye(n.state===`unblocked`&&t.state===`blocked`||n.state===`blocked`&&t.state===`blocked`||n.state===`blocked`&&t.state===`proceeding`||n.state===`blocked`&&t.state===`unblocked`||n.state===`proceeding`&&t.state===`unblocked`,`Invalid blocker state transition: ${n.state} -> ${t.state}`);let r=new Map(w.blockers);r.set(e,t),J({blockers:r})}function Me({currentLocation:e,nextLocation:t,historyAction:n}){if(U.size===0)return;U.size>1&&be(!1,`A router only supports one blocker at a time`);let r=Array.from(U.entries()),[i,a]=r[r.length-1],o=w.blockers.get(i);if(!(o&&o.state===`proceeding`)&&a({currentLocation:e,nextLocation:t,historyAction:n}))return i}function Ne(e){let t=Fn(404,{pathname:e}),n=s.activeRoutes,{matches:r,route:i}=Pn(n);return{notFoundMatches:r,route:i,error:t}}function Pe(e,t,n){if(m=e,g=t,h=n||null,!_&&w.navigation===Vt){_=!0;let e=Be(w.location,w.matches);e!=null&&J({restoreScrollPosition:e})}return()=>{m=null,g=null,h=null}}function Ie(e,t){return h&&h(e,t.map(e=>ze(e,w.loaderData)))||e.key}function Le(e,t){if(m&&g){let n=Ie(e,t);m[n]=g()}}function Be(e,t){if(m){let n=Ie(e,t),r=m[n];if(typeof r==`number`)return r}return null}function Ve(t,n,r){if(e.patchRoutesOnNavigation){let e=s.branches;if(!t)return{active:!0,matches:Re(n,r,c,!0,e)||[]};if(Object.keys(t[0].params).length>0)return{active:!0,matches:Re(n,r,c,!0,e)}}return{active:!1,matches:null}}async function He(t,n,r,i){if(!e.patchRoutesOnNavigation)return{type:`success`,matches:t};let l=t;for(;;){let t=o;try{await e.patchRoutesOnNavigation({signal:r,path:n,matches:l,fetcherKey:i,patch:(e,n)=>{r.aborted||sn(e,n,s,t,a,!1)}})}catch(e){return{type:`error`,error:e,partialMatches:l}}if(r.aborted)return{type:`aborted`};let u=s.branches,d=Re(s.activeRoutes,n,c,!1,u),f=null;if(d&&(Object.keys(d[0].params).length===0||(f=Re(s.activeRoutes,n,c,!0,u),!(f&&l.length<f.length&&Ue(l,f.slice(0,l.length))))))return{type:`success`,matches:d};if(f||=Re(s.activeRoutes,n,c,!0,u),!f||Ue(l,f))return{type:`success`,matches:null};l=f}}function Ue(e,t){return e.length===t.length&&e.every((e,n)=>e.route.id===t[n].route.id)}function We(e){o={},s.setHmrRoutes(Fe(e,a,void 0,o))}function Ge(e,t,n=!1){sn(e,t,s,o,a,n),s.hasHMRRoutes||J({})}return C={get basename(){return c},get future(){return u},get state(){return w},get routes(){return s.stableRoutes},get branches(){return s.branches},get manifest(){return o},get window(){return t},initialize:K,subscribe:ee,enableScrollRestoration:Pe,navigate:Y,fetch:se,revalidate:ne,createHref:t=>e.history.createHref(t),encodeLocation:t=>e.history.encodeLocation(t),getFetcher:he,resetFetcher:ge,deleteFetcher:ve,dispose:q,getBlocker:Oe,deleteBlocker:Ae,patchRoutes:Ge,_internalFetchControllers:F,_internalSetRoutes:We,_internalSetStateDoNotUseOrYouWillBreakYourApp(e){J(e)}},e.instrumentations&&(C=Et(C,e.instrumentations.map(e=>e.router).filter(Boolean))),C}function tee(e){return e!=null&&(`formData`in e&&e.formData!=null||`body`in e&&e.body!==void 0)}function Qt(e,t,n,r,i,a){let o,s;if(i){o=[];for(let e of t)if(o.push(e),e.route.id===i){s=e;break}}else o=t,s=t[t.length-1];let c=ft(r||`.`,dt(o),rt(e.pathname,n)||e.pathname,a===`path`);if(r??(c.search=e.search,c.hash=e.hash),(r==null||r===``||r===`.`)&&s){let e=qn(c.search);if(s.route.index&&!e)c.search=c.search?c.search.replace(/^\?/,`?index&`):`?index`;else if(!s.route.index&&e){let e=new URLSearchParams(c.search),t=e.getAll(`index`);e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();c.search=n?`?${n}`:``}}return n!==`/`&&(c.pathname=it({basename:n,pathname:c.pathname})),we(c)}function $t(e,t,n){if(!n||!tee(n))return{path:t};if(n.formMethod&&!Gn(n.formMethod))return{path:t,error:Fn(405,{method:n.formMethod})};let r=()=>({path:t,error:Fn(400,{type:`invalid-body`})}),i=(n.formMethod||`get`).toUpperCase(),a=Ln(t);if(n.body!==void 0){if(n.formEncType===`text/plain`){if(!Kn(i))return r();let e=typeof n.body==`string`?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((e,[t,n])=>`${e}${t}=${n}
3
3
  `,``):String(n.body);return{path:t,submission:{formMethod:i,formAction:a,formEncType:n.formEncType,formData:void 0,json:void 0,text:e}}}else if(n.formEncType===`application/json`){if(!Kn(i))return r();try{let e=typeof n.body==`string`?JSON.parse(n.body):n.body;return{path:t,submission:{formMethod:i,formAction:a,formEncType:n.formEncType,formData:void 0,json:e,text:void 0}}}catch{return r()}}}ye(typeof FormData==`function`,`FormData is not available in this environment`);let o,s;if(n.formData)o=Dn(n.formData),s=n.formData;else if(n.body instanceof FormData)o=Dn(n.body),s=n.body;else if(n.body instanceof URLSearchParams)o=n.body,s=On(o);else if(n.body==null)o=new URLSearchParams,s=new FormData;else try{o=new URLSearchParams(n.body),s=On(o)}catch{return r()}let c={formMethod:i,formAction:a,formEncType:n&&n.formEncType||`application/x-www-form-urlencoded`,formData:s,json:void 0,text:void 0};if(Kn(c.formMethod))return{path:t,submission:c};let l=Te(t);return e&&l.search&&qn(l.search)&&o.append(`index`,``),l.search=`?${o}`,{path:we(l),submission:c}}function en(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x){let S=b?zn(b[1])?b[1].error:b[1].data:void 0,C=i.createURL(a.location),w=i.createURL(c),T;if(u&&a.errors){let e=Object.keys(a.errors)[0];T=o.findIndex(t=>t.route.id===e)}else if(b&&zn(b[1])){let e=b[0];T=o.findIndex(t=>t.route.id===e)-1}let E=b?b[1].statusCode:void 0,D=E&&E>=400,O={currentUrl:C,currentParams:a.matches[0]?.params||{},nextUrl:w,nextParams:o[0].params,...s,actionResult:S,actionStatus:E},k=xt(o),A=o.map((i,o)=>{let{route:s}=i,f=null;if(T!=null&&o>T)f=!1;else if(s.lazy)f=!0;else if(!tn(s))f=!1;else if(u){let{shouldLoad:e}=nn(s,a.loaderData,a.errors);f=e}else rn(a.loaderData,a.matches[o],i)&&(f=!0);if(f!==null)return gn(n,r,e,c,k,i,l,t,f);let p=!1;typeof x==`boolean`?p=x:D?p=!1:d||C.pathname+C.search===w.pathname+w.search?p=!0:C.search===w.search?an(a.matches[o],i)&&(p=!0):p=!0;let m={...O,defaultShouldRevalidate:p};return gn(n,r,e,c,k,i,l,t,on(i,m),m,x)}),j=[];return m.forEach((e,s)=>{if(u||!o.some(t=>t.route.id===e.routeId)||p.has(s))return;let c=a.fetchers.get(s),m=c&&c.state!==`idle`&&c.data===void 0,b=Re(g,e.path,_??`/`,!1,y);if(!b){if(v&&m)return;j.push({key:s,routeId:e.routeId,path:e.path,matches:null,match:null,request:null,controller:null});return}if(h.has(s))return;let S=Jn(b,e.path),C=new AbortController,w=Tn(i,e.path,C.signal),T=null;if(f.has(s))f.delete(s),T=_n(n,r,w,e.path,b,S,l,t);else if(m)d&&(T=_n(n,r,w,e.path,b,S,l,t));else{let i;i=typeof x==`boolean`?x:D?!1:d;let a={...O,defaultShouldRevalidate:i};on(S,a)&&(T=_n(n,r,w,e.path,b,S,l,t,a))}T&&j.push({key:s,routeId:e.routeId,path:e.path,matches:T,match:S,request:w,controller:C})}),{dsMatches:A,revalidatingFetchers:j}}function tn(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function nn(e,t,n){if(e.lazy)return{shouldLoad:!0,renderFallback:!0};if(!tn(e))return{shouldLoad:!1,renderFallback:!1};let r=t!=null&&e.id in t,i=n!=null&&n[e.id]!==void 0;if(!r&&i)return{shouldLoad:!1,renderFallback:!1};if(typeof e.loader==`function`&&e.loader.hydrate===!0)return{shouldLoad:!0,renderFallback:!r};let a=!r&&!i;return{shouldLoad:a,renderFallback:a}}function rn(e,t,n){let r=!t||n.route.id!==t.route.id,i=!e.hasOwnProperty(n.route.id);return r||i}function an(e,t){let n=e.route.path;return e.pathname!==t.pathname||n!=null&&n.endsWith(`*`)&&e.params[`*`]!==t.params[`*`]}function on(e,t){if(e.route.shouldRevalidate){let n=e.route.shouldRevalidate(t);if(typeof n==`boolean`)return n}return t.defaultShouldRevalidate}function sn(e,t,n,r,i,a){let o;if(e){let t=r[e];ye(t,`No route found to patch children into: routeId = ${e}`),t.children||=[],o=t.children}else o=n.activeRoutes;let s=[],c=[];if(t.forEach(e=>{let t=o.find(t=>cn(e,t));t?c.push({existingRoute:t,newRoute:e}):s.push(e)}),s.length>0){let t=Fe(s,i,[e||`_`,`patch`,String(o?.length||`0`)],r);o.push(...t)}if(a&&c.length>0)for(let e=0;e<c.length;e++){let{existingRoute:t,newRoute:n}=c[e],r=t,[a]=Fe([n],i,[],{},!0);Object.assign(r,{element:a.element?a.element:r.element,errorElement:a.errorElement?a.errorElement:r.errorElement,hydrateFallbackElement:a.hydrateFallbackElement?a.hydrateFallbackElement:r.hydrateFallbackElement})}n.hasHMRRoutes||n.setRoutes([...n.activeRoutes])}function cn(e,t){return`id`in e&&`id`in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children?.every((e,n)=>t.children?.some(t=>cn(e,t)))??!1:!1}var ln=new WeakMap,un=({key:e,route:t,manifest:n,mapRouteProperties:r})=>{let i=n[t.id];if(ye(i,`No route found in manifest`),!i.lazy||typeof i.lazy!=`object`)return;let a=i.lazy[e];if(!a)return;let o=ln.get(i);o||(o={},ln.set(i,o));let s=o[e];if(s)return s;let c=(async()=>{let t=je(e),n=i[e]!==void 0&&e!==`hasErrorBoundary`;if(t)be(!t,`Route property `+e+` is not a supported lazy route property. This property will be ignored.`),o[e]=Promise.resolve();else if(n)be(!1,`Route "${i.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let t=await a();t!=null&&(Object.assign(i,{[e]:t}),Object.assign(i,r(i)))}typeof i.lazy==`object`&&(i.lazy[e]=void 0,Object.values(i.lazy).every(e=>e===void 0)&&(i.lazy=void 0))})();return o[e]=c,c},dn=new WeakMap;function nee(e,t,n,r,i){let a=n[e.id];if(ye(a,`No route found in manifest`),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy==`function`){let t=dn.get(a);if(t)return{lazyRoutePromise:t,lazyHandlerPromise:t};let n=(async()=>{ye(typeof e.lazy==`function`,`No lazy route function found`);let t=await e.lazy(),n={};for(let e in t){let r=t[e];if(r===void 0)continue;let i=Ne(e),o=a[e]!==void 0&&e!==`hasErrorBoundary`;i?be(!i,`Route property `+e+` is not a supported property to be returned from a lazy route function. This property will be ignored.`):o?be(!o,`Route "${a.id}" has a static property "${e}" defined but its lazy function is also returning a value for this property. The lazy route property "${e}" will be ignored.`):n[e]=r}Object.assign(a,n),Object.assign(a,{...r(a),lazy:void 0})})();return dn.set(a,n),n.catch(()=>{}),{lazyRoutePromise:n,lazyHandlerPromise:n}}let o=Object.keys(e.lazy),s=[],c;for(let a of o){if(i&&i.includes(a))continue;let o=un({key:a,route:e,manifest:n,mapRouteProperties:r});o&&(s.push(o),a===t&&(c=o))}let l=s.length>0?Promise.all(s).then(()=>{}):void 0;return l?.catch(()=>{}),c?.catch(()=>{}),{lazyRoutePromise:l,lazyHandlerPromise:c}}async function fn(e){let t=e.matches.filter(e=>e.shouldLoad),n={};return(await Promise.all(t.map(e=>e.resolve()))).forEach((e,r)=>{n[t[r].route.id]=e}),n}async function ree(e){return e.matches.some(e=>e.route.middleware)?pn(e,()=>fn(e)):fn(e)}function pn(e,t){return iee(e,t,e=>{if(Wn(e))throw e;return e},see,n);function n(t,n,r){if(r)return Promise.resolve(Object.assign(r.value,{[n]:{type:`error`,result:t}}));{let{matches:r}=e,i=Nn(r,r[Math.min(Math.max(r.findIndex(e=>e.route.id===n),0),Math.max(r.findIndex(e=>e.shouldCallHandler()),0))].route.id).route.id;return Promise.resolve({[i]:{type:`error`,result:t}})}}}async function iee(e,t,n,r,i){let{matches:a,...o}=e;return await mn(o,a.flatMap(e=>e.route.middleware?e.route.middleware.map(t=>[e.route.id,t]):[]),t,n,r,i)}async function mn(e,t,n,r,i,a,o=0){let{request:s}=e;if(s.signal.aborted)throw s.signal.reason??Error(`Request aborted: ${s.method} ${s.url}`);let c=t[o];if(!c)return await n();let[l,u]=c,d,f=async()=>{if(d)throw Error("You may only call `next()` once per middleware");try{return d={value:await mn(e,t,n,r,i,a,o+1)},d.value}catch(e){return d={value:await a(e,l,d)},d.value}};try{let t=await u(e,f),n=t==null?void 0:r(t);return i(n)?n:d?n??d.value:(d={value:await f()},d.value)}catch(e){return await a(e,l,d)}}function hn(e,t,n,r,i){let a=un({key:`middleware`,route:r.route,manifest:t,mapRouteProperties:e}),o=nee(r.route,Kn(n.method)?`action`:`loader`,t,e,i);return{middleware:a,route:o.lazyRoutePromise,handler:o.lazyHandlerPromise}}function gn(e,t,n,r,i,a,o,s,c,l=null,u){let d=!1,f=hn(e,t,n,a,o);return{...a,_lazyPromises:f,shouldLoad:c,shouldRevalidateArgs:l,shouldCallHandler(e){return d=!0,l?typeof u==`boolean`?on(a,{...l,defaultShouldRevalidate:u}):typeof e==`boolean`?on(a,{...l,defaultShouldRevalidate:e}):on(a,l):c},resolve(e){let{lazy:t,loader:o,middleware:l}=a.route,u=d||c||e&&!Kn(n.method)&&(t||o),p=l&&l.length>0&&!o&&!t;return u&&(Kn(n.method)||!p)?yn({request:n,path:r,pattern:i,match:a,lazyHandlerPromise:f?.handler,lazyRoutePromise:f?.route,handlerOverride:e,scopedContext:s}):Promise.resolve({type:`data`,result:void 0})}}}function _n(e,t,n,r,i,a,o,s,c=null){return i.map(l=>l.route.id===a.route.id?gn(e,t,n,r,xt(i),l,o,s,!0,c):{...l,shouldLoad:!1,shouldRevalidateArgs:c,shouldCallHandler:()=>!1,_lazyPromises:hn(e,t,n,l,o),resolve:()=>Promise.resolve({type:`data`,result:void 0})})}async function vn(e,t,n,r,i,a,o){r.some(e=>e._lazyPromises?.middleware)&&await Promise.all(r.map(e=>e._lazyPromises?.middleware));let s={request:t,url:En(t,n),pattern:xt(r),params:r[0].params,context:a,matches:r},c=o?()=>{throw Error("You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`")}:e=>{let t=s;return pn(t,()=>e({...t,fetcherKey:i,runClientMiddleware:()=>{throw Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))},l=await e({...s,fetcherKey:i,runClientMiddleware:c});try{await Promise.all(r.flatMap(e=>[e._lazyPromises?.handler,e._lazyPromises?.route]))}catch{}return l}async function yn({request:e,path:t,pattern:n,match:r,lazyHandlerPromise:i,lazyRoutePromise:a,handlerOverride:o,scopedContext:s}){let c,l,u=Kn(e.method),d=u?`action`:`loader`,f=i=>{let a,c=new Promise((e,t)=>a=t);l=()=>a(),e.signal.addEventListener(`abort`,l);let u=a=>typeof i==`function`?i({request:e,url:En(e,t),pattern:n,params:r.params,context:s},...a===void 0?[]:[a]):Promise.reject(Error(`You cannot call the handler for a route which defines a boolean "${d}" [routeId: ${r.route.id}]`)),f=(async()=>{try{return{type:`data`,result:await(o?o(e=>u(e)):u())}}catch(e){return{type:`error`,result:e}}})();return Promise.race([f,c])};try{let t=u?r.route.action:r.route.loader;if(i||a)if(t){let e,[n]=await Promise.all([f(t).catch(t=>{e=t}),i,a]);if(e!==void 0)throw e;c=n}else{await i;let t=u?r.route.action:r.route.loader;if(t)[c]=await Promise.all([f(t),a]);else if(d===`action`){let t=new URL(e.url),n=t.pathname+t.search;throw Fn(405,{method:e.method,pathname:n,routeId:r.route.id})}else return{type:`data`,result:void 0}}else if(t)c=await f(t);else{let t=new URL(e.url);throw Fn(404,{pathname:t.pathname+t.search})}}catch(e){return{type:`error`,result:e}}finally{l&&e.signal.removeEventListener(`abort`,l)}return c}async function bn(e){let t=e.headers.get(`Content-Type`);return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}async function xn(e){let{result:t,type:n}=e;if(Hn(t)){let e;try{e=await bn(t)}catch(e){return{type:`error`,error:e}}return n===`error`?{type:`error`,error:new yt(t.status,t.statusText,e),statusCode:t.status,headers:t.headers}:{type:`data`,data:e,statusCode:t.status,headers:t.headers}}return n===`error`?Vn(t)?t.data instanceof Error?{type:`error`,error:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`error`,error:oee(t),statusCode:bt(t)?t.status:void 0,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`error`,error:t,statusCode:bt(t)?t.status:void 0}:Vn(t)?{type:`data`,data:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`data`,data:t}}function Sn(e,t,n,r,i){let a=e.headers.get(`Location`);if(ye(a,`Redirects returned/thrown from loaders/actions must have a Location header`),!ot(a)){let o=r.slice(0,r.findIndex(e=>e.route.id===n)+1);a=Qt(new URL(t.url),o,i,a),e.headers.set(`Location`,a)}return e}var Cn=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function wn(e,t,n,r){if(ot(e)){let r=e,i=r.startsWith(`//`)?new URL(t.protocol+r):new URL(r);if(Cn.includes(i.protocol))throw Error(`Invalid redirect location`);let a=rt(i.pathname,n)!=null;if(i.origin===t.origin&&a)return pt(i.pathname)+i.search+i.hash}try{let t=r.createURL(e);if(Cn.includes(t.protocol))throw Error(`Invalid redirect location`)}catch{}return e}function Tn(e,t,n,r){let i=e.createURL(Ln(t)).toString(),a={signal:n};if(r&&Kn(r.formMethod)){let{formMethod:e,formEncType:t}=r;a.method=e.toUpperCase(),t===`application/json`?(a.headers=new Headers({"Content-Type":t}),a.body=JSON.stringify(r.json)):t===`text/plain`?a.body=r.text:t===`application/x-www-form-urlencoded`&&r.formData?a.body=Dn(r.formData):a.body=r.formData}return new Request(i,a)}function En(e,t){let n=new URL(e.url),r=typeof t==`string`?Te(t):t;if(n.pathname=r.pathname||`/`,r.search){let e=new URLSearchParams(r.search),t=e.getAll(`index`);e.delete(`index`);for(let n of t.filter(Boolean))e.append(`index`,n);n.search=e.size?`?${e.toString()}`:``}else n.search=``;return n.hash=r.hash||``,n}function Dn(e){let t=new URLSearchParams;for(let[n,r]of e.entries())t.append(n,typeof r==`string`?r:r.name);return t}function On(e){let t=new FormData;for(let[n,r]of e.entries())t.append(n,r);return t}function kn(e,t,n,r=!1,i=!1){let a={},o=null,s,c=!1,l={},u=n&&zn(n[1])?n[1].error:void 0;return e.forEach(n=>{if(!(n.route.id in t))return;let d=n.route.id,f=t[d];if(ye(!Bn(f),`Cannot handle redirect results in processLoaderData`),zn(f)){let t=f.error;if(u!==void 0&&(t=u,u=void 0),o||={},i)o[d]=t;else{let n=Nn(e,d);o[n.route.id]??(o[n.route.id]=t)}r||(a[d]=Kt),c||(c=!0,s=bt(f.error)?f.error.status:500),f.headers&&(l[d]=f.headers)}else a[d]=f.data,f.statusCode&&f.statusCode!==200&&!c&&(s=f.statusCode),f.headers&&(l[d]=f.headers)}),u!==void 0&&n&&(o={[n[0]]:u},n[2]&&(a[n[2]]=void 0)),{loaderData:a,errors:o,statusCode:s||200,loaderHeaders:l}}function An(e,t,n,r,i,a,o){let{loaderData:s,errors:c}=kn(t,n,r);return i.filter(e=>!e.matches||e.matches.some(e=>e.shouldLoad)).forEach(t=>{let{key:n,match:r,controller:i}=t;if(i&&i.signal.aborted)return;let s=a[n];if(ye(s,`Did not find corresponding fetcher result`),zn(s)){let t=Nn(e.matches,r?.route.id);c&&c[t.route.id]||(c={...c,[t.route.id]:s.error}),o.delete(n)}else if(Bn(s))ye(!1,`Unhandled fetcher revalidation redirect`);else{let e=er(s.data);o.set(n,e)}}),{loaderData:s,errors:c}}function jn(e,t,n,r){let i=Object.entries(t).filter(([,e])=>e!==Kt).reduce((e,[t,n])=>(e[t]=n,e),{});for(let a of n){let n=a.route.id;if(!t.hasOwnProperty(n)&&e.hasOwnProperty(n)&&a.route.loader&&(i[n]=e[n]),r&&r.hasOwnProperty(n))break}return i}function Mn(e){return e?zn(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function Nn(e,t){return(t?e.slice(0,e.findIndex(e=>e.route.id===t)+1):[...e]).reverse().find(e=>e.route.hasErrorBoundary===!0)||e[0]}function Pn(e){let t=e.length===1?e[0]:e.find(e=>e.index||!e.path||e.path===`/`)||{id:`__shim-error-route__`};return{matches:[{params:{},pathname:``,pathnameBase:``,route:t}],route:t}}function Fn(e,{pathname:t,routeId:n,method:r,type:i,message:a}={}){let o=`Unknown Server Error`,s=`Unknown @remix-run/router error`;return e===400?(o=`Bad Request`,r&&t&&n?s=`You made a ${r} request to "${t}" but did not provide a \`loader\` for route "${n}", so there is no way to handle the request.`:i===`invalid-body`&&(s=`Unable to encode submission body`)):e===403?(o=`Forbidden`,s=`Route "${n}" does not match URL "${t}"`):e===404?(o=`Not Found`,s=`No route matches URL "${t}"`):e===405&&(o=`Method Not Allowed`,r&&t&&n?s=`You made a ${r.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${n}", so there is no way to handle the request.`:r&&(s=`Invalid request method "${r.toUpperCase()}"`)),new yt(e||500,o,Error(s),!0)}function In(e){let t=Object.entries(e);for(let e=t.length-1;e>=0;e--){let[n,r]=t[e];if(Bn(r))return{key:n,result:r}}}function Ln(e){return we({...typeof e==`string`?Te(e):e,hash:``})}function aee(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===``?t.hash!==``:e.hash===t.hash?!0:t.hash!==``}function oee(e){return new yt(e.init?.status??500,e.init?.statusText??`Internal Server Error`,e.data)}function see(e){return typeof e==`object`&&!!e&&Object.entries(e).every(([e,t])=>typeof e==`string`&&cee(t))}function cee(e){return typeof e==`object`&&!!e&&`type`in e&&`result`in e&&(e.type===`data`||e.type===`error`)}function Rn(e){return Hn(e.result)&&zt.has(e.result.status)}function zn(e){return e.type===`error`}function Bn(e){return(e&&e.type)===`redirect`}function Vn(e){return typeof e==`object`&&!!e&&`type`in e&&`data`in e&&`init`in e&&e.type===`DataWithResponseInit`}function Hn(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.headers==`object`&&e.body!==void 0}function Un(e){return zt.has(e)}function Wn(e){return Hn(e)&&Un(e.status)&&e.headers.has(`Location`)}function Gn(e){return Rt.has(e.toUpperCase())}function Kn(e){return It.has(e.toUpperCase())}function qn(e){return new URLSearchParams(e).getAll(`index`).some(e=>e===``)}function Jn(e,t){let n=typeof t==`string`?Te(t).search:t.search;if(e[e.length-1].route.index&&qn(n||``))return e[e.length-1];let r=ut(e);return r[r.length-1]}function Yn(e){let{formMethod:t,formAction:n,formEncType:r,text:i,formData:a,json:o}=e;if(!(!t||!n||!r)){if(i!=null)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:void 0,text:i};if(a!=null)return{formMethod:t,formAction:n,formEncType:r,formData:a,json:void 0,text:void 0};if(o!==void 0)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:o,text:void 0}}}function Xn(e,t,n,r){return r?{state:`loading`,location:e,matches:t,historyAction:n,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}:{state:`loading`,location:e,matches:t,historyAction:n,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function Zn(e,t,n,r){return{state:`submitting`,location:e,matches:t,historyAction:n,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}}function Qn(e,t){return e?{state:`loading`,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:`loading`,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function $n(e,t){return{state:`submitting`,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function er(e){return{state:`idle`,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function tr(e,t){try{let n=e.sessionStorage.getItem(Gt);if(n){let e=JSON.parse(n);for(let[n,r]of Object.entries(e||{}))r&&Array.isArray(r)&&t.set(n,new Set(r||[]))}}catch{}}function nr(e,t){if(t.size>0){let n={};for(let[e,r]of t)n[e]=[...r];try{e.sessionStorage.setItem(Gt,JSON.stringify(n))}catch(e){be(!1,`Failed to save applied view transitions in sessionStorage (${e}).`)}}}function rr(){let e,t,n=new Promise((r,i)=>{e=async e=>{r(e);try{await n}catch{}},t=async e=>{i(e);try{await n}catch{}}});return{promise:n,resolve:e,reject:t}}var ir=Z.createContext(null);ir.displayName=`DataRouter`;var ar=Z.createContext(null);ar.displayName=`DataRouterState`;var or=Z.createContext(!1);function sr(){return Z.useContext(or)}var cr=Z.createContext({isTransitioning:!1});cr.displayName=`ViewTransition`;var lr=Z.createContext(new Map);lr.displayName=`Fetchers`;var ur=Z.createContext(null);ur.displayName=`Await`;var dr=Z.createContext(null);dr.displayName=`Navigation`;var fr=Z.createContext(null);fr.displayName=`Location`;var pr=Z.createContext({outlet:null,matches:[],isDataRoute:!1});pr.displayName=`Route`;var mr=Z.createContext(null);mr.displayName=`RouteError`;var hr=`REACT_ROUTER_ERROR`,lee=`REDIRECT`,uee=`ROUTE_ERROR_RESPONSE`;function dee(e){if(e.startsWith(`${hr}:${lee}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function fee(e){if(e.startsWith(`${hr}:${uee}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new yt(t.status,t.statusText,t.data)}catch{}}function pee(e,{relative:t}={}){ye(gr(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=Z.useContext(dr),{hash:i,pathname:a,search:o}=Tr(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:mt([n,a])),r.createHref({pathname:s,search:o,hash:i})}function gr(){return Z.useContext(fr)!=null}function _r(){return ye(gr(),`useLocation() may be used only in the context of a <Router> component.`),Z.useContext(fr).location}var vr=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function yr(e){Z.useContext(dr).static||Z.useLayoutEffect(e)}function br(){let{isDataRoute:e}=Z.useContext(pr);return e?Ur():xr()}function xr(){ye(gr(),`useNavigate() may be used only in the context of a <Router> component.`);let e=Z.useContext(ir),{basename:t,navigator:n}=Z.useContext(dr),{matches:r}=Z.useContext(pr),{pathname:i}=_r(),a=JSON.stringify(dt(r)),o=Z.useRef(!1);return yr(()=>{o.current=!0}),Z.useCallback((r,s={})=>{if(be(o.current,vr),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=ft(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:mt([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var Sr=Z.createContext(null);function Cr(e){let t=Z.useContext(pr).outlet;return Z.useMemo(()=>t&&Z.createElement(Sr.Provider,{value:e},t),[t,e])}function wr(){let{matches:e}=Z.useContext(pr);return e[e.length-1]?.params??{}}function Tr(e,{relative:t}={}){let{matches:n}=Z.useContext(pr),{pathname:r}=_r(),i=JSON.stringify(dt(n));return Z.useMemo(()=>ft(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Er(e,t,n){ye(gr(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=Z.useContext(dr),{matches:i}=Z.useContext(pr),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;Gr(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
4
4
 
@@ -10,7 +10,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
10
10
 
11
11
  `,WN=/\r\n/g,GN=`xopc.npmPendingRestart`,KN=typeof window<`u`&&window.electronAPI?.updater!==void 0;function qN(){return null}function JN(e){if(!(!e||typeof window>`u`))try{let t=sessionStorage.getItem(GN);if(!t)return;let n=JSON.parse(t),r=typeof n.installedVersion==`string`?n.installedVersion.trim():``;r&&r===e&&sessionStorage.removeItem(GN)}catch{}}function YN(e){return JN(e.currentVersion),e}function XN(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(()=>qN()),[o,s]=(0,Z.useState)(KN?{state:`idle`}:qN()),c=(0,Z.useRef)(null),l=KN||i!==null;(0,Z.useEffect)(()=>{if(l)return;QN().then(e=>t(YN(e))).catch(()=>{});let e=e=>{let n=e.detail;if(n===null)t(e=>e&&YN({...e,updateAvailable:!1,latestVersion:null,channel:null}));else if(n&&typeof n==`object`){let e=n;t(YN({currentVersion:e.currentVersion??``,updateAvailable:!0,latestVersion:e.latestVersion??null,channel:e.channel??null}))}};return window.addEventListener(`update-available`,e),()=>window.removeEventListener(`update-available`,e)},[l]),(0,Z.useEffect)(()=>{if(!KN)return;let e=window.electronAPI.updater;return e.getStatus().then(e=>s(e)),e.onStatusChanged(e=>s(e))},[]),(0,Z.useEffect)(()=>{},[]),(0,Z.useEffect)(()=>()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},[]);let u=(0,Z.useCallback)(async()=>{if(l)return!1;try{let e=await Y(X(`/api/update/check`),{method:`POST`});if(!e.ok)return!1;let n=await e.json();return n.payload?(t(YN(n.payload)),!0):!1}catch{return!1}},[l]),d=(0,Z.useCallback)(async()=>{if(l)return{ok:!1,error:`not-applicable`,message:`npm update is not used in the desktop app.`,status:400};r(!0);try{let e=await Y(X(`/api/update/run/stream`),{method:`POST`,headers:{Accept:`text/event-stream`}});if(!e.ok||!e.body){let t=await e.text().catch(()=>``),n=`HTTP ${e.status}`;try{let e=JSON.parse(t);typeof e.message==`string`&&(n=e.message)}catch{t&&(n=t.slice(0,500))}return{ok:!1,error:e.status===409?`busy`:`unknown`,message:n,status:e.status}}let t=await $N(e.body);if(t.ok&&t.result){let e=t.result;if(e&&typeof e==`object`&&e.status===`ok`&&typeof e.installedVersion==`string`){try{sessionStorage.setItem(GN,JSON.stringify({installedVersion:e.installedVersion}))}catch{}window.dispatchEvent(new CustomEvent(`xopc:npm-update-installed`,{detail:{version:e.installedVersion}}))}else e&&typeof e==`object`&&e.status===`up-to-date`&&typeof e.latestVersion==`string`&&window.dispatchEvent(new CustomEvent(`xopc:npm-update-installed`,{detail:{version:e.latestVersion}}))}return t}catch(e){return{ok:!1,error:`network`,message:e instanceof Error?e.message:String(e),status:0}}finally{r(!1)}},[l]),f=(0,Z.useCallback)(()=>{if(KN){window.electronAPI.updater.check();return}},[i]),p=(0,Z.useCallback)(()=>{KN&&window.electronAPI.updater.quitAndInstall()},[]);return{npm:e,electron:KN?o:i??o,isElectron:l,checkNow:u,runNpmUpdate:d,npmUpdateRunning:n,electronCheck:f,electronQuitAndInstall:p}}var ZN=null;async function QN(){return ZN||(ZN=(async()=>{let e=await Y(X(`/api/update/status`));if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).payload})().finally(()=>{ZN=null}),ZN)}async function $N(e){let t=e.getReader(),n=new TextDecoder,r=``,i=null,a=e=>{try{let t=JSON.parse(e);typeof t.line==`string`&&window.dispatchEvent(new CustomEvent(`xopc:npm-update-progress`,{detail:{line:t.line,source:t.source===`stderr`?`stderr`:`stdout`}}))}catch{}},o=e=>{let t=``,n=``;for(let r of e.split(`
12
12
  `)){let e=r.replace(/\r$/,``);e.startsWith(`event:`)?t=e.slice(6).trim():e.startsWith(`data:`)&&(n+=e.slice(5).trimStart())}if(n){if(t===`progress`){a(n);return}if(t===`result`)try{let e=JSON.parse(n);i=e.ok?{ok:!0,result:e.result??null}:{ok:!1,error:String(e.error??`unknown`),message:String(e.message??`Update failed`),status:e.error===`busy`?409:400,result:e.result??null}}catch{i={ok:!1,error:`parse`,message:`Invalid update stream`,status:0}}}};try{let e=async()=>{if(i!==null)return i;let{done:a,value:s}=await t.read();if(a)return i;r+=n.decode(s,{stream:!0}),r=r.replace(WN,`
13
- `);let c=r.split(UN);r=c.pop()??``;for(let e of c)e.length&&o(e);return e()},a=await e();if(a)return a}finally{t.releaseLock()}return i??{ok:!1,error:`no-result`,message:`Update stream ended without a result`,status:0}}var eP=`xopc.updateReminder.dismissed`,tP=typeof window<`u`&&window.electronAPI?.updater!==void 0,nP=`xopc:electron-update-recheck`;function rP(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(eP);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}var iP=160;function aP(e){let t=e.trim();return t.length<=iP?t:`${t.slice(0,iP-1)}…`}function oP(){let{npm:e,electron:t,isElectron:n,electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}=XN(),[o,s]=(0,Z.useState)(rP),[c,l]=(0,Z.useState)({downloading:!1,electronError:!1}),[u,d]=(0,Z.useState)(()=>{if(typeof window>`u`||tP)return null;try{let e=sessionStorage.getItem(GN);if(!e)return null;let t=JSON.parse(e);return(typeof t.installedVersion==`string`?t.installedVersion.trim():``)||null}catch{return null}}),f=(0,Z.useRef)(t?.state);f.current!==t?.state&&(f.current=t?.state,t?.state!==`downloading`&&c.downloading&&l(e=>({...e,downloading:!1})),t?.state!==`error`&&c.electronError&&l(e=>({...e,electronError:!1})));let p=(0,Z.useRef)(null);if(u&&e?.currentVersion===u&&p.current!==u){p.current=u;try{sessionStorage.removeItem(GN)}catch{}d(null)}(0,Z.useEffect)(()=>{if(n)return;let e=()=>{try{let e=sessionStorage.getItem(GN);if(!e){d(null);return}let t=JSON.parse(e);d((typeof t.installedVersion==`string`?t.installedVersion.trim():``)||null)}catch{d(null)}};return e(),window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[n]),(0,Z.useEffect)(()=>{let e=()=>{l(e=>({...e,downloading:!1})),s(e=>{let t={...e};delete t.electronReady;try{localStorage.setItem(eP,JSON.stringify(t))}catch{}return t})};return window.addEventListener(nP,e),()=>window.removeEventListener(nP,e)},[]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail?.version?.trim();t&&s(e=>{let n={...e,npm:t};try{localStorage.setItem(eP,JSON.stringify(n))}catch{}return n})};return window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[]);let m=(0,Z.useMemo)(()=>n&&t?.state===`downloaded`&&t.version?o.electronReady===t.version?{kind:`none`}:{kind:`electron-ready`,version:t.version}:n&&t?.state===`downloading`&&!c.downloading?{kind:`electron-downloading`,percent:Math.round(t.percent??0)}:n&&t?.state===`error`&&t.message&&!c.electronError?{kind:`electron-error`,message:aP(t.message)}:!n&&u&&e&&e.currentVersion!==u?{kind:`npm-restart-required`,version:u}:!n&&e?.updateAvailable&&e.latestVersion?o.npm===e.latestVersion?{kind:`none`}:{kind:`npm`,version:e.latestVersion,channel:e.channel}:{kind:`none`},[o.npm,o.electronReady,t,c.downloading,c.electronError,n,e,u]);return{show:m,dismiss:(0,Z.useCallback)(()=>{if(m.kind===`electron-downloading`){l(e=>({...e,downloading:!0}));return}if(m.kind===`electron-error`){l(e=>({...e,electronError:!0}));return}if(m.kind===`npm-restart-required`){try{sessionStorage.removeItem(GN)}catch{}d(null);return}if(m.kind===`none`)return;let e={...o};m.kind===`npm`?e.npm=m.version:m.kind===`electron-ready`&&(e.electronReady=m.version);try{localStorage.setItem(eP,JSON.stringify(e))}catch{}s(e)},[o,m]),electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}}var sP={version:`0.0.128`,commit:`f832b7e3c8a4c30d66c7e5a1f646fd47f2d15ed9`,buildTimeIso:`2026-07-13T14:31:15.985Z`};function cP(){return function(e,t){switch(t.type){case`start`:return e.loading?e:{...e,loading:!0,error:null};case`success`:return{data:t.data,loading:!1,error:null};case`error`:return{data:t.data,loading:!1,error:t.error};case`patch`:return{...e,data:t.updater(e.data)}}}}function lP(e,t,n){let{enabled:r=!0,initial:i,errorData:a}=n,[o,s]=(0,Z.useReducer)(cP(),void 0,()=>({data:i,loading:!1,error:null})),c=(0,Z.useRef)(e);c.current=e;let l=(0,Z.useRef)(a);l.current=a;let u=(0,Z.useRef)(i);u.current=i,(0,Z.useEffect)(()=>{if(!r)return;let e=!1;return s({type:`start`}),c.current().then(t=>{e||s({type:`success`,data:t})}).catch(t=>{if(e)return;let n=l.current;s({type:`error`,data:typeof n==`function`?n(t):n===void 0?u.current:n,error:t})}),()=>{e=!0}},[r,...t]);let d=(0,Z.useCallback)(e=>{s({type:`patch`,updater:typeof e==`function`?e:()=>e})},[]);return{...o,setData:d}}var uP=`https://github.com/xopcai/xopc`,dP=new Intl.DateTimeFormat(`zh-CN`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),fP=new Intl.DateTimeFormat(`en-US`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function pP(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return(t===`zh`?dP:fP).format(n)}catch{return n.toISOString()}}function mP({open:e,onOpenChange:t}){let n=_(e=>e.language),r=m(n),i=r.aboutDialog,a=r.updatePanel,{isElectron:o,electron:s,electronCheck:c,checkNow:l,npm:d,runNpmUpdate:f,npmUpdateRunning:p}=XN(),[h,g]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),{data:S}=lP(async()=>{let e=await J(X(`/health`));return typeof e.version==`string`?e.version:null},[e],{enabled:e,initial:null,errorData:null}),C=(0,Z.useCallback)(e=>{e||(g(!1),y(!1),x(!1)),t(e)},[t]),w=(0,Z.useCallback)(async()=>{let e=m(n).updatePanel,t=await f();if(t.ok){re({type:`success`,title:e.updateSuccess,message:e.updateSuccessDetail});return}re({type:`error`,title:t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed,message:t.message})},[f,n]),T=sP.commit,E=n===`zh`?`zh-CN`:`en-US`,D=pP(sP.buildTimeIso,E),O=new Date().getFullYear(),k=i.copyright.replace(`{year}`,String(O));return(0,$.jsx)(FN,{open:e,onOpenChange:C,children:(0,$.jsxs)(LN,{children:[(0,$.jsx)(RN,{className:`xopc-dialog-overlay fixed inset-0 z-[200] bg-scrim`}),(0,$.jsxs)(zN,{className:u(`xopc-dialog-content fixed left-1/2 top-1/2 z-[201] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-panel shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#ff5f57]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#febc2e]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#28c840]`})]}),(0,$.jsxs)(`div`,{className:`px-6 pb-2 pt-1`,children:[(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(HN,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":i.close,children:(0,$.jsx)(Sk,{className:`size-4`,strokeWidth:2})})})}),(0,$.jsxs)(`div`,{className:`-mt-2 flex flex-col items-center text-center`,children:[(0,$.jsx)(Hk,{className:`size-[4.5rem]`,alt:r.appBrand}),(0,$.jsx)(BN,{className:`mt-3 text-xl font-semibold tracking-tight text-fg`,children:r.appBrand}),(0,$.jsx)(VN,{className:`sr-only`,children:i.windowTitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 space-y-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.versionLabel}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2 sm:justify-start`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[13px] text-fg tabular-nums`,children:sP.version}),(0,$.jsx)(`button`,{type:`button`,className:u(`shrink-0 rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,`transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{o?(window.dispatchEvent(new CustomEvent(nP)),g(!0),c()):(g(!0),x(!1),y(!0),(async()=>{let e=await l();y(!1),e||x(!0)})())},disabled:o&&[`checking`,`available`,`downloading`,`downloaded`].includes(s?.state??``)||!o&&(v||p),children:o&&s?.state===`checking`||!o&&v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Fv,{className:`size-3 animate-spin`}),i.checkUpdatesChecking]}):i.checkUpdates})]})]}),o&&h&&(0,$.jsx)(hP,{state:s?.state,version:s?.version,percent:s?.percent,d:i}),!o&&h&&(0,$.jsx)(gP,{checking:v,checkFailed:b,npm:d,npmUpdateRunning:p,onUpgrade:w,d:i,tp:a}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`pt-0.5 text-fg-muted`,children:i.commitLabel}),(0,$.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg`,children:T})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.buildDateLabel}),(0,$.jsx)(`span`,{className:`text-right text-[13px] text-fg sm:text-left`,children:D})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.gatewayVersionLabel}),(0,$.jsx)(`span`,{className:`text-right font-mono text-[13px] text-fg sm:text-left`,children:S??i.gatewayUnavailable})]}),(0,$.jsx)(`p`,{className:`pt-0.5 text-[11px] text-fg-subtle`,children:i.consoleBuildHint})]}),(0,$.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 text-center text-[11px] leading-relaxed text-fg-muted`,children:[(0,$.jsx)(`p`,{children:(0,$.jsx)(`a`,{className:`text-accent-fg underline decoration-accent-fg/40 underline-offset-2 hover:decoration-accent-fg`,href:uP,target:`_blank`,rel:`noopener noreferrer`,children:i.repositoryLink})}),(0,$.jsx)(`p`,{className:`mt-2`,children:k})]})]})]})]})})}function hP(e){let t=(0,Q.c)(29),{state:n,version:r,percent:i,d:a}=e;if(!n||n===`idle`)return null;if(n===`checking`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Fv,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===a.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesChecking})]}),t[1]=a.checkUpdatesChecking,t[2]=n),n}if(n===`not-available`){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(vd,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===a.checkUpdatesUpToDate?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesUpToDate})]}),t[4]=a.checkUpdatesUpToDate,t[5]=n),n}if(n===`available`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Lb,{className:`size-3.5`}),t[6]=e):e=t[6];let n;t[7]!==a.checkUpdatesAvailable||t[8]!==r?(n=a.checkUpdatesAvailable.replace(`{version}`,r??`?`),t[7]=a.checkUpdatesAvailable,t[8]=r,t[9]=n):n=t[9];let i;return t[10]===n?i=t[11]:(i=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[10]=n,t[11]=i),i}if(n===`downloading`){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Bm,{className:`size-3.5 motion-safe:animate-[bounce_1s_ease-out_infinite]`}),t[12]=e):e=t[12];let n=a.checkUpdatesDownloading,r;if(t[13]!==a.checkUpdatesDownloading||t[14]!==i){let e;t[16]===i?e=t[17]:(e=Math.round(i??0),t[16]=i,t[17]=e),r=n.replace(`{percent}`,String(e)),t[13]=a.checkUpdatesDownloading,t[14]=i,t[15]=r}else r=t[15];let o;return t[18]===r?o=t[19]:(o=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:r})]}),t[18]=r,t[19]=o),o}if(n===`downloaded`){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Bm,{className:`size-3.5`}),t[20]=e):e=t[20];let n;t[21]!==a.checkUpdatesDownloaded||t[22]!==r?(n=a.checkUpdatesDownloaded.replace(`{version}`,r??`?`),t[21]=a.checkUpdatesDownloaded,t[22]=r,t[23]=n):n=t[23];let i;return t[24]===n?i=t[25]:(i=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] font-semibold text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[24]=n,t[25]=i),i}if(n===`error`){let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ld,{className:`size-3.5`}),t[26]=e):e=t[26];let n;return t[27]===a.checkUpdatesError?n=t[28]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesError})]}),t[27]=a.checkUpdatesError,t[28]=n),n}return null}function gP(e){let t=(0,Q.c)(25),{checking:n,checkFailed:r,npm:i,npmUpdateRunning:a,onUpgrade:o,d:s,tp:c}=e;if(n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Fv,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===s.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:s.checkUpdatesChecking})]}),t[1]=s.checkUpdatesChecking,t[2]=n),n}if(r){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ld,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===s.checkUpdatesError?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:s.checkUpdatesError})]}),t[4]=s.checkUpdatesError,t[5]=n),n}if(a){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Fv,{className:`size-3.5 animate-spin`}),t[6]=e):e=t[6];let n;return t[7]===c.updateRunning?n=t[8]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:c.updateRunning})]}),t[7]=c.updateRunning,t[8]=n),n}if(i?.updateAvailable&&i.latestVersion){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Lb,{className:`mt-0.5 size-3.5 shrink-0`}),t[9]=e):e=t[9];let n;t[10]!==i.latestVersion||t[11]!==c.reminderNpm?(n=c.reminderNpm.replace(`{{version}}`,i.latestVersion),t[10]=i.latestVersion,t[11]=c.reminderNpm,t[12]=n):n=t[12];let r;t[13]===n?r=t[14]:(r=(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[13]=n,t[14]=r);let a;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(a=u(`w-full rounded-lg bg-accent px-3 py-1.5 text-center text-xs font-medium text-white`,`hover:bg-accent/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),t[15]=a):a=t[15];let s;t[16]!==o||t[17]!==c.updateNow?(s=(0,$.jsx)(`button`,{type:`button`,onClick:o,className:a,children:c.updateNow}),t[16]=o,t[17]=c.updateNow,t[18]=s):s=t[18];let l;return t[19]!==r||t[20]!==s?(l=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[r,s]}),t[19]=r,t[20]=s,t[21]=l):l=t[21],l}let l;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(vd,{className:`size-3.5`}),t[22]=l):l=t[22];let d;return t[23]===s.checkUpdatesUpToDate?d=t[24]:(d=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[l,(0,$.jsx)(`span`,{children:s.checkUpdatesUpToDate})]}),t[23]=s.checkUpdatesUpToDate,t[24]=d),d}var _P=u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out`,`hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),vP=u(`rounded-xl border border-edge bg-surface-panel p-1 shadow-popover`,`dark:border-edge`);function yP(e){let t=(0,Q.c)(14),{selected:n,label:r,onSelect:i}=e,a=n&&`bg-accent-soft text-accent-fg hover:bg-accent-soft`,o;t[0]===a?o=t[1]:(o=u(`flex w-full items-center justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),t[2]=r,t[3]=s);let c=n?`opacity-100`:`opacity-0`,l;t[4]===c?l=t[5]:(l=u(`size-4 shrink-0`,c),t[4]=c,t[5]=l);let d;t[6]===l?d=t[7]:(d=(0,$.jsx)(Iu,{className:l,strokeWidth:2,"aria-hidden":!0}),t[6]=l,t[7]=d);let f;return t[8]!==i||t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:o,onClick:i,children:[s,d]}),t[8]=i,t[9]=n,t[10]=o,t[11]=s,t[12]=d,t[13]=f):f=t[13],f}function bP(e){let t=(0,Q.c)(198),{onOpenFullSettings:n,onAboutClick:r}=e,[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),c=_(EP),l=_(TP),d=x(wP),f=x(CP),p=jA(SP),h=jA(xP),g;t[0]===c?g=t[1]:(g=m(c),t[0]=c,t[1]=g);let v=g,y=v.appearanceSettings,b=c===`zh`?y.langOptionZh:y.langOptionEn,S=d===`light`?y.themeOptionLight:d===`dark`?y.themeOptionDark:y.themeOptionSystem,C=p===`compact`?y.fontScaleCompact:p===`large`?y.fontScaleLarge:y.fontScaleDefault,w=typeof window<`u`?window.electronAPI?.pet:void 0,T=!!w,E=o?.visible?y.hideDesktopPet:y.showDesktopPet,D,O;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{if(!w)return;let e=!1;w.getState().then(t=>{e||s(t)});let t=w.onStateChanged(t=>{e||s(t)});return()=>{e=!0,t()}},O=[w],t[2]=D,t[3]=O):(D=t[2],O=t[3]),(0,Z.useEffect)(D,O);let k;t[4]===o?.visible?k=t[5]:(k=async()=>{w&&(o?.visible?await w.hide():await w.show(),s(await w.getState()))},t[4]=o?.visible,t[5]=k);let A=k,j;t[6]===i?j=t[7]:(j=e=>u(`absolute left-full top-0 z-[60] min-w-[8.75rem] max-w-[min(calc(100vw-2rem),12rem)]`,`ml-2 sm:ml-2.5`,i===e?`block`:`hidden`),t[6]=i,t[7]=j);let M=j,N;t[8]===i?N=t[9]:(N=e=>u(`absolute left-full top-0 z-[55] h-full w-8 sm:w-9`,i===e?`pointer-events-auto`:`pointer-events-none`),t[8]=i,t[9]=N);let P=N,F;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>a(null),t[10]=F):F=t[10];let I;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>a(`lang`),t[11]=I):I=t[11];let L=i===`lang`&&`bg-surface-hover`,R;t[12]===L?R=t[13]:(R=u(_P,L),t[12]=L,t[13]=R);let z=i===`lang`,B;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(ov,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=B):B=t[14];let V;t[15]===y.languageTitle?V=t[16]:(V=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:y.languageTitle}),t[15]=y.languageTitle,t[16]=V);let H;t[17]===b?H=t[18]:(H=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:b}),t[17]=b,t[18]=H);let U;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(Yu,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[19]=U):U=t[19];let W;t[20]!==R||t[21]!==z||t[22]!==V||t[23]!==H?(W=(0,$.jsxs)(`button`,{type:`button`,className:R,"aria-haspopup":`menu`,"aria-expanded":z,children:[B,V,H,U]}),t[20]=R,t[21]=z,t[22]=V,t[23]=H,t[24]=W):W=t[24];let G;t[25]===P?G=t[26]:(G=P(`lang`),t[25]=P,t[26]=G);let K;t[27]===G?K=t[28]:(K=(0,$.jsx)(`div`,{className:G,"aria-hidden":!0}),t[27]=G,t[28]=K);let q;t[29]===M?q=t[30]:(q=M(`lang`),t[29]=M,t[30]=q);let ee=c===`en`,J;t[31]===l?J=t[32]:(J=()=>l(`en`),t[31]=l,t[32]=J);let te;t[33]!==y.langOptionEn||t[34]!==ee||t[35]!==J?(te=(0,$.jsx)(yP,{selected:ee,label:y.langOptionEn,onSelect:J}),t[33]=y.langOptionEn,t[34]=ee,t[35]=J,t[36]=te):te=t[36];let Y=c===`zh`,ne;t[37]===l?ne=t[38]:(ne=()=>l(`zh`),t[37]=l,t[38]=ne);let re;t[39]!==y.langOptionZh||t[40]!==Y||t[41]!==ne?(re=(0,$.jsx)(yP,{selected:Y,label:y.langOptionZh,onSelect:ne}),t[39]=y.langOptionZh,t[40]=Y,t[41]=ne,t[42]=re):re=t[42];let X;t[43]!==te||t[44]!==re?(X=(0,$.jsxs)(`div`,{className:vP,children:[te,re]}),t[43]=te,t[44]=re,t[45]=X):X=t[45];let ie;t[46]!==y.languageTitle||t[47]!==q||t[48]!==X?(ie=(0,$.jsx)(`div`,{className:q,role:`menu`,"aria-label":y.languageTitle,children:X}),t[46]=y.languageTitle,t[47]=q,t[48]=X,t[49]=ie):ie=t[49];let ae;t[50]!==W||t[51]!==K||t[52]!==ie?(ae=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:I,children:[W,K,ie]}),t[50]=W,t[51]=K,t[52]=ie,t[53]=ae):ae=t[53];let oe;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>a(`theme`),t[54]=oe):oe=t[54];let se=i===`theme`&&`bg-surface-hover`,ce;t[55]===se?ce=t[56]:(ce=u(_P,se),t[55]=se,t[56]=ce);let le=i===`theme`,ue;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)($v,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=ue):ue=t[57];let de;t[58]===y.themeTitle?de=t[59]:(de=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:y.themeTitle}),t[58]=y.themeTitle,t[59]=de);let fe;t[60]===S?fe=t[61]:(fe=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:S}),t[60]=S,t[61]=fe);let pe;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(Yu,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[62]=pe):pe=t[62];let me;t[63]!==ce||t[64]!==le||t[65]!==de||t[66]!==fe?(me=(0,$.jsxs)(`button`,{type:`button`,className:ce,"aria-haspopup":`menu`,"aria-expanded":le,children:[ue,de,fe,pe]}),t[63]=ce,t[64]=le,t[65]=de,t[66]=fe,t[67]=me):me=t[67];let he;t[68]===P?he=t[69]:(he=P(`theme`),t[68]=P,t[69]=he);let ge;t[70]===he?ge=t[71]:(ge=(0,$.jsx)(`div`,{className:he,"aria-hidden":!0}),t[70]=he,t[71]=ge);let _e;t[72]===M?_e=t[73]:(_e=M(`theme`),t[72]=M,t[73]=_e);let ve=d===`light`,ye;t[74]===f?ye=t[75]:(ye=()=>f(`light`),t[74]=f,t[75]=ye);let be;t[76]!==y.themeOptionLight||t[77]!==ve||t[78]!==ye?(be=(0,$.jsx)(yP,{selected:ve,label:y.themeOptionLight,onSelect:ye}),t[76]=y.themeOptionLight,t[77]=ve,t[78]=ye,t[79]=be):be=t[79];let xe=d===`dark`,Se;t[80]===f?Se=t[81]:(Se=()=>f(`dark`),t[80]=f,t[81]=Se);let Ce;t[82]!==y.themeOptionDark||t[83]!==xe||t[84]!==Se?(Ce=(0,$.jsx)(yP,{selected:xe,label:y.themeOptionDark,onSelect:Se}),t[82]=y.themeOptionDark,t[83]=xe,t[84]=Se,t[85]=Ce):Ce=t[85];let we=d===`system`,Te;t[86]===f?Te=t[87]:(Te=()=>f(`system`),t[86]=f,t[87]=Te);let Ee;t[88]!==y.themeOptionSystem||t[89]!==we||t[90]!==Te?(Ee=(0,$.jsx)(yP,{selected:we,label:y.themeOptionSystem,onSelect:Te}),t[88]=y.themeOptionSystem,t[89]=we,t[90]=Te,t[91]=Ee):Ee=t[91];let De;t[92]!==be||t[93]!==Ce||t[94]!==Ee?(De=(0,$.jsxs)(`div`,{className:vP,children:[be,Ce,Ee]}),t[92]=be,t[93]=Ce,t[94]=Ee,t[95]=De):De=t[95];let Oe;t[96]!==y.themeTitle||t[97]!==_e||t[98]!==De?(Oe=(0,$.jsx)(`div`,{className:_e,role:`menu`,"aria-label":y.themeTitle,children:De}),t[96]=y.themeTitle,t[97]=_e,t[98]=De,t[99]=Oe):Oe=t[99];let ke;t[100]!==me||t[101]!==ge||t[102]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:oe,children:[me,ge,Oe]}),t[100]=me,t[101]=ge,t[102]=Oe,t[103]=ke):ke=t[103];let Ae;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=()=>a(`font`),t[104]=Ae):Ae=t[104];let je=i===`font`&&`bg-surface-hover`,Me;t[105]===je?Me=t[106]:(Me=u(_P,je),t[105]=je,t[106]=Me);let Ne=i===`font`,Pe;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,$.jsx)(OD,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[107]=Pe):Pe=t[107];let Fe;t[108]===y.fontScaleTitle?Fe=t[109]:(Fe=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:y.fontScaleTitle}),t[108]=y.fontScaleTitle,t[109]=Fe);let Ie;t[110]===C?Ie=t[111]:(Ie=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:C}),t[110]=C,t[111]=Ie);let Le;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,$.jsx)(Yu,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[112]=Le):Le=t[112];let Re;t[113]!==Me||t[114]!==Ne||t[115]!==Fe||t[116]!==Ie?(Re=(0,$.jsxs)(`button`,{type:`button`,className:Me,"aria-haspopup":`menu`,"aria-expanded":Ne,children:[Pe,Fe,Ie,Le]}),t[113]=Me,t[114]=Ne,t[115]=Fe,t[116]=Ie,t[117]=Re):Re=t[117];let ze;t[118]===P?ze=t[119]:(ze=P(`font`),t[118]=P,t[119]=ze);let Be;t[120]===ze?Be=t[121]:(Be=(0,$.jsx)(`div`,{className:ze,"aria-hidden":!0}),t[120]=ze,t[121]=Be);let Ve;t[122]===M?Ve=t[123]:(Ve=M(`font`),t[122]=M,t[123]=Ve);let He=p===`compact`,Ue;t[124]===h?Ue=t[125]:(Ue=()=>h(`compact`),t[124]=h,t[125]=Ue);let We;t[126]!==y.fontScaleCompact||t[127]!==He||t[128]!==Ue?(We=(0,$.jsx)(yP,{selected:He,label:y.fontScaleCompact,onSelect:Ue}),t[126]=y.fontScaleCompact,t[127]=He,t[128]=Ue,t[129]=We):We=t[129];let Ge=p==="default",Ke;t[130]===h?Ke=t[131]:(Ke=()=>h(`default`),t[130]=h,t[131]=Ke);let qe;t[132]!==y.fontScaleDefault||t[133]!==Ge||t[134]!==Ke?(qe=(0,$.jsx)(yP,{selected:Ge,label:y.fontScaleDefault,onSelect:Ke}),t[132]=y.fontScaleDefault,t[133]=Ge,t[134]=Ke,t[135]=qe):qe=t[135];let Je=p===`large`,Ye;t[136]===h?Ye=t[137]:(Ye=()=>h(`large`),t[136]=h,t[137]=Ye);let Xe;t[138]!==y.fontScaleLarge||t[139]!==Je||t[140]!==Ye?(Xe=(0,$.jsx)(yP,{selected:Je,label:y.fontScaleLarge,onSelect:Ye}),t[138]=y.fontScaleLarge,t[139]=Je,t[140]=Ye,t[141]=Xe):Xe=t[141];let Ze;t[142]!==We||t[143]!==qe||t[144]!==Xe?(Ze=(0,$.jsxs)(`div`,{className:vP,children:[We,qe,Xe]}),t[142]=We,t[143]=qe,t[144]=Xe,t[145]=Ze):Ze=t[145];let Qe;t[146]!==y.fontScaleTitle||t[147]!==Ve||t[148]!==Ze?(Qe=(0,$.jsx)(`div`,{className:Ve,role:`menu`,"aria-label":y.fontScaleTitle,children:Ze}),t[146]=y.fontScaleTitle,t[147]=Ve,t[148]=Ze,t[149]=Qe):Qe=t[149];let $e;t[150]!==Re||t[151]!==Be||t[152]!==Qe?($e=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:Ae,children:[Re,Be,Qe]}),t[150]=Re,t[151]=Be,t[152]=Qe,t[153]=$e):$e=t[153];let et;t[154]!==E||t[155]!==A?(et=T?(0,$.jsxs)(`button`,{type:`button`,className:_P,onClick:()=>void A(),onMouseEnter:()=>a(null),onFocus:()=>a(null),children:[(0,$.jsx)(iy,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:E})]}):null,t[154]=E,t[155]=A,t[156]=et):et=t[156];let tt;t[157]===Symbol.for(`react.memo_cache_sentinel`)?(tt=(0,$.jsx)(`div`,{className:`my-2 h-px bg-edge-subtle`,role:`separator`}),t[157]=tt):tt=t[157];let nt;t[158]===r?nt=t[159]:(nt=()=>r?.(),t[158]=r,t[159]=nt);let rt,it,at;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(rt=()=>a(null),it=()=>a(null),at=(0,$.jsx)(yv,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[160]=rt,t[161]=it,t[162]=at):(rt=t[160],it=t[161],at=t[162]);let ot;t[163]===y.aboutApp?ot=t[164]:(ot=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:y.aboutApp}),t[163]=y.aboutApp,t[164]=ot);let st;t[165]!==nt||t[166]!==ot?(st=(0,$.jsxs)(`button`,{type:`button`,className:_P,onClick:nt,onMouseEnter:rt,onFocus:it,children:[at,ot]}),t[165]=nt,t[166]=ot,t[167]=st):st=t[167];let ct;t[168]===c?ct=t[169]:(ct=qj(c),t[168]=c,t[169]=ct);let lt,ut,dt;t[170]===Symbol.for(`react.memo_cache_sentinel`)?(lt=()=>a(null),ut=()=>a(null),dt=(0,$.jsx)(bc,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[170]=lt,t[171]=ut,t[172]=dt):(lt=t[170],ut=t[171],dt=t[172]);let ft;t[173]===v.sidebar.helpDocs?ft=t[174]:(ft=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.sidebar.helpDocs}),t[173]=v.sidebar.helpDocs,t[174]=ft);let pt;t[175]===Symbol.for(`react.memo_cache_sentinel`)?(pt=(0,$.jsx)(gh,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[175]=pt):pt=t[175];let mt;t[176]!==ct||t[177]!==ft?(mt=(0,$.jsxs)(`a`,{href:ct,target:`_blank`,rel:`noopener noreferrer`,className:_P,onMouseEnter:lt,onFocus:ut,children:[dt,ft,pt]}),t[176]=ct,t[177]=ft,t[178]=mt):mt=t[178];let ht,gt,_t;t[179]===Symbol.for(`react.memo_cache_sentinel`)?(ht=u(_P,`text-accent-fg hover:bg-accent-soft hover:text-accent-fg`),gt=()=>a(null),_t=()=>a(null),t[179]=ht,t[180]=gt,t[181]=_t):(ht=t[179],gt=t[180],_t=t[181]);let vt;t[182]===n?vt=t[183]:(vt=()=>n?.(),t[182]=n,t[183]=vt);let yt;t[184]===Symbol.for(`react.memo_cache_sentinel`)?(yt=(0,$.jsx)(uS,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[184]=yt):yt=t[184];let bt;t[185]===y.openFullPreferences?bt=t[186]:(bt=(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:y.openFullPreferences}),t[185]=y.openFullPreferences,t[186]=bt);let xt;t[187]!==vt||t[188]!==bt?(xt=(0,$.jsxs)(Hi,{to:`/settings/overview`,className:ht,onMouseEnter:gt,onFocus:_t,onClick:vt,children:[yt,bt]}),t[187]=vt,t[188]=bt,t[189]=xt):xt=t[189];let St;return t[190]!==ae||t[191]!==ke||t[192]!==$e||t[193]!==et||t[194]!==st||t[195]!==mt||t[196]!==xt?(St=(0,$.jsxs)(`div`,{className:`w-[min(calc(100vw-2rem),13rem)] shrink-0 py-0.5`,onMouseLeave:F,children:[ae,ke,$e,et,tt,st,mt,xt]}),t[190]=ae,t[191]=ke,t[192]=$e,t[193]=et,t[194]=st,t[195]=mt,t[196]=xt,t[197]=St):St=t[197],St}function xP(e){return e.setPreference}function SP(e){return e.preference}function CP(e){return e.setPreference}function wP(e){return e.preference}function TP(e){return e.setLanguage}function EP(e){return e.language}function DP({collapsed:e=!1,onNavigate:t}){let n=m(_(e=>e.language)),r=n.appearanceSettings,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{c(()=>import(`./settings-page-BLY6onMK.js`),__vite__mapDeps([0,1,2,3,4])),c(()=>import(`./sessions-page-vkORZvUB.js`),__vite__mapDeps([5,1,2,6,7,3,8,9,10,4,11,12])),c(()=>import(`./logs-page-J8fw1O8x.js`),__vite__mapDeps([13,1,2,7,3,9,4,11,12])),c(()=>import(`./automations-page-Dxn5-hGx.js`),__vite__mapDeps([14,1,2,6,7,3,15,4,11,12,16,17,18])),c(()=>import(`./skills-page-C1re61FQ.js`),__vite__mapDeps([19,1,20,2,7,3,8,21,22,11,4,12]))},[]),(0,$.jsxs)(`div`,{className:u(`flex shrink-0 flex-col`,e&&`mt-auto`,e?`items-center px-1 py-2`:`p-3`),children:[(0,$.jsxs)(oj,{open:i,onOpenChange:a,children:[e?(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u(`flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full outline-none ring-offset-surface-base transition-transform`,`hover:opacity-95 active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2`,i&&`ring-2 ring-accent`,`motion-reduce:opacity-100 motion-reduce:active:scale-100`),"aria-expanded":i,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:(0,$.jsx)(Hk,{className:`size-full rounded-full`,alt:n.appBrand})})}):(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:u(`flex w-full min-w-0 items-center gap-2 rounded-xl p-1 text-left outline-none transition-colors duration-150 ease-out`,`hover:bg-surface-active/70`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i&&`bg-surface-active/70`),"aria-expanded":i,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:[(0,$.jsx)(`span`,{className:`size-8 shrink-0 overflow-hidden rounded-full`,"aria-hidden":!0,children:(0,$.jsx)(Hk,{className:`size-full rounded-full`,alt:``,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight text-fg`,children:n.appBrand}),(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:r.quickMenuHint})]}),(0,$.jsx)(`span`,{className:u(`flex size-9 shrink-0 items-center justify-center rounded-xl text-fg-muted transition-colors`,i&&`bg-accent-soft text-accent-fg`),"aria-hidden":!0,children:(0,$.jsx)(uS,{className:`size-[18px]`,strokeWidth:1.5})})]})}),(0,$.jsx)(lj,{children:(0,$.jsx)(uj,{className:u(`z-50 w-max max-w-[min(calc(100vw-1rem),28rem)] overflow-visible`,`rounded-xl border border-edge bg-surface-panel p-2 shadow-popover dark:border-edge`),side:`top`,align:e?`center`:`start`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,$.jsx)(bP,{onOpenFullSettings:()=>{a(!1),t?.()},onAboutClick:()=>{s(!0),a(!1)}})})})]}),(0,$.jsx)(mP,{open:o,onOpenChange:s})]})}var OP=`xopc-web-sidebar-nav-order`;function kP(){try{let e=globalThis.localStorage?.getItem(OP);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function AP(e){try{globalThis.localStorage?.setItem(OP,JSON.stringify(e))}catch{}}function jP(e,t,n,r,i){if(t===n)return e;let a=e.filter(e=>e!==t),o=a.indexOf(n),s=o===-1?a.length:r===`before`?o:o+1;return NP([...a.slice(0,s),t,...a.slice(s)],i)}function MP(e,t,n){return NP([...e.filter(e=>e!==t),t],n)}function NP(e,t){let n=new Set(e),r=[];for(let e of t)n.has(e)||r.push(e);return r.length===0?e:[...e,...r]}var PP=h((e,t)=>({order:kP(),move:(n,r,i)=>{let a=jP(t().order,n,r,i,new Set(t().order));a!==t().order&&(e({order:a}),queueMicrotask(()=>AP(a)))},moveToEnd:n=>{let r=MP(t().order,n,new Set(t().order));r!==t().order&&(e({order:r}),queueMicrotask(()=>AP(r)))},setOrder:t=>{e({order:t}),queueMicrotask(()=>AP(t))}})),FP=()=>c(()=>import(`./sessions-page-vkORZvUB.js`),__vite__mapDeps([5,1,2,6,7,3,8,9,10,4,11,12])),IP=()=>c(()=>import(`./automations-page-Dxn5-hGx.js`),__vite__mapDeps([14,1,2,6,7,3,15,4,11,12,16,17,18])),LP=()=>c(()=>import(`./projects-page-DBp2WExF.js`),__vite__mapDeps([23,1,2,7,3,24,4])),RP=()=>c(()=>import(`./project-detail-page-dkHzwhDL.js`),__vite__mapDeps([25,1,2,7,3,8,24,26,27,20,6,28,4,11,18,29,30,31,12,32,15])),zP=()=>c(()=>import(`./work-item-detail-page-BYvZjBuJ.js`),__vite__mapDeps([33,1,2,7,3,4])),BP=()=>c(()=>import(`./goals-page-CBfCPiNK.js`),__vite__mapDeps([34,1,2,7,3,26,31,11,4,12])),VP=()=>c(()=>import(`./goal-detail-page-aaIMRRor.js`),__vite__mapDeps([35,1,2,7,3,28,6,4,11,12])),HP=()=>c(()=>import(`./notes-page-CeWoUGI-.js`),__vite__mapDeps([36,2,1,27,20,6,7,3,28,4,11,18,29,30])),UP=()=>c(()=>import(`./workflows-page-0-640fQi.js`),__vite__mapDeps([37,1,2,6,7,3,8,28,4,32,15,11,12])),WP=()=>c(()=>import(`./skills-page-C1re61FQ.js`),__vite__mapDeps([19,1,20,2,7,3,8,21,22,11,4,12])),GP=()=>c(()=>import(`./connectors-page-Df0TJNgv.js`),__vite__mapDeps([38,1,2,7,3,8,10,4,11,18,12])),KP=()=>c(()=>import(`./logs-page-J8fw1O8x.js`),__vite__mapDeps([13,1,2,7,3,9,4,11,12])),qP=()=>c(()=>import(`./settings-page-BLY6onMK.js`),__vite__mapDeps([0,1,2,3,4])),JP=()=>c(()=>import(`./agents-Ceb_WmSZ.js`),__vite__mapDeps([39,1,40,2,6,7,3,41,20,42,43,8,24,44,45,11,4,12,46,47,10,48,49,29,30])),YP=()=>c(()=>import(`./browser-settings-page-DSB-ZKIX.js`),__vite__mapDeps([50,1,2,7,3,8,45,51,11,4,12,52,10,48,49,18])),XP=()=>c(()=>import(`./channels-settings-C1iggCG3.js`),__vite__mapDeps([53,1,2,6,7,3,54,55,56,11,4,12,48,49])),ZP=()=>c(()=>import(`./apps-page-D05daQF8.js`),__vite__mapDeps([57,1,2,6,7,3,8,4,11,12])),QP=()=>c(()=>import(`./extension-page-DhnpWAUJ.js`),__vite__mapDeps([58,1,2])),$P=()=>c(()=>import(`./extension-settings-page-D7JDxFGh.js`),__vite__mapDeps([59,1,2,6,7,3,55,60,11,4,12,48,18])),eF=()=>c(()=>import(`./extension-debug-page-C4sQuETO.js`),__vite__mapDeps([61,1,2,3,4])),tF=()=>c(()=>import(`./share-preview-page-SgKIyNQ7.js`),__vite__mapDeps([62,1,20,2,3,12])),nF=()=>c(()=>import(`./setup-status-panel-BU0JUWIA.js`),__vite__mapDeps([63,1,2,6,7,3,10,48,49,4,11,12])),rF=()=>c(()=>import(`./appearance-settings-BQQf_iLu.js`),__vite__mapDeps([64,2,1,7,3,52,49,4,29,30])),iF=()=>c(()=>import(`./keyboard-shortcuts-settings-ClVhEihC.js`),__vite__mapDeps([65,2,1,7,3,49,4])),aF=()=>c(()=>import(`./user-profile-settings-panel-DBgcbZfp.js`),__vite__mapDeps([66,1,2,7,3,46,10,49,4])),oF=()=>c(()=>import(`./system-settings-panel-CntJCZEg.js`),__vite__mapDeps([67,1,2,7,3,10,49,4])),sF=()=>c(()=>import(`./desktop-pet-settings-PRnTI9no.js`),__vite__mapDeps([68,1,2,7,3,69,49,4])),cF=()=>c(()=>import(`./app-management-settings-panel-DGtoXVvI.js`),__vite__mapDeps([70,1,2,6,7,3,10,48,49,4,11,12])),lF=()=>c(()=>import(`./models-hub-panel-D9csuY5T.js`),__vite__mapDeps([71,1,2,6,7,3,8,60,11,4,12,72,52,73,10,48,49,18])),uF=()=>c(()=>import(`./gateway-settings-C0TutwM5.js`),__vite__mapDeps([74,1,2,6,7,3,8,51,11,4,12,52,10,48,49,18])),dF=()=>c(()=>import(`./heartbeat-settings-DqJBKlza.js`),__vite__mapDeps([75,1,2,6,7,3,8,76,17,47,11,4,12,72,48,49])),fF=()=>c(()=>import(`./remote-access-hub-Cgzg4pNN.js`),__vite__mapDeps([77,1,2,6,7,3,54,8,73,52,10,49,4,11,12])),pF=()=>c(()=>import(`./shares-settings-aiY_QGsl.js`),__vite__mapDeps([78,1,2,6,7,3,8,10,49,4,11,12])),mF=()=>c(()=>import(`./dreaming-settings-D0_2JavX.js`),__vite__mapDeps([79,1,2,6,7,3,8,76,17,16,10,49,4,11,12])),hF=()=>c(()=>import(`./goals-settings-4rKUC3EH.js`),__vite__mapDeps([80,1,2,6,7,3,8,56,11,4,12,31,72,49])),gF=()=>c(()=>import(`./capability-presets-settings-panel-M7jOJxZX.js`),__vite__mapDeps([81,1,2,6,7,3,44,45,11,4,12,10,48,49])),_F=new Set;function vF(e){_F.has(e)||(_F.add(e),e().catch(()=>{_F.delete(e)}))}function yF(e){let[t]=e.split(/[?#]/,1);return t||`/`}function bF(e){vF(qP);let t=e.slice(10);if(t===`overview`)return vF(nF);if(t===`appearance`)return vF(rF);if(t===`keyboard-shortcuts`)return vF(iF);if(t===`user-profile`)return vF(aF);if(t===`system`)return vF(oF);if(t===`desktop-pet`)return vF(sF);if(t===`desktop-app`)return vF(cF);if(t===`credentials`)return vF(lF);if(t===`gateway`)return vF(uF);if(t===`heartbeat`)return vF(dF);if(t===`tunnel`||t===`remote-access`)return vF(fF);if(t===`shares`)return vF(pF);if(t===`dreams`)return vF(mF);if(t===`goals`)return vF(hF);if(t===`capability-presets`)return vF(gF);if(t===`agent-browser`)return vF(YP)}function xF(e){if(!e.startsWith(`/`))return;let t=yF(e);if(t===`/skills`)return vF(WP);if(t===`/connectors`)return vF(GP);if(t===`/automations`)return vF(IP);if(t===`/projects`)return vF(LP);if(t.startsWith(`/projects/`))return vF(RP);if(t.startsWith(`/work-items/`))return vF(zP);if(t===`/goals`)return vF(BP);if(t.startsWith(`/goals/`))return vF(VP);if(t===`/notes`||t.startsWith(`/notes/`))return vF(HP);if(t===`/workflows`)return vF(UP);if(t===`/channels`||t.startsWith(`/channels/`))return vF(XP);if(t===`/agents`||t.startsWith(`/agents/`))return vF(JP);if(t===`/extensions`)return vF(ZP);if(t.startsWith(`/extensions/`))return vF(QP);if(t.startsWith(`/share/`))return vF(tF);if(t===`/settings/sessions`)return vF(FP);if(t===`/settings/logs`)return vF(KP);if(t===`/settings/extensions/debug`)return vF(eF);if(t.startsWith(`/settings/ext/`))return vF($P);if(t.startsWith(`/settings/`))return bF(t)}var SF=null,CF=h((e,t)=>({variables:{},loaded:!1,updateContext:t=>e(e=>({variables:{...e.variables,...t}})),setContext:t=>e({variables:t,loaded:!0}),fetchContext:async()=>SF||(SF=(async()=>{let e=await J(X(`/api/context`));t().setContext(e)})().finally(()=>{SF=null}),SF)})),wF=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({}),TF=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function EF(e){let t=getComputedStyle(document.documentElement),n={};for(let e of TF){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var DF={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"ui.navigate":`theme`,"theme.get":`theme`},OF=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n){let r=this.iframes.get(e);r&&r!==t&&r.contentWindow&&this.byContentWindow.delete(r.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{sessionKey:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow??(t?.source instanceof Window?t.source:null),o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};a&&a.postMessage(o,`*`)}isTrustedExtensionSource(e,t){if(t.source===null)return!0;let n=e.contentWindow;if(t.source===n)return!0;if(n&&typeof Window<`u`&&t.source instanceof Window)try{return t.source.frameElement===e}catch{}return!1}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`)return;let n,r=t.extensionId;if(e.source instanceof Window){let t=this.byContentWindow.get(e.source);t&&(n=t.iframe,r=t.extensionId)}if(n||(n=this.iframes.get(t.extensionId),r=t.extensionId),!n||!(e.source instanceof Window&&this.byContentWindow.has(e.source))&&!this.isTrustedExtensionSource(n,e))return;if(t.type===`event`){this.handleExtensionEvent(r,t.event,t.data);let e=this.eventSubscribers.get(r);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:i,method:a,params:o}=t,s=this.handlers.get(a);if(!s){this.postResponse(n,e,i,void 0,{code:wF.MethodNotFound,message:`Unknown method: ${a}`});return}let c=DF[a],l=this.extensionPermissions.get(r)??new Set;if(c&&!l.has(c)){this.postResponse(n,e,i,void 0,{code:wF.PermissionDenied,message:`Missing permission: ${c}`});return}try{let t=await s(r,o);this.postResponse(n,e,i,t)}catch(t){let r=t instanceof Error?t.message:String(t);this.postResponse(n,e,i,void 0,{code:wF.InternalError,message:r})}}};function kF(e){e.registerMethod(`theme.get`,async()=>EF(x.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;n&&window.dispatchEvent(new CustomEvent(`extension-navigate`,{detail:{path:n}}))}),e.registerMethod(`ui.notification`,async(e,t)=>{if(!t||typeof t!=`object`)return;let n=t,r=typeof n.title==`string`?n.title.trim():``;r&&re({type:n.type===`success`||n.type===`warning`||n.type===`error`||n.type===`info`?n.type:`info`,title:r,message:typeof n.message==`string`?n.message:void 0,duration:typeof n.duration==`number`?n.duration:void 0})}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`sessionKey`in t?String(t.sessionKey??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await Y(X(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({sessionKey:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,sessionKey:r,newSession:i}=t,a=r?.trim()||``;if(i||!a){let e=await Y(X(`/api/sessions`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({channel:`webchat`})});if(!e.ok)throw Error(`Session create failed: ${e.status}`);if(a=(await e.json()).session?.key??``,!a)throw Error(`Session create did not return a session key`)}let o=await Y(X(`/api/agent`),{method:`POST`,headers:{Accept:`application/json`},body:JSON.stringify({message:n,channel:`webchat`,sessionKey:a})});if(!o.ok)throw Error(`Agent request failed: ${o.status}`);let s=await o.json();return{sessionKey:s.payload?.sessionKey??s.payload?.key??s.sessionKey??a}}),e.registerMethod(`config.get`,async e=>{let t=await Y(X(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await Y(X(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await Y(X(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,i=await Y(X(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!i.ok)throw Error(`Failed to set storage key: ${i.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await Y(X(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await Y(X(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}function AF(e){return e.active||e.activationEligible===!0}function jF(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0||Array.isArray(t.sidebarPanels)&&t.sidebarPanels.length>0:!1}function MF(e){return e.source===`bundled`&&e.hasUi===!0&&jF(e)}function NF(e){return e.kind===`image-generation`||e.kind===`media-provider`}function PF(e){return AF(e)?e.hasConfigSchema||NF(e)?!0:e.hasUi?jF(e):!1:!1}function FF(e){return PF(e)||MF(e)}var IF=(0,Z.createContext)(null);function LF({children:e}){let t=(0,Z.useRef)(null);if(!t.current){let e=new OF;kF(e),t.current=e}let n=t.current,r=q(e=>!!e.token),{data:i,isLoading:a}=ie(r?`gateway-extensions-list`:null,()=>J(X(`/api/extensions`)),{revalidateOnFocus:!1}),o=i?.extensions??[],s=x(e=>e.resolved);(0,Z.useEffect)(()=>{r&&CF.getState().fetchContext()},[r]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&!Array.isArray(t)&&CF.getState().updateContext(t)},t=()=>{CF.getState().fetchContext()};return window.addEventListener(`context-update`,e),window.addEventListener(`config-reload`,t),window.addEventListener(`registry-updated`,t),()=>{window.removeEventListener(`context-update`,e),window.removeEventListener(`config-reload`,t),window.removeEventListener(`registry-updated`,t)}},[]);let c=(0,Z.useCallback)(e=>{let t=e.detail;t?.sessionKey&&n.forwardAgentStreamEvent(t.sessionKey,t.event??t)},[n]),l=(0,Z.useRef)(c);l.current=c,(0,Z.useEffect)(()=>{let e=e=>{l.current(e)};return window.addEventListener(`agent-stream-event`,e),()=>{window.removeEventListener(`agent-stream-event`,e)}},[]),(0,Z.useEffect)(()=>{let e=EF(s);n.broadcastEvent(`theme.changed`,e)},[s,n]);let u=(0,Z.useRef)(n);u.current=n,(0,Z.useEffect)(()=>()=>{u.current.dispose(),t.current=null},[]);let d=(0,Z.useMemo)(()=>({router:n,extensions:o,loading:a}),[n,o,a]);return(0,$.jsx)(IF.Provider,{value:d,children:e})}function RF(){let e=(0,Z.useContext)(IF);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function zF(){let e=(0,Z.useContext)(IF);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function BF(){let e=(0,Q.c)(2),t=zF(),n;return e[0]===t?n=e[1]:(n=t.filter(PF),e[0]=t,e[1]=n),n}function VF(){let e=(0,Z.useContext)(IF);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}function HF(e,t){return t.path.startsWith(`/extensions/`)?t.path:`/extensions/${e}/${t.id.startsWith(`${e}.`)?t.id.slice(e.length+1):t.id}`}function UF(e){return Bk[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]}var WF=[{id:`builtin:agents`,to:`/agents`,Icon:dO},{id:`builtin:projects`,to:`/projects`,Icon:p_},{id:`builtin:goals`,to:`/goals`,Icon:kv},{id:`builtin:skills`,to:`/skills`,Icon:Cv},{id:`builtin:connectors`,to:`/connectors`,Icon:gl},{id:`builtin:automations`,to:`/automations`,Icon:wk},{id:`builtin:channels`,to:`/channels`,Icon:Iy},{id:`builtin:extensions`,to:`/extensions`,Icon:$y},{id:`builtin:notes`,to:`/notes`,Icon:hT},{id:`builtin:workflows`,to:`/workflows`,Icon:iv}];function GF(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r=[],i=new Set;for(let e of t){let t=n.get(e);!t||i.has(e)||(r.push(t),i.add(e))}for(let t of e)i.has(t.id)||(r.push(t),i.add(t.id));return r.length<=4?{visible:r,overflow:[],hasOverflow:!1}:{visible:r.slice(0,4),overflow:r.slice(4),hasOverflow:!0}}var KF=`text/plain`,qF=`xopc-nav:`;function JF(e){return`${qF}${e}`}function YF(e){return e.startsWith(qF)?e.slice(9):null}function XF(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function ZF({isActive:e},t,n,r){return u(`group relative flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,t?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,n&&`opacity-40`,r===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,r===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`)}function QF({isActive:e},t,n){return u(`group relative flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm font-medium leading-5 transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,t&&`opacity-40`,n===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,n===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`)}function $F(e){let t=(0,Q.c)(11),{item:n,collapsed:r}=e,{Icon:i,letter:a}=n;if(i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=u(`size-4`,`shrink-0 opacity-90`),t[0]=e):e=t[0];let n;return t[1]===i?n=t[2]:(n=(0,$.jsx)(i,{className:e,strokeWidth:1.75,"aria-hidden":!0}),t[1]=i,t[2]=n),n}let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=u(`size-4`,`flex shrink-0 items-center justify-center text-[10px] font-bold opacity-70`),t[3]=o):o=t[3];let s;t[4]!==n.label||t[5]!==a?(s=a??n.label.charAt(0),t[4]=n.label,t[5]=a,t[6]=s):s=t[6];let c;t[7]===s?c=t[8]:(c=s.toUpperCase(),t[7]=s,t[8]=c);let l;return t[9]===c?l=t[10]:(l=(0,$.jsx)(`span`,{className:o,"aria-hidden":!0,children:c}),t[9]=c,t[10]=l),l}function eI(e){let t=[];for(let n of e){if(n.activationEligible===!1)continue;let e=n.ui?.contributions?.pages;if(e)for(let r of e){if(!r.showInNav)continue;let e=r.navIcon?UF(r.navIcon):void 0;t.push({id:`ext:${n.id}:${r.id}`,kind:`extension`,label:r.title,to:HF(n.id,r),Icon:e,letter:r.title.charAt(0),title:r.title})}}return t}function tI(e){let t=(0,Q.c)(52),{collapsed:n,onNavigate:r}=e,i=n===void 0?!1:n,a=_(sI),o;t[0]===a?o=t[1]:(o=m(a),t[0]=a,t[1]=o);let s=o,c=BF(),l=PP(oI),d=PP(aI),f=PP(iI),[p,h]=(0,Z.useState)(null),[g,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),C;if(t[2]!==s.nav||t[3]!==c){let e;t[5]===s.nav?e=t[6]:(e=e=>{let t=e.id.slice(8);return{id:e.id,kind:`builtin`,label:s.nav[t],to:e.to,Icon:e.Icon}},t[5]=s.nav,t[6]=e);let n=WF.map(e),r=eI(c);C=[...n,...r],t[2]=s.nav,t[3]=c,t[4]=C}else C=t[4];let w=C,T;t[7]!==w||t[8]!==l?(T=GF(w,l),t[7]=w,t[8]=l,t[9]=T):T=t[9];let E=T,D;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>t=>{t.dataTransfer.setData(KF,JF(e)),t.dataTransfer.effectAllowed=`move`,h(e)},t[10]=D):D=t[10];let O=D,k;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{h(null),v(null),b(!1)},t[11]=k):k=t[11];let A=k,j;t[12]!==p||t[13]!==g?(j=e=>t=>{if(!p)return;t.preventDefault(),t.dataTransfer.dropEffect=`move`;let n=XF(t);g?.id===e&&g.position===n||v({id:e,position:n})},t[12]=p,t[13]=g,t[14]=j):j=t[14];let M=j,N;t[15]===d?N=t[16]:(N=e=>t=>{t.preventDefault();let n=YF(t.dataTransfer.getData(KF));if(!n||n===e){A();return}d(n,e,XF(t)),A()},t[15]=d,t[16]=N);let P=N,F;t[17]===p?F=t[18]:(F=e=>{p&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,b(!0))},t[17]=p,t[18]=F);let I=F,L;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>b(!1),t[19]=L):L=t[19];let R=L,z;t[20]===f?z=t[21]:(z=e=>{e.preventDefault();let t=YF(e.dataTransfer.getData(KF));t&&f(t),A()},t[20]=f,t[21]=z);let B=z,V=rI,H;t[22]!==i||t[23]!==p||t[24]!==g||t[25]!==r||t[26]!==M||t[27]!==P?(H=function(e){let t=p===e.id,n=g?.id===e.id?g.position:null;return(0,$.jsxs)(Ui,{to:e.to,draggable:!0,onDragStart:O(e.id),onDragEnd:A,onDragOver:M(e.id),onDrop:P(e.id),className:e=>ZF(e,i,t,n),title:e.title??e.label,onMouseEnter:()=>V(e.to),onFocus:()=>V(e.to),onClick:()=>r?.(),children:[(0,$.jsx)($F,{item:e,collapsed:i}),i?null:(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id)},t[22]=i,t[23]=p,t[24]=g,t[25]=r,t[26]=M,t[27]=P,t[28]=H):H=t[28];let U=H,W;t[29]!==i||t[30]!==p||t[31]!==g||t[32]!==s.sidebar.moreApps||t[33]!==s.sidebar.moreAppsAria||t[34]!==y||t[35]!==I||t[36]!==B||t[37]!==r||t[38]!==M||t[39]!==P||t[40]!==x||t[41]!==E.overflow?(W=function(){return(0,$.jsxs)(oj,{open:x,onOpenChange:S,children:[(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onDragOver:I,onDragLeave:R,onDrop:B,className:u(`flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,x?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,y&&`ring-2 ring-accent ring-offset-2 ring-offset-surface-base`),"aria-label":s.sidebar.moreAppsAria,title:s.sidebar.moreApps,children:[(0,$.jsx)(sh,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),i?null:(0,$.jsx)(`span`,{className:`truncate`,children:s.sidebar.moreApps})]})}),(0,$.jsx)(lj,{children:(0,$.jsx)(uj,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,className:u(`z-50 min-w-[14rem] max-w-[20rem] rounded-lg border border-edge bg-surface-panel p-1 shadow-md`),onOpenAutoFocus:nI,children:(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,role:`list`,"aria-label":s.sidebar.moreAppsAria,children:E.overflow.map(e=>{let t=p===e.id,n=g?.id===e.id?g.position:null;return(0,$.jsx)(`li`,{className:`contents`,children:(0,$.jsxs)(Ui,{to:e.to,draggable:!0,onDragStart:O(e.id),onDragEnd:A,onDragOver:M(e.id),onDrop:P(e.id),className:e=>QF(e,t,n),title:e.title??e.label,onMouseEnter:()=>V(e.to),onFocus:()=>V(e.to),onClick:()=>{S(!1),r?.()},children:[(0,$.jsx)($F,{item:e}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.id)})})})})]})},t[29]=i,t[30]=p,t[31]=g,t[32]=s.sidebar.moreApps,t[33]=s.sidebar.moreAppsAria,t[34]=y,t[35]=I,t[36]=B,t[37]=r,t[38]=M,t[39]=P,t[40]=x,t[41]=E.overflow,t[42]=W):W=t[42];let G=W,K;t[43]!==E.visible||t[44]!==U?(K=E.visible.map(U),t[43]=E.visible,t[44]=U,t[45]=K):K=t[45];let q;t[46]!==E.hasOverflow||t[47]!==G?(q=E.hasOverflow?G():null,t[46]=E.hasOverflow,t[47]=G,t[48]=q):q=t[48];let ee;return t[49]!==K||t[50]!==q?(ee=(0,$.jsxs)($.Fragment,{children:[K,q]}),t[49]=K,t[50]=q,t[51]=ee):ee=t[51],ee}function nI(e){return e.preventDefault()}function rI(e){xF(e)}function iI(e){return e.moveToEnd}function aI(e){return e.move}function oI(e){return e.order}function sI(e){return e.language}var cI={feishu:`/channel-icons/feishu.svg`,lark:`/channel-icons/lark.svg`,telegram:`/channel-icons/telegram.svg`,wechat:`/channel-icons/wechat.svg`,weixin:`/channel-icons/weixin.svg`};function lI(e){let t=(0,Q.c)(9),{sourceChannel:n,className:r}=e,i=cI[n.toLowerCase()];if(i){let e;t[0]===r?e=t[1]:(e=u(`shrink-0`,r),t[0]=r,t[1]=e);let n;return t[2]!==i||t[3]!==e?(n=(0,$.jsx)(`img`,{src:i,alt:``,draggable:!1,className:e,"aria-hidden":!0}),t[2]=i,t[3]=e,t[4]=n):n=t[4],n}let a;t[5]===r?a=t[6]:(a=u(`shrink-0`,r),t[5]=r,t[6]=a);let o;return t[7]===a?o=t[8]:(o=(0,$.jsx)(cv,{className:a,strokeWidth:1.75,"aria-hidden":!0}),t[7]=a,t[8]=o),o}function uI(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=u(`animate-pulse rounded-md bg-surface-hover/70 motion-reduce:animate-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"aria-hidden":`true`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function dI(){return X(`/api/config`)}var fI=null;async function pI(){return fI||(fI=J(dI()).finally(()=>{fI=null}),fI)}function mI(e){let t=(0,Q.c)(6),n;t[0]===e?n=t[1]:(n=e?dI():null,t[0]=e,t[1]=n);let r=n,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let a=ie(r,pI,i),o,s;return t[3]===e?(o=t[4],s=t[5]):(o=()=>{if(!e)return;let t=dI(),n=e=>{ce(e.detail)||oe(t)};return window.addEventListener(`config-reload`,n),()=>window.removeEventListener(`config-reload`,n)},s=[e],t[3]=e,t[4]=o,t[5]=s),(0,Z.useEffect)(o,s),a}function hI(){return oe(dI())}var gI=null;async function _I(){return gI||(gI=vI().finally(()=>{gI=null}),gI)}async function vI(){let e=await Y(X(`/api/agents`));if(e.ok){let t=await e.json();if(t.ok&&t.payload?.defaultId&&Array.isArray(t.payload.agents)){let e=t.payload.defaultId.trim().toLowerCase(),n=t.payload.agents.filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{}}));if(n.length>0)return{defaultId:e,items:n}}}let t=(await pI()).payload?.config?.agents,n=(t?.defaultId??`main`).trim().toLowerCase(),r=(Array.isArray(t?.list)?t.list:[]).filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase()}));return r.length===0?{defaultId:n,items:[{id:n}]}:{defaultId:n,items:r}}var yI=`xopc-pending-agent-run-changed`;function bI(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(yI,{detail:{chatId:e}}))}var xI=/^No API key found for (\S+)/i;function SI(e){try{let t=JSON.parse(e);return typeof t.kind!=`string`||typeof t.message!=`string`?null:{kind:t.kind,code:typeof t.code==`string`?t.code:t.kind,provider:typeof t.provider==`string`?t.provider:void 0,modelRef:typeof t.modelRef==`string`?t.modelRef:void 0,deepLink:typeof t.deepLink==`string`?t.deepLink:void 0,message:t.message}}catch{return null}}function CI(){return{kind:`send_failed`,code:`send_failed`,message:`Send failed`}}function wI(e){let t=e.trim();if(!t)return null;if(t.startsWith(`{`)){let e=SI(t);if(e)return e}let n=xI.exec(t);return n?{kind:`provider_setup_required`,code:`provider_setup_required`,provider:n[1].replace(/[.,]$/,``),deepLink:`/settings/credentials`,message:t}:t===`Assistant turn failed`||t.startsWith(`Error: `)?{kind:`unknown`,code:`unknown`,message:t.startsWith(`Error: `)?t.slice(7):t}:{kind:`unknown`,code:`unknown`,message:t}}function TI(e){return e.kind!==`provider_setup_required`||!e.provider?null:{kind:`provider_setup_required`,provider:e.provider,deepLink:`/settings/credentials`,message:e.message}}function EI(e){return typeof e==`object`&&!!e&&`role`in e}function DI(e){if(!e||typeof e!=`object`)return!1;let t=e.type;return t===`tool_use`||t===`tool_call`||t===`toolCall`}function OI(e){return typeof e==`object`&&!!e}function kI(e){return typeof e.id==`string`&&e.id.length>0?e.id:crypto.randomUUID()}function AI(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function jI(e){return AI(e.args??e.arguments??e.input??e.function?.arguments)??{}}function MI(e){if(typeof e==`string`){let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}return Date.now()}var NI=3e5;function PI(e,t){let n=new URLSearchParams({uri:e.trim()});return t?.trim()&&n.set(`sessionKey`,t.trim()),`/api/media/read?${n.toString()}`}function FI(e){if(typeof e.content==`string`&&e.content.length>0)return e.content;if(typeof e.data==`string`&&e.data.length>0)return e.data}var II=[`.txt`,`.md`,`.json`,`.xml`,`.html`,`.css`,`.js`,`.ts`,`.jsx`,`.tsx`,`.yml`,`.yaml`];function LI(e){let t=e.mimeType?.toLowerCase()??``;if(t.startsWith(`text/`)||t===`application/json`||t===`application/xml`||t===`application/javascript`||t===`application/typescript`)return!0;let n=e.name?.toLowerCase()??``;return II.some(e=>n.endsWith(e))}function RI(e){if(e.extractedText!=null&&e.extractedText!==``)return e.extractedText;if(!LI(e))return;let t=FI(e);if(t)try{let e=VI(t);return new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(e))}catch{return}}function zI(e,t){let n=t.trim();if(n.startsWith(`data:`))return n;let r=n.replace(/\s/g,``);return`data:${e&&typeof e==`string`&&e.includes(`/`)?e:`application/octet-stream`};base64,${r}`}function BI(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode(...i)}return btoa(n)}function VI(e){if(e==null||e===``)throw Error(`Missing file data`);let t=e;if(e.startsWith(`data:`)){let n=e.match(/base64,(.+)/);n&&(t=n[1])}let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}function HI(e){let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(1)} ${t[n]}`}function UI(e){let t=e.toLowerCase();for(let[e,n]of[[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.bmp`,`image/bmp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.ico`,`image/x-icon`],[`.tif`,`image/tiff`],[`.tiff`,`image/tiff`],[`.avif`,`image/avif`],[`.jxl`,`image/jxl`]])if(t.endsWith(e))return n}function WI(e,t){return(t?.startsWith(`text/`)??!1)||II.some(t=>e.toLowerCase().endsWith(t))}function GI(e){if(Array.isArray(e))return e.map(e=>KI(e))}function KI(e){if(!e||typeof e!=`object`)return{name:`file`,mimeType:`application/octet-stream`};let t=e,n=qI(t.uri),r=JI(t.name),i=YI(t.mimeType,r),a=typeof t.type==`string`?t.type:void 0,o=a===`photo`||a===`image`||i.startsWith(`image/`)?`image`:a===`voice`||a===`audio`||i.startsWith(`audio/`)?`voice`:a;return{id:typeof t.id==`string`?t.id:void 0,name:r,mimeType:i,type:o,size:typeof t.size==`number`?t.size:void 0,uri:n,bucket:typeof t.bucket==`string`?t.bucket:void 0,path:typeof t.path==`string`?t.path:void 0}}function qI(e){return typeof e==`string`&&e.trim().startsWith(`media://`)?e.trim():void 0}function JI(e){return typeof e==`string`&&e.trim().length>0?e.trim():`file`}function YI(e,t){if(typeof e==`string`&&e.trim().length>0){let t=e.trim();if(t.toLowerCase().split(`;`)[0]?.trim()!==`application/octet-stream`)return t}return UI(t)??`application/octet-stream`}function XI(e){let t=e.uri?.trim();return t?`uri:${t}`:e.id?`id:${e.id}`:`name:${e.name??`file`}|${e.mimeType??``}`}function ZI(e){if(!e?.length)return;let t=[],n=new Set;for(let r of e){let e=XI(r);n.has(e)||(n.add(e),t.push(r))}return t.length?t:void 0}var QI=`[Startup context loaded by runtime]`,$I=`...[additional startup memory truncated]...`,eL=`END_QUOTED_NOTES`;function tL(e){if(!e.includes(QI))return e;let t=e.replace(/^\uFEFF/,``);if(!t.startsWith(QI))return e;let n=-1,r=t.lastIndexOf(eL);if(r>=0)n=r+16;else{let e=t.indexOf($I);e>=0&&(n=e+43)}if(n<0){let n=t.slice(35),r=n.indexOf(`
13
+ `);let c=r.split(UN);r=c.pop()??``;for(let e of c)e.length&&o(e);return e()},a=await e();if(a)return a}finally{t.releaseLock()}return i??{ok:!1,error:`no-result`,message:`Update stream ended without a result`,status:0}}var eP=`xopc.updateReminder.dismissed`,tP=typeof window<`u`&&window.electronAPI?.updater!==void 0,nP=`xopc:electron-update-recheck`;function rP(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(eP);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}var iP=160;function aP(e){let t=e.trim();return t.length<=iP?t:`${t.slice(0,iP-1)}…`}function oP(){let{npm:e,electron:t,isElectron:n,electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}=XN(),[o,s]=(0,Z.useState)(rP),[c,l]=(0,Z.useState)({downloading:!1,electronError:!1}),[u,d]=(0,Z.useState)(()=>{if(typeof window>`u`||tP)return null;try{let e=sessionStorage.getItem(GN);if(!e)return null;let t=JSON.parse(e);return(typeof t.installedVersion==`string`?t.installedVersion.trim():``)||null}catch{return null}}),f=(0,Z.useRef)(t?.state);f.current!==t?.state&&(f.current=t?.state,t?.state!==`downloading`&&c.downloading&&l(e=>({...e,downloading:!1})),t?.state!==`error`&&c.electronError&&l(e=>({...e,electronError:!1})));let p=(0,Z.useRef)(null);if(u&&e?.currentVersion===u&&p.current!==u){p.current=u;try{sessionStorage.removeItem(GN)}catch{}d(null)}(0,Z.useEffect)(()=>{if(n)return;let e=()=>{try{let e=sessionStorage.getItem(GN);if(!e){d(null);return}let t=JSON.parse(e);d((typeof t.installedVersion==`string`?t.installedVersion.trim():``)||null)}catch{d(null)}};return e(),window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[n]),(0,Z.useEffect)(()=>{let e=()=>{l(e=>({...e,downloading:!1})),s(e=>{let t={...e};delete t.electronReady;try{localStorage.setItem(eP,JSON.stringify(t))}catch{}return t})};return window.addEventListener(nP,e),()=>window.removeEventListener(nP,e)},[]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail?.version?.trim();t&&s(e=>{let n={...e,npm:t};try{localStorage.setItem(eP,JSON.stringify(n))}catch{}return n})};return window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[]);let m=(0,Z.useMemo)(()=>n&&t?.state===`downloaded`&&t.version?o.electronReady===t.version?{kind:`none`}:{kind:`electron-ready`,version:t.version}:n&&t?.state===`downloading`&&!c.downloading?{kind:`electron-downloading`,percent:Math.round(t.percent??0)}:n&&t?.state===`error`&&t.message&&!c.electronError?{kind:`electron-error`,message:aP(t.message)}:!n&&u&&e&&e.currentVersion!==u?{kind:`npm-restart-required`,version:u}:!n&&e?.updateAvailable&&e.latestVersion?o.npm===e.latestVersion?{kind:`none`}:{kind:`npm`,version:e.latestVersion,channel:e.channel}:{kind:`none`},[o.npm,o.electronReady,t,c.downloading,c.electronError,n,e,u]);return{show:m,dismiss:(0,Z.useCallback)(()=>{if(m.kind===`electron-downloading`){l(e=>({...e,downloading:!0}));return}if(m.kind===`electron-error`){l(e=>({...e,electronError:!0}));return}if(m.kind===`npm-restart-required`){try{sessionStorage.removeItem(GN)}catch{}d(null);return}if(m.kind===`none`)return;let e={...o};m.kind===`npm`?e.npm=m.version:m.kind===`electron-ready`&&(e.electronReady=m.version);try{localStorage.setItem(eP,JSON.stringify(e))}catch{}s(e)},[o,m]),electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}}var sP={version:`0.0.129`,commit:`99f39bc81ef41d66c1e73522f767068874d669fd`,buildTimeIso:`2026-07-13T15:21:33.489Z`};function cP(){return function(e,t){switch(t.type){case`start`:return e.loading?e:{...e,loading:!0,error:null};case`success`:return{data:t.data,loading:!1,error:null};case`error`:return{data:t.data,loading:!1,error:t.error};case`patch`:return{...e,data:t.updater(e.data)}}}}function lP(e,t,n){let{enabled:r=!0,initial:i,errorData:a}=n,[o,s]=(0,Z.useReducer)(cP(),void 0,()=>({data:i,loading:!1,error:null})),c=(0,Z.useRef)(e);c.current=e;let l=(0,Z.useRef)(a);l.current=a;let u=(0,Z.useRef)(i);u.current=i,(0,Z.useEffect)(()=>{if(!r)return;let e=!1;return s({type:`start`}),c.current().then(t=>{e||s({type:`success`,data:t})}).catch(t=>{if(e)return;let n=l.current;s({type:`error`,data:typeof n==`function`?n(t):n===void 0?u.current:n,error:t})}),()=>{e=!0}},[r,...t]);let d=(0,Z.useCallback)(e=>{s({type:`patch`,updater:typeof e==`function`?e:()=>e})},[]);return{...o,setData:d}}var uP=`https://github.com/xopcai/xopc`,dP=new Intl.DateTimeFormat(`zh-CN`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),fP=new Intl.DateTimeFormat(`en-US`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function pP(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return(t===`zh`?dP:fP).format(n)}catch{return n.toISOString()}}function mP({open:e,onOpenChange:t}){let n=_(e=>e.language),r=m(n),i=r.aboutDialog,a=r.updatePanel,{isElectron:o,electron:s,electronCheck:c,checkNow:l,npm:d,runNpmUpdate:f,npmUpdateRunning:p}=XN(),[h,g]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),{data:S}=lP(async()=>{let e=await J(X(`/health`));return typeof e.version==`string`?e.version:null},[e],{enabled:e,initial:null,errorData:null}),C=(0,Z.useCallback)(e=>{e||(g(!1),y(!1),x(!1)),t(e)},[t]),w=(0,Z.useCallback)(async()=>{let e=m(n).updatePanel,t=await f();if(t.ok){re({type:`success`,title:e.updateSuccess,message:e.updateSuccessDetail});return}re({type:`error`,title:t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed,message:t.message})},[f,n]),T=sP.commit,E=n===`zh`?`zh-CN`:`en-US`,D=pP(sP.buildTimeIso,E),O=new Date().getFullYear(),k=i.copyright.replace(`{year}`,String(O));return(0,$.jsx)(FN,{open:e,onOpenChange:C,children:(0,$.jsxs)(LN,{children:[(0,$.jsx)(RN,{className:`xopc-dialog-overlay fixed inset-0 z-[200] bg-scrim`}),(0,$.jsxs)(zN,{className:u(`xopc-dialog-content fixed left-1/2 top-1/2 z-[201] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-panel shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#ff5f57]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#febc2e]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#28c840]`})]}),(0,$.jsxs)(`div`,{className:`px-6 pb-2 pt-1`,children:[(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(HN,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":i.close,children:(0,$.jsx)(Sk,{className:`size-4`,strokeWidth:2})})})}),(0,$.jsxs)(`div`,{className:`-mt-2 flex flex-col items-center text-center`,children:[(0,$.jsx)(Hk,{className:`size-[4.5rem]`,alt:r.appBrand}),(0,$.jsx)(BN,{className:`mt-3 text-xl font-semibold tracking-tight text-fg`,children:r.appBrand}),(0,$.jsx)(VN,{className:`sr-only`,children:i.windowTitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 space-y-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.versionLabel}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2 sm:justify-start`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[13px] text-fg tabular-nums`,children:sP.version}),(0,$.jsx)(`button`,{type:`button`,className:u(`shrink-0 rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,`transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{o?(window.dispatchEvent(new CustomEvent(nP)),g(!0),c()):(g(!0),x(!1),y(!0),(async()=>{let e=await l();y(!1),e||x(!0)})())},disabled:o&&[`checking`,`available`,`downloading`,`downloaded`].includes(s?.state??``)||!o&&(v||p),children:o&&s?.state===`checking`||!o&&v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Fv,{className:`size-3 animate-spin`}),i.checkUpdatesChecking]}):i.checkUpdates})]})]}),o&&h&&(0,$.jsx)(hP,{state:s?.state,version:s?.version,percent:s?.percent,d:i}),!o&&h&&(0,$.jsx)(gP,{checking:v,checkFailed:b,npm:d,npmUpdateRunning:p,onUpgrade:w,d:i,tp:a}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`pt-0.5 text-fg-muted`,children:i.commitLabel}),(0,$.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg`,children:T})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.buildDateLabel}),(0,$.jsx)(`span`,{className:`text-right text-[13px] text-fg sm:text-left`,children:D})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.gatewayVersionLabel}),(0,$.jsx)(`span`,{className:`text-right font-mono text-[13px] text-fg sm:text-left`,children:S??i.gatewayUnavailable})]}),(0,$.jsx)(`p`,{className:`pt-0.5 text-[11px] text-fg-subtle`,children:i.consoleBuildHint})]}),(0,$.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 text-center text-[11px] leading-relaxed text-fg-muted`,children:[(0,$.jsx)(`p`,{children:(0,$.jsx)(`a`,{className:`text-accent-fg underline decoration-accent-fg/40 underline-offset-2 hover:decoration-accent-fg`,href:uP,target:`_blank`,rel:`noopener noreferrer`,children:i.repositoryLink})}),(0,$.jsx)(`p`,{className:`mt-2`,children:k})]})]})]})]})})}function hP(e){let t=(0,Q.c)(29),{state:n,version:r,percent:i,d:a}=e;if(!n||n===`idle`)return null;if(n===`checking`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Fv,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===a.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesChecking})]}),t[1]=a.checkUpdatesChecking,t[2]=n),n}if(n===`not-available`){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(vd,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===a.checkUpdatesUpToDate?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesUpToDate})]}),t[4]=a.checkUpdatesUpToDate,t[5]=n),n}if(n===`available`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Lb,{className:`size-3.5`}),t[6]=e):e=t[6];let n;t[7]!==a.checkUpdatesAvailable||t[8]!==r?(n=a.checkUpdatesAvailable.replace(`{version}`,r??`?`),t[7]=a.checkUpdatesAvailable,t[8]=r,t[9]=n):n=t[9];let i;return t[10]===n?i=t[11]:(i=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[10]=n,t[11]=i),i}if(n===`downloading`){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Bm,{className:`size-3.5 motion-safe:animate-[bounce_1s_ease-out_infinite]`}),t[12]=e):e=t[12];let n=a.checkUpdatesDownloading,r;if(t[13]!==a.checkUpdatesDownloading||t[14]!==i){let e;t[16]===i?e=t[17]:(e=Math.round(i??0),t[16]=i,t[17]=e),r=n.replace(`{percent}`,String(e)),t[13]=a.checkUpdatesDownloading,t[14]=i,t[15]=r}else r=t[15];let o;return t[18]===r?o=t[19]:(o=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:r})]}),t[18]=r,t[19]=o),o}if(n===`downloaded`){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Bm,{className:`size-3.5`}),t[20]=e):e=t[20];let n;t[21]!==a.checkUpdatesDownloaded||t[22]!==r?(n=a.checkUpdatesDownloaded.replace(`{version}`,r??`?`),t[21]=a.checkUpdatesDownloaded,t[22]=r,t[23]=n):n=t[23];let i;return t[24]===n?i=t[25]:(i=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] font-semibold text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[24]=n,t[25]=i),i}if(n===`error`){let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ld,{className:`size-3.5`}),t[26]=e):e=t[26];let n;return t[27]===a.checkUpdatesError?n=t[28]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesError})]}),t[27]=a.checkUpdatesError,t[28]=n),n}return null}function gP(e){let t=(0,Q.c)(25),{checking:n,checkFailed:r,npm:i,npmUpdateRunning:a,onUpgrade:o,d:s,tp:c}=e;if(n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Fv,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===s.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:s.checkUpdatesChecking})]}),t[1]=s.checkUpdatesChecking,t[2]=n),n}if(r){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ld,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===s.checkUpdatesError?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:s.checkUpdatesError})]}),t[4]=s.checkUpdatesError,t[5]=n),n}if(a){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Fv,{className:`size-3.5 animate-spin`}),t[6]=e):e=t[6];let n;return t[7]===c.updateRunning?n=t[8]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:c.updateRunning})]}),t[7]=c.updateRunning,t[8]=n),n}if(i?.updateAvailable&&i.latestVersion){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Lb,{className:`mt-0.5 size-3.5 shrink-0`}),t[9]=e):e=t[9];let n;t[10]!==i.latestVersion||t[11]!==c.reminderNpm?(n=c.reminderNpm.replace(`{{version}}`,i.latestVersion),t[10]=i.latestVersion,t[11]=c.reminderNpm,t[12]=n):n=t[12];let r;t[13]===n?r=t[14]:(r=(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[13]=n,t[14]=r);let a;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(a=u(`w-full rounded-lg bg-accent px-3 py-1.5 text-center text-xs font-medium text-white`,`hover:bg-accent/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),t[15]=a):a=t[15];let s;t[16]!==o||t[17]!==c.updateNow?(s=(0,$.jsx)(`button`,{type:`button`,onClick:o,className:a,children:c.updateNow}),t[16]=o,t[17]=c.updateNow,t[18]=s):s=t[18];let l;return t[19]!==r||t[20]!==s?(l=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[r,s]}),t[19]=r,t[20]=s,t[21]=l):l=t[21],l}let l;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(vd,{className:`size-3.5`}),t[22]=l):l=t[22];let d;return t[23]===s.checkUpdatesUpToDate?d=t[24]:(d=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[l,(0,$.jsx)(`span`,{children:s.checkUpdatesUpToDate})]}),t[23]=s.checkUpdatesUpToDate,t[24]=d),d}var _P=u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out`,`hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),vP=u(`rounded-xl border border-edge bg-surface-panel p-1 shadow-popover`,`dark:border-edge`);function yP(e){let t=(0,Q.c)(14),{selected:n,label:r,onSelect:i}=e,a=n&&`bg-accent-soft text-accent-fg hover:bg-accent-soft`,o;t[0]===a?o=t[1]:(o=u(`flex w-full items-center justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),t[2]=r,t[3]=s);let c=n?`opacity-100`:`opacity-0`,l;t[4]===c?l=t[5]:(l=u(`size-4 shrink-0`,c),t[4]=c,t[5]=l);let d;t[6]===l?d=t[7]:(d=(0,$.jsx)(Iu,{className:l,strokeWidth:2,"aria-hidden":!0}),t[6]=l,t[7]=d);let f;return t[8]!==i||t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:o,onClick:i,children:[s,d]}),t[8]=i,t[9]=n,t[10]=o,t[11]=s,t[12]=d,t[13]=f):f=t[13],f}function bP(e){let t=(0,Q.c)(198),{onOpenFullSettings:n,onAboutClick:r}=e,[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),c=_(EP),l=_(TP),d=x(wP),f=x(CP),p=jA(SP),h=jA(xP),g;t[0]===c?g=t[1]:(g=m(c),t[0]=c,t[1]=g);let v=g,y=v.appearanceSettings,b=c===`zh`?y.langOptionZh:y.langOptionEn,S=d===`light`?y.themeOptionLight:d===`dark`?y.themeOptionDark:y.themeOptionSystem,C=p===`compact`?y.fontScaleCompact:p===`large`?y.fontScaleLarge:y.fontScaleDefault,w=typeof window<`u`?window.electronAPI?.pet:void 0,T=!!w,E=o?.visible?y.hideDesktopPet:y.showDesktopPet,D,O;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{if(!w)return;let e=!1;w.getState().then(t=>{e||s(t)});let t=w.onStateChanged(t=>{e||s(t)});return()=>{e=!0,t()}},O=[w],t[2]=D,t[3]=O):(D=t[2],O=t[3]),(0,Z.useEffect)(D,O);let k;t[4]===o?.visible?k=t[5]:(k=async()=>{w&&(o?.visible?await w.hide():await w.show(),s(await w.getState()))},t[4]=o?.visible,t[5]=k);let A=k,j;t[6]===i?j=t[7]:(j=e=>u(`absolute left-full top-0 z-[60] min-w-[8.75rem] max-w-[min(calc(100vw-2rem),12rem)]`,`ml-2 sm:ml-2.5`,i===e?`block`:`hidden`),t[6]=i,t[7]=j);let M=j,N;t[8]===i?N=t[9]:(N=e=>u(`absolute left-full top-0 z-[55] h-full w-8 sm:w-9`,i===e?`pointer-events-auto`:`pointer-events-none`),t[8]=i,t[9]=N);let P=N,F;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>a(null),t[10]=F):F=t[10];let I;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>a(`lang`),t[11]=I):I=t[11];let L=i===`lang`&&`bg-surface-hover`,R;t[12]===L?R=t[13]:(R=u(_P,L),t[12]=L,t[13]=R);let z=i===`lang`,B;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(ov,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=B):B=t[14];let V;t[15]===y.languageTitle?V=t[16]:(V=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:y.languageTitle}),t[15]=y.languageTitle,t[16]=V);let H;t[17]===b?H=t[18]:(H=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:b}),t[17]=b,t[18]=H);let U;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(Yu,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[19]=U):U=t[19];let W;t[20]!==R||t[21]!==z||t[22]!==V||t[23]!==H?(W=(0,$.jsxs)(`button`,{type:`button`,className:R,"aria-haspopup":`menu`,"aria-expanded":z,children:[B,V,H,U]}),t[20]=R,t[21]=z,t[22]=V,t[23]=H,t[24]=W):W=t[24];let G;t[25]===P?G=t[26]:(G=P(`lang`),t[25]=P,t[26]=G);let K;t[27]===G?K=t[28]:(K=(0,$.jsx)(`div`,{className:G,"aria-hidden":!0}),t[27]=G,t[28]=K);let q;t[29]===M?q=t[30]:(q=M(`lang`),t[29]=M,t[30]=q);let ee=c===`en`,J;t[31]===l?J=t[32]:(J=()=>l(`en`),t[31]=l,t[32]=J);let te;t[33]!==y.langOptionEn||t[34]!==ee||t[35]!==J?(te=(0,$.jsx)(yP,{selected:ee,label:y.langOptionEn,onSelect:J}),t[33]=y.langOptionEn,t[34]=ee,t[35]=J,t[36]=te):te=t[36];let Y=c===`zh`,ne;t[37]===l?ne=t[38]:(ne=()=>l(`zh`),t[37]=l,t[38]=ne);let re;t[39]!==y.langOptionZh||t[40]!==Y||t[41]!==ne?(re=(0,$.jsx)(yP,{selected:Y,label:y.langOptionZh,onSelect:ne}),t[39]=y.langOptionZh,t[40]=Y,t[41]=ne,t[42]=re):re=t[42];let X;t[43]!==te||t[44]!==re?(X=(0,$.jsxs)(`div`,{className:vP,children:[te,re]}),t[43]=te,t[44]=re,t[45]=X):X=t[45];let ie;t[46]!==y.languageTitle||t[47]!==q||t[48]!==X?(ie=(0,$.jsx)(`div`,{className:q,role:`menu`,"aria-label":y.languageTitle,children:X}),t[46]=y.languageTitle,t[47]=q,t[48]=X,t[49]=ie):ie=t[49];let ae;t[50]!==W||t[51]!==K||t[52]!==ie?(ae=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:I,children:[W,K,ie]}),t[50]=W,t[51]=K,t[52]=ie,t[53]=ae):ae=t[53];let oe;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>a(`theme`),t[54]=oe):oe=t[54];let se=i===`theme`&&`bg-surface-hover`,ce;t[55]===se?ce=t[56]:(ce=u(_P,se),t[55]=se,t[56]=ce);let le=i===`theme`,ue;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)($v,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=ue):ue=t[57];let de;t[58]===y.themeTitle?de=t[59]:(de=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:y.themeTitle}),t[58]=y.themeTitle,t[59]=de);let fe;t[60]===S?fe=t[61]:(fe=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:S}),t[60]=S,t[61]=fe);let pe;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(Yu,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[62]=pe):pe=t[62];let me;t[63]!==ce||t[64]!==le||t[65]!==de||t[66]!==fe?(me=(0,$.jsxs)(`button`,{type:`button`,className:ce,"aria-haspopup":`menu`,"aria-expanded":le,children:[ue,de,fe,pe]}),t[63]=ce,t[64]=le,t[65]=de,t[66]=fe,t[67]=me):me=t[67];let he;t[68]===P?he=t[69]:(he=P(`theme`),t[68]=P,t[69]=he);let ge;t[70]===he?ge=t[71]:(ge=(0,$.jsx)(`div`,{className:he,"aria-hidden":!0}),t[70]=he,t[71]=ge);let _e;t[72]===M?_e=t[73]:(_e=M(`theme`),t[72]=M,t[73]=_e);let ve=d===`light`,ye;t[74]===f?ye=t[75]:(ye=()=>f(`light`),t[74]=f,t[75]=ye);let be;t[76]!==y.themeOptionLight||t[77]!==ve||t[78]!==ye?(be=(0,$.jsx)(yP,{selected:ve,label:y.themeOptionLight,onSelect:ye}),t[76]=y.themeOptionLight,t[77]=ve,t[78]=ye,t[79]=be):be=t[79];let xe=d===`dark`,Se;t[80]===f?Se=t[81]:(Se=()=>f(`dark`),t[80]=f,t[81]=Se);let Ce;t[82]!==y.themeOptionDark||t[83]!==xe||t[84]!==Se?(Ce=(0,$.jsx)(yP,{selected:xe,label:y.themeOptionDark,onSelect:Se}),t[82]=y.themeOptionDark,t[83]=xe,t[84]=Se,t[85]=Ce):Ce=t[85];let we=d===`system`,Te;t[86]===f?Te=t[87]:(Te=()=>f(`system`),t[86]=f,t[87]=Te);let Ee;t[88]!==y.themeOptionSystem||t[89]!==we||t[90]!==Te?(Ee=(0,$.jsx)(yP,{selected:we,label:y.themeOptionSystem,onSelect:Te}),t[88]=y.themeOptionSystem,t[89]=we,t[90]=Te,t[91]=Ee):Ee=t[91];let De;t[92]!==be||t[93]!==Ce||t[94]!==Ee?(De=(0,$.jsxs)(`div`,{className:vP,children:[be,Ce,Ee]}),t[92]=be,t[93]=Ce,t[94]=Ee,t[95]=De):De=t[95];let Oe;t[96]!==y.themeTitle||t[97]!==_e||t[98]!==De?(Oe=(0,$.jsx)(`div`,{className:_e,role:`menu`,"aria-label":y.themeTitle,children:De}),t[96]=y.themeTitle,t[97]=_e,t[98]=De,t[99]=Oe):Oe=t[99];let ke;t[100]!==me||t[101]!==ge||t[102]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:oe,children:[me,ge,Oe]}),t[100]=me,t[101]=ge,t[102]=Oe,t[103]=ke):ke=t[103];let Ae;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=()=>a(`font`),t[104]=Ae):Ae=t[104];let je=i===`font`&&`bg-surface-hover`,Me;t[105]===je?Me=t[106]:(Me=u(_P,je),t[105]=je,t[106]=Me);let Ne=i===`font`,Pe;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=(0,$.jsx)(OD,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[107]=Pe):Pe=t[107];let Fe;t[108]===y.fontScaleTitle?Fe=t[109]:(Fe=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:y.fontScaleTitle}),t[108]=y.fontScaleTitle,t[109]=Fe);let Ie;t[110]===C?Ie=t[111]:(Ie=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:C}),t[110]=C,t[111]=Ie);let Le;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Le=(0,$.jsx)(Yu,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[112]=Le):Le=t[112];let Re;t[113]!==Me||t[114]!==Ne||t[115]!==Fe||t[116]!==Ie?(Re=(0,$.jsxs)(`button`,{type:`button`,className:Me,"aria-haspopup":`menu`,"aria-expanded":Ne,children:[Pe,Fe,Ie,Le]}),t[113]=Me,t[114]=Ne,t[115]=Fe,t[116]=Ie,t[117]=Re):Re=t[117];let ze;t[118]===P?ze=t[119]:(ze=P(`font`),t[118]=P,t[119]=ze);let Be;t[120]===ze?Be=t[121]:(Be=(0,$.jsx)(`div`,{className:ze,"aria-hidden":!0}),t[120]=ze,t[121]=Be);let Ve;t[122]===M?Ve=t[123]:(Ve=M(`font`),t[122]=M,t[123]=Ve);let He=p===`compact`,Ue;t[124]===h?Ue=t[125]:(Ue=()=>h(`compact`),t[124]=h,t[125]=Ue);let We;t[126]!==y.fontScaleCompact||t[127]!==He||t[128]!==Ue?(We=(0,$.jsx)(yP,{selected:He,label:y.fontScaleCompact,onSelect:Ue}),t[126]=y.fontScaleCompact,t[127]=He,t[128]=Ue,t[129]=We):We=t[129];let Ge=p==="default",Ke;t[130]===h?Ke=t[131]:(Ke=()=>h(`default`),t[130]=h,t[131]=Ke);let qe;t[132]!==y.fontScaleDefault||t[133]!==Ge||t[134]!==Ke?(qe=(0,$.jsx)(yP,{selected:Ge,label:y.fontScaleDefault,onSelect:Ke}),t[132]=y.fontScaleDefault,t[133]=Ge,t[134]=Ke,t[135]=qe):qe=t[135];let Je=p===`large`,Ye;t[136]===h?Ye=t[137]:(Ye=()=>h(`large`),t[136]=h,t[137]=Ye);let Xe;t[138]!==y.fontScaleLarge||t[139]!==Je||t[140]!==Ye?(Xe=(0,$.jsx)(yP,{selected:Je,label:y.fontScaleLarge,onSelect:Ye}),t[138]=y.fontScaleLarge,t[139]=Je,t[140]=Ye,t[141]=Xe):Xe=t[141];let Ze;t[142]!==We||t[143]!==qe||t[144]!==Xe?(Ze=(0,$.jsxs)(`div`,{className:vP,children:[We,qe,Xe]}),t[142]=We,t[143]=qe,t[144]=Xe,t[145]=Ze):Ze=t[145];let Qe;t[146]!==y.fontScaleTitle||t[147]!==Ve||t[148]!==Ze?(Qe=(0,$.jsx)(`div`,{className:Ve,role:`menu`,"aria-label":y.fontScaleTitle,children:Ze}),t[146]=y.fontScaleTitle,t[147]=Ve,t[148]=Ze,t[149]=Qe):Qe=t[149];let $e;t[150]!==Re||t[151]!==Be||t[152]!==Qe?($e=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:Ae,children:[Re,Be,Qe]}),t[150]=Re,t[151]=Be,t[152]=Qe,t[153]=$e):$e=t[153];let et;t[154]!==E||t[155]!==A?(et=T?(0,$.jsxs)(`button`,{type:`button`,className:_P,onClick:()=>void A(),onMouseEnter:()=>a(null),onFocus:()=>a(null),children:[(0,$.jsx)(iy,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:E})]}):null,t[154]=E,t[155]=A,t[156]=et):et=t[156];let tt;t[157]===Symbol.for(`react.memo_cache_sentinel`)?(tt=(0,$.jsx)(`div`,{className:`my-2 h-px bg-edge-subtle`,role:`separator`}),t[157]=tt):tt=t[157];let nt;t[158]===r?nt=t[159]:(nt=()=>r?.(),t[158]=r,t[159]=nt);let rt,it,at;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(rt=()=>a(null),it=()=>a(null),at=(0,$.jsx)(yv,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[160]=rt,t[161]=it,t[162]=at):(rt=t[160],it=t[161],at=t[162]);let ot;t[163]===y.aboutApp?ot=t[164]:(ot=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:y.aboutApp}),t[163]=y.aboutApp,t[164]=ot);let st;t[165]!==nt||t[166]!==ot?(st=(0,$.jsxs)(`button`,{type:`button`,className:_P,onClick:nt,onMouseEnter:rt,onFocus:it,children:[at,ot]}),t[165]=nt,t[166]=ot,t[167]=st):st=t[167];let ct;t[168]===c?ct=t[169]:(ct=qj(c),t[168]=c,t[169]=ct);let lt,ut,dt;t[170]===Symbol.for(`react.memo_cache_sentinel`)?(lt=()=>a(null),ut=()=>a(null),dt=(0,$.jsx)(bc,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[170]=lt,t[171]=ut,t[172]=dt):(lt=t[170],ut=t[171],dt=t[172]);let ft;t[173]===v.sidebar.helpDocs?ft=t[174]:(ft=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:v.sidebar.helpDocs}),t[173]=v.sidebar.helpDocs,t[174]=ft);let pt;t[175]===Symbol.for(`react.memo_cache_sentinel`)?(pt=(0,$.jsx)(gh,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[175]=pt):pt=t[175];let mt;t[176]!==ct||t[177]!==ft?(mt=(0,$.jsxs)(`a`,{href:ct,target:`_blank`,rel:`noopener noreferrer`,className:_P,onMouseEnter:lt,onFocus:ut,children:[dt,ft,pt]}),t[176]=ct,t[177]=ft,t[178]=mt):mt=t[178];let ht,gt,_t;t[179]===Symbol.for(`react.memo_cache_sentinel`)?(ht=u(_P,`text-accent-fg hover:bg-accent-soft hover:text-accent-fg`),gt=()=>a(null),_t=()=>a(null),t[179]=ht,t[180]=gt,t[181]=_t):(ht=t[179],gt=t[180],_t=t[181]);let vt;t[182]===n?vt=t[183]:(vt=()=>n?.(),t[182]=n,t[183]=vt);let yt;t[184]===Symbol.for(`react.memo_cache_sentinel`)?(yt=(0,$.jsx)(uS,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[184]=yt):yt=t[184];let bt;t[185]===y.openFullPreferences?bt=t[186]:(bt=(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:y.openFullPreferences}),t[185]=y.openFullPreferences,t[186]=bt);let xt;t[187]!==vt||t[188]!==bt?(xt=(0,$.jsxs)(Hi,{to:`/settings/overview`,className:ht,onMouseEnter:gt,onFocus:_t,onClick:vt,children:[yt,bt]}),t[187]=vt,t[188]=bt,t[189]=xt):xt=t[189];let St;return t[190]!==ae||t[191]!==ke||t[192]!==$e||t[193]!==et||t[194]!==st||t[195]!==mt||t[196]!==xt?(St=(0,$.jsxs)(`div`,{className:`w-[min(calc(100vw-2rem),13rem)] shrink-0 py-0.5`,onMouseLeave:F,children:[ae,ke,$e,et,tt,st,mt,xt]}),t[190]=ae,t[191]=ke,t[192]=$e,t[193]=et,t[194]=st,t[195]=mt,t[196]=xt,t[197]=St):St=t[197],St}function xP(e){return e.setPreference}function SP(e){return e.preference}function CP(e){return e.setPreference}function wP(e){return e.preference}function TP(e){return e.setLanguage}function EP(e){return e.language}function DP({collapsed:e=!1,onNavigate:t}){let n=m(_(e=>e.language)),r=n.appearanceSettings,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{c(()=>import(`./settings-page-xQx2Pkg5.js`),__vite__mapDeps([0,1,2,3,4])),c(()=>import(`./sessions-page-CiOreA2k.js`),__vite__mapDeps([5,1,2,6,7,3,8,9,10,4,11,12])),c(()=>import(`./logs-page-BiL302Ve.js`),__vite__mapDeps([13,1,2,7,3,9,4,11,12])),c(()=>import(`./automations-page-B8JTjkCr.js`),__vite__mapDeps([14,1,2,6,7,3,15,4,11,12,16,17,18])),c(()=>import(`./skills-page-bo695odu.js`),__vite__mapDeps([19,1,20,2,7,3,8,21,22,11,4,12]))},[]),(0,$.jsxs)(`div`,{className:u(`flex shrink-0 flex-col`,e&&`mt-auto`,e?`items-center px-1 py-2`:`p-3`),children:[(0,$.jsxs)(oj,{open:i,onOpenChange:a,children:[e?(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u(`flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full outline-none ring-offset-surface-base transition-transform`,`hover:opacity-95 active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2`,i&&`ring-2 ring-accent`,`motion-reduce:opacity-100 motion-reduce:active:scale-100`),"aria-expanded":i,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:(0,$.jsx)(Hk,{className:`size-full rounded-full`,alt:n.appBrand})})}):(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:u(`flex w-full min-w-0 items-center gap-2 rounded-xl p-1 text-left outline-none transition-colors duration-150 ease-out`,`hover:bg-surface-active/70`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i&&`bg-surface-active/70`),"aria-expanded":i,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:[(0,$.jsx)(`span`,{className:`size-8 shrink-0 overflow-hidden rounded-full`,"aria-hidden":!0,children:(0,$.jsx)(Hk,{className:`size-full rounded-full`,alt:``,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight text-fg`,children:n.appBrand}),(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:r.quickMenuHint})]}),(0,$.jsx)(`span`,{className:u(`flex size-9 shrink-0 items-center justify-center rounded-xl text-fg-muted transition-colors`,i&&`bg-accent-soft text-accent-fg`),"aria-hidden":!0,children:(0,$.jsx)(uS,{className:`size-[18px]`,strokeWidth:1.5})})]})}),(0,$.jsx)(lj,{children:(0,$.jsx)(uj,{className:u(`z-50 w-max max-w-[min(calc(100vw-1rem),28rem)] overflow-visible`,`rounded-xl border border-edge bg-surface-panel p-2 shadow-popover dark:border-edge`),side:`top`,align:e?`center`:`start`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,$.jsx)(bP,{onOpenFullSettings:()=>{a(!1),t?.()},onAboutClick:()=>{s(!0),a(!1)}})})})]}),(0,$.jsx)(mP,{open:o,onOpenChange:s})]})}var OP=`xopc-web-sidebar-nav-order`;function kP(){try{let e=globalThis.localStorage?.getItem(OP);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function AP(e){try{globalThis.localStorage?.setItem(OP,JSON.stringify(e))}catch{}}function jP(e,t,n,r,i){if(t===n)return e;let a=e.filter(e=>e!==t),o=a.indexOf(n),s=o===-1?a.length:r===`before`?o:o+1;return NP([...a.slice(0,s),t,...a.slice(s)],i)}function MP(e,t,n){return NP([...e.filter(e=>e!==t),t],n)}function NP(e,t){let n=new Set(e),r=[];for(let e of t)n.has(e)||r.push(e);return r.length===0?e:[...e,...r]}var PP=h((e,t)=>({order:kP(),move:(n,r,i)=>{let a=jP(t().order,n,r,i,new Set(t().order));a!==t().order&&(e({order:a}),queueMicrotask(()=>AP(a)))},moveToEnd:n=>{let r=MP(t().order,n,new Set(t().order));r!==t().order&&(e({order:r}),queueMicrotask(()=>AP(r)))},setOrder:t=>{e({order:t}),queueMicrotask(()=>AP(t))}})),FP=()=>c(()=>import(`./sessions-page-CiOreA2k.js`),__vite__mapDeps([5,1,2,6,7,3,8,9,10,4,11,12])),IP=()=>c(()=>import(`./automations-page-B8JTjkCr.js`),__vite__mapDeps([14,1,2,6,7,3,15,4,11,12,16,17,18])),LP=()=>c(()=>import(`./projects-page-GDVTFAY7.js`),__vite__mapDeps([23,1,2,7,3,24,4])),RP=()=>c(()=>import(`./project-detail-page-iXX1Ceo2.js`),__vite__mapDeps([25,1,2,7,3,8,24,26,27,20,6,28,4,11,18,29,30,31,12,32,15])),zP=()=>c(()=>import(`./work-item-detail-page-B-8rex4u.js`),__vite__mapDeps([33,1,2,7,3,4])),BP=()=>c(()=>import(`./goals-page-CMk-9ZYN.js`),__vite__mapDeps([34,1,2,7,3,26,31,11,4,12])),VP=()=>c(()=>import(`./goal-detail-page-DHWVRafk.js`),__vite__mapDeps([35,1,2,7,3,28,6,4,11,12])),HP=()=>c(()=>import(`./notes-page-BurgcdVZ.js`),__vite__mapDeps([36,2,1,27,20,6,7,3,28,4,11,18,29,30])),UP=()=>c(()=>import(`./workflows-page-Brb3UGvs.js`),__vite__mapDeps([37,1,2,6,7,3,8,28,4,32,15,11,12])),WP=()=>c(()=>import(`./skills-page-bo695odu.js`),__vite__mapDeps([19,1,20,2,7,3,8,21,22,11,4,12])),GP=()=>c(()=>import(`./connectors-page-C5fx4Qs9.js`),__vite__mapDeps([38,1,2,7,3,8,10,4,11,18,12])),KP=()=>c(()=>import(`./logs-page-BiL302Ve.js`),__vite__mapDeps([13,1,2,7,3,9,4,11,12])),qP=()=>c(()=>import(`./settings-page-xQx2Pkg5.js`),__vite__mapDeps([0,1,2,3,4])),JP=()=>c(()=>import(`./agents-CMxKKFQD.js`),__vite__mapDeps([39,1,40,2,6,7,3,41,20,42,43,8,24,44,45,11,4,12,46,47,10,48,49,29,30])),YP=()=>c(()=>import(`./browser-settings-page-slHLiZgi.js`),__vite__mapDeps([50,1,2,7,3,8,45,51,11,4,12,52,10,48,49,18])),XP=()=>c(()=>import(`./channels-settings-KIsISXw0.js`),__vite__mapDeps([53,1,2,6,7,3,54,55,56,11,4,12,48,49])),ZP=()=>c(()=>import(`./apps-page-DdZvDf5B.js`),__vite__mapDeps([57,1,2,6,7,3,8,4,11,12])),QP=()=>c(()=>import(`./extension-page-CP9P2lGM.js`),__vite__mapDeps([58,1,2])),$P=()=>c(()=>import(`./extension-settings-page-DnhU-tx0.js`),__vite__mapDeps([59,1,2,6,7,3,55,60,11,4,12,48,18])),eF=()=>c(()=>import(`./extension-debug-page-DJ1ABK95.js`),__vite__mapDeps([61,1,2,3,4])),tF=()=>c(()=>import(`./share-preview-page-8m_ACH0z.js`),__vite__mapDeps([62,1,20,2,3,12])),nF=()=>c(()=>import(`./setup-status-panel-DWB8VdLK.js`),__vite__mapDeps([63,1,2,6,7,3,10,48,49,4,11,12])),rF=()=>c(()=>import(`./appearance-settings-bYeEj3IW.js`),__vite__mapDeps([64,2,1,7,3,52,49,4,29,30])),iF=()=>c(()=>import(`./keyboard-shortcuts-settings-BrENZzM7.js`),__vite__mapDeps([65,2,1,7,3,49,4])),aF=()=>c(()=>import(`./user-profile-settings-panel-CERVLuaW.js`),__vite__mapDeps([66,1,2,7,3,46,10,49,4])),oF=()=>c(()=>import(`./system-settings-panel-CW22OkZ4.js`),__vite__mapDeps([67,1,2,7,3,10,49,4])),sF=()=>c(()=>import(`./desktop-pet-settings-B-u63N4e.js`),__vite__mapDeps([68,1,2,7,3,69,49,4])),cF=()=>c(()=>import(`./app-management-settings-panel-ptk9c5BN.js`),__vite__mapDeps([70,1,2,6,7,3,10,48,49,4,11,12])),lF=()=>c(()=>import(`./models-hub-panel-CFPpl3Cq.js`),__vite__mapDeps([71,1,2,6,7,3,8,60,11,4,12,72,52,73,10,48,49,18])),uF=()=>c(()=>import(`./gateway-settings-TING7224.js`),__vite__mapDeps([74,1,2,6,7,3,8,51,11,4,12,52,10,48,49,18])),dF=()=>c(()=>import(`./heartbeat-settings-BQIm0P3V.js`),__vite__mapDeps([75,1,2,6,7,3,8,76,17,47,11,4,12,72,48,49])),fF=()=>c(()=>import(`./remote-access-hub-BUrbUnwv.js`),__vite__mapDeps([77,1,2,6,7,3,54,8,73,52,10,49,4,11,12])),pF=()=>c(()=>import(`./shares-settings-CgxfhNxI.js`),__vite__mapDeps([78,1,2,6,7,3,8,10,49,4,11,12])),mF=()=>c(()=>import(`./dreaming-settings-CCkKP-I4.js`),__vite__mapDeps([79,1,2,6,7,3,8,76,17,16,10,49,4,11,12])),hF=()=>c(()=>import(`./goals-settings-BHzOAU_l.js`),__vite__mapDeps([80,1,2,6,7,3,8,56,11,4,12,31,72,49])),gF=()=>c(()=>import(`./capability-presets-settings-panel-Dng8Grpv.js`),__vite__mapDeps([81,1,2,6,7,3,44,45,11,4,12,10,48,49])),_F=new Set;function vF(e){_F.has(e)||(_F.add(e),e().catch(()=>{_F.delete(e)}))}function yF(e){let[t]=e.split(/[?#]/,1);return t||`/`}function bF(e){vF(qP);let t=e.slice(10);if(t===`overview`)return vF(nF);if(t===`appearance`)return vF(rF);if(t===`keyboard-shortcuts`)return vF(iF);if(t===`user-profile`)return vF(aF);if(t===`system`)return vF(oF);if(t===`desktop-pet`)return vF(sF);if(t===`desktop-app`)return vF(cF);if(t===`credentials`)return vF(lF);if(t===`gateway`)return vF(uF);if(t===`heartbeat`)return vF(dF);if(t===`tunnel`||t===`remote-access`)return vF(fF);if(t===`shares`)return vF(pF);if(t===`dreams`)return vF(mF);if(t===`goals`)return vF(hF);if(t===`capability-presets`)return vF(gF);if(t===`agent-browser`)return vF(YP)}function xF(e){if(!e.startsWith(`/`))return;let t=yF(e);if(t===`/skills`)return vF(WP);if(t===`/connectors`)return vF(GP);if(t===`/automations`)return vF(IP);if(t===`/projects`)return vF(LP);if(t.startsWith(`/projects/`))return vF(RP);if(t.startsWith(`/work-items/`))return vF(zP);if(t===`/goals`)return vF(BP);if(t.startsWith(`/goals/`))return vF(VP);if(t===`/notes`||t.startsWith(`/notes/`))return vF(HP);if(t===`/workflows`)return vF(UP);if(t===`/channels`||t.startsWith(`/channels/`))return vF(XP);if(t===`/agents`||t.startsWith(`/agents/`))return vF(JP);if(t===`/extensions`)return vF(ZP);if(t.startsWith(`/extensions/`))return vF(QP);if(t.startsWith(`/share/`))return vF(tF);if(t===`/settings/sessions`)return vF(FP);if(t===`/settings/logs`)return vF(KP);if(t===`/settings/extensions/debug`)return vF(eF);if(t.startsWith(`/settings/ext/`))return vF($P);if(t.startsWith(`/settings/`))return bF(t)}var SF=null,CF=h((e,t)=>({variables:{},loaded:!1,updateContext:t=>e(e=>({variables:{...e.variables,...t}})),setContext:t=>e({variables:t,loaded:!0}),fetchContext:async()=>SF||(SF=(async()=>{let e=await J(X(`/api/context`));t().setContext(e)})().finally(()=>{SF=null}),SF)})),wF=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({}),TF=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function EF(e){let t=getComputedStyle(document.documentElement),n={};for(let e of TF){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var DF={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"ui.navigate":`theme`,"theme.get":`theme`},OF=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n){let r=this.iframes.get(e);r&&r!==t&&r.contentWindow&&this.byContentWindow.delete(r.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{sessionKey:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow??(t?.source instanceof Window?t.source:null),o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};a&&a.postMessage(o,`*`)}isTrustedExtensionSource(e,t){if(t.source===null)return!0;let n=e.contentWindow;if(t.source===n)return!0;if(n&&typeof Window<`u`&&t.source instanceof Window)try{return t.source.frameElement===e}catch{}return!1}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`)return;let n,r=t.extensionId;if(e.source instanceof Window){let t=this.byContentWindow.get(e.source);t&&(n=t.iframe,r=t.extensionId)}if(n||(n=this.iframes.get(t.extensionId),r=t.extensionId),!n||!(e.source instanceof Window&&this.byContentWindow.has(e.source))&&!this.isTrustedExtensionSource(n,e))return;if(t.type===`event`){this.handleExtensionEvent(r,t.event,t.data);let e=this.eventSubscribers.get(r);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:i,method:a,params:o}=t,s=this.handlers.get(a);if(!s){this.postResponse(n,e,i,void 0,{code:wF.MethodNotFound,message:`Unknown method: ${a}`});return}let c=DF[a],l=this.extensionPermissions.get(r)??new Set;if(c&&!l.has(c)){this.postResponse(n,e,i,void 0,{code:wF.PermissionDenied,message:`Missing permission: ${c}`});return}try{let t=await s(r,o);this.postResponse(n,e,i,t)}catch(t){let r=t instanceof Error?t.message:String(t);this.postResponse(n,e,i,void 0,{code:wF.InternalError,message:r})}}};function kF(e){e.registerMethod(`theme.get`,async()=>EF(x.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;n&&window.dispatchEvent(new CustomEvent(`extension-navigate`,{detail:{path:n}}))}),e.registerMethod(`ui.notification`,async(e,t)=>{if(!t||typeof t!=`object`)return;let n=t,r=typeof n.title==`string`?n.title.trim():``;r&&re({type:n.type===`success`||n.type===`warning`||n.type===`error`||n.type===`info`?n.type:`info`,title:r,message:typeof n.message==`string`?n.message:void 0,duration:typeof n.duration==`number`?n.duration:void 0})}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`sessionKey`in t?String(t.sessionKey??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await Y(X(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({sessionKey:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,sessionKey:r,newSession:i}=t,a=r?.trim()||``;if(i||!a){let e=await Y(X(`/api/sessions`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({channel:`webchat`})});if(!e.ok)throw Error(`Session create failed: ${e.status}`);if(a=(await e.json()).session?.key??``,!a)throw Error(`Session create did not return a session key`)}let o=await Y(X(`/api/agent`),{method:`POST`,headers:{Accept:`application/json`},body:JSON.stringify({message:n,channel:`webchat`,sessionKey:a})});if(!o.ok)throw Error(`Agent request failed: ${o.status}`);let s=await o.json();return{sessionKey:s.payload?.sessionKey??s.payload?.key??s.sessionKey??a}}),e.registerMethod(`config.get`,async e=>{let t=await Y(X(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await Y(X(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await Y(X(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,i=await Y(X(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!i.ok)throw Error(`Failed to set storage key: ${i.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await Y(X(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await Y(X(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}function AF(e){return e.active||e.activationEligible===!0}function jF(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0||Array.isArray(t.sidebarPanels)&&t.sidebarPanels.length>0:!1}function MF(e){return e.source===`bundled`&&e.hasUi===!0&&jF(e)}function NF(e){return e.kind===`image-generation`||e.kind===`media-provider`}function PF(e){return AF(e)?e.hasConfigSchema||NF(e)?!0:e.hasUi?jF(e):!1:!1}function FF(e){return PF(e)||MF(e)}var IF=(0,Z.createContext)(null);function LF({children:e}){let t=(0,Z.useRef)(null);if(!t.current){let e=new OF;kF(e),t.current=e}let n=t.current,r=q(e=>!!e.token),{data:i,isLoading:a}=ie(r?`gateway-extensions-list`:null,()=>J(X(`/api/extensions`)),{revalidateOnFocus:!1}),o=i?.extensions??[],s=x(e=>e.resolved);(0,Z.useEffect)(()=>{r&&CF.getState().fetchContext()},[r]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&!Array.isArray(t)&&CF.getState().updateContext(t)},t=()=>{CF.getState().fetchContext()};return window.addEventListener(`context-update`,e),window.addEventListener(`config-reload`,t),window.addEventListener(`registry-updated`,t),()=>{window.removeEventListener(`context-update`,e),window.removeEventListener(`config-reload`,t),window.removeEventListener(`registry-updated`,t)}},[]);let c=(0,Z.useCallback)(e=>{let t=e.detail;t?.sessionKey&&n.forwardAgentStreamEvent(t.sessionKey,t.event??t)},[n]),l=(0,Z.useRef)(c);l.current=c,(0,Z.useEffect)(()=>{let e=e=>{l.current(e)};return window.addEventListener(`agent-stream-event`,e),()=>{window.removeEventListener(`agent-stream-event`,e)}},[]),(0,Z.useEffect)(()=>{let e=EF(s);n.broadcastEvent(`theme.changed`,e)},[s,n]);let u=(0,Z.useRef)(n);u.current=n,(0,Z.useEffect)(()=>()=>{u.current.dispose(),t.current=null},[]);let d=(0,Z.useMemo)(()=>({router:n,extensions:o,loading:a}),[n,o,a]);return(0,$.jsx)(IF.Provider,{value:d,children:e})}function RF(){let e=(0,Z.useContext)(IF);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function zF(){let e=(0,Z.useContext)(IF);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function BF(){let e=(0,Q.c)(2),t=zF(),n;return e[0]===t?n=e[1]:(n=t.filter(PF),e[0]=t,e[1]=n),n}function VF(){let e=(0,Z.useContext)(IF);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}function HF(e,t){return t.path.startsWith(`/extensions/`)?t.path:`/extensions/${e}/${t.id.startsWith(`${e}.`)?t.id.slice(e.length+1):t.id}`}function UF(e){return Bk[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]}var WF=[{id:`builtin:agents`,to:`/agents`,Icon:dO},{id:`builtin:projects`,to:`/projects`,Icon:p_},{id:`builtin:goals`,to:`/goals`,Icon:kv},{id:`builtin:skills`,to:`/skills`,Icon:Cv},{id:`builtin:connectors`,to:`/connectors`,Icon:gl},{id:`builtin:automations`,to:`/automations`,Icon:wk},{id:`builtin:channels`,to:`/channels`,Icon:Iy},{id:`builtin:extensions`,to:`/extensions`,Icon:$y},{id:`builtin:notes`,to:`/notes`,Icon:hT},{id:`builtin:workflows`,to:`/workflows`,Icon:iv}];function GF(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r=[],i=new Set;for(let e of t){let t=n.get(e);!t||i.has(e)||(r.push(t),i.add(e))}for(let t of e)i.has(t.id)||(r.push(t),i.add(t.id));return r.length<=4?{visible:r,overflow:[],hasOverflow:!1}:{visible:r.slice(0,4),overflow:r.slice(4),hasOverflow:!0}}var KF=`text/plain`,qF=`xopc-nav:`;function JF(e){return`${qF}${e}`}function YF(e){return e.startsWith(qF)?e.slice(9):null}function XF(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function ZF({isActive:e},t,n,r){return u(`group relative flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,t?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,n&&`opacity-40`,r===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,r===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`)}function QF({isActive:e},t,n){return u(`group relative flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm font-medium leading-5 transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,t&&`opacity-40`,n===`before`&&`shadow-[inset_0_2px_0_0_var(--color-accent)]`,n===`after`&&`shadow-[inset_0_-2px_0_0_var(--color-accent)]`)}function $F(e){let t=(0,Q.c)(11),{item:n,collapsed:r}=e,{Icon:i,letter:a}=n;if(i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=u(`size-4`,`shrink-0 opacity-90`),t[0]=e):e=t[0];let n;return t[1]===i?n=t[2]:(n=(0,$.jsx)(i,{className:e,strokeWidth:1.75,"aria-hidden":!0}),t[1]=i,t[2]=n),n}let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=u(`size-4`,`flex shrink-0 items-center justify-center text-[10px] font-bold opacity-70`),t[3]=o):o=t[3];let s;t[4]!==n.label||t[5]!==a?(s=a??n.label.charAt(0),t[4]=n.label,t[5]=a,t[6]=s):s=t[6];let c;t[7]===s?c=t[8]:(c=s.toUpperCase(),t[7]=s,t[8]=c);let l;return t[9]===c?l=t[10]:(l=(0,$.jsx)(`span`,{className:o,"aria-hidden":!0,children:c}),t[9]=c,t[10]=l),l}function eI(e){let t=[];for(let n of e){if(n.activationEligible===!1)continue;let e=n.ui?.contributions?.pages;if(e)for(let r of e){if(!r.showInNav)continue;let e=r.navIcon?UF(r.navIcon):void 0;t.push({id:`ext:${n.id}:${r.id}`,kind:`extension`,label:r.title,to:HF(n.id,r),Icon:e,letter:r.title.charAt(0),title:r.title})}}return t}function tI(e){let t=(0,Q.c)(52),{collapsed:n,onNavigate:r}=e,i=n===void 0?!1:n,a=_(sI),o;t[0]===a?o=t[1]:(o=m(a),t[0]=a,t[1]=o);let s=o,c=BF(),l=PP(oI),d=PP(aI),f=PP(iI),[p,h]=(0,Z.useState)(null),[g,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),C;if(t[2]!==s.nav||t[3]!==c){let e;t[5]===s.nav?e=t[6]:(e=e=>{let t=e.id.slice(8);return{id:e.id,kind:`builtin`,label:s.nav[t],to:e.to,Icon:e.Icon}},t[5]=s.nav,t[6]=e);let n=WF.map(e),r=eI(c);C=[...n,...r],t[2]=s.nav,t[3]=c,t[4]=C}else C=t[4];let w=C,T;t[7]!==w||t[8]!==l?(T=GF(w,l),t[7]=w,t[8]=l,t[9]=T):T=t[9];let E=T,D;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>t=>{t.dataTransfer.setData(KF,JF(e)),t.dataTransfer.effectAllowed=`move`,h(e)},t[10]=D):D=t[10];let O=D,k;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>{h(null),v(null),b(!1)},t[11]=k):k=t[11];let A=k,j;t[12]!==p||t[13]!==g?(j=e=>t=>{if(!p)return;t.preventDefault(),t.dataTransfer.dropEffect=`move`;let n=XF(t);g?.id===e&&g.position===n||v({id:e,position:n})},t[12]=p,t[13]=g,t[14]=j):j=t[14];let M=j,N;t[15]===d?N=t[16]:(N=e=>t=>{t.preventDefault();let n=YF(t.dataTransfer.getData(KF));if(!n||n===e){A();return}d(n,e,XF(t)),A()},t[15]=d,t[16]=N);let P=N,F;t[17]===p?F=t[18]:(F=e=>{p&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,b(!0))},t[17]=p,t[18]=F);let I=F,L;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>b(!1),t[19]=L):L=t[19];let R=L,z;t[20]===f?z=t[21]:(z=e=>{e.preventDefault();let t=YF(e.dataTransfer.getData(KF));t&&f(t),A()},t[20]=f,t[21]=z);let B=z,V=rI,H;t[22]!==i||t[23]!==p||t[24]!==g||t[25]!==r||t[26]!==M||t[27]!==P?(H=function(e){let t=p===e.id,n=g?.id===e.id?g.position:null;return(0,$.jsxs)(Ui,{to:e.to,draggable:!0,onDragStart:O(e.id),onDragEnd:A,onDragOver:M(e.id),onDrop:P(e.id),className:e=>ZF(e,i,t,n),title:e.title??e.label,onMouseEnter:()=>V(e.to),onFocus:()=>V(e.to),onClick:()=>r?.(),children:[(0,$.jsx)($F,{item:e,collapsed:i}),i?null:(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id)},t[22]=i,t[23]=p,t[24]=g,t[25]=r,t[26]=M,t[27]=P,t[28]=H):H=t[28];let U=H,W;t[29]!==i||t[30]!==p||t[31]!==g||t[32]!==s.sidebar.moreApps||t[33]!==s.sidebar.moreAppsAria||t[34]!==y||t[35]!==I||t[36]!==B||t[37]!==r||t[38]!==M||t[39]!==P||t[40]!==x||t[41]!==E.overflow?(W=function(){return(0,$.jsxs)(oj,{open:x,onOpenChange:S,children:[(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onDragOver:I,onDragLeave:R,onDrop:B,className:u(`flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,x?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`,y&&`ring-2 ring-accent ring-offset-2 ring-offset-surface-base`),"aria-label":s.sidebar.moreAppsAria,title:s.sidebar.moreApps,children:[(0,$.jsx)(sh,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),i?null:(0,$.jsx)(`span`,{className:`truncate`,children:s.sidebar.moreApps})]})}),(0,$.jsx)(lj,{children:(0,$.jsx)(uj,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,className:u(`z-50 min-w-[14rem] max-w-[20rem] rounded-lg border border-edge bg-surface-panel p-1 shadow-md`),onOpenAutoFocus:nI,children:(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,role:`list`,"aria-label":s.sidebar.moreAppsAria,children:E.overflow.map(e=>{let t=p===e.id,n=g?.id===e.id?g.position:null;return(0,$.jsx)(`li`,{className:`contents`,children:(0,$.jsxs)(Ui,{to:e.to,draggable:!0,onDragStart:O(e.id),onDragEnd:A,onDragOver:M(e.id),onDrop:P(e.id),className:e=>QF(e,t,n),title:e.title??e.label,onMouseEnter:()=>V(e.to),onFocus:()=>V(e.to),onClick:()=>{S(!1),r?.()},children:[(0,$.jsx)($F,{item:e}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.id)})})})})]})},t[29]=i,t[30]=p,t[31]=g,t[32]=s.sidebar.moreApps,t[33]=s.sidebar.moreAppsAria,t[34]=y,t[35]=I,t[36]=B,t[37]=r,t[38]=M,t[39]=P,t[40]=x,t[41]=E.overflow,t[42]=W):W=t[42];let G=W,K;t[43]!==E.visible||t[44]!==U?(K=E.visible.map(U),t[43]=E.visible,t[44]=U,t[45]=K):K=t[45];let q;t[46]!==E.hasOverflow||t[47]!==G?(q=E.hasOverflow?G():null,t[46]=E.hasOverflow,t[47]=G,t[48]=q):q=t[48];let ee;return t[49]!==K||t[50]!==q?(ee=(0,$.jsxs)($.Fragment,{children:[K,q]}),t[49]=K,t[50]=q,t[51]=ee):ee=t[51],ee}function nI(e){return e.preventDefault()}function rI(e){xF(e)}function iI(e){return e.moveToEnd}function aI(e){return e.move}function oI(e){return e.order}function sI(e){return e.language}var cI={feishu:`/channel-icons/feishu.svg`,lark:`/channel-icons/lark.svg`,telegram:`/channel-icons/telegram.svg`,wechat:`/channel-icons/wechat.svg`,weixin:`/channel-icons/weixin.svg`};function lI(e){let t=(0,Q.c)(9),{sourceChannel:n,className:r}=e,i=cI[n.toLowerCase()];if(i){let e;t[0]===r?e=t[1]:(e=u(`shrink-0`,r),t[0]=r,t[1]=e);let n;return t[2]!==i||t[3]!==e?(n=(0,$.jsx)(`img`,{src:i,alt:``,draggable:!1,className:e,"aria-hidden":!0}),t[2]=i,t[3]=e,t[4]=n):n=t[4],n}let a;t[5]===r?a=t[6]:(a=u(`shrink-0`,r),t[5]=r,t[6]=a);let o;return t[7]===a?o=t[8]:(o=(0,$.jsx)(cv,{className:a,strokeWidth:1.75,"aria-hidden":!0}),t[7]=a,t[8]=o),o}function uI(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=u(`animate-pulse rounded-md bg-surface-hover/70 motion-reduce:animate-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{"aria-hidden":`true`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function dI(){return X(`/api/config`)}var fI=null;async function pI(){return fI||(fI=J(dI()).finally(()=>{fI=null}),fI)}function mI(e){let t=(0,Q.c)(6),n;t[0]===e?n=t[1]:(n=e?dI():null,t[0]=e,t[1]=n);let r=n,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let a=ie(r,pI,i),o,s;return t[3]===e?(o=t[4],s=t[5]):(o=()=>{if(!e)return;let t=dI(),n=e=>{ce(e.detail)||oe(t)};return window.addEventListener(`config-reload`,n),()=>window.removeEventListener(`config-reload`,n)},s=[e],t[3]=e,t[4]=o,t[5]=s),(0,Z.useEffect)(o,s),a}function hI(){return oe(dI())}var gI=null;async function _I(){return gI||(gI=vI().finally(()=>{gI=null}),gI)}async function vI(){let e=await Y(X(`/api/agents`));if(e.ok){let t=await e.json();if(t.ok&&t.payload?.defaultId&&Array.isArray(t.payload.agents)){let e=t.payload.defaultId.trim().toLowerCase(),n=t.payload.agents.filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{}}));if(n.length>0)return{defaultId:e,items:n}}}let t=(await pI()).payload?.config?.agents,n=(t?.defaultId??`main`).trim().toLowerCase(),r=(Array.isArray(t?.list)?t.list:[]).filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase()}));return r.length===0?{defaultId:n,items:[{id:n}]}:{defaultId:n,items:r}}var yI=`xopc-pending-agent-run-changed`;function bI(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(yI,{detail:{chatId:e}}))}var xI=/^No API key found for (\S+)/i;function SI(e){try{let t=JSON.parse(e);return typeof t.kind!=`string`||typeof t.message!=`string`?null:{kind:t.kind,code:typeof t.code==`string`?t.code:t.kind,provider:typeof t.provider==`string`?t.provider:void 0,modelRef:typeof t.modelRef==`string`?t.modelRef:void 0,deepLink:typeof t.deepLink==`string`?t.deepLink:void 0,message:t.message}}catch{return null}}function CI(){return{kind:`send_failed`,code:`send_failed`,message:`Send failed`}}function wI(e){let t=e.trim();if(!t)return null;if(t.startsWith(`{`)){let e=SI(t);if(e)return e}let n=xI.exec(t);return n?{kind:`provider_setup_required`,code:`provider_setup_required`,provider:n[1].replace(/[.,]$/,``),deepLink:`/settings/credentials`,message:t}:t===`Assistant turn failed`||t.startsWith(`Error: `)?{kind:`unknown`,code:`unknown`,message:t.startsWith(`Error: `)?t.slice(7):t}:{kind:`unknown`,code:`unknown`,message:t}}function TI(e){return e.kind!==`provider_setup_required`||!e.provider?null:{kind:`provider_setup_required`,provider:e.provider,deepLink:`/settings/credentials`,message:e.message}}function EI(e){return typeof e==`object`&&!!e&&`role`in e}function DI(e){if(!e||typeof e!=`object`)return!1;let t=e.type;return t===`tool_use`||t===`tool_call`||t===`toolCall`}function OI(e){return typeof e==`object`&&!!e}function kI(e){return typeof e.id==`string`&&e.id.length>0?e.id:crypto.randomUUID()}function AI(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function jI(e){return AI(e.args??e.arguments??e.input??e.function?.arguments)??{}}function MI(e){if(typeof e==`string`){let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}return Date.now()}var NI=3e5;function PI(e,t){let n=new URLSearchParams({uri:e.trim()});return t?.trim()&&n.set(`sessionKey`,t.trim()),`/api/media/read?${n.toString()}`}function FI(e){if(typeof e.content==`string`&&e.content.length>0)return e.content;if(typeof e.data==`string`&&e.data.length>0)return e.data}var II=[`.txt`,`.md`,`.json`,`.xml`,`.html`,`.css`,`.js`,`.ts`,`.jsx`,`.tsx`,`.yml`,`.yaml`];function LI(e){let t=e.mimeType?.toLowerCase()??``;if(t.startsWith(`text/`)||t===`application/json`||t===`application/xml`||t===`application/javascript`||t===`application/typescript`)return!0;let n=e.name?.toLowerCase()??``;return II.some(e=>n.endsWith(e))}function RI(e){if(e.extractedText!=null&&e.extractedText!==``)return e.extractedText;if(!LI(e))return;let t=FI(e);if(t)try{let e=VI(t);return new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(e))}catch{return}}function zI(e,t){let n=t.trim();if(n.startsWith(`data:`))return n;let r=n.replace(/\s/g,``);return`data:${e&&typeof e==`string`&&e.includes(`/`)?e:`application/octet-stream`};base64,${r}`}function BI(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode(...i)}return btoa(n)}function VI(e){if(e==null||e===``)throw Error(`Missing file data`);let t=e;if(e.startsWith(`data:`)){let n=e.match(/base64,(.+)/);n&&(t=n[1])}let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}function HI(e){let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(1)} ${t[n]}`}function UI(e){let t=e.toLowerCase();for(let[e,n]of[[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.bmp`,`image/bmp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.ico`,`image/x-icon`],[`.tif`,`image/tiff`],[`.tiff`,`image/tiff`],[`.avif`,`image/avif`],[`.jxl`,`image/jxl`]])if(t.endsWith(e))return n}function WI(e,t){return(t?.startsWith(`text/`)??!1)||II.some(t=>e.toLowerCase().endsWith(t))}function GI(e){if(Array.isArray(e))return e.map(e=>KI(e))}function KI(e){if(!e||typeof e!=`object`)return{name:`file`,mimeType:`application/octet-stream`};let t=e,n=qI(t.uri),r=JI(t.name),i=YI(t.mimeType,r),a=typeof t.type==`string`?t.type:void 0,o=a===`photo`||a===`image`||i.startsWith(`image/`)?`image`:a===`voice`||a===`audio`||i.startsWith(`audio/`)?`voice`:a;return{id:typeof t.id==`string`?t.id:void 0,name:r,mimeType:i,type:o,size:typeof t.size==`number`?t.size:void 0,uri:n,bucket:typeof t.bucket==`string`?t.bucket:void 0,path:typeof t.path==`string`?t.path:void 0}}function qI(e){return typeof e==`string`&&e.trim().startsWith(`media://`)?e.trim():void 0}function JI(e){return typeof e==`string`&&e.trim().length>0?e.trim():`file`}function YI(e,t){if(typeof e==`string`&&e.trim().length>0){let t=e.trim();if(t.toLowerCase().split(`;`)[0]?.trim()!==`application/octet-stream`)return t}return UI(t)??`application/octet-stream`}function XI(e){let t=e.uri?.trim();return t?`uri:${t}`:e.id?`id:${e.id}`:`name:${e.name??`file`}|${e.mimeType??``}`}function ZI(e){if(!e?.length)return;let t=[],n=new Set;for(let r of e){let e=XI(r);n.has(e)||(n.add(e),t.push(r))}return t.length?t:void 0}var QI=`[Startup context loaded by runtime]`,$I=`...[additional startup memory truncated]...`,eL=`END_QUOTED_NOTES`;function tL(e){if(!e.includes(QI))return e;let t=e.replace(/^\uFEFF/,``);if(!t.startsWith(QI))return e;let n=-1,r=t.lastIndexOf(eL);if(r>=0)n=r+16;else{let e=t.indexOf($I);e>=0&&(n=e+43)}if(n<0){let n=t.slice(35),r=n.indexOf(`
14
14
 
15
15
  `);return r>=0?n.slice(r+2).replace(/^\s+/,``):e}return t.slice(n).replace(/^\s+/,``)}function nL(e){if(typeof e!=`string`||!e.includes(`## Skill:`))return e;let t=e.match(/## Skill:\s*([^\s\r\n]+)/);if(!t)return e;let n=t[1]??``;if(!n)return e;let r=[...e.matchAll(/\*\*Arguments\*\*:\s*([^\r\n]+)/g)],i=r.length>0?(r[r.length-1]?.[1]??``).trim():``;return i?`/skill:${n} ${i}`:`/skill:${n}`}function rL(e){return e.includes(`<file path=`)?e.replace(/<file\s+path="[^"]*">\r?\n[\s\S]*?<\/file>(?:\r?\n)*/g,``).replace(/\n{3,}/g,`
16
16
 
@@ -21,7 +21,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
21
21
 
22
22
  `).trim()}function TL(e,t){let n=e[t];if(!n||n.role!==`user`)return!1;for(let n=t+1;n<e.length;n++)if(e[n].role===`user`)return!1;return!0}function EL(e){if(e?.length)return e.map(e=>{let t=e.data??e.content;return{id:e.id,type:e.type??(e.mimeType?.startsWith(`image/`)?`image`:`document`),mimeType:e.mimeType,...t?{data:t}:{},name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...e.bucket?{bucket:e.bucket}:{},...e.path?{path:e.path}:{},durationSeconds:e.durationSeconds}})}function DL(e){return e===`user`}function OL(e,t){if(t<0||t>=e.length)return null;let n=e[t];if(!n||!DL(n.role))return null;let r=0;for(let n=0;n<=t;n++){let t=e[n];t&&DL(t.role)&&(r+=1)}return r-1}function kL(e,t){let n=1;for(let r=t+1;r<e.length;r++){let t=e[r];if(t&&DL(t.role))break;n+=1}return n}function AL(e){let t=typeof e.timestamp==`number`&&Number.isFinite(e.timestamp)?e.timestamp:Date.now();if(Array.isArray(e.content)||typeof e.content==`string`){let[n]=lL([{role:`user`,content:e.content,media:e.media,timestamp:t}]);return n??null}let n=typeof e.text==`string`?aL(e.text.trim()):``,r=GI(e.media);return!n&&!r?.length?null:{role:`user`,content:n?[{type:`text`,text:n}]:[],attachments:r,timestamp:t}}var jL=12e4;function ML(e,t){if(!DL(e.role)||!DL(t.role))return!1;let n=wL(e.content).trim(),r=wL(t.content).trim(),i=e.attachments?.length??0,a=t.attachments?.length??0,o=i===0||a>=i;return!!(o&&n&&r&&(n===r||r.startsWith(n))||i>0&&o&&Math.abs((t.timestamp??0)-(e.timestamp??0))<=jL)}function NL(e,t){return!DL(e.role)||!DL(t.role)?!1:e.timestamp===t.timestamp?!0:wL(e.content)===wL(t.content)}var PL=32*1024*1024;function FL(e){return`xopc:pendingRun:${e}`}function IL(e){try{let t=globalThis.sessionStorage?.getItem(FL(e));if(!t)return!1;let n=JSON.parse(t);return typeof n.runId==`string`&&n.runId.trim().length>0}catch{return!1}}function LL(e,t){let n=t.trim();if(n)try{sessionStorage.setItem(FL(e),JSON.stringify({runId:n})),bI(e)}catch{}}var RL=class{_abort;_sseChatId=``;_trackedRunId;get isSending(){return!!this._abort}get activeChatId(){return this._sseChatId}isStreamingFor(e){return!!this._abort&&this._sseChatId===e}async send(e,t,n,r,i){this._trackedRunId=void 0,this._abort=new AbortController,this._sseChatId=t;let a=n&&n.length>10?n.slice(0,10):n,o=Date.now(),s=await Y(X(`/api/agent`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify({message:e,channel:`webchat`,sessionKey:t,attachments:a,thinking:r,clientCreatedAtMs:o}),signal:this._abort.signal});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(te(s.status,s.statusText,e.error?.message))}if(await new Promise(e=>requestAnimationFrame(()=>e())),(s.headers.get(`Content-Type`)||``).includes(`text/event-stream`)&&s.body){let e=this._wrapTerminalCallbacks(i);await this._consumeSSE(s.body,e.wrapped),!e.sawTerminal&&!this._abort?.signal.aborted&&e.onMissingTerminal()}else{let e=await s.json();e.ok&&e.payload?.content&&(i?.onToken(e.payload.content),i?.onResult())}this._clearPendingRun(),this._abort=void 0}abort(){this._notifyServerAbort(),this._abort?.abort(),this._abort=void 0,this._clearPendingRun()}_notifyServerAbort(){if(this._sseChatId)try{let e=sessionStorage.getItem(FL(this._sseChatId));if(!e)return;let t=JSON.parse(e);if(typeof t.runId!=`string`||!t.runId)return;Y(X(`/api/agent/abort`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({runId:t.runId})}).catch(()=>{})}catch{}}async resume(e,t,n){this._trackedRunId=void 0,this._abort=new AbortController,this._sseChatId=t;let r=await Y(X(`/api/agent/resume`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify({runId:e,sessionKey:t}),signal:this._abort.signal});if(!r.ok){this._clearPendingRun(),this._abort=void 0;return}if((r.headers.get(`Content-Type`)||``).includes(`text/event-stream`)&&r.body){let e=this._wrapTerminalCallbacks(n);await this._consumeSSE(r.body,e.wrapped),!e.sawTerminal&&!this._abort?.signal.aborted&&e.onMissingTerminal()}this._clearPendingRun(),this._abort=void 0}_wrapTerminalCallbacks(e){if(!e)return{wrapped:void 0,sawTerminal:!1,onMissingTerminal:()=>{}};let t=!1,n=()=>{t=!0};return{get sawTerminal(){return t},wrapped:{...e,onResult:()=>{t||(n(),e.onResult())},onError:r=>{t||(n(),e.onError(r))}},onMissingTerminal:()=>{t||(n(),e.onResult())}}}_clearPendingRun(){let e=this._sseChatId;if(e)try{let t=FL(e),n=sessionStorage.getItem(t);if(n){let e=JSON.parse(n),t=typeof e?.runId==`string`?e.runId:``;if(this._trackedRunId&&t&&t!==this._trackedRunId)return}sessionStorage.removeItem(t),bI(e)}catch{}this._trackedRunId=void 0}async _consumeSSE(e,t){let n=e.pipeThrough(new TextDecoderStream).getReader(),r=``,i=``,a=``,o=async()=>{let{done:e,value:s}=await n.read();if(e){a&&this._dispatchSSE(i||`message`,a,t);return}r+=s;let c=r.split(`
23
23
  `);r=c.pop()??``;for(let e of c){let n=e.replace(/\r$/,``);if(n.startsWith(`event:`))a=``,i=n.slice(6).trim();else if(n.startsWith(`data:`)){let e=n.startsWith(`data: `)?n.slice(6):n.slice(5);a+=(a?`
24
- `:``)+e}else n===``&&a&&(this._dispatchSSE(i||`message`,a,t),i=``,a=``)}await o()};try{await o()}finally{n.releaseLock()}}_dispatchSSE(e,t,n){let r;try{r=JSON.parse(t)}catch{e===`run_end`&&n?.onResult();return}let i=r.payload&&typeof r.payload==`object`?r.payload:{};switch(e){case`run_start`:typeof r.runId==`string`&&this._sseChatId&&(this._trackedRunId=r.runId,LL(this._sseChatId,r.runId)),n?.onStreamStart();break;case`user_message`:{let e=AL(i.message);e&&n?.onUserMessage?.(e);break}case`user_transcript`:{let e=AL({text:i.text,media:i.media,timestamp:r.timestamp});e&&n?.onUserMessage?.(e);break}case`assistant_message_start`:n?.onStreamStart();break;case`assistant_delta`:typeof i.delta==`string`&&i.delta&&n?.onToken(i.delta);break;case`thinking_delta`:typeof i.delta==`string`&&i.delta&&n?.onThinking(i.delta,!0);break;case`thinking_end`:case`assistant_message_end`:n?.onThinkingEnd();break;case`tool_start`:{let e=String(i.toolName||`unknown`),t=typeof i.toolCallId==`string`?i.toolCallId:void 0;if(e===`clarify`)break;n?.onToolStart(e,i.args,t);break}case`tool_update`:{let e=typeof i.toolName==`string`&&i.toolName?i.toolName:`unknown`,t=typeof i.toolCallId==`string`?i.toolCallId:void 0;i.details!==void 0&&n?.onToolUpdate?.(e,t,i.details),typeof i.textDelta==`string`&&i.textDelta&&n?.onToolUpdate?.(e,t,{textDelta:i.textDelta});break}case`tool_end`:n?.onToolEnd(typeof i.toolName==`string`&&i.toolName?i.toolName:`unknown`,i.status===`error`||i.status===`cancelled`,zL(i.result));break;case`progress`:n?.onProgress({stage:String(i.stage||`thinking`),message:String(i.message||``),detail:i.detail,toolName:i.toolName,completed:typeof i.completed==`number`?i.completed:void 0,total:typeof i.total==`number`?i.total:void 0,timestamp:Date.now()});break;case`compaction`:n?.onCompaction?.({status:i.status||`started`,tokensBefore:typeof i.tokensBefore==`number`?i.tokensBefore:void 0,tokensAfter:typeof i.tokensAfter==`number`?i.tokensAfter:void 0,summary:typeof i.summary==`string`?i.summary:void 0});break;case`turn_plan`:{let e=BL(i.plan);e.length>0&&n?.onTurnPlanUpdated?.({explanation:typeof i.explanation==`string`&&i.explanation.trim()?i.explanation.trim():void 0,plan:e});break}case`tts_audio`:n?.onTtsAudio?.({uri:String(i.uri||``),mimeType:String(i.mimeType||`audio/mpeg`),name:String(i.name||`voice.mp3`),attachTo:i.attachTo===`last_assistant`?`last_assistant`:void 0,messageId:typeof i.messageId==`string`?i.messageId:void 0});break;case`clarify_request`:{let e=typeof i.requestId==`string`?i.requestId.trim():``,t=typeof i.question==`string`?i.question.trim():``;if(e&&t&&n?.onClarifyRequest){let r=Array.isArray(i.choices)?i.choices.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,a=typeof i.default==`string`&&i.default.trim()?i.default.trim():void 0;n.onClarifyRequest({requestId:e,question:t,choices:r&&r.length>=2?r:void 0,default:a})}break}case`workflow_run_started`:{let e=i.workflowRun;if(e?.ok===!0){let t=typeof e.runId==`string`?e.runId:``,r=typeof e.sessionKey==`string`?e.sessionKey:``,i=typeof e.definitionId==`string`?e.definitionId:``,a=typeof e.parentSessionKey==`string`?e.parentSessionKey:void 0;t&&r&&i&&n?.onWorkflowRunStarted?.({runId:t,sessionKey:r,definitionId:i,parentSessionKey:a})}break}case`run_end`:n?.onResult();break;case`error`:n?.onError(String(i.message||JSON.stringify(CI())));break}}};function zL(e){if(typeof e==`string`||e==null)return e;try{return JSON.stringify(e)}catch{return String(e)}}function BL(e){return Array.isArray(e)?e.map(e=>{let t=e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,n=typeof t?.step==`string`?t.step.trim():``,r=t?.status;if(!(!n||r!==`pending`&&r!==`in_progress`&&r!==`completed`))return{step:n,status:r}}).filter(e=>!!e):[]}function VL(e,t){let n=e=>DL(e.role),r=e.filter(n).length;if(t.filter(n).length<=r)return e;let i=t.filter(n).slice(r);return i.length===0?e:cL([...e,...i])}var HL=`medium`,UL=`stream`;function WL(){return{name:null,model:``,thinkingLevel:HL,reasoningLevel:UL,modelSupportsThinking:!1,workingDirectoryLocked:!1}}var GL=`xopc.webchat.agentId`;function KL(){if(globalThis.localStorage===void 0)return null;try{return globalThis.localStorage.getItem(`xopc.webchat.agentId`)?.trim().toLowerCase()||null}catch{return null}}var qL=class e{static instance;sender=new RL;activeStreamSessionKey=null;activeResumeRunId=null;userAborted=!1;static get(){return e.instance||=new e,e.instance}clearActiveStreamSessionKey(e){e&&this.activeStreamSessionKey!==e||(this.activeStreamSessionKey=null)}resetRunTracking(){this.activeStreamSessionKey=null,this.activeResumeRunId=null}abort(){this.sender.abort()}isStreamingFor(e){return this.sender.isStreamingFor(e)}get isSending(){return this.sender.isSending}}.get(),JL={get current(){return qL.activeStreamSessionKey},set current(e){qL.activeStreamSessionKey=e}};function YL(e){if(e.type!==`thinking`)return``;let t=e;return(typeof t.text==`string`&&t.text.length>0?t.text:typeof t.thinking==`string`?t.thinking:``).trim()}function XL(e){if(e.role!==`assistant`)return!1;for(let t of e.content)if(t.type===`text`&&(t.text||``).trim().length>0||t.type===`thinking`&&YL(t).length>0||t.type===`tool_use`||t.type===`review`)return!0;return!1}function ZL(e,t){return e&&e.role===`assistant`?{...e,content:[...e.content]}:{role:`assistant`,content:[],timestamp:t}}function QL(e){return{...e,content:e.content.map(e=>({...e})),attachments:e.attachments?e.attachments.map(e=>({...e})):void 0}}function $L(e,t){if(!t)return e;if(!e)return t;if(e.endsWith(t))return e;let n=Math.min(e.length,t.length,512);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return e+t.slice(r);return e+t}function eR(e){let t=e[e.length-1];t?.type===`thinking`&&t.streaming&&(t.streaming=!1)}function tR(e){let t=e[e.length-1];t?.type===`thinking`&&t.streaming||e.push({type:`thinking`,text:``,streaming:!0})}function nR(e,t,n){let r=e[e.length-1];if(r?.type===`thinking`){n?r.text=$L(r.text||``,t):r.text=t,r.streaming=!0;return}e.push({type:`thinking`,text:t,streaming:!0})}function rR(e){eR(e);for(let t of e)t.type===`thinking`&&typeof t.text==`string`&&(t.text=t.text.trim())}function iR(e){for(let t of e)t.type===`tool_use`&&t.status===`running`&&(t.status=`done`)}function aR(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function oR(e,t){eR(e);let n=e[e.length-1];if(n?.type===`text`){n.text=$L(n.text||``,t);return}e.push({type:`text`,text:t})}function sR(e){let t=fR(e);if(!t||t.type!==`review`)return null;let n=Array.isArray(t.findings)?t.findings:[],r={type:`review`,target:typeof t.target==`string`?t.target:`working tree changes`,summary:typeof t.summary==`string`?t.summary:``,findings:n.map(e=>{let t=fR(e);if(!t)return null;let n=t.priority===0||t.priority===1||t.priority===2||t.priority===3?t.priority:2,r=typeof t.title==`string`?t.title:``,i=typeof t.body==`string`?t.body:``;if(!r&&!i)return null;let a={title:r,body:i,priority:n};return typeof t.confidenceScore==`number`&&(a.confidenceScore=t.confidenceScore),typeof t.filePath==`string`&&(a.filePath=t.filePath),typeof t.lineStart==`number`&&(a.lineStart=t.lineStart),typeof t.lineEnd==`number`&&(a.lineEnd=t.lineEnd),a}).filter(e=>e!=null),overallCorrectness:t.overallCorrectness===`patch is correct`||t.overallCorrectness===`patch is incorrect`?t.overallCorrectness:`unknown`,overallExplanation:typeof t.overallExplanation==`string`?t.overallExplanation:``};return typeof t.overallConfidenceScore==`number`&&(r.overallConfidenceScore=t.overallConfidenceScore),typeof t.generatedAt==`number`&&(r.generatedAt=t.generatedAt),(t.source===`model`||t.source===`local`)&&(r.source=t.source),r}function cR(e,t){eR(e);let n=sR(t);if(!n)return;let r=e.findIndex(e=>e.type===`review`&&e.target===n.target);if(r>=0){e[r]=n;return}e.push(n)}function lR(e,t,n,r){eR(e);let i={type:`tool_use`,id:crypto.randomUUID(),toolCallId:r,name:t,input:n,status:`running`};e.push(i)}function uR(e,t,n,r){for(let i=e.length-1;i>=0;i--){let a=e[i];if(a.type===`tool_use`&&a.status===`running`&&aR(a.name,t)){a.status=n?`error`:`done`,a.result=r;return}}}function dR(e,t,n,r){for(let i=e.length-1;i>=0;i--){let a=e[i];if(a.type===`tool_use`&&a.status===`running`){if(n&&a.toolCallId===n){a.details=pR(a.details,r);return}if(!n&&aR(a.name,t)){a.details=pR(a.details,r);return}}}}function fR(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function pR(e,t){let n=fR(t);if(n?.kind!==`command_output_delta`)return t;let r=fR(e)??{},i=n.stream===`stderr`?`stderr`:`stdout`,a=typeof n.delta==`string`?n.delta:``,o=i===`stdout`?`${String(r.stdout??``)}${a}`:String(r.stdout??``),s=i===`stderr`?`${String(r.stderr??``)}${a}`:String(r.stderr??``);return{...r,command:typeof n.command==`string`?n.command:r.command,cwd:typeof n.cwd==`string`?n.cwd:r.cwd,stdout:o,stderr:s,aggregatedOutput:`${String(r.aggregatedOutput??``)}${a}`}}var mR={streamingMsg:null,progress:null,sending:!1,streaming:!1};function hR(e){return e.map(e=>QL(e))}function gR(e){let t=e.uri?.trim();return t?`uri:${t}`:e.id?`id:${e.id}`:`name:${e.name??`file`}|${e.mimeType??``}`}function _R(e,t){let n=[...e??[]],r=gR(t);return n.some(e=>gR(e)===r)||n.push({...t}),n}function vR(e){return{name:e.name,model:e.model,thinkingLevel:e.thinkingLevel,reasoningLevel:e.reasoningLevel,modelSupportsThinking:e.modelSupportsThinking,workingDirectoryLocked:e.workingDirectoryLocked,messages:hR(e.messages),hasMore:e.hasMore,streamingMsg:e.streamingMsg?QL(e.streamingMsg):null,progress:e.progress,sending:e.sending,streaming:e.streaming}}function yR(e){return String(e??``).trim()}function bR(e){return e?{name:e.name,model:e.model,thinkingLevel:e.thinkingLevel,reasoningLevel:e.reasoningLevel,modelSupportsThinking:e.modelSupportsThinking,workingDirectoryLocked:e.workingDirectoryLocked}:WL()}var xR=h((e,t)=>({focusedSessionKey:null,initLoading:!0,loadingSessionKey:null,loadingMore:!1,shellError:null,sessions:{},setFocusedSessionKey:t=>e({focusedSessionKey:t}),setInitLoading:t=>e({initLoading:t}),setLoadingSessionKey:t=>e({loadingSessionKey:t}),setLoadingMore:t=>e({loadingMore:t}),setShellError:t=>e({shellError:t}),patchSessionMeta:(t,n)=>{let r=yR(t);r&&e(e=>{let t=e.sessions[r]??{...WL(),messages:[],hasMore:!1,...mR};return{sessions:{...e.sessions,[r]:{...t,...n}}}})},initSessionSnapshot:(t,n)=>{let r=yR(t);r&&e(e=>({sessions:{...e.sessions,[r]:vR(n)}}))},setCommittedSnapshot:(t,n)=>{let r=yR(t);r&&e(e=>{let t=e.sessions[r],i=n.hasMore,a=hR(n.messages),o=bR(t);return n.name!==void 0&&(o.name=n.name),t?SR(t)?{sessions:{...e.sessions,[r]:{...t,...o,hasMore:i}}}:{sessions:{...e.sessions,[r]:{...t,...o,messages:a,hasMore:i,...mR}}}:{sessions:{...e.sessions,[r]:{...o,messages:a,hasMore:i,...mR}}}})},updateSessionMessages:(t,n)=>{let r=yR(t);r&&e(e=>{let t=e.sessions[r];return t?{sessions:{...e.sessions,[r]:{...t,messages:hR(n(t.messages))}}}:e})},finalizeStreamingTurn:(t,n)=>{let r=yR(t);r&&e(e=>{let t=e.sessions[r],i=bR(t),a=t?.hasMore??!1;return{sessions:{...e.sessions,[r]:{...i,messages:hR(n),hasMore:a,...mR}}}})},clearStreamingState:t=>{let n=yR(t);n&&e(e=>{let t=e.sessions[n];return t?{sessions:{...e.sessions,[n]:{...t,...mR}}}:e})},clearSession:t=>{let n=yR(t);n&&e(e=>{if(!(n in e.sessions))return e;let{[n]:t,...r}=e.sessions;return{sessions:r}})},getSessionSnapshot:e=>{let n=yR(e);if(!n)return;let r=t().sessions[n];return r?vR(r):void 0},seedSessionIfEmpty:(e,n,r,i,a=!1)=>{let o=yR(e);!o||t().sessions[o]||t().initSessionSnapshot(o,{...WL(),messages:n,hasMore:a,streamingMsg:null,progress:null,sending:r,streaming:i})},setSessionFlags:(t,n)=>{let r=yR(t);r&&e(e=>{let t=e.sessions[r];return t?{sessions:{...e.sessions,[r]:{...t,...n.sending===void 0?{}:{sending:n.sending},...n.streaming===void 0?{}:{streaming:n.streaming}}}}:e})},setSessionProgress:(t,n)=>{let r=yR(t);r&&e(e=>{let t=e.sessions[r];return t?{sessions:{...e.sessions,[r]:{...t,progress:n}}}:e})},mutateSessionStreaming:(t,n,r=Date.now())=>{let i=yR(t);i&&e(e=>{let t=e.sessions[i];if(!t)return e;let a=ZL(t.streamingMsg,r);return n(a),{sessions:{...e.sessions,[i]:{...t,streamingMsg:QL(a),streaming:!0}}}})},appendAttachmentToCurrentAssistant:(t,n,r)=>{let i=yR(t);i&&e(e=>{let t=e.sessions[i];if(!t)return e;if(t.streamingMsg?.role===`assistant`){let r=QL(t.streamingMsg);return r.attachments=_R(r.attachments,n),{sessions:{...e.sessions,[i]:{...t,streamingMsg:r}}}}let r=hR(t.messages);for(let a=r.length-1;a>=0;a--){let o=r[a];if(o?.role===`assistant`)return r[a]={...o,attachments:_R(o.attachments,n)},{sessions:{...e.sessions,[i]:{...t,messages:r}}}}return e})},applyHydratedTail:(t,n,r)=>{let i=yR(t);i&&e(e=>{let t=e.sessions[i];return t?{sessions:{...e.sessions,[i]:{...t,messages:hR(n),streamingMsg:r?QL(r):null,streaming:!0,sending:!0}}}:e})},appendUserMessageIfMissing:(t,n)=>{let r=yR(t);!r||!DL(n.role)||e(e=>{let t=e.sessions[r],i=bR(t);if(!t)return{sessions:{...e.sessions,[r]:{...i,messages:hR([n]),hasMore:!1,...mR}}};let a=t.messages[t.messages.length-1];return a&&ML(a,n)?{sessions:{...e.sessions,[r]:{...t,messages:hR(cL([...t.messages.slice(0,-1),n]))}}}:t.messages.some(e=>NL(e,n))?e:{sessions:{...e.sessions,[r]:{...t,messages:hR(cL([...t.messages,n]))}}}})},mergeCommittedFromServer:(t,n,r)=>{let i=yR(t);i&&e(e=>{let t=e.sessions[i],a=bR(t),o=r??t?.hasMore??!1;if(!t||!SR(t))return{sessions:{...e.sessions,[i]:{...a,messages:hR(n),hasMore:o,...mR}}};let s=VL(t.messages,n);return s===t.messages&&o===t.hasMore?e:{sessions:{...e.sessions,[i]:{...t,messages:hR(s),hasMore:o}}}})},prependHistoryMessages:(t,n,r)=>{let i=yR(t);i&&e(e=>{let t=e.sessions[i],a=bR(t);if(!t)return{sessions:{...e.sessions,[i]:{...a,messages:hR(n),hasMore:r,...mR}}};let o=new Set(t.messages.map(e=>e.timestamp)),s=cL([...n.filter(e=>!o.has(e.timestamp)),...t.messages]);return{sessions:{...e.sessions,[i]:{...t,messages:hR(s),hasMore:r}}}})}}));function SR(e){return e?e.streaming||e.sending||!!e.streamingMsg:!1}function CR(e){return xR.getState().getSessionSnapshot(e)}function wR(e){return xR.getState().sessions[yR(e)]?.messages??[]}function TR(e){let t=yR(e);if(!t)return!1;let n=xR.getState().sessions[t];return SR(n)||qL.isStreamingFor(t)?!0:IL(t)}function ER(e){let t=xR(t=>SR(t.sessions[e])),[n,r]=(0,Z.useState)(()=>TR(e)),i=(0,Z.useRef)(e);return i.current!==e&&(i.current=e,r(TR(e))),(0,Z.useEffect)(()=>{r(TR(e))},[e,t]),(0,Z.useEffect)(()=>{let t=t=>{t.detail?.chatId===e&&r(TR(e))};return window.addEventListener(yI,t),()=>window.removeEventListener(yI,t)},[e]),t||n}async function DR(e){let t=new URLSearchParams;e?.status&&t.set(`status`,e.status),e?.search?.trim()&&t.set(`search`,e.search.trim()),e?.sortBy&&t.set(`sortBy`,e.sortBy),e?.sortOrder&&t.set(`sortOrder`,e.sortOrder),e?.limit&&t.set(`limit`,String(e.limit)),e?.offset&&t.set(`offset`,String(e.offset));let n=t.toString();return J(X(`/api/projects${n?`?${n}`:``}`))}async function OR(e){return(await J(X(`/api/projects/${encodeURIComponent(e)}`))).project}async function kR(e){return(await J(X(`/api/projects/${encodeURIComponent(e)}/overview`))).overview}async function AR(e,t={}){let n=new URLSearchParams;n.set(`visibility`,`timeline`),t.includeRelated&&n.set(`includeRelated`,`true`),t.limit&&n.set(`limit`,String(t.limit)),t.offset&&n.set(`offset`,String(t.offset));let r=n.toString();return J(X(`/api/projects/${encodeURIComponent(e)}/activity${r?`?${r}`:``}`))}async function jR(e){return(await J(X(`/api/projects`),{method:`POST`,body:JSON.stringify(e)})).project}async function MR(e){let t=await J(X(`/api/projects/infer-defaults`),{method:`POST`,body:JSON.stringify(e)});return{inference:t.inference,defaultAgentId:t.defaultAgentId}}async function NR(e,t){return(await J(X(`/api/projects/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)})).project}async function PR(e,t){return NR(e,{name:t})}async function FR(e){return NR(e,{status:`archived`})}async function IR(e){return NR(e,{status:`active`})}async function LR(e){return(await J(X(`/api/projects/${encodeURIComponent(e)}/pin`),{method:`POST`})).project}async function RR(e){return(await J(X(`/api/projects/${encodeURIComponent(e)}/unpin`),{method:`POST`})).project}async function zR(e){await J(X(`/api/projects/${encodeURIComponent(e)}`),{method:`DELETE`})}async function BR(e){return(await J(X(`/api/projects/${encodeURIComponent(e)}/sessions?limit=100`))).sessions}async function VR(e){await J(X(`/api/projects/${encodeURIComponent(e)}/digest-memory`),{method:`POST`,body:JSON.stringify({})})}async function HR(e,t){return(await J(X(`/api/projects/${encodeURIComponent(e)}/blockers`),{method:`POST`,body:JSON.stringify(t)})).goal}async function UR(e){return(await J(X(`/api/projects/${encodeURIComponent(e)}/goals?limit=100`))).goals}async function WR(e,t){let n=new URLSearchParams;t&&n.set(`path`,t);let r=n.toString();return J(X(`/api/projects/${encodeURIComponent(e)}/files${r?`?${r}`:``}`))}async function GR(e,t,n=50){let r=new URLSearchParams({q:t.trim(),limit:String(n)});return(await J(X(`/api/projects/${encodeURIComponent(e)}/files/search?${r.toString()}`))).entries}async function KR(e,t){return(await J(X(`/api/sessions`),{method:`POST`,body:JSON.stringify({projectId:e,...t?{agentId:t}:{}})})).session}async function qR(e,t){return(await J(X(`/api/goals`),{method:`POST`,body:JSON.stringify({title:t.title,projectId:e,priority:t.priority??`normal`,contextMessage:{text:t.description??``,attachments:t.attachments?.length?t.attachments:void 0},deadlineAt:t.deadlineAt,maxTurns:t.maxTurns,agentId:t.agentId,judgeModelRef:t.judgeModelRef,contract:t.contract,source:`api`})})).goal}var JR=new Map,YR=`xopc-agent-avatar-updated`;function XR(e){let t=(JR.get(e)??0)+1;return JR.set(e,t),typeof window<`u`&&window.dispatchEvent(new CustomEvent(YR,{detail:{agentId:e}})),t}function ZR(e){return JR.get(e)??0}var QR=`xopc:custom`,$R=`xopc:dicebear:`,ez=[`adventurer`,`bottts`,`lorelei`,`thumbs`,`fun-emoji`],tz=[...ez,`pixel-art`],nz=[`Avery`,`Blake`,`Casey`,`Drew`,`Eden`],rz=[`Fern`,`Gray`,`Harper`,`Indigo`,`Jules`,`Kai`,`Lane`,`Morgan`,`Noel`,`Oakley`,`Parker`,`Quinn`,`Reese`,`Sage`,`Tatum`];function iz(e){return ez.includes(e)}function az(e){return tz.includes(e)}function oz(e,t){return`${$R}${e}:${t}`}function sz(e){if(!e.startsWith($R))return null;let t=e.slice(14),n=t.indexOf(`:`);if(n<=0)return null;let r=t.slice(0,n),i=t.slice(n+1);return!az(r)||!i.trim()?null:{styleId:r,seed:i}}function cz(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)>>>0;return t}function lz(e,t=128){let n=cz(e)%360,r=(e.trim().charAt(0)||`A`).toUpperCase(),i=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 ${t} ${t}"><rect width="100%" height="100%" rx="${t/2}" fill="hsl(${n} 58% 42%)"/><text x="50%" y="54%" text-anchor="middle" dominant-baseline="middle" font-family="Inter, system-ui, sans-serif" font-size="${Math.round(t*.42)}" font-weight="700" fill="white">${r}</text></svg>`;return`data:image/svg+xml,${encodeURIComponent(i)}`}function uz(e,t,n,r,i){let a=t?.trim()??``,o=lz(e,r);if(!a)return{kind:`dicebear`,styleId:`adventurer`,seed:e,fallbackSrc:o};if(a===`xopc:custom`){let t=X(`/api/agents/${encodeURIComponent(e)}/avatar`),r=new URLSearchParams;n&&r.set(`token`,n),i>0&&r.set(`v`,String(i));let a=r.toString();return{kind:`sync`,src:a?`${t}?${a}`:t}}if(/^https?:\/\//i.test(a))return{kind:`sync`,src:a};let s=sz(a);return s?{kind:`dicebear`,styleId:s.styleId,seed:s.seed,fallbackSrc:o}:{kind:`dicebear`,styleId:`adventurer`,seed:e,fallbackSrc:o}}function dz(e){let t=q(e=>e.token),n=e.token===void 0?t:e.token,{agentId:r,avatar:i,size:a=44}=e,[,o]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=e=>{e.detail?.agentId===r&&o(e=>e+1)};return window.addEventListener(YR,e),()=>window.removeEventListener(YR,e)},[r]);let s=ZR(r),l=(0,Z.useMemo)(()=>uz(r,i,n,a,s),[r,i,n,a,s]),d=l.kind===`sync`?l.src:l.fallbackSrc,[f,p]=(0,Z.useState)(d);return(0,Z.useEffect)(()=>{p(d)},[d]),(0,Z.useEffect)(()=>{if(l.kind!==`dicebear`)return;let e=!1;return c(async()=>{let{dicebearToDataUri:e}=await import(`./agent-avatar-dicebear-Dx3HQkOk.js`).then(e=>e.t);return{dicebearToDataUri:e}},__vite__mapDeps([40,1])).then(({dicebearToDataUri:t})=>{e||p(t(l.styleId,l.seed,a))}),()=>{e=!0}},[l,a]),(0,$.jsx)(`img`,{src:f,alt:``,width:a,height:a,className:u(`rounded-full object-cover bg-surface-hover`,e.className),draggable:!1,onError:()=>{p(lz(r,a))}})}function fz(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function pz(e,t){return t.find(t=>t.id===e)?.avatar}var mz;function hz(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var gz=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},_z=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(mz=globalThis).__zod_globalConfig??(mz.__zod_globalConfig={});var vz=globalThis.__zod_globalConfig;function yz(e){return e&&Object.assign(vz,e),vz}function bz(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function xz(e,t){return typeof t==`bigint`?t.toString():t}function Sz(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Cz(e){return e==null}function wz(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Tz(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Ez=Symbol(`evaluating`);function Dz(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ez)return r===void 0&&(r=Ez,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Oz(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function kz(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function Az(e){return JSON.stringify(e)}function jz(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Mz=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Nz(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Pz=Sz(()=>{if(vz.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Fz(e){if(Nz(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Nz(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Iz(e){return Fz(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Lz=new Set([`string`,`number`,`symbol`]);function Rz(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function zz(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Bz(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Vz(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Hz={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Uz(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return zz(e,kz(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Oz(this,`shape`,e),e},checks:[]}))}function Wz(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return zz(e,kz(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Oz(this,`shape`,r),r},checks:[]}))}function Gz(e,t){if(!Fz(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return zz(e,kz(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Oz(this,`shape`,n),n}}))}function Kz(e,t){if(!Fz(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return zz(e,kz(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Oz(this,`shape`,n),n}}))}function qz(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return zz(e,kz(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Oz(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Jz(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return zz(t,kz(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Oz(this,`shape`,i),i},checks:[]}))}function Yz(e,t,n){return zz(t,kz(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Oz(this,`shape`,i),i}}))}function Xz(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Zz(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Qz(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function $z(e){return typeof e==`string`?e:e?.message}function eB(e,t,n){let r=e.message?e.message:$z(e.inst?._zod.def?.error?.(e))??$z(t?.error?.(e))??$z(n.customError?.(e))??$z(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function tB(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function nB(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var rB=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,xz,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},iB=hz(`$ZodError`,rB),aB=hz(`$ZodError`,rB,{Parent:Error});function oB(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function sB(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var cB=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new gz;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>eB(e,a,yz())));throw Mz(t,i?.callee),t}return o.value},lB=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>eB(e,a,yz())));throw Mz(t,i?.callee),t}return o.value},uB=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new gz;return a.issues.length?{success:!1,error:new(e??iB)(a.issues.map(e=>eB(e,i,yz())))}:{success:!0,data:a.value}},dB=uB(aB),fB=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>eB(e,i,yz())))}:{success:!0,data:a.value}},pB=fB(aB),mB=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return cB(e)(t,n,i)},hB=e=>(t,n,r)=>cB(e)(t,n,r),gB=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return lB(e)(t,n,i)},_B=e=>async(t,n,r)=>lB(e)(t,n,r),vB=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return uB(e)(t,n,i)},yB=e=>(t,n,r)=>uB(e)(t,n,r),bB=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return fB(e)(t,n,i)},xB=e=>async(t,n,r)=>fB(e)(t,n,r),SB=/^[cC][0-9a-z]{6,}$/,CB=/^[0-9a-z]+$/,wB=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,TB=/^[0-9a-vA-V]{20}$/,EB=/^[A-Za-z0-9]{27}$/,DB=/^[a-zA-Z0-9_-]{21}$/,OB=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,kB=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,AB=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,jB=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,MB=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function NB(){return new RegExp(MB,`u`)}var PB=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,FB=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,IB=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,LB=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,RB=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,zB=/^[A-Za-z0-9_-]*$/,BB=/^https?$/,VB=/^\+[1-9]\d{6,14}$/,HB=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,UB=RegExp(`^${HB}$`);function WB(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function GB(e){return RegExp(`^${WB(e)}$`)}function KB(e){let t=WB({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${HB}T(?:${r})$`)}var qB=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},JB=/^-?\d+$/,YB=/^-?\d+(?:\.\d+)?$/,XB=/^(?:true|false)$/i,ZB=/^[^A-Z]*$/,QB=/^[^a-z]*$/,$B=hz(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),eV={number:`number`,bigint:`bigint`,object:`date`},tV=hz(`$ZodCheckLessThan`,(e,t)=>{$B.init(e,t);let n=eV[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nV=hz(`$ZodCheckGreaterThan`,(e,t)=>{$B.init(e,t);let n=eV[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rV=hz(`$ZodCheckMultipleOf`,(e,t)=>{$B.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Tz(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),iV=hz(`$ZodCheckNumberFormat`,(e,t)=>{$B.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Hz[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=JB)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),aV=hz(`$ZodCheckMaxLength`,(e,t)=>{var n;$B.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Cz(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=tB(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),oV=hz(`$ZodCheckMinLength`,(e,t)=>{var n;$B.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Cz(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=tB(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),sV=hz(`$ZodCheckLengthEquals`,(e,t)=>{var n;$B.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Cz(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=tB(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),cV=hz(`$ZodCheckStringFormat`,(e,t)=>{var n,r;$B.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),lV=hz(`$ZodCheckRegex`,(e,t)=>{cV.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),uV=hz(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ZB,cV.init(e,t)}),dV=hz(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=QB,cV.init(e,t)}),fV=hz(`$ZodCheckIncludes`,(e,t)=>{$B.init(e,t);let n=Rz(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),pV=hz(`$ZodCheckStartsWith`,(e,t)=>{$B.init(e,t);let n=RegExp(`^${Rz(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),mV=hz(`$ZodCheckEndsWith`,(e,t)=>{$B.init(e,t);let n=RegExp(`.*${Rz(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),hV=hz(`$ZodCheckOverwrite`,(e,t)=>{$B.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),gV=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
24
+ `:``)+e}else n===``&&a&&(this._dispatchSSE(i||`message`,a,t),i=``,a=``)}await o()};try{await o()}finally{n.releaseLock()}}_dispatchSSE(e,t,n){let r;try{r=JSON.parse(t)}catch{e===`run_end`&&n?.onResult();return}let i=r.payload&&typeof r.payload==`object`?r.payload:{};switch(e){case`run_start`:typeof r.runId==`string`&&this._sseChatId&&(this._trackedRunId=r.runId,LL(this._sseChatId,r.runId)),n?.onStreamStart();break;case`user_message`:{let e=AL(i.message);e&&n?.onUserMessage?.(e);break}case`user_transcript`:{let e=AL({text:i.text,media:i.media,timestamp:r.timestamp});e&&n?.onUserMessage?.(e);break}case`assistant_message_start`:n?.onStreamStart();break;case`assistant_delta`:typeof i.delta==`string`&&i.delta&&n?.onToken(i.delta);break;case`thinking_delta`:typeof i.delta==`string`&&i.delta&&n?.onThinking(i.delta,!0);break;case`thinking_end`:case`assistant_message_end`:n?.onThinkingEnd();break;case`tool_start`:{let e=String(i.toolName||`unknown`),t=typeof i.toolCallId==`string`?i.toolCallId:void 0;if(e===`clarify`)break;n?.onToolStart(e,i.args,t);break}case`tool_update`:{let e=typeof i.toolName==`string`&&i.toolName?i.toolName:`unknown`,t=typeof i.toolCallId==`string`?i.toolCallId:void 0;i.details!==void 0&&n?.onToolUpdate?.(e,t,i.details),typeof i.textDelta==`string`&&i.textDelta&&n?.onToolUpdate?.(e,t,{textDelta:i.textDelta});break}case`tool_end`:n?.onToolEnd(typeof i.toolName==`string`&&i.toolName?i.toolName:`unknown`,i.status===`error`||i.status===`cancelled`,zL(i.result));break;case`progress`:n?.onProgress({stage:String(i.stage||`thinking`),message:String(i.message||``),detail:i.detail,toolName:i.toolName,completed:typeof i.completed==`number`?i.completed:void 0,total:typeof i.total==`number`?i.total:void 0,timestamp:Date.now()});break;case`compaction`:n?.onCompaction?.({status:i.status||`started`,tokensBefore:typeof i.tokensBefore==`number`?i.tokensBefore:void 0,tokensAfter:typeof i.tokensAfter==`number`?i.tokensAfter:void 0,summary:typeof i.summary==`string`?i.summary:void 0});break;case`turn_plan`:{let e=BL(i.plan);e.length>0&&n?.onTurnPlanUpdated?.({explanation:typeof i.explanation==`string`&&i.explanation.trim()?i.explanation.trim():void 0,plan:e});break}case`tts_audio`:n?.onTtsAudio?.({uri:String(i.uri||``),mimeType:String(i.mimeType||`audio/mpeg`),name:String(i.name||`voice.mp3`),attachTo:i.attachTo===`last_assistant`?`last_assistant`:void 0,messageId:typeof i.messageId==`string`?i.messageId:void 0});break;case`clarify_request`:{let e=typeof i.requestId==`string`?i.requestId.trim():``,t=typeof i.question==`string`?i.question.trim():``;if(e&&t&&n?.onClarifyRequest){let r=Array.isArray(i.choices)?i.choices.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,a=typeof i.default==`string`&&i.default.trim()?i.default.trim():void 0;n.onClarifyRequest({requestId:e,question:t,choices:r&&r.length>=2?r:void 0,default:a})}break}case`workflow_run_started`:{let e=i.workflowRun;if(e?.ok===!0){let t=typeof e.runId==`string`?e.runId:``,r=typeof e.sessionKey==`string`?e.sessionKey:``,i=typeof e.definitionId==`string`?e.definitionId:``,a=typeof e.parentSessionKey==`string`?e.parentSessionKey:void 0;t&&r&&i&&n?.onWorkflowRunStarted?.({runId:t,sessionKey:r,definitionId:i,parentSessionKey:a})}break}case`run_end`:n?.onResult();break;case`error`:n?.onError(String(i.message||JSON.stringify(CI())));break}}};function zL(e){if(typeof e==`string`||e==null)return e;try{return JSON.stringify(e)}catch{return String(e)}}function BL(e){return Array.isArray(e)?e.map(e=>{let t=e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,n=typeof t?.step==`string`?t.step.trim():``,r=t?.status;if(!(!n||r!==`pending`&&r!==`in_progress`&&r!==`completed`))return{step:n,status:r}}).filter(e=>!!e):[]}function VL(e,t){let n=e=>DL(e.role),r=e.filter(n).length;if(t.filter(n).length<=r)return e;let i=t.filter(n).slice(r);return i.length===0?e:cL([...e,...i])}var HL=`medium`,UL=`stream`;function WL(){return{name:null,model:``,thinkingLevel:HL,reasoningLevel:UL,modelSupportsThinking:!1,workingDirectoryLocked:!1}}var GL=`xopc.webchat.agentId`;function KL(){if(globalThis.localStorage===void 0)return null;try{return globalThis.localStorage.getItem(`xopc.webchat.agentId`)?.trim().toLowerCase()||null}catch{return null}}var qL=class e{static instance;sender=new RL;activeStreamSessionKey=null;activeResumeRunId=null;userAborted=!1;static get(){return e.instance||=new e,e.instance}clearActiveStreamSessionKey(e){e&&this.activeStreamSessionKey!==e||(this.activeStreamSessionKey=null)}resetRunTracking(){this.activeStreamSessionKey=null,this.activeResumeRunId=null}abort(){this.sender.abort()}isStreamingFor(e){return this.sender.isStreamingFor(e)}get isSending(){return this.sender.isSending}}.get(),JL={get current(){return qL.activeStreamSessionKey},set current(e){qL.activeStreamSessionKey=e}};function YL(e){if(e.type!==`thinking`)return``;let t=e;return(typeof t.text==`string`&&t.text.length>0?t.text:typeof t.thinking==`string`?t.thinking:``).trim()}function XL(e){if(e.role!==`assistant`)return!1;for(let t of e.content)if(t.type===`text`&&(t.text||``).trim().length>0||t.type===`thinking`&&YL(t).length>0||t.type===`tool_use`||t.type===`review`)return!0;return!1}function ZL(e,t){return e&&e.role===`assistant`?{...e,content:[...e.content]}:{role:`assistant`,content:[],timestamp:t}}function QL(e){return{...e,content:e.content.map(e=>({...e})),attachments:e.attachments?e.attachments.map(e=>({...e})):void 0}}function $L(e,t){if(!t)return e;if(!e)return t;if(e.endsWith(t))return e;let n=Math.min(e.length,t.length,512);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return e+t.slice(r);return e+t}function eR(e){let t=e[e.length-1];t?.type===`thinking`&&t.streaming&&(t.streaming=!1)}function tR(e){let t=e[e.length-1];t?.type===`thinking`&&t.streaming||e.push({type:`thinking`,text:``,streaming:!0})}function nR(e,t,n){let r=e[e.length-1];if(r?.type===`thinking`){n?r.text=$L(r.text||``,t):r.text=t,r.streaming=!0;return}e.push({type:`thinking`,text:t,streaming:!0})}function rR(e){eR(e);for(let t of e)t.type===`thinking`&&typeof t.text==`string`&&(t.text=t.text.trim())}function iR(e){for(let t of e)t.type===`tool_use`&&t.status===`running`&&(t.status=`done`)}function aR(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function oR(e,t){eR(e);let n=e[e.length-1];if(n?.type===`text`){n.text=$L(n.text||``,t);return}e.push({type:`text`,text:t})}function sR(e){let t=fR(e);if(!t||t.type!==`review`)return null;let n=Array.isArray(t.findings)?t.findings:[],r={type:`review`,target:typeof t.target==`string`?t.target:`working tree changes`,summary:typeof t.summary==`string`?t.summary:``,findings:n.map(e=>{let t=fR(e);if(!t)return null;let n=t.priority===0||t.priority===1||t.priority===2||t.priority===3?t.priority:2,r=typeof t.title==`string`?t.title:``,i=typeof t.body==`string`?t.body:``;if(!r&&!i)return null;let a={title:r,body:i,priority:n};return typeof t.confidenceScore==`number`&&(a.confidenceScore=t.confidenceScore),typeof t.filePath==`string`&&(a.filePath=t.filePath),typeof t.lineStart==`number`&&(a.lineStart=t.lineStart),typeof t.lineEnd==`number`&&(a.lineEnd=t.lineEnd),a}).filter(e=>e!=null),overallCorrectness:t.overallCorrectness===`patch is correct`||t.overallCorrectness===`patch is incorrect`?t.overallCorrectness:`unknown`,overallExplanation:typeof t.overallExplanation==`string`?t.overallExplanation:``};return typeof t.overallConfidenceScore==`number`&&(r.overallConfidenceScore=t.overallConfidenceScore),typeof t.generatedAt==`number`&&(r.generatedAt=t.generatedAt),(t.source===`model`||t.source===`local`)&&(r.source=t.source),r}function cR(e,t){eR(e);let n=sR(t);if(!n)return;let r=e.findIndex(e=>e.type===`review`&&e.target===n.target);if(r>=0){e[r]=n;return}e.push(n)}function lR(e,t,n,r){eR(e);let i={type:`tool_use`,id:crypto.randomUUID(),toolCallId:r,name:t,input:n,status:`running`};e.push(i)}function uR(e,t,n,r){for(let i=e.length-1;i>=0;i--){let a=e[i];if(a.type===`tool_use`&&a.status===`running`&&aR(a.name,t)){a.status=n?`error`:`done`,a.result=r;return}}}function dR(e,t,n,r){for(let i=e.length-1;i>=0;i--){let a=e[i];if(a.type===`tool_use`&&a.status===`running`){if(n&&a.toolCallId===n){a.details=pR(a.details,r);return}if(!n&&aR(a.name,t)){a.details=pR(a.details,r);return}}}}function fR(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function pR(e,t){let n=fR(t);if(n?.kind!==`command_output_delta`)return t;let r=fR(e)??{},i=n.stream===`stderr`?`stderr`:`stdout`,a=typeof n.delta==`string`?n.delta:``,o=i===`stdout`?`${String(r.stdout??``)}${a}`:String(r.stdout??``),s=i===`stderr`?`${String(r.stderr??``)}${a}`:String(r.stderr??``);return{...r,command:typeof n.command==`string`?n.command:r.command,cwd:typeof n.cwd==`string`?n.cwd:r.cwd,stdout:o,stderr:s,aggregatedOutput:`${String(r.aggregatedOutput??``)}${a}`}}var mR={streamingMsg:null,progress:null,sending:!1,streaming:!1};function hR(e){return e.map(e=>QL(e))}function gR(e){let t=e.uri?.trim();return t?`uri:${t}`:e.id?`id:${e.id}`:`name:${e.name??`file`}|${e.mimeType??``}`}function _R(e,t){let n=[...e??[]],r=gR(t);return n.some(e=>gR(e)===r)||n.push({...t}),n}function vR(e){return{name:e.name,model:e.model,thinkingLevel:e.thinkingLevel,reasoningLevel:e.reasoningLevel,modelSupportsThinking:e.modelSupportsThinking,workingDirectoryLocked:e.workingDirectoryLocked,messages:hR(e.messages),hasMore:e.hasMore,streamingMsg:e.streamingMsg?QL(e.streamingMsg):null,progress:e.progress,sending:e.sending,streaming:e.streaming}}function yR(e){return String(e??``).trim()}function bR(e){return e?{name:e.name,model:e.model,thinkingLevel:e.thinkingLevel,reasoningLevel:e.reasoningLevel,modelSupportsThinking:e.modelSupportsThinking,workingDirectoryLocked:e.workingDirectoryLocked}:WL()}var xR=h((e,t)=>({focusedSessionKey:null,initLoading:!0,loadingSessionKey:null,loadingMore:!1,shellError:null,sessions:{},setFocusedSessionKey:t=>e({focusedSessionKey:t}),setInitLoading:t=>e({initLoading:t}),setLoadingSessionKey:t=>e({loadingSessionKey:t}),setLoadingMore:t=>e({loadingMore:t}),setShellError:t=>e({shellError:t}),patchSessionMeta:(t,n)=>{let r=yR(t);r&&e(e=>{let t=e.sessions[r]??{...WL(),messages:[],hasMore:!1,...mR};return{sessions:{...e.sessions,[r]:{...t,...n}}}})},initSessionSnapshot:(t,n)=>{let r=yR(t);r&&e(e=>({sessions:{...e.sessions,[r]:vR(n)}}))},setCommittedSnapshot:(t,n)=>{let r=yR(t);r&&e(e=>{let t=e.sessions[r],i=n.hasMore,a=hR(n.messages),o=bR(t);return n.name!==void 0&&(o.name=n.name),t?SR(t)?{sessions:{...e.sessions,[r]:{...t,...o,hasMore:i}}}:{sessions:{...e.sessions,[r]:{...t,...o,messages:a,hasMore:i,...mR}}}:{sessions:{...e.sessions,[r]:{...o,messages:a,hasMore:i,...mR}}}})},updateSessionMessages:(t,n)=>{let r=yR(t);r&&e(e=>{let t=e.sessions[r];return t?{sessions:{...e.sessions,[r]:{...t,messages:hR(n(t.messages))}}}:e})},finalizeStreamingTurn:(t,n)=>{let r=yR(t);r&&e(e=>{let t=e.sessions[r],i=bR(t),a=t?.hasMore??!1;return{sessions:{...e.sessions,[r]:{...i,messages:hR(n),hasMore:a,...mR}}}})},clearStreamingState:t=>{let n=yR(t);n&&e(e=>{let t=e.sessions[n];return t?{sessions:{...e.sessions,[n]:{...t,...mR}}}:e})},clearSession:t=>{let n=yR(t);n&&e(e=>{if(!(n in e.sessions))return e;let{[n]:t,...r}=e.sessions;return{sessions:r}})},getSessionSnapshot:e=>{let n=yR(e);if(!n)return;let r=t().sessions[n];return r?vR(r):void 0},seedSessionIfEmpty:(e,n,r,i,a=!1)=>{let o=yR(e);!o||t().sessions[o]||t().initSessionSnapshot(o,{...WL(),messages:n,hasMore:a,streamingMsg:null,progress:null,sending:r,streaming:i})},setSessionFlags:(t,n)=>{let r=yR(t);r&&e(e=>{let t=e.sessions[r];return t?{sessions:{...e.sessions,[r]:{...t,...n.sending===void 0?{}:{sending:n.sending},...n.streaming===void 0?{}:{streaming:n.streaming}}}}:e})},setSessionProgress:(t,n)=>{let r=yR(t);r&&e(e=>{let t=e.sessions[r];return t?{sessions:{...e.sessions,[r]:{...t,progress:n}}}:e})},mutateSessionStreaming:(t,n,r=Date.now())=>{let i=yR(t);i&&e(e=>{let t=e.sessions[i];if(!t)return e;let a=ZL(t.streamingMsg,r);return n(a),{sessions:{...e.sessions,[i]:{...t,streamingMsg:QL(a),streaming:!0}}}})},appendAttachmentToCurrentAssistant:(t,n,r)=>{let i=yR(t);i&&e(e=>{let t=e.sessions[i];if(!t)return e;if(t.streamingMsg?.role===`assistant`){let r=QL(t.streamingMsg);return r.attachments=_R(r.attachments,n),{sessions:{...e.sessions,[i]:{...t,streamingMsg:r}}}}let r=hR(t.messages);for(let a=r.length-1;a>=0;a--){let o=r[a];if(o?.role===`assistant`)return r[a]={...o,attachments:_R(o.attachments,n)},{sessions:{...e.sessions,[i]:{...t,messages:r}}}}return e})},applyHydratedTail:(t,n,r)=>{let i=yR(t);i&&e(e=>{let t=e.sessions[i];return t?{sessions:{...e.sessions,[i]:{...t,messages:hR(n),streamingMsg:r?QL(r):null,streaming:!0,sending:!0}}}:e})},appendUserMessageIfMissing:(t,n)=>{let r=yR(t);!r||!DL(n.role)||e(e=>{let t=e.sessions[r],i=bR(t);if(!t)return{sessions:{...e.sessions,[r]:{...i,messages:hR([n]),hasMore:!1,...mR}}};let a=t.messages[t.messages.length-1];return a&&ML(a,n)?{sessions:{...e.sessions,[r]:{...t,messages:hR(cL([...t.messages.slice(0,-1),n]))}}}:t.messages.some(e=>NL(e,n))?e:{sessions:{...e.sessions,[r]:{...t,messages:hR(cL([...t.messages,n]))}}}})},mergeCommittedFromServer:(t,n,r)=>{let i=yR(t);i&&e(e=>{let t=e.sessions[i],a=bR(t),o=r??t?.hasMore??!1;if(!t||!SR(t))return{sessions:{...e.sessions,[i]:{...a,messages:hR(n),hasMore:o,...mR}}};let s=VL(t.messages,n);return s===t.messages&&o===t.hasMore?e:{sessions:{...e.sessions,[i]:{...t,messages:hR(s),hasMore:o}}}})},prependHistoryMessages:(t,n,r)=>{let i=yR(t);i&&e(e=>{let t=e.sessions[i],a=bR(t);if(!t)return{sessions:{...e.sessions,[i]:{...a,messages:hR(n),hasMore:r,...mR}}};let o=new Set(t.messages.map(e=>e.timestamp)),s=cL([...n.filter(e=>!o.has(e.timestamp)),...t.messages]);return{sessions:{...e.sessions,[i]:{...t,messages:hR(s),hasMore:r}}}})}}));function SR(e){return e?e.streaming||e.sending||!!e.streamingMsg:!1}function CR(e){return xR.getState().getSessionSnapshot(e)}function wR(e){return xR.getState().sessions[yR(e)]?.messages??[]}function TR(e){let t=yR(e);if(!t)return!1;let n=xR.getState().sessions[t];return SR(n)||qL.isStreamingFor(t)?!0:IL(t)}function ER(e){let t=xR(t=>SR(t.sessions[e])),[n,r]=(0,Z.useState)(()=>TR(e)),i=(0,Z.useRef)(e);return i.current!==e&&(i.current=e,r(TR(e))),(0,Z.useEffect)(()=>{r(TR(e))},[e,t]),(0,Z.useEffect)(()=>{let t=t=>{t.detail?.chatId===e&&r(TR(e))};return window.addEventListener(yI,t),()=>window.removeEventListener(yI,t)},[e]),t||n}async function DR(e){let t=new URLSearchParams;e?.status&&t.set(`status`,e.status),e?.search?.trim()&&t.set(`search`,e.search.trim()),e?.sortBy&&t.set(`sortBy`,e.sortBy),e?.sortOrder&&t.set(`sortOrder`,e.sortOrder),e?.limit&&t.set(`limit`,String(e.limit)),e?.offset&&t.set(`offset`,String(e.offset));let n=t.toString();return J(X(`/api/projects${n?`?${n}`:``}`))}async function OR(e){return(await J(X(`/api/projects/${encodeURIComponent(e)}`))).project}async function kR(e){return(await J(X(`/api/projects/${encodeURIComponent(e)}/overview`))).overview}async function AR(e,t={}){let n=new URLSearchParams;n.set(`visibility`,`timeline`),t.includeRelated&&n.set(`includeRelated`,`true`),t.limit&&n.set(`limit`,String(t.limit)),t.offset&&n.set(`offset`,String(t.offset));let r=n.toString();return J(X(`/api/projects/${encodeURIComponent(e)}/activity${r?`?${r}`:``}`))}async function jR(e){return(await J(X(`/api/projects`),{method:`POST`,body:JSON.stringify(e)})).project}async function MR(e){let t=await J(X(`/api/projects/infer-defaults`),{method:`POST`,body:JSON.stringify(e)});return{inference:t.inference,defaultAgentId:t.defaultAgentId}}async function NR(e,t){return(await J(X(`/api/projects/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)})).project}async function PR(e,t){return NR(e,{name:t})}async function FR(e){return NR(e,{status:`archived`})}async function IR(e){return NR(e,{status:`active`})}async function LR(e){return(await J(X(`/api/projects/${encodeURIComponent(e)}/pin`),{method:`POST`})).project}async function RR(e){return(await J(X(`/api/projects/${encodeURIComponent(e)}/unpin`),{method:`POST`})).project}async function zR(e){await J(X(`/api/projects/${encodeURIComponent(e)}`),{method:`DELETE`})}async function BR(e){return(await J(X(`/api/projects/${encodeURIComponent(e)}/sessions?limit=100`))).sessions}async function VR(e){await J(X(`/api/projects/${encodeURIComponent(e)}/digest-memory`),{method:`POST`,body:JSON.stringify({})})}async function HR(e,t){return(await J(X(`/api/projects/${encodeURIComponent(e)}/blockers`),{method:`POST`,body:JSON.stringify(t)})).goal}async function UR(e){return(await J(X(`/api/projects/${encodeURIComponent(e)}/goals?limit=100`))).goals}async function WR(e,t){let n=new URLSearchParams;t&&n.set(`path`,t);let r=n.toString();return J(X(`/api/projects/${encodeURIComponent(e)}/files${r?`?${r}`:``}`))}async function GR(e,t,n=50){let r=new URLSearchParams({q:t.trim(),limit:String(n)});return(await J(X(`/api/projects/${encodeURIComponent(e)}/files/search?${r.toString()}`))).entries}async function KR(e,t){return(await J(X(`/api/sessions`),{method:`POST`,body:JSON.stringify({projectId:e,...t?{agentId:t}:{}})})).session}async function qR(e,t){return(await J(X(`/api/goals`),{method:`POST`,body:JSON.stringify({title:t.title,projectId:e,priority:t.priority??`normal`,contextMessage:{text:t.description??``,attachments:t.attachments?.length?t.attachments:void 0},deadlineAt:t.deadlineAt,maxTurns:t.maxTurns,agentId:t.agentId,judgeModelRef:t.judgeModelRef,contract:t.contract,source:`api`})})).goal}var JR=new Map,YR=`xopc-agent-avatar-updated`;function XR(e){let t=(JR.get(e)??0)+1;return JR.set(e,t),typeof window<`u`&&window.dispatchEvent(new CustomEvent(YR,{detail:{agentId:e}})),t}function ZR(e){return JR.get(e)??0}var QR=`xopc:custom`,$R=`xopc:dicebear:`,ez=[`adventurer`,`bottts`,`lorelei`,`thumbs`,`fun-emoji`],tz=[...ez,`pixel-art`],nz=[`Avery`,`Blake`,`Casey`,`Drew`,`Eden`],rz=[`Fern`,`Gray`,`Harper`,`Indigo`,`Jules`,`Kai`,`Lane`,`Morgan`,`Noel`,`Oakley`,`Parker`,`Quinn`,`Reese`,`Sage`,`Tatum`];function iz(e){return ez.includes(e)}function az(e){return tz.includes(e)}function oz(e,t){return`${$R}${e}:${t}`}function sz(e){if(!e.startsWith($R))return null;let t=e.slice(14),n=t.indexOf(`:`);if(n<=0)return null;let r=t.slice(0,n),i=t.slice(n+1);return!az(r)||!i.trim()?null:{styleId:r,seed:i}}function cz(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)>>>0;return t}function lz(e,t=128){let n=cz(e)%360,r=(e.trim().charAt(0)||`A`).toUpperCase(),i=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 ${t} ${t}"><rect width="100%" height="100%" rx="${t/2}" fill="hsl(${n} 58% 42%)"/><text x="50%" y="54%" text-anchor="middle" dominant-baseline="middle" font-family="Inter, system-ui, sans-serif" font-size="${Math.round(t*.42)}" font-weight="700" fill="white">${r}</text></svg>`;return`data:image/svg+xml,${encodeURIComponent(i)}`}function uz(e,t,n,r,i){let a=t?.trim()??``,o=lz(e,r);if(!a)return{kind:`dicebear`,styleId:`adventurer`,seed:e,fallbackSrc:o};if(a===`xopc:custom`){let t=X(`/api/agents/${encodeURIComponent(e)}/avatar`),r=new URLSearchParams;n&&r.set(`token`,n),i>0&&r.set(`v`,String(i));let a=r.toString();return{kind:`sync`,src:a?`${t}?${a}`:t}}if(/^https?:\/\//i.test(a))return{kind:`sync`,src:a};let s=sz(a);return s?{kind:`dicebear`,styleId:s.styleId,seed:s.seed,fallbackSrc:o}:{kind:`dicebear`,styleId:`adventurer`,seed:e,fallbackSrc:o}}function dz(e){let t=q(e=>e.token),n=e.token===void 0?t:e.token,{agentId:r,avatar:i,size:a=44}=e,[,o]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=e=>{e.detail?.agentId===r&&o(e=>e+1)};return window.addEventListener(YR,e),()=>window.removeEventListener(YR,e)},[r]);let s=ZR(r),l=(0,Z.useMemo)(()=>uz(r,i,n,a,s),[r,i,n,a,s]),d=l.kind===`sync`?l.src:l.fallbackSrc,[f,p]=(0,Z.useState)(d);return(0,Z.useEffect)(()=>{p(d)},[d]),(0,Z.useEffect)(()=>{if(l.kind!==`dicebear`)return;let e=!1;return c(async()=>{let{dicebearToDataUri:e}=await import(`./agent-avatar-dicebear-DHzfg5D-.js`).then(e=>e.t);return{dicebearToDataUri:e}},__vite__mapDeps([40,1])).then(({dicebearToDataUri:t})=>{e||p(t(l.styleId,l.seed,a))}),()=>{e=!0}},[l,a]),(0,$.jsx)(`img`,{src:f,alt:``,width:a,height:a,className:u(`rounded-full object-cover bg-surface-hover`,e.className),draggable:!1,onError:()=>{p(lz(r,a))}})}function fz(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function pz(e,t){return t.find(t=>t.id===e)?.avatar}var mz;function hz(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var gz=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},_z=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(mz=globalThis).__zod_globalConfig??(mz.__zod_globalConfig={});var vz=globalThis.__zod_globalConfig;function yz(e){return e&&Object.assign(vz,e),vz}function bz(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function xz(e,t){return typeof t==`bigint`?t.toString():t}function Sz(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Cz(e){return e==null}function wz(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Tz(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Ez=Symbol(`evaluating`);function Dz(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ez)return r===void 0&&(r=Ez,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Oz(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function kz(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function Az(e){return JSON.stringify(e)}function jz(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Mz=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Nz(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Pz=Sz(()=>{if(vz.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Fz(e){if(Nz(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Nz(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Iz(e){return Fz(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Lz=new Set([`string`,`number`,`symbol`]);function Rz(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function zz(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Bz(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Vz(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Hz={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Uz(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return zz(e,kz(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Oz(this,`shape`,e),e},checks:[]}))}function Wz(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return zz(e,kz(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Oz(this,`shape`,r),r},checks:[]}))}function Gz(e,t){if(!Fz(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return zz(e,kz(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Oz(this,`shape`,n),n}}))}function Kz(e,t){if(!Fz(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return zz(e,kz(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Oz(this,`shape`,n),n}}))}function qz(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return zz(e,kz(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Oz(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Jz(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return zz(t,kz(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Oz(this,`shape`,i),i},checks:[]}))}function Yz(e,t,n){return zz(t,kz(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Oz(this,`shape`,i),i}}))}function Xz(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Zz(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Qz(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function $z(e){return typeof e==`string`?e:e?.message}function eB(e,t,n){let r=e.message?e.message:$z(e.inst?._zod.def?.error?.(e))??$z(t?.error?.(e))??$z(n.customError?.(e))??$z(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function tB(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function nB(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var rB=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,xz,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},iB=hz(`$ZodError`,rB),aB=hz(`$ZodError`,rB,{Parent:Error});function oB(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function sB(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var cB=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new gz;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>eB(e,a,yz())));throw Mz(t,i?.callee),t}return o.value},lB=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>eB(e,a,yz())));throw Mz(t,i?.callee),t}return o.value},uB=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new gz;return a.issues.length?{success:!1,error:new(e??iB)(a.issues.map(e=>eB(e,i,yz())))}:{success:!0,data:a.value}},dB=uB(aB),fB=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>eB(e,i,yz())))}:{success:!0,data:a.value}},pB=fB(aB),mB=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return cB(e)(t,n,i)},hB=e=>(t,n,r)=>cB(e)(t,n,r),gB=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return lB(e)(t,n,i)},_B=e=>async(t,n,r)=>lB(e)(t,n,r),vB=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return uB(e)(t,n,i)},yB=e=>(t,n,r)=>uB(e)(t,n,r),bB=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return fB(e)(t,n,i)},xB=e=>async(t,n,r)=>fB(e)(t,n,r),SB=/^[cC][0-9a-z]{6,}$/,CB=/^[0-9a-z]+$/,wB=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,TB=/^[0-9a-vA-V]{20}$/,EB=/^[A-Za-z0-9]{27}$/,DB=/^[a-zA-Z0-9_-]{21}$/,OB=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,kB=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,AB=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,jB=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,MB=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function NB(){return new RegExp(MB,`u`)}var PB=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,FB=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,IB=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,LB=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,RB=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,zB=/^[A-Za-z0-9_-]*$/,BB=/^https?$/,VB=/^\+[1-9]\d{6,14}$/,HB=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,UB=RegExp(`^${HB}$`);function WB(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function GB(e){return RegExp(`^${WB(e)}$`)}function KB(e){let t=WB({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${HB}T(?:${r})$`)}var qB=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},JB=/^-?\d+$/,YB=/^-?\d+(?:\.\d+)?$/,XB=/^(?:true|false)$/i,ZB=/^[^A-Z]*$/,QB=/^[^a-z]*$/,$B=hz(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),eV={number:`number`,bigint:`bigint`,object:`date`},tV=hz(`$ZodCheckLessThan`,(e,t)=>{$B.init(e,t);let n=eV[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nV=hz(`$ZodCheckGreaterThan`,(e,t)=>{$B.init(e,t);let n=eV[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rV=hz(`$ZodCheckMultipleOf`,(e,t)=>{$B.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Tz(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),iV=hz(`$ZodCheckNumberFormat`,(e,t)=>{$B.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Hz[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=JB)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),aV=hz(`$ZodCheckMaxLength`,(e,t)=>{var n;$B.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Cz(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=tB(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),oV=hz(`$ZodCheckMinLength`,(e,t)=>{var n;$B.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Cz(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=tB(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),sV=hz(`$ZodCheckLengthEquals`,(e,t)=>{var n;$B.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Cz(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=tB(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),cV=hz(`$ZodCheckStringFormat`,(e,t)=>{var n,r;$B.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),lV=hz(`$ZodCheckRegex`,(e,t)=>{cV.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),uV=hz(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ZB,cV.init(e,t)}),dV=hz(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=QB,cV.init(e,t)}),fV=hz(`$ZodCheckIncludes`,(e,t)=>{$B.init(e,t);let n=Rz(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),pV=hz(`$ZodCheckStartsWith`,(e,t)=>{$B.init(e,t);let n=RegExp(`^${Rz(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),mV=hz(`$ZodCheckEndsWith`,(e,t)=>{$B.init(e,t);let n=RegExp(`.*${Rz(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),hV=hz(`$ZodCheckOverwrite`,(e,t)=>{$B.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),gV=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
25
25
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
26
26
  `))}},_V={major:4,minor:4,patch:3},vV=hz(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_V;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Xz(e),i;for(let a of t){if(a._zod.def.when){if(Zz(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new gz;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Xz(e,t))});else{if(e.issues.length===t)continue;r||=Xz(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Xz(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new gz;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new gz;return o.then(e=>t(e,r,a))}return t(o,r,a)}}Dz(e,`~standard`,()=>({validate:t=>{try{let n=dB(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return pB(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),yV=hz(`$ZodString`,(e,t)=>{vV.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??qB(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),bV=hz(`$ZodStringFormat`,(e,t)=>{cV.init(e,t),yV.init(e,t)}),xV=hz(`$ZodGUID`,(e,t)=>{t.pattern??=kB,bV.init(e,t)}),SV=hz(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=AB(e)}else t.pattern??=AB();bV.init(e,t)}),CV=hz(`$ZodEmail`,(e,t)=>{t.pattern??=jB,bV.init(e,t)}),wV=hz(`$ZodURL`,(e,t)=>{bV.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===BB.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),TV=hz(`$ZodEmoji`,(e,t)=>{t.pattern??=NB(),bV.init(e,t)}),EV=hz(`$ZodNanoID`,(e,t)=>{t.pattern??=DB,bV.init(e,t)}),DV=hz(`$ZodCUID`,(e,t)=>{t.pattern??=SB,bV.init(e,t)}),OV=hz(`$ZodCUID2`,(e,t)=>{t.pattern??=CB,bV.init(e,t)}),kV=hz(`$ZodULID`,(e,t)=>{t.pattern??=wB,bV.init(e,t)}),AV=hz(`$ZodXID`,(e,t)=>{t.pattern??=TB,bV.init(e,t)}),jV=hz(`$ZodKSUID`,(e,t)=>{t.pattern??=EB,bV.init(e,t)}),MV=hz(`$ZodISODateTime`,(e,t)=>{t.pattern??=KB(t),bV.init(e,t)}),NV=hz(`$ZodISODate`,(e,t)=>{t.pattern??=UB,bV.init(e,t)}),PV=hz(`$ZodISOTime`,(e,t)=>{t.pattern??=GB(t),bV.init(e,t)}),FV=hz(`$ZodISODuration`,(e,t)=>{t.pattern??=OB,bV.init(e,t)}),IV=hz(`$ZodIPv4`,(e,t)=>{t.pattern??=PB,bV.init(e,t),e._zod.bag.format=`ipv4`}),LV=hz(`$ZodIPv6`,(e,t)=>{t.pattern??=FB,bV.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),RV=hz(`$ZodCIDRv4`,(e,t)=>{t.pattern??=IB,bV.init(e,t)}),zV=hz(`$ZodCIDRv6`,(e,t)=>{t.pattern??=LB,bV.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function BV(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var VV=hz(`$ZodBase64`,(e,t)=>{t.pattern??=RB,bV.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{BV(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function HV(e){if(!zB.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return BV(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var UV=hz(`$ZodBase64URL`,(e,t)=>{t.pattern??=zB,bV.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{HV(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),WV=hz(`$ZodE164`,(e,t)=>{t.pattern??=VB,bV.init(e,t)});function GV(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var KV=hz(`$ZodJWT`,(e,t)=>{bV.init(e,t),e._zod.check=n=>{GV(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),qV=hz(`$ZodNumber`,(e,t)=>{vV.init(e,t),e._zod.pattern=e._zod.bag.pattern??YB,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),JV=hz(`$ZodNumberFormat`,(e,t)=>{iV.init(e,t),qV.init(e,t)}),YV=hz(`$ZodBoolean`,(e,t)=>{vV.init(e,t),e._zod.pattern=XB,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),XV=hz(`$ZodUnknown`,(e,t)=>{vV.init(e,t),e._zod.parse=e=>e}),ZV=hz(`$ZodNever`,(e,t)=>{vV.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function QV(e,t,n){e.issues.length&&t.issues.push(...Qz(n,e.issues)),t.value[n]=e.value}var $V=hz(`$ZodArray`,(e,t)=>{vV.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>QV(t,n,e))):QV(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function eH(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Qz(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function tH(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Vz(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function nH(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>eH(e,n,i,t,u,d))):eH(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var rH=hz(`$ZodObject`,(e,t)=>{if(vV.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Sz(()=>tH(t));Dz(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Nz,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>eH(n,t,e,s,r,i))):eH(a,t,e,s,r,i)}return i?nH(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),iH=hz(`$ZodObjectJIT`,(e,t)=>{rH.init(e,t);let n=e._zod.parse,r=Sz(()=>tH(t)),i=e=>{let t=new gV([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Az(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Az(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
27
27
  if (${n}.issues.length) {
@@ -151,7 +151,7 @@ ${e}</tr>
151
151
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${LX(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=RX(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+LX(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=RX(e);if(i===null)return LX(n);e=i;let a=`<img src="${e}" alt="${LX(n)}"`;return t&&(a+=` title="${LX(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:LX(e.text)}},YX=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},XX=class e{options;renderer;textRenderer;constructor(e){this.options=e||CY,this.options.renderer=this.options.renderer||new JX,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new YX}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},ZX=class{options;block;constructor(e){this.options=e||CY}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?qX.lex:qX.lexInline}provideParser(e=this.block){return e?XX.parse:XX.parseInline}},QX=new class{defaults=SY();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=XX;Renderer=JX;TextRenderer=YX;Lexer=qX;Tokenizer=KX;Hooks=ZX;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new JX(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new KX(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new ZX;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];ZX.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&ZX.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return qX.lex(e,t??this.defaults)}parser(e,t){return XX.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?qX.lex:qX.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?XX.parse:XX.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?qX.lex:qX.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?XX.parse:XX.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
152
152
  Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+LX(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function $X(e,t){return QX.parse(e,t)}$X.options=$X.setOptions=function(e){return QX.setOptions(e),$X.defaults=QX.defaults,wY($X.defaults),$X},$X.getDefaults=SY,$X.defaults=CY,$X.use=function(...e){return QX.use(...e),$X.defaults=QX.defaults,wY($X.defaults),$X},$X.walkTokens=function(e,t){return QX.walkTokens(e,t)},$X.parseInline=QX.parseInline,$X.Parser=XX,$X.parser=XX.parse,$X.Renderer=JX,$X.TextRenderer=YX,$X.Lexer=qX,$X.lexer=qX.lex,$X.Tokenizer=KX,$X.Hooks=ZX,$X.parse=$X,$X.options,$X.setOptions,$X.use,$X.walkTokens,$X.parseInline,XX.parse,qX.lex;function eZ(e){if(typeof e==`function`&&(e={highlight:e}),!e||typeof e.highlight!=`function`)throw Error(`Must provide highlight function`);return typeof e.langPrefix!=`string`&&(e.langPrefix=`language-`),typeof e.emptyLangClass!=`string`&&(e.emptyLangClass=``),{async:!!e.async,walkTokens(t){if(t.type!==`code`)return;let n=tZ(t.lang);if(e.async)return Promise.resolve(e.highlight(t.text,n,t.lang||``)).then(nZ(t));let r=e.highlight(t.text,n,t.lang||``);if(r instanceof Promise)throw Error(`markedHighlight is not set to async but the highlight function is async. Set the async option to true on markedHighlight to await the async highlight function.`);nZ(t)(r)},useNewRenderer:!0,renderer:{code(t,n,r){typeof t==`object`&&(r=t.escaped,n=t.lang,t=t.text);let i=tZ(n),a=i?e.langPrefix+lZ(i):e.emptyLangClass,o=a?` class="${a}"`:``;return t=t.replace(/\n$/,``),`<pre><code${o}>${r?t:lZ(t,!0)}\n</code></pre>`}}}}function tZ(e){return(e||``).match(/\S*/)[0]}function nZ(e){return t=>{typeof t==`string`&&t!==e.text&&(e.escaped=!0,e.text=t)}}var rZ=/[&<>"']/,iZ=new RegExp(rZ.source,`g`),aZ=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,oZ=new RegExp(aZ.source,`g`),sZ={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},cZ=e=>sZ[e];function lZ(e,t){if(t){if(rZ.test(e))return e.replace(iZ,cZ)}else if(aZ.test(e))return e.replace(oZ,cZ);return e}var uZ=e(n(((e,t)=>{function n(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw Error(`map is read-only`)}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw Error(`set is read-only`)}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{let r=e[t],i=typeof r;(i===`object`||i===`function`)&&!Object.isFrozen(r)&&n(r)}),e}var r=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function i(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#x27;`)}function a(e,...t){let n=Object.create(null);for(let t in e)n[t]=e[t];return t.forEach(function(e){for(let t in e)n[t]=e[t]}),n}var o=`</span>`,s=e=>!!e.scope,c=(e,{prefix:t})=>{if(e.startsWith(`language:`))return e.replace(`language:`,`language-`);if(e.includes(`.`)){let n=e.split(`.`);return[`${t}${n.shift()}`,...n.map((e,t)=>`${e}${`_`.repeat(t+1)}`)].join(` `)}return`${t}${e}`},l=class{constructor(e,t){this.buffer=``,this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=i(e)}openNode(e){if(!s(e))return;let t=c(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){s(e)&&(this.buffer+=o)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}},u=(e={})=>{let t={children:[]};return Object.assign(t,e),t},d=class e{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let t=u({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return typeof t==`string`?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(t=>this._walk(e,t)),e.closeNode(t)),e}static _collapse(t){typeof t!=`string`&&t.children&&(t.children.every(e=>typeof e==`string`)?t.children=[t.children.join(``)]:t.children.forEach(t=>{e._collapse(t)}))}},f=class extends d{constructor(e){super(),this.options=e}addText(e){e!==``&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){let n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function p(e){return e?typeof e==`string`?e:e.source:null}function m(e){return _(`(?=`,e,`)`)}function h(e){return _(`(?:`,e,`)*`)}function g(e){return _(`(?:`,e,`)?`)}function _(...e){return e.map(e=>p(e)).join(``)}function v(e){let t=e[e.length-1];return typeof t==`object`&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function y(...e){return`(`+(v(e).capture?``:`?:`)+e.map(e=>p(e)).join(`|`)+`)`}function b(e){return RegExp(e.toString()+`|`).exec(``).length-1}function x(e,t){let n=e&&e.exec(t);return n&&n.index===0}var S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function C(e,{joinWith:t}){let n=0;return e.map(e=>{n+=1;let t=n,r=p(e),i=``;for(;r.length>0;){let e=S.exec(r);if(!e){i+=r;break}i+=r.substring(0,e.index),r=r.substring(e.index+e[0].length),e[0][0]===`\\`&&e[1]?i+=`\\`+String(Number(e[1])+t):(i+=e[0],e[0]===`(`&&n++)}return i}).map(e=>`(${e})`).join(t)}var w=/\b\B/,T=`[a-zA-Z]\\w*`,E=`[a-zA-Z_]\\w*`,D=`\\b\\d+(\\.\\d+)?`,O=`(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)`,k=`\\b(0b[01]+)`,A=`!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~`,j=(e={})=>{let t=/^#![ ]*\//;return e.binary&&(e.begin=_(t,/.*\b/,e.binary,/\b.*/)),a({scope:`meta`,begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{e.index!==0&&t.ignoreMatch()}},e)},M={begin:`\\\\[\\s\\S]`,relevance:0},N={scope:`string`,begin:`'`,end:`'`,illegal:`\\n`,contains:[M]},P={scope:`string`,begin:`"`,end:`"`,illegal:`\\n`,contains:[M]},F={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},I=function(e,t,n={}){let r=a({scope:`comment`,begin:e,end:t,contains:[]},n);r.contains.push({scope:`doctag`,begin:`[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)`,end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let i=y(`I`,`a`,`is`,`so`,`us`,`to`,`at`,`if`,`in`,`it`,`on`,/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return r.contains.push({begin:_(/[ ]+/,`(`,i,/[.]?[:]?([.][ ]|[ ])/,`){3}`)}),r},L=I(`//`,`$`),R=I(`/\\*`,`\\*/`),z=I(`#`,`$`),B=Object.freeze({__proto__:null,APOS_STRING_MODE:N,BACKSLASH_ESCAPE:M,BINARY_NUMBER_MODE:{scope:`number`,begin:k,relevance:0},BINARY_NUMBER_RE:k,COMMENT:I,C_BLOCK_COMMENT_MODE:R,C_LINE_COMMENT_MODE:L,C_NUMBER_MODE:{scope:`number`,begin:O,relevance:0},C_NUMBER_RE:O,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:z,IDENT_RE:T,MATCH_NOTHING_RE:w,METHOD_GUARD:{begin:`\\.\\s*[a-zA-Z_]\\w*`,relevance:0},NUMBER_MODE:{scope:`number`,begin:D,relevance:0},NUMBER_RE:D,PHRASAL_WORDS_MODE:F,QUOTE_STRING_MODE:P,REGEXP_MODE:{scope:`regexp`,begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[M,{begin:/\[/,end:/\]/,relevance:0,contains:[M]}]},RE_STARTERS_RE:A,SHEBANG:j,TITLE_MODE:{scope:`title`,begin:T,relevance:0},UNDERSCORE_IDENT_RE:E,UNDERSCORE_TITLE_MODE:{scope:`title`,begin:E,relevance:0}});function V(e,t){e.input[e.index-1]===`.`&&t.ignoreMatch()}function H(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function U(e,t){t&&e.beginKeywords&&(e.begin=`\\b(`+e.beginKeywords.split(` `).join(`|`)+`)(?!\\.)(?=\\b|\\s)`,e.__beforeBegin=V,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function W(e,t){Array.isArray(e.illegal)&&(e.illegal=y(...e.illegal))}function G(e,t){if(e.match){if(e.begin||e.end)throw Error(`begin & end are not supported with match`);e.begin=e.match,delete e.match}}function K(e,t){e.relevance===void 0&&(e.relevance=1)}var q=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw Error(`beforeMatch cannot be used with starts`);let n=Object.assign({},e);Object.keys(e).forEach(t=>{delete e[t]}),e.keywords=n.keywords,e.begin=_(n.beforeMatch,m(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},ee=[`of`,`and`,`for`,`in`,`not`,`or`,`if`,`then`,`parent`,`list`,`value`],J=`keyword`;function te(e,t,n=J){let r=Object.create(null);return typeof e==`string`?i(n,e.split(` `)):Array.isArray(e)?i(n,e):Object.keys(e).forEach(function(n){Object.assign(r,te(e[n],t,n))}),r;function i(e,n){t&&(n=n.map(e=>e.toLowerCase())),n.forEach(function(t){let n=t.split(`|`);r[n[0]]=[e,Y(n[0],n[1])]})}}function Y(e,t){return t?Number(t):+!ne(e)}function ne(e){return ee.includes(e.toLowerCase())}var re={},X=e=>{console.error(e)},ie=(e,...t)=>{console.log(`WARN: ${e}`,...t)},ae=(e,t)=>{re[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),re[`${e}/${t}`]=!0)},oe=Error();function se(e,t,{key:n}){let r=0,i=e[n],a={},o={};for(let e=1;e<=t.length;e++)o[e+r]=i[e],a[e+r]=!0,r+=b(t[e-1]);e[n]=o,e[n]._emit=a,e[n]._multi=!0}function ce(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw X(`skip, excludeBegin, returnBegin not compatible with beginScope: {}`),oe;if(typeof e.beginScope!=`object`||e.beginScope===null)throw X(`beginScope must be object`),oe;se(e,e.begin,{key:`beginScope`}),e.begin=C(e.begin,{joinWith:``})}}function le(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw X(`skip, excludeEnd, returnEnd not compatible with endScope: {}`),oe;if(typeof e.endScope!=`object`||e.endScope===null)throw X(`endScope must be object`),oe;se(e,e.end,{key:`endScope`}),e.end=C(e.end,{joinWith:``})}}function ue(e){e.scope&&typeof e.scope==`object`&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function Z(e){ue(e),typeof e.beginScope==`string`&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope==`string`&&(e.endScope={_wrap:e.endScope}),ce(e),le(e)}function de(e){function t(t,n){return new RegExp(p(t),`m`+(e.case_insensitive?`i`:``)+(e.unicodeRegex?`u`:``)+(n?`g`:``))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=b(e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let e=this.regexes.map(e=>e[1]);this.matcherRe=t(C(e,{joinWith:`|`}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;let t=this.matcherRe.exec(e);if(!t)return null;let n=t.findIndex((e,t)=>t>0&&e!==void 0),r=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,r)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];let t=new n;return this.rules.slice(e).forEach(([e,n])=>t.addRule(e,n)),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),t.type===`begin`&&this.count++}exec(e){let t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition()&&!(n&&n.index===this.lastIndex)){let t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}function i(e){let t=new r;return e.contains.forEach(e=>t.addRule(e.begin,{rule:e,type:`begin`})),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:`end`}),e.illegal&&t.addRule(e.illegal,{type:`illegal`}),t}function o(n,r){let a=n;if(n.isCompiled)return a;[H,G,Z,q].forEach(e=>e(n,r)),e.compilerExtensions.forEach(e=>e(n,r)),n.__beforeBegin=null,[U,W,K].forEach(e=>e(n,r)),n.isCompiled=!0;let s=null;return typeof n.keywords==`object`&&n.keywords.$pattern&&(n.keywords=Object.assign({},n.keywords),s=n.keywords.$pattern,delete n.keywords.$pattern),s||=/\w+/,n.keywords&&=te(n.keywords,e.case_insensitive),a.keywordPatternRe=t(s,!0),r&&(n.begin||=/\B|\b/,a.beginRe=t(a.begin),!n.end&&!n.endsWithParent&&(n.end=/\B|\b/),n.end&&(a.endRe=t(a.end)),a.terminatorEnd=p(a.end)||``,n.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(n.end?`|`:``)+r.terminatorEnd)),n.illegal&&(a.illegalRe=t(n.illegal)),n.contains||=[],n.contains=[].concat(...n.contains.map(function(e){return pe(e===`self`?n:e)})),n.contains.forEach(function(e){o(e,a)}),n.starts&&o(n.starts,r),a.matcher=i(a),a}if(e.compilerExtensions||=[],e.contains&&e.contains.includes(`self`))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=a(e.classNameAliases||{}),o(e)}function fe(e){return e?e.endsWithParent||fe(e.starts):!1}function pe(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return a(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:fe(e)?a(e,{starts:e.starts?a(e.starts):null}):Object.isFrozen(e)?a(e):e}var me=`11.11.1`,he=class extends Error{constructor(e,t){super(e),this.name=`HTMLInjectionError`,this.html=t}},ge=i,_e=a,ve=Symbol(`nomatch`),ye=7,be=function(e){let t=Object.create(null),i=Object.create(null),a=[],o=!0,s=`Could not find the language '{}', did you forget to load/include a language module?`,c={disableAutodetect:!0,name:`Plain text`,contains:[]},l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:`hljs-`,cssSelector:`pre code`,languages:null,__emitter:f};function u(e){return l.noHighlightRe.test(e)}function d(e){let t=e.className+` `;t+=e.parentNode?e.parentNode.className:``;let n=l.languageDetectRe.exec(t);if(n){let t=N(n[1]);return t||(ie(s.replace(`{}`,n[1])),ie(`Falling back to no-highlight mode for this block.`,e)),t?n[1]:`no-highlight`}return t.split(/\s+/).find(e=>u(e)||N(e))}function p(e,t,n){let r=``,i=``;typeof t==`object`?(r=e,n=t.ignoreIllegals,i=t.language):(ae(`10.7.0`,`highlight(lang, code, ...args) has been deprecated.`),ae(`10.7.0`,`Please use highlight(code, options) instead.
153
153
  https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(n=!0);let a={code:r,language:i};z(`before:highlight`,a);let o=a.result?a.result:v(a.language,a.code,n);return o.code=a.code,z(`after:highlight`,o),o}function v(e,n,i,a){let c=Object.create(null);function u(e,t){return e.keywords[t]}function d(){if(!A.keywords){M.addText(P);return}let e=0;A.keywordPatternRe.lastIndex=0;let t=A.keywordPatternRe.exec(P),n=``;for(;t;){n+=P.substring(e,t.index);let r=D.case_insensitive?t[0].toLowerCase():t[0],i=u(A,r);if(i){let[e,a]=i;if(M.addText(n),n=``,c[r]=(c[r]||0)+1,c[r]<=ye&&(F+=a),e.startsWith(`_`))n+=t[0];else{let n=D.classNameAliases[e]||e;m(t[0],n)}}else n+=t[0];e=A.keywordPatternRe.lastIndex,t=A.keywordPatternRe.exec(P)}n+=P.substring(e),M.addText(n)}function f(){if(P===``)return;let e=null;if(typeof A.subLanguage==`string`){if(!t[A.subLanguage]){M.addText(P);return}e=v(A.subLanguage,P,!0,j[A.subLanguage]),j[A.subLanguage]=e._top}else e=S(P,A.subLanguage.length?A.subLanguage:null);A.relevance>0&&(F+=e.relevance),M.__addSublanguage(e._emitter,e.language)}function p(){A.subLanguage==null?d():f(),P=``}function m(e,t){e!==``&&(M.startScope(t),M.addText(e),M.endScope())}function h(e,t){let n=1,r=t.length-1;for(;n<=r;){if(!e._emit[n]){n++;continue}let r=D.classNameAliases[e[n]]||e[n],i=t[n];r?m(i,r):(P=i,d(),P=``),n++}}function g(e,t){return e.scope&&typeof e.scope==`string`&&M.openNode(D.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(m(P,D.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),P=``):e.beginScope._multi&&(h(e.beginScope,t),P=``)),A=Object.create(e,{parent:{value:A}}),A}function _(e,t,n){let i=x(e.endRe,n);if(i){if(e[`on:end`]){let n=new r(e);e[`on:end`](t,n),n.isMatchIgnored&&(i=!1)}if(i){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return _(e.parent,t,n)}function y(e){return A.matcher.regexIndex===0?(P+=e[0],1):(R=!0,0)}function b(e){let t=e[0],n=e.rule,i=new r(n),a=[n.__beforeBegin,n[`on:begin`]];for(let n of a)if(n&&(n(e,i),i.isMatchIgnored))return y(t);return n.skip?P+=t:(n.excludeBegin&&(P+=t),p(),!n.returnBegin&&!n.excludeBegin&&(P=t)),g(n,e),n.returnBegin?0:t.length}function C(e){let t=e[0],r=n.substring(e.index),i=_(A,e,r);if(!i)return ve;let a=A;A.endScope&&A.endScope._wrap?(p(),m(t,A.endScope._wrap)):A.endScope&&A.endScope._multi?(p(),h(A.endScope,e)):a.skip?P+=t:(a.returnEnd||a.excludeEnd||(P+=t),p(),a.excludeEnd&&(P=t));do A.scope&&M.closeNode(),!A.skip&&!A.subLanguage&&(F+=A.relevance),A=A.parent;while(A!==i.parent);return i.starts&&g(i.starts,e),a.returnEnd?0:t.length}function w(){let e=[];for(let t=A;t!==D;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach(e=>M.openNode(e))}let T={};function E(t,r){let a=r&&r[0];if(P+=t,a==null)return p(),0;if(T.type===`begin`&&r.type===`end`&&T.index===r.index&&a===``){if(P+=n.slice(r.index,r.index+1),!o){let t=Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=T.rule,t}return 1}if(T=r,r.type===`begin`)return b(r);if(r.type===`illegal`&&!i){let e=Error(`Illegal lexeme "`+a+`" for mode "`+(A.scope||`<unnamed>`)+`"`);throw e.mode=A,e}else if(r.type===`end`){let e=C(r);if(e!==ve)return e}if(r.type===`illegal`&&a===``)return P+=`
154
- `,1;if(L>1e5&&L>r.index*3)throw Error(`potential infinite loop, way more iterations than matches`);return P+=a,a.length}let D=N(e);if(!D)throw X(s.replace(`{}`,e)),Error(`Unknown language: "`+e+`"`);let O=de(D),k=``,A=a||O,j={},M=new l.__emitter(l);w();let P=``,F=0,I=0,L=0,R=!1;try{if(D.__emitTokens)D.__emitTokens(n,M);else{for(A.matcher.considerAll();;){L++,R?R=!1:A.matcher.considerAll(),A.matcher.lastIndex=I;let e=A.matcher.exec(n);if(!e)break;let t=E(n.substring(I,e.index),e);I=e.index+t}E(n.substring(I))}return M.finalize(),k=M.toHTML(),{language:e,value:k,relevance:F,illegal:!1,_emitter:M,_top:A}}catch(t){if(t.message&&t.message.includes(`Illegal`))return{language:e,value:ge(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:I,context:n.slice(I-100,I+100),mode:t.mode,resultSoFar:k},_emitter:M};if(o)return{language:e,value:ge(n),illegal:!1,relevance:0,errorRaised:t,_emitter:M,_top:A};throw t}}function b(e){let t={value:ge(e),illegal:!1,relevance:0,_top:c,_emitter:new l.__emitter(l)};return t._emitter.addText(e),t}function S(e,n){n=n||l.languages||Object.keys(t);let r=b(e),i=n.filter(N).filter(F).map(t=>v(t,e,!1));i.unshift(r);let[a,o]=i.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(N(e.language).supersetOf===t.language)return 1;if(N(t.language).supersetOf===e.language)return-1}return 0}),s=a;return s.secondBest=o,s}function C(e,t,n){let r=t&&i[t]||n;e.classList.add(`hljs`),e.classList.add(`language-${r}`)}function w(e){let t=null,n=d(e);if(u(n))return;if(z(`before:highlightElement`,{el:e,language:n}),e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);return}if(e.children.length>0&&(l.ignoreUnescapedHTML||(console.warn(`One of your code blocks includes unescaped HTML. This is a potentially serious security risk.`),console.warn(`https://github.com/highlightjs/highlight.js/wiki/security`),console.warn(`The element with unescaped HTML:`),console.warn(e)),l.throwUnescapedHTML))throw new he(`One of your code blocks includes unescaped HTML.`,e.innerHTML);t=e;let r=t.textContent,i=n?p(r,{language:n,ignoreIllegals:!0}):S(r);e.innerHTML=i.value,e.dataset.highlighted=`yes`,C(e,n,i.language),e.result={language:i.language,re:i.relevance,relevance:i.relevance},i.secondBest&&(e.secondBest={language:i.secondBest.language,relevance:i.secondBest.relevance}),z(`after:highlightElement`,{el:e,result:i,text:r})}function T(e){l=_e(l,e)}let E=()=>{k(),ae(`10.6.0`,`initHighlighting() deprecated. Use highlightAll() now.`)};function D(){k(),ae(`10.6.0`,`initHighlightingOnLoad() deprecated. Use highlightAll() now.`)}let O=!1;function k(){function e(){k()}if(document.readyState===`loading`){O||window.addEventListener(`DOMContentLoaded`,e,!1),O=!0;return}document.querySelectorAll(l.cssSelector).forEach(w)}function A(n,r){let i=null;try{i=r(e)}catch(e){if(X(`Language definition for '{}' could not be registered.`.replace(`{}`,n)),o)X(e);else throw e;i=c}i.name||=n,t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&P(i.aliases,{languageName:n})}function j(e){delete t[e];for(let t of Object.keys(i))i[t]===e&&delete i[t]}function M(){return Object.keys(t)}function N(e){return e=(e||``).toLowerCase(),t[e]||t[i[e]]}function P(e,{languageName:t}){typeof e==`string`&&(e=[e]),e.forEach(e=>{i[e.toLowerCase()]=t})}function F(e){let t=N(e);return t&&!t.disableAutodetect}function I(e){e[`before:highlightBlock`]&&!e[`before:highlightElement`]&&(e[`before:highlightElement`]=t=>{e[`before:highlightBlock`](Object.assign({block:t.el},t))}),e[`after:highlightBlock`]&&!e[`after:highlightElement`]&&(e[`after:highlightElement`]=t=>{e[`after:highlightBlock`](Object.assign({block:t.el},t))})}function L(e){I(e),a.push(e)}function R(e){let t=a.indexOf(e);t!==-1&&a.splice(t,1)}function z(e,t){let n=e;a.forEach(function(e){e[n]&&e[n](t)})}function V(e){return ae(`10.7.0`,`highlightBlock will be removed entirely in v12.0`),ae(`10.7.0`,`Please use highlightElement now.`),w(e)}Object.assign(e,{highlight:p,highlightAuto:S,highlightAll:k,highlightElement:w,highlightBlock:V,configure:T,initHighlighting:E,initHighlightingOnLoad:D,registerLanguage:A,unregisterLanguage:j,listLanguages:M,getLanguage:N,registerAliases:P,autoDetection:F,inherit:_e,addPlugin:L,removePlugin:R}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=me,e.regex={concat:_,lookahead:m,either:y,optional:g,anyNumberOfTimes:h};for(let e in B)typeof B[e]==`object`&&n(B[e]);return Object.assign(e,B),e},xe=be({});xe.newInstance=()=>be({}),t.exports=xe,xe.HighlightJS=xe,xe.default=xe}))()).default;function dZ(e){let t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:[`self`,{begin:/:-/,contains:[n]}]};Object.assign(n,{className:`variable`,variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,`(?![\\w\\d])(?![$])`)},r]});let i={className:`subst`,begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:`comment`}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:`string`})]}},s={className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(s);let c={match:/\\"/},l={className:`string`,begin:/'/,end:/'/},u={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:`number`},e.NUMBER_MODE,n]},f=e.SHEBANG({binary:`(${[`fish`,`bash`,`zsh`,`sh`,`csh`,`ksh`,`tcsh`,`dash`,`scsh`].join(`|`)})`,relevance:10}),p={className:`function`,begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=[`if`,`then`,`else`,`elif`,`fi`,`time`,`for`,`while`,`until`,`in`,`do`,`done`,`case`,`esac`,`coproc`,`function`,`select`],h=[`true`,`false`],g={match:/(\/[a-z._-]+)+/},_=[`break`,`cd`,`continue`,`eval`,`exec`,`exit`,`export`,`getopts`,`hash`,`pwd`,`readonly`,`return`,`shift`,`test`,`times`,`trap`,`umask`,`unset`],v=[`alias`,`bind`,`builtin`,`caller`,`command`,`declare`,`echo`,`enable`,`help`,`let`,`local`,`logout`,`mapfile`,`printf`,`read`,`readarray`,`source`,`sudo`,`type`,`typeset`,`ulimit`,`unalias`],y=`autoload.bg.bindkey.bye.cap.chdir.clone.comparguments.compcall.compctl.compdescribe.compfiles.compgroups.compquote.comptags.comptry.compvalues.dirs.disable.disown.echotc.echoti.emulate.fc.fg.float.functions.getcap.getln.history.integer.jobs.kill.limit.log.noglob.popd.print.pushd.pushln.rehash.sched.setcap.setopt.stat.suspend.ttyctl.unfunction.unhash.unlimit.unsetopt.vared.wait.whence.where.which.zcompile.zformat.zftp.zle.zmodload.zparseopts.zprof.zpty.zregexparse.zsocket.zstyle.ztcp`.split(`.`),b=`chcon.chgrp.chown.chmod.cp.dd.df.dir.dircolors.ln.ls.mkdir.mkfifo.mknod.mktemp.mv.realpath.rm.rmdir.shred.sync.touch.truncate.vdir.b2sum.base32.base64.cat.cksum.comm.csplit.cut.expand.fmt.fold.head.join.md5sum.nl.numfmt.od.paste.ptx.pr.sha1sum.sha224sum.sha256sum.sha384sum.sha512sum.shuf.sort.split.sum.tac.tail.tr.tsort.unexpand.uniq.wc.arch.basename.chroot.date.dirname.du.echo.env.expr.factor.groups.hostid.id.link.logname.nice.nohup.nproc.pathchk.pinky.printenv.printf.pwd.readlink.runcon.seq.sleep.stat.stdbuf.stty.tee.test.timeout.tty.uname.unlink.uptime.users.who.whoami.yes`.split(`.`);return{name:`Bash`,aliases:[`sh`,`zsh`],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:h,built_in:[..._,...v,`set`,`shopt`,...y,...b]},contains:[f,e.SHEBANG(),p,d,a,o,g,s,c,l,u,n]}}var fZ=e=>({IMPORTANT:{scope:`meta`,begin:`!important`},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:`number`,begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:`built_in`,begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:`selector-attr`,begin:/\[/,end:/\]/,illegal:`$`,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:`number`,begin:e.NUMBER_RE+`(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?`,relevance:0},CSS_VARIABLE:{className:`attr`,begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),pZ=`a.abbr.address.article.aside.audio.b.blockquote.body.button.canvas.caption.cite.code.dd.del.details.dfn.div.dl.dt.em.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.html.i.iframe.img.input.ins.kbd.label.legend.li.main.mark.menu.nav.object.ol.optgroup.option.p.picture.q.quote.samp.section.select.source.span.strong.summary.sup.table.tbody.td.textarea.tfoot.th.thead.time.tr.ul.var.video`.split(`.`),mZ=`defs.g.marker.mask.pattern.svg.switch.symbol.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feFlood.feGaussianBlur.feImage.feMerge.feMorphology.feOffset.feSpecularLighting.feTile.feTurbulence.linearGradient.radialGradient.stop.circle.ellipse.image.line.path.polygon.polyline.rect.text.use.textPath.tspan.foreignObject.clipPath`.split(`.`),hZ=[...pZ,...mZ],gZ=`any-hover.any-pointer.aspect-ratio.color.color-gamut.color-index.device-aspect-ratio.device-height.device-width.display-mode.forced-colors.grid.height.hover.inverted-colors.monochrome.orientation.overflow-block.overflow-inline.pointer.prefers-color-scheme.prefers-contrast.prefers-reduced-motion.prefers-reduced-transparency.resolution.scan.scripting.update.width.min-width.max-width.min-height.max-height`.split(`.`).sort().reverse(),_Z=`active.any-link.blank.checked.current.default.defined.dir.disabled.drop.empty.enabled.first.first-child.first-of-type.fullscreen.future.focus.focus-visible.focus-within.has.host.host-context.hover.indeterminate.in-range.invalid.is.lang.last-child.last-of-type.left.link.local-link.not.nth-child.nth-col.nth-last-child.nth-last-col.nth-last-of-type.nth-of-type.only-child.only-of-type.optional.out-of-range.past.placeholder-shown.read-only.read-write.required.right.root.scope.target.target-within.user-invalid.valid.visited.where`.split(`.`).sort().reverse(),vZ=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),yZ=`accent-color.align-content.align-items.align-self.alignment-baseline.all.anchor-name.animation.animation-composition.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-range.animation-range-end.animation-range-start.animation-timeline.animation-timing-function.appearance.aspect-ratio.backdrop-filter.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.baseline-shift.block-size.border.border-block.border-block-color.border-block-end.border-block-end-color.border-block-end-style.border-block-end-width.border-block-start.border-block-start-color.border-block-start-style.border-block-start-width.border-block-style.border-block-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-end-end-radius.border-end-start-radius.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline.border-inline-color.border-inline-end.border-inline-end-color.border-inline-end-style.border-inline-end-width.border-inline-start.border-inline-start-color.border-inline-start-style.border-inline-start-width.border-inline-style.border-inline-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-start-end-radius.border-start-start-radius.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-align.box-decoration-break.box-direction.box-flex.box-flex-group.box-lines.box-ordinal-group.box-orient.box-pack.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.color-scheme.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.column-span.column-width.columns.contain.contain-intrinsic-block-size.contain-intrinsic-height.contain-intrinsic-inline-size.contain-intrinsic-size.contain-intrinsic-width.container.container-name.container-type.content.content-visibility.counter-increment.counter-reset.counter-set.cue.cue-after.cue-before.cursor.cx.cy.direction.display.dominant-baseline.empty-cells.enable-background.field-sizing.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.flow.font.font-display.font-family.font-feature-settings.font-kerning.font-language-override.font-optical-sizing.font-palette.font-size.font-size-adjust.font-smooth.font-smoothing.font-stretch.font-style.font-synthesis.font-synthesis-position.font-synthesis-small-caps.font-synthesis-style.font-synthesis-weight.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-emoji.font-variant-ligatures.font-variant-numeric.font-variant-position.font-variation-settings.font-weight.forced-color-adjust.gap.glyph-orientation-horizontal.glyph-orientation-vertical.grid.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.hanging-punctuation.height.hyphenate-character.hyphenate-limit-chars.hyphens.icon.image-orientation.image-rendering.image-resolution.ime-mode.initial-letter.initial-letter-align.inline-size.inset.inset-area.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.isolation.justify-content.justify-items.justify-self.kerning.left.letter-spacing.lighting-color.line-break.line-height.line-height-step.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.margin-trim.marker.marker-end.marker-mid.marker-start.marks.mask.mask-border.mask-border-mode.mask-border-outset.mask-border-repeat.mask-border-slice.mask-border-source.mask-border-width.mask-clip.mask-composite.mask-image.mask-mode.mask-origin.mask-position.mask-repeat.mask-size.mask-type.masonry-auto-flow.math-depth.math-shift.math-style.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.nav-down.nav-index.nav-left.nav-right.nav-up.none.normal.object-fit.object-position.offset.offset-anchor.offset-distance.offset-path.offset-position.offset-rotate.opacity.order.orphans.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-anchor.overflow-block.overflow-clip-margin.overflow-inline.overflow-wrap.overflow-x.overflow-y.overlay.overscroll-behavior.overscroll-behavior-block.overscroll-behavior-inline.overscroll-behavior-x.overscroll-behavior-y.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page.page-break-after.page-break-before.page-break-inside.paint-order.pause.pause-after.pause-before.perspective.perspective-origin.place-content.place-items.place-self.pointer-events.position.position-anchor.position-visibility.print-color-adjust.quotes.r.resize.rest.rest-after.rest-before.right.rotate.row-gap.ruby-align.ruby-position.scale.scroll-behavior.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.scroll-snap-align.scroll-snap-stop.scroll-snap-type.scroll-timeline.scroll-timeline-axis.scroll-timeline-name.scrollbar-color.scrollbar-gutter.scrollbar-width.shape-image-threshold.shape-margin.shape-outside.shape-rendering.speak.speak-as.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.table-layout.text-align.text-align-all.text-align-last.text-anchor.text-combine-upright.text-decoration.text-decoration-color.text-decoration-line.text-decoration-skip.text-decoration-skip-ink.text-decoration-style.text-decoration-thickness.text-emphasis.text-emphasis-color.text-emphasis-position.text-emphasis-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-size-adjust.text-transform.text-underline-offset.text-underline-position.text-wrap.text-wrap-mode.text-wrap-style.timeline-scope.top.touch-action.transform.transform-box.transform-origin.transform-style.transition.transition-behavior.transition-delay.transition-duration.transition-property.transition-timing-function.translate.unicode-bidi.user-modify.user-select.vector-effect.vertical-align.view-timeline.view-timeline-axis.view-timeline-inset.view-timeline-name.view-transition-name.visibility.voice-balance.voice-duration.voice-family.voice-pitch.voice-range.voice-rate.voice-stress.voice-volume.white-space.white-space-collapse.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.x.y.z-index.zoom`.split(`.`).sort().reverse();function bZ(e){let t=e.regex,n=fZ(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i=/@-?\w[\w]*(-\w+)*/,a=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:`CSS`,case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:`from to`},classNameAliases:{keyframePosition:`selector-tag`},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:`selector-id`,begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:`selector-class`,begin:`\\.[a-zA-Z-][a-zA-Z0-9_-]*`,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:`selector-pseudo`,variants:[{begin:`:(`+_Z.join(`|`)+`)`},{begin:`:(:)?(`+vZ.join(`|`)+`)`}]},n.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+yZ.join(`|`)+`)\\b`},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:`url data-uri`},contains:[...a,{className:`string`,begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:`[{;]`,relevance:0,illegal:/:/,contains:[{className:`keyword`,begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:`and or not only`,attribute:gZ.join(` `)},contains:[{begin:/[a-z-]+(?=:)/,className:`attribute`},...a,n.CSS_NUMBER_MODE]}]},{className:`selector-tag`,begin:`\\b(`+hZ.join(`|`)+`)\\b`}]}}var xZ=`[A-Za-z$_][0-9A-Za-z$_]*`,SZ=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),CZ=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],wZ=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),TZ=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],EZ=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],DZ=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],OZ=[].concat(EZ,wZ,TZ);function kZ(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=xZ,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:xZ,keyword:SZ,literal:CZ,built_in:OZ,"variable.language":DZ},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:`[A-Za-z$_][0-9A-Za-z$_]*(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...wZ,...TZ]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...EZ,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},j=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,M={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},M,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:j,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$[A-Za-z$_][0-9A-Za-z$_]*`,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function AZ(e){let t={className:`attr`,begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:`punctuation`,relevance:0},r=[`true`,`false`,`null`],i={scope:`literal`,beginKeywords:r.join(` `)};return{name:`JSON`,aliases:[`jsonc`],keywords:{literal:r},contains:[t,n,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:`\\S`}}function jZ(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:`>`,subLanguage:`xml`,relevance:0},r={begin:`^[-\\*]{3,}`,end:`$`},i={className:`code`,variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:`(~{3,})[^~](.|\\n)*?\\1~*[ ]*`},{begin:"```",end:"```+[ ]*$"},{begin:`~~~`,end:`~~~+[ ]*$`},{begin:"`.+?`"},{begin:`(?=^( {4}|\\t))`,contains:[{begin:`^( {4}|\\t)`,end:`(\\n)$`}],relevance:0}]},a={className:`bullet`,begin:`^[ ]*([*+-]|(\\d+\\.))(?=\\s+)`,end:`\\s+`,excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:`symbol`,begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:`link`,begin:/:\s*/,end:/$/,excludeBegin:!0}]},s={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:`string`,relevance:0,begin:`\\[`,end:`\\]`,excludeBegin:!0,returnEnd:!0},{className:`link`,relevance:0,begin:`\\]\\(`,end:`\\)`,excludeBegin:!0,excludeEnd:!0},{className:`symbol`,relevance:0,begin:`\\]\\[`,end:`\\]`,excludeBegin:!0,excludeEnd:!0}]},c={className:`strong`,contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},l={className:`emphasis`,contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},u=e.inherit(c,{contains:[]}),d=e.inherit(l,{contains:[]});c.contains.push(d),l.contains.push(u);let f=[n,s];return[c,l,u,d].forEach(e=>{e.contains=e.contains.concat(f)}),f=f.concat(c,l),{name:`Markdown`,aliases:[`md`,`mkdown`,`mkd`],contains:[{className:`section`,variants:[{begin:`^#{1,6}`,end:`$`,contains:f},{begin:`(?=^.+?\\n[=-]{2,}$)`,contains:[{begin:`^[=-]*$`},{begin:`^`,end:`\\n`,contains:f}]}]},n,a,c,l,{className:`quote`,begin:`^>\\s+`,contains:f,end:`$`},i,r,s,o,{scope:`literal`,match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function MZ(e){return{name:`Plain text`,aliases:[`text`,`txt`],disableAutodetect:!0}}var NZ=`[A-Za-z$_][0-9A-Za-z$_]*`,PZ=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),FZ=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],IZ=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),LZ=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],RZ=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],zZ=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],BZ=[].concat(RZ,IZ,LZ);function VZ(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=NZ,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:NZ,keyword:PZ,literal:FZ,built_in:BZ,"variable.language":zZ},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:`[A-Za-z$_][0-9A-Za-z$_]*(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...IZ,...LZ]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...RZ,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},j=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,M={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},M,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:j,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$[A-Za-z$_][0-9A-Za-z$_]*`,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function HZ(e){let t=e.regex,n=VZ(e),r=NZ,i=[`any`,`void`,`number`,`boolean`,`string`,`object`,`never`,`symbol`,`bigint`,`unknown`],a={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:`keyword`,3:`title.class`}},o={beginKeywords:`interface`,end:/\{/,excludeEnd:!0,keywords:{keyword:`interface extends`,built_in:i},contains:[n.exports.CLASS_REFERENCE]},s={className:`meta`,relevance:10,begin:/^\s*['"]use strict['"]/},c={$pattern:NZ,keyword:PZ.concat([`type`,`interface`,`public`,`private`,`protected`,`implements`,`declare`,`abstract`,`readonly`,`enum`,`override`,`satisfies`]),literal:FZ,built_in:BZ.concat(i),"variable.language":zZ},l={className:`meta`,begin:`@[A-Za-z$_][0-9A-Za-z$_]*`},u=(e,t,n)=>{let r=e.contains.findIndex(e=>e.label===t);if(r===-1)throw Error(`can not find mode to replace`);e.contains.splice(r,1,n)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(l);let d=n.contains.find(e=>e.scope===`attr`),f=Object.assign({},d,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,d,f]),n.contains=n.contains.concat([l,a,o,f]),u(n,`shebang`,e.SHEBANG()),u(n,`use_strict`,s);let p=n.contains.find(e=>e.label===`func.def`);return p.relevance=0,Object.assign(n,{name:`TypeScript`,aliases:[`ts`,`tsx`,`mts`,`cts`]}),n}function UZ(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:`symbol`,begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:`keyword`,begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(a,{begin:/\(/,end:/\)/}),s=e.inherit(e.APOS_STRING_MODE,{className:`string`}),c=e.inherit(e.QUOTE_STRING_MODE,{className:`string`}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:`attr`,begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:`string`,endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:`HTML, XML`,aliases:[`html`,`xhtml`,`rss`,`atom`,`xjb`,`xsd`,`xsl`,`plist`,`wsf`,`svg`],case_insensitive:!0,unicodeRegex:!0,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,relevance:10,contains:[a,c,s,o,{begin:/\[/,end:/\]/,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,contains:[a,o,c,s]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:`meta`,end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:`tag`,begin:/<style(?=\s|>)/,end:/>/,keywords:{name:`style`},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:[`css`,`xml`]}},{className:`tag`,begin:/<script(?=\s|>)/,end:/>/,keywords:{name:`script`},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:[`javascript`,`handlebars`,`xml`]}},{className:`tag`,begin:/<>|<\/>/},{className:`tag`,begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:`name`,begin:n,relevance:0,starts:l}]},{className:`tag`,begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:`name`,begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}uZ.registerLanguage(`bash`,dZ),uZ.registerLanguage(`css`,bZ),uZ.registerLanguage(`html`,UZ),uZ.registerLanguage(`javascript`,kZ),uZ.registerLanguage(`json`,AZ),uZ.registerLanguage(`markdown`,jZ),uZ.registerLanguage(`md`,jZ),uZ.registerLanguage(`plaintext`,MZ),uZ.registerLanguage(`typescript`,HZ),uZ.registerLanguage(`xml`,UZ),uZ.registerAliases([`js`,`jsx`],{languageName:`javascript`}),uZ.registerAliases([`ts`,`tsx`],{languageName:`typescript`}),uZ.registerAliases([`sh`,`shell`,`zsh`],{languageName:`bash`}),$X.use(eZ({emptyLangClass:`hljs`,langPrefix:`hljs language-`,highlight(e,t){let n=(t??``).trim()||`plaintext`,r=uZ.getLanguage(n)?n:`plaintext`;return uZ.highlight(e,{language:r}).value}}));var WZ={gfm:!0,breaks:!1,async:!1};function GZ(e,t){return $X.parse(e,{...WZ,...t,async:!1})}var KZ=`png|jpe?g|gif|webp|bmp|svg|pdf|docx?|xlsx?|pptx?|txt|md|json|html?|css|mjs?|cjs|js|ts|tsx|jsx|yaml|yml|toml|xml`,qZ=new RegExp(String.raw`((?:\.\/)?(?:[A-Za-z0-9_.-]+\/)+[A-Za-z0-9_.-]+\.(?:${KZ})(?::\d+|#L\d+)?)`,`gi`),JZ=new RegExp(String.raw`(\/(?:Users|usr|var|opt|tmp|home|root|System|private|dev|media|mnt|Volumes|data)\/[^\s"'<>()|*?\n]+?\.(?:${KZ})(?::\d+|#L\d+)?)`,`gi`),YZ=new RegExp(String.raw`([A-Za-z]:[\\/][^"'<>()\n|*?=]+?\.(?:${KZ})(?::\d+|#L\d+)?)`,`gi`);function XZ(e){try{let t=new URL(e);return t.protocol!==`xopc:`||t.hostname!==`settings`?null:`/settings${t.pathname===`/`?``:t.pathname}${t.search}${t.hash}`}catch{return null}}function ZZ(e){try{let t=new URL(e);return t.protocol!==`xopc:`||t.hostname!==`workspace`||t.pathname!==`/file`||!t.searchParams.get(`path`)?.trim()?null:`/xopc/workspace/file${t.search}${t.hash}`}catch{return null}}function QZ(e){return e.replace(/xopc:\/\/(?:settings|workspace\/file)[^\s)<>"']*/gi,e=>XZ(e)??ZZ(e)??e)}function $Z(e){let t=e.trim();if(!t)return null;if(t.startsWith(`xopc://workspace/file`)||t.startsWith(`/xopc/workspace/file`))try{let e=t.startsWith(`/xopc/`)?new URL(t,`https://xopc.local`):new URL(t),n=e.searchParams.get(`path`)?.trim()??``;if(!n)return null;t=n;let r=Number(e.searchParams.get(`line`)??``);return eQ(t,Number.isFinite(r)&&r>0?Math.floor(r):void 0)}catch{return null}return tQ(t)||(/^[a-z][a-z0-9+.-]*:/i.test(t)||t.startsWith(`/`)||t.startsWith(`\\`)||t.includes(`..`)?null:eQ(t))}function eQ(e,t){let n=e.trim().replace(/\\/g,`/`);if(!n||n.includes(`..`))return null;let r=t,i=n.match(/#L(\d+)$/i);if(i?.[1])r=Number(i[1]),n=n.slice(0,-i[0].length);else{let e=n.match(/:(\d+)$/);e?.[1]&&(r=Number(e[1]),n=n.slice(0,-e[0].length))}return n=n.replace(/^\.\//,``),!n||n.startsWith(`/`)||/^[A-Za-z]:/.test(n)||!new RegExp(String.raw`\.(?:${KZ})$`,`i`).test(n)?null:{path:n,line:Number.isFinite(r)&&r&&r>0?Math.floor(r):void 0,kind:`workspace-relative`}}function tQ(e){let t=e.trim().replace(/\\/g,`/`);if(!t||/^[A-Za-z]:\/{2,}/.test(t)||!(t.startsWith(`/`)||/^[A-Za-z]:\//.test(t)))return null;let n,r=t.match(/#L(\d+)$/i);if(r?.[1])n=Number(r[1]),t=t.slice(0,-r[0].length);else{let e=t.match(/:(\d+)$/);e?.[1]&&(n=Number(e[1]),t=t.slice(0,-e[0].length))}return new RegExp(String.raw`\.(?:${KZ})$`,`i`).test(t)?{path:t,line:Number.isFinite(n)&&n&&n>0?Math.floor(n):void 0,kind:`absolute`}:null}function nQ(e){let t=[],n=[JZ,YZ,qZ];for(let r of n){r.lastIndex=0;let n;for(;(n=r.exec(e))!==null;){let r=n[1];if(!r)continue;let i=n.index,a=i+r.length,o=e[i-1]??``;if(o===`:`||o===`@`)continue;let s=$Z(r);s&&(s.kind===`workspace-relative`&&o===`/`||t.push({raw:r,start:i,end:a,target:s}))}}t.sort((e,t)=>e.start-t.start||t.end-e.end);let r=[],i=-1;for(let e of t)e.start<i||(r.push(e),i=e.end);return r}function rQ(e){let t=e.parentElement;return t?!!t.closest(`a, code, pre, kbd, samp, textarea, script, style, [data-xopc-inline-file]`):!0}function iQ(e){let t=e.ownerDocument,n=t.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){return!(e instanceof Text)||rQ(e)?NodeFilter.FILTER_REJECT:nQ(e.data).length>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),r=[],i;for(;i=n.nextNode();)r.push(i);for(let e of r){let n=e.data,r=nQ(n);if(r.length===0)continue;let i=t.createDocumentFragment(),a=0;for(let e of r){e.start>a&&i.appendChild(t.createTextNode(n.slice(a,e.start)));let r=t.createElement(`a`);r.href=`#`,r.className=`markdown-file-link`,r.dataset.xopcFilePath=e.target.path,r.dataset.xopcFileKind=e.target.kind,e.target.line&&(r.dataset.xopcLine=String(e.target.line)),r.textContent=e.raw,i.appendChild(r),a=e.end}a!==0&&(a<n.length&&i.appendChild(t.createTextNode(n.slice(a))),e.parentNode?.replaceChild(i,e))}}var aQ=!1;function oQ(){aQ||typeof window>`u`||(aQ=!0,xY.addHook(`afterSanitizeAttributes`,e=>{if(e.tagName!==`A`||!e.hasAttribute(`href`))return;let t=e.getAttribute(`href`)??``;try{let n=new URL(t,window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`||n.origin===window.location.origin)return;e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)}catch{}}))}oQ();var sQ=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,cQ=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>`;function lQ(e){return e.querySelector(`code`)?.textContent??e.textContent??``}function uQ(e){let t=e.querySelector(`code`);if(!t?.className)return`plaintext`;for(let e of t.className.split(/\s+/))if(e.startsWith(`language-`))return e.slice(9).trim()||`plaintext`;return`plaintext`}function dQ(e,t){let n=document.createDocumentFragment(),r=document.createElement(`span`);r.className=`markdown-code-copy-inner`,r.innerHTML=e===`idle`?sQ:cQ;let i=document.createElement(`span`);return i.className=`markdown-code-copy-label`,i.textContent=e===`idle`?t.copy:t.copied,n.appendChild(r),n.appendChild(i),n}function fQ(e){e.querySelectorAll(`[data-md-code-block]`).forEach(e=>{let t=e.querySelector(`:scope > pre`),n=e.parentNode;t&&n&&(n.insertBefore(t,e),e.remove())})}function pQ(e,t){let n=e.querySelectorAll(`.markdown-body pre`),r=[];for(let e of n){if(e.closest(`[data-md-code-block]`)||e.closest(`[data-mermaid-fallback]`))continue;let n=e.parentNode;if(!n)continue;let i=document.createElement(`div`);i.className=`markdown-code-block`,i.setAttribute(`data-md-code-block`,``);let a=document.createElement(`div`);a.className=`markdown-code-block-header`;let o=document.createElement(`span`);o.className=`markdown-code-block-lang`,o.textContent=uQ(e);let s=document.createElement(`button`);s.type=`button`,s.className=`markdown-code-copy-btn`,s.dataset.mdCodeCopy=``,s.title=t.copy,s.setAttribute(`aria-label`,t.copy),s.replaceChildren(dQ(`idle`,t));let c=n=>{n.preventDefault(),n.stopPropagation(),mA(lQ(e)).then(e=>{!e||!s.isConnected||(s.replaceChildren(dQ(`copied`,t)),s.title=t.copied,s.setAttribute(`aria-label`,t.copied),window.setTimeout(()=>{s.isConnected&&(s.replaceChildren(dQ(`idle`,t)),s.title=t.copy,s.setAttribute(`aria-label`,t.copy))},2e3))})};s.addEventListener(`click`,c),a.appendChild(o),a.appendChild(s),i.appendChild(a),n.insertBefore(i,e),i.appendChild(e),r.push(()=>{s.removeEventListener(`click`,c);let t=e.parentElement;t?.matches(`[data-md-code-block]`)&&t.parentNode&&(t.parentNode.insertBefore(e,t),t.remove())})}return()=>{for(let e of r)e()}}function mQ(e){return Array.from(e.querySelectorAll(`pre code.language-mermaid, pre code.hljs.language-mermaid`))}function hQ({content:e,compact:t=!1,breaks:n=!1,className:r,codeCopy:i=!0,onWorkspaceFileOpen:a}){let o=_(e=>e.language),s=(0,Z.useMemo)(()=>{let e=m(o).chat;return{copy:e.codeBlockCopy,copied:e.messageCopied}},[o]),l=(0,Z.useMemo)(()=>{if(!e.trim())return``;let t=GZ(QZ(e),n?{breaks:!0}:void 0);return xY.sanitize(t,{USE_PROFILES:{html:!0,svg:!0},ADD_ATTR:`viewBox.xmlns.d.fill.stroke.transform.stroke-width.stroke-linecap.stroke-linejoin.stroke-dasharray.x.y.width.height.rx.ry.cx.cy.r.x1.y1.x2.y2.offset.stop-color.stop-opacity.points.text-anchor.dominant-baseline.font-size.font-family.font-weight.font-style.class.id.style.markerWidth.markerHeight.refX.refY.orient.markerUnits.text-decoration.opacity.clip-path.mask.filter.preserveAspectRatio.xmlns:xlink.xlink:href.xml:space`.split(`.`)})},[e,n]),u=(0,Z.useRef)(null);return(0,Z.useLayoutEffect)(()=>{let e=u.current;if(e&&(fQ(e),a&&iQ(e),!(!i||!l)))return pQ(e,s)},[i,l,s,a]),(0,Z.useLayoutEffect)(()=>{let e=u.current;if(!e||!l)return;let t=mQ(e);if(t.length===0)return;let n=!1;return c(async()=>{let{renderMermaidBlock:e}=await import(`./mermaid-render-BbqDc_LQ.js`);return{renderMermaidBlock:e}},__vite__mapDeps([82,1])).then(({renderMermaidBlock:e})=>{if(!n)for(let n of t){if(!n.isConnected)continue;let t=n.closest(`pre`);if(!t)continue;let r=t.closest(`[data-md-code-block]`)??t,i=e(n.textContent??``),a=document.createElement(`template`);a.innerHTML=i.html.trim();let o=a.content.firstElementChild;o&&r.replaceWith(o)}}),()=>{n=!0}},[l]),(0,Z.useLayoutEffect)(()=>{let e=u.current;if(!e)return;let t=t=>{let n=(t.target instanceof Element?t.target:null)?.closest(`a[href]`);if(!n||!e.contains(n))return;let r=n.dataset.xopcFilePath;if(r&&a){t.preventDefault();let e=Number(n.dataset.xopcLine??``);a({path:r,line:Number.isFinite(e)&&e>0?Math.floor(e):void 0,kind:n.dataset.xopcFileKind===`absolute`?`absolute`:`workspace-relative`});return}let i=n.getAttribute(`href`)??``,o=a?$Z(i):null;if(o&&a){t.preventDefault(),a(o);return}i.startsWith(`/settings/`)&&(t.preventDefault(),window.location.hash=`#${i}`)};return e.addEventListener(`click`,t),()=>e.removeEventListener(`click`,t)},[a]),(0,$.jsx)(`div`,{ref:u,children:(0,$.jsx)(`div`,{className:[`markdown-body`,t?`markdown-compact`:``,r??``].filter(Boolean).join(` `),dangerouslySetInnerHTML:{__html:l}})})}var gQ=(0,Z.memo)(hQ);gQ.displayName=`MarkdownView`;var _Q=()=>c(()=>import(`./markdown-split-DQYDAL4r.js`),__vite__mapDeps([83,1,2,41,20,42,43])),vQ=()=>c(()=>import(`./html-workspace-editor-COqmtESs.js`),__vite__mapDeps([84,1,42,2,43])),yQ=(0,Z.lazy)(()=>_Q().then(e=>({default:e.MarkdownSplit}))),bQ=(0,Z.lazy)(()=>vQ().then(e=>({default:e.HtmlWorkspaceEditor})));function xQ(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-4 py-3`,"aria-busy":!0,children:[(0,$.jsx)(`div`,{className:`h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function SQ(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t).toLowerCase():``}function CQ(e){return{".ts":`typescript`,".tsx":`tsx`,".js":`javascript`,".jsx":`jsx`,".json":`json`,".css":`css`,".yml":`yaml`,".yaml":`yaml`,".py":`python`,".go":`go`,".rs":`rust`,".sh":`bash`}[SQ(e)]??`plaintext`}function wQ(e){let t=(0,Q.c)(12),{text:n,targetLine:r}=e,i=(0,Z.useRef)(null),a;if(t[0]!==n){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\r\n|\n|\r/,t[2]=e):e=t[2],a=n.split(e),t[0]=n,t[1]=a}else a=t[1];let o=a,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{i.current?.scrollIntoView({block:`center`})},t[3]=s):s=t[3];let c;t[4]!==r||t[5]!==n?(c=[r,n],t[4]=r,t[5]=n,t[6]=c):c=t[6],(0,Z.useEffect)(s,c);let l;t[7]!==o||t[8]!==r?(l=o.map((e,t)=>{let n=t+1,a=n===r;return(0,$.jsxs)(`div`,{ref:a?i:void 0,className:a?`flex bg-accent-soft/60 text-fg`:`flex`,"data-line":n,children:[(0,$.jsx)(`span`,{className:`w-12 shrink-0 select-none pr-3 text-right text-fg-subtle`,children:n}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words`,children:e||` `})]},n)}),t[7]=o,t[8]=r,t[9]=l):l=t[9];let u;return t[10]===l?u=t[11]:(u=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:(0,$.jsx)(`div`,{className:`min-w-max font-mono text-xs leading-relaxed text-fg`,children:l})}),t[10]=l,t[11]=u),u}function TQ(e,t){let n=e.textContent??``,r=e.descriptor.context===`workspace`,i=e.workspaceEditing;return t===`markdown`?r&&i?.markdownEditMode?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(xQ,{}),children:(0,$.jsx)(yQ,{initialContent:n,onSave:e=>void i?.onSaveMarkdown?.(e),isDark:(i?.isDark??e.resolvedTheme===`dark`)===!0,wordWrap:i?.markdownWordWrap===!0,onToggleWordWrap:i?.onToggleMarkdownWordWrap},e.descriptor.id)})}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsx)(gQ,{content:n})}):t===`html`?r&&i?.htmlCodeMode?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(xQ,{}),children:(0,$.jsx)(bQ,{initialContent:n,onChange:e=>i?.onHtmlChange?.(e),isDark:(i?.isDark??e.resolvedTheme===`dark`)===!0},e.descriptor.id)})}):(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:(0,$.jsx)(`iframe`,{title:e.descriptor.fileName,className:`min-h-0 w-full flex-1 rounded-lg border border-edge-subtle bg-white dark:border-edge dark:bg-[#1e1e1e]`,srcDoc:n,sandbox:`allow-scripts allow-popups allow-popups-to-escape-sandbox allow-downloads allow-forms allow-modals`})}):e.targetLine&&e.targetLine>0?(0,$.jsx)(wQ,{text:n,targetLine:e.targetLine}):t===`code`?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsx)(gQ,{content:`\`\`\`${CQ(e.descriptor.fileName)}\n${n}\n\`\`\``})}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-fg`,children:n})})}var EQ={id:`text`,readMode:`text`,capabilities:[`download`],render:e=>TQ(e,`text`)},DQ={id:`markdown`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>TQ(e,`markdown`)},OQ={id:`code`,readMode:`text`,capabilities:[`download`],render:e=>TQ(e,`code`)},kQ={id:`html`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>TQ(e,`html`)};function AQ(){return(0,$.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:`Loading preview...`})}function jQ(e,t,n,r=`binary`){let i=(0,Z.lazy)(n);return{id:e,readMode:r,capabilities:t,render:e=>(0,$.jsx)(Z.Suspense,{fallback:AQ(),children:(0,$.jsx)(i,{...e})})}}var MQ={text:EQ,markdown:DQ,code:OQ,html:kQ,image:jQ(`image`,[`download`,`zoom`,`rotate`],()=>c(()=>import(`./binary-plugins-DnJO0VG7.js`).then(e=>({default:e.InteractiveImagePreview})),__vite__mapDeps([85,1,20,2,86,87,7,4]))),pdf:jQ(`pdf`,[`download`,`zoom`,`rotate`,`pageNavigation`,`print`],()=>c(()=>import(`./binary-plugins-DnJO0VG7.js`).then(e=>({default:e.PdfPreviewPluginView})),__vite__mapDeps([85,1,20,2,86,87,7,4]))),docx:jQ(`docx`,[`download`],()=>c(()=>import(`./binary-plugins-DnJO0VG7.js`).then(e=>({default:e.DocxPreviewPluginView})),__vite__mapDeps([85,1,20,2,86,87,7,4]))),spreadsheet:jQ(`spreadsheet`,[`download`],()=>c(()=>import(`./binary-plugins-DnJO0VG7.js`).then(e=>({default:e.SpreadsheetPreviewPluginView})),__vite__mapDeps([85,1,20,2,86,87,7,4]))),pptx:jQ(`pptx`,[`download`],()=>c(()=>import(`./binary-plugins-DnJO0VG7.js`).then(e=>({default:e.PptxPreviewPluginView})),__vite__mapDeps([85,1,20,2,86,87,7,4]))),audio:jQ(`audio`,[`download`],()=>c(()=>import(`./media-plugins-o5fchHfb.js`).then(e=>({default:e.AudioPreviewPluginView})),__vite__mapDeps([88,1,2,86,87,7,4]))),video:jQ(`video`,[`download`],()=>c(()=>import(`./media-plugins-o5fchHfb.js`).then(e=>({default:e.VideoPreviewPluginView})),__vite__mapDeps([88,1,2,86,87,7,4]))),archive:jQ(`archive`,[`download`],()=>c(()=>import(`./archive-plugin-HuCFa2UL.js`).then(e=>({default:e.ArchivePreviewPluginView})),__vite__mapDeps([89,1,2,90,87,7,4]))),unsupported:jQ(`unsupported`,[`download`],()=>c(()=>import(`./media-plugins-o5fchHfb.js`).then(e=>({default:e.UnsupportedPreviewPluginView})),__vite__mapDeps([88,1,2,86,87,7,4])),`metadata`)};function NQ(e){return MQ[e]??MQ.unsupported}function PQ(e){let t=(0,Q.c)(81),{plugin:n,actions:r,controls:i,onZoomIn:a,onZoomOut:o,onZoomReset:s,onRotate:c,onSearchChange:l}=e,[u,d]=(0,Z.useState)(!1),f;t[0]===n.capabilities?f=t[1]:(f=n.capabilities.includes(`zoom`),t[0]=n.capabilities,t[1]=f);let p=f,m;t[2]===n.capabilities?m=t[3]:(m=n.capabilities.includes(`search`),t[2]=n.capabilities,t[3]=m);let h=m,g;t[4]===n.capabilities?g=t[5]:(g=n.capabilities.includes(`rotate`),t[4]=n.capabilities,t[5]=g);let _=g,v;t[6]!==i||t[7]!==n.capabilities?(v=n.capabilities.includes(`pageNavigation`)&&i.pageCount!=null&&i.pageCount>1,t[6]=i,t[7]=n.capabilities,t[8]=v):v=t[8];let y=v;if(!(p||h||_||y||r.canDownload))return null;let b;if(t[9]!==r||t[10]!==y||t[11]!==_||t[12]!==h||t[13]!==p||t[14]!==i||t[15]!==c||t[16]!==l||t[17]!==a||t[18]!==o||t[19]!==s){if(b=[],y){let e=i.page<=1,n;t[21]===i?n=t[22]:(n=()=>i.setPage(Math.max(1,i.page-1)),t[21]=i,t[22]=n);let r;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(cT,{className:`size-3.5`}),t[23]=r):r=t[23];let a;t[24]!==e||t[25]!==n?(a=(0,$.jsx)(LQ,{label:`Previous page`,disabled:e,onClick:n,children:r}),t[24]=e,t[25]=n,t[26]=a):a=t[26];let o;t[27]!==i.page||t[28]!==i.pageCount?(o=(0,$.jsxs)(`span`,{className:`min-w-16 px-1 text-center text-xs text-fg-muted`,children:[i.page,` / `,i.pageCount]}),t[27]=i.page,t[28]=i.pageCount,t[29]=o):o=t[29];let s=i.page>=(i.pageCount??1),c;t[30]===i?c=t[31]:(c=()=>i.setPage(Math.min(i.pageCount??i.page,i.page+1)),t[30]=i,t[31]=c);let l;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(sT,{className:`size-3.5`}),t[32]=l):l=t[32];let u;t[33]!==s||t[34]!==c?(u=(0,$.jsx)(LQ,{label:`Next page`,disabled:s,onClick:c,children:l}),t[33]=s,t[34]=c,t[35]=u):u=t[35];let d;t[36]!==u||t[37]!==a||t[38]!==o?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-edge-subtle bg-surface-base p-0.5 dark:border-edge`,children:[a,o,u]},`page`),t[36]=u,t[37]=a,t[38]=o,t[39]=d):d=t[39],b.push(d)}if(p){let e;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Gv,{className:`size-3.5`}),t[40]=e):e=t[40];let n;t[41]===o?n=t[42]:(n=(0,$.jsx)(LQ,{label:`Zoom out`,onClick:o,children:e}),t[41]=o,t[42]=n);let r;t[43]===i.zoom?r=t[44]:(r=Math.round(i.zoom*100),t[43]=i.zoom,t[44]=r);let c;t[45]!==s||t[46]!==r?(c=(0,$.jsxs)(`button`,{type:`button`,className:`min-w-14 rounded px-1.5 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:s,title:`Reset zoom`,children:[r,`%`]}),t[45]=s,t[46]=r,t[47]=c):c=t[47];let l;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ly,{className:`size-3.5`}),t[48]=l):l=t[48];let u;t[49]===a?u=t[50]:(u=(0,$.jsx)(LQ,{label:`Zoom in`,onClick:a,children:l}),t[49]=a,t[50]=u);let d;t[51]!==u||t[52]!==n||t[53]!==c?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-edge-subtle bg-surface-base p-0.5 dark:border-edge`,children:[n,c,u]},`zoom`),t[51]=u,t[52]=n,t[53]=c,t[54]=d):d=t[54],b.push(d)}if(_){let e;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(cx,{className:`size-3.5`}),t[55]=e):e=t[55];let n;t[56]===c?n=t[57]:(n=(0,$.jsx)(LQ,{label:`Rotate`,onClick:c,children:e}),t[56]=c,t[57]=n),b.push(n)}if(h){let e;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Qx,{className:`size-3.5`,"aria-hidden":!0}),t[58]=e):e=t[58];let n;t[59]===l?n=t[60]:(n=e=>l(e.target.value),t[59]=l,t[60]=n);let r;t[61]!==i.searchQuery||t[62]!==n?(r=(0,$.jsxs)(`label`,{className:`flex min-w-40 items-center gap-1 rounded-md border border-edge-subtle bg-surface-base px-2 py-1 text-xs text-fg-muted dark:border-edge`,children:[e,(0,$.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:i.searchQuery,onChange:n,placeholder:`Search`})]},`search`),t[61]=i.searchQuery,t[62]=n,t[63]=r):r=t[63],b.push(r)}if(r.canDownload){let e;t[64]===r?e=t[65]:(e=()=>void r.onDownload(),t[64]=r,t[65]=e);let n;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Bm,{className:`size-3.5`}),t[66]=n):n=t[66];let i;t[67]===e?i=t[68]:(i=(0,$.jsx)(LQ,{label:`Download`,onClick:e,children:n},`download`),t[67]=e,t[68]=i),b.push(i)}t[9]=r,t[10]=y,t[11]=_,t[12]=h,t[13]=p,t[14]=i,t[15]=c,t[16]=l,t[17]=a,t[18]=o,t[19]=s,t[20]=b}else b=t[20];let x=b.length>4,S;t[69]!==x||t[70]!==b?(S=x?b.slice(0,3):b,t[69]=x,t[70]=b,t[71]=S):S=t[71];let C=S,w;t[72]!==x||t[73]!==b?(w=x?b.slice(3):[],t[72]=x,t[73]=b,t[74]=w):w=t[74];let T=w,E;t[75]!==u||t[76]!==T?(E=T.length>0?(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 cursor-default bg-transparent`,"aria-hidden":!0,tabIndex:-1,onPointerDown:e=>{e.preventDefault(),d(!1)}}):null,(0,$.jsx)(LQ,{label:`More actions`,onClick:()=>d(IQ),children:(0,$.jsx)(sh,{className:`size-3.5`})}),u?(0,$.jsx)(`div`,{role:`menu`,className:`absolute right-0 top-full z-50 mt-1 flex min-w-52 flex-col gap-1 rounded-md border border-edge bg-surface-panel p-1 shadow-popover`,children:T.map(FQ)}):null]}):null,t[75]=u,t[76]=T,t[77]=E):E=t[77];let D;return t[78]!==E||t[79]!==C?(D=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center gap-1`,children:[C,E]}),t[78]=E,t[79]=C,t[80]=D):D=t[80],D}function FQ(e,t){return(0,$.jsx)(`div`,{className:`flex min-w-0 items-center justify-end`,children:e},t)}function IQ(e){return!e}function LQ(e){let t=(0,Q.c)(6),{label:n,disabled:r,onClick:i,children:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-40`),t[0]=o):o=t[0];let s;return t[1]!==a||t[2]!==r||t[3]!==n||t[4]!==i?(s=(0,$.jsx)(`button`,{type:`button`,className:o,title:n,"aria-label":n,disabled:r,onClick:i,children:a}),t[1]=a,t[2]=r,t[3]=n,t[4]=i,t[5]=s):s=t[5],s}function RQ(e){let t=(0,Q.c)(22),n;t[0]===e.type?n=t[1]:(n=NQ(e.type),t[0]=e.type,t[1]=n);let r=n,[i,a]=(0,Z.useState)(1),[o,s]=(0,Z.useState)(0),[c,l]=(0,Z.useState)(1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(``),m;t[2]===u?m=t[3]:(m=e=>{l(Math.max(1,Math.min(u??e,Math.floor(e))))},t[2]=u,t[3]=m);let h=m,g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{a(1),s(0),l(1),d(null),p(``)},t[4]=g):g=t[4];let _;t[5]!==e.id||t[6]!==e.type?(_=[e.id,e.type],t[5]=e.id,t[6]=e.type,t[7]=_):_=t[7],(0,Z.useEffect)(g,_);let v;t[8]!==c||t[9]!==u||t[10]!==o||t[11]!==f||t[12]!==h||t[13]!==i?(v={zoom:i,rotation:o,page:c,pageCount:u,searchQuery:f,setPageCount:d,setPage:h},t[8]=c,t[9]=u,t[10]=o,t[11]=f,t[12]=h,t[13]=i,t[14]=v):v=t[14];let y=v,b,x,S,C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>a(VQ),x=()=>a(BQ),S=()=>{a(1),s(0)},C=()=>s(zQ),t[15]=b,t[16]=x,t[17]=S,t[18]=C):(b=t[15],x=t[16],S=t[17],C=t[18]);let w;return t[19]!==y||t[20]!==r?(w={plugin:r,controls:y,onZoomIn:b,onZoomOut:x,onZoomReset:S,onRotate:C,onSearchChange:p},t[19]=y,t[20]=r,t[21]=w):w=t[21],w}function zQ(e){return(e+90)%360}function BQ(e){return Math.max(.25,Number((e-.15).toFixed(2)))}function VQ(e){return Math.min(4,Number((e+.15).toFixed(2)))}function HQ(e){let t=(0,Q.c)(9),{controller:n,actions:r}=e,i;return t[0]!==r||t[1]!==n.controls||t[2]!==n.onRotate||t[3]!==n.onSearchChange||t[4]!==n.onZoomIn||t[5]!==n.onZoomOut||t[6]!==n.onZoomReset||t[7]!==n.plugin?(i=(0,$.jsx)(PQ,{plugin:n.plugin,actions:r,controls:n.controls,onZoomIn:n.onZoomIn,onZoomOut:n.onZoomOut,onZoomReset:n.onZoomReset,onRotate:n.onRotate,onSearchChange:n.onSearchChange}),t[0]=r,t[1]=n.controls,t[2]=n.onRotate,t[3]=n.onSearchChange,t[4]=n.onZoomIn,t[5]=n.onZoomOut,t[6]=n.onZoomReset,t[7]=n.plugin,t[8]=i):i=t[8],i}function UQ(e){let t=(0,Q.c)(23),n;t[0]===e.language?n=t[1]:(n=m(e.language),t[0]=e.language,t[1]=n);let r=n,i=RQ(e.descriptor),a=e.controller??i,o;t[2]!==a||t[3]!==e.actions?(o=(0,$.jsx)(HQ,{controller:a,actions:e.actions}),t[2]=a,t[3]=e.actions,t[4]=o):o=t[4];let s=o;if(e.loading){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-4 py-6`,"aria-busy":`true`,children:[(0,$.jsx)(uI,{className:`h-5 w-48 max-w-full`}),(0,$.jsx)(uI,{className:`h-4 w-full`}),(0,$.jsx)(uI,{className:`h-4 w-11/12`}),(0,$.jsx)(uI,{className:`h-4 w-3/4`}),(0,$.jsx)(uI,{className:`mt-3 min-h-48 flex-1 rounded-lg`})]}),t[5]=e):e=t[5],e}if(e.loadError){let n=(e.descriptor.context===`workspace`?r.workspace.loadError:r.chat.attachmentPreviewLoadError)+`: `+e.loadError,i;return t[6]===n?i=t[7]:(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:n})}),t[6]=n,t[7]=i),i}if(e.descriptor.context===`attachment`&&e.showExtractedText&&e.descriptor.type!==`image`){let n=e.extractedText||r.chat.attachmentPreviewNoText,i;return t[8]===n?i=t[9]:(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-hover/40 p-4 dark:border-edge`,children:(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg-muted`,children:n})})}),t[8]=n,t[9]=i),i}let c;t[10]!==e.renderToolbar||t[11]!==s?(c=e.renderToolbar?e.renderToolbar(s):s,t[10]=e.renderToolbar,t[11]=s,t[12]=c):c=t[12];let l=`${e.descriptor.id}:${a.plugin.id}`,u;t[13]!==a.controls||t[14]!==e?(u={...e,controls:a.controls},t[13]=a.controls,t[14]=e,t[15]=u):u=t[15];let d;t[16]!==a.plugin.render||t[17]!==l||t[18]!==u?(d=(0,$.jsx)(WQ,{pluginRender:a.plugin.render,props:u},l),t[16]=a.plugin.render,t[17]=l,t[18]=u,t[19]=d):d=t[19];let f;return t[20]!==c||t[21]!==d?(f=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[c,d]}),t[20]=c,t[21]=d,t[22]=f):f=t[22],f}function WQ(e){let t=(0,Q.c)(5),{pluginRender:n,props:r}=e,i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),t[3]=i,t[4]=a),a}function GQ(e){return e.id?String(e.id):`${e.name}:${e.uri??``}`}function KQ(){return{id:`__empty__`,context:`attachment`,fileName:``,mimeType:`application/octet-stream`,type:`unsupported`,source:{kind:`inline`}}}function qQ(e){let t=(0,Q.c)(63),{open:n,attachment:r,authToken:i,sessionKey:a,language:o}=e,[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),p;t[0]!==r||t[1]!==n?(p=n&&r?GQ(r):null,t[0]=r,t[1]=n,t[2]=p):p=t[2];let h=p,g=(0,Z.useRef)(h);h!==g.current&&(g.current=h,c(n&&r?r:null),u(!1),f(!1));let _=s,v;bb0:{if(!_){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=KQ(),t[3]=e):e=t[3],v=e;break bb0}let e=_.name??`attachment`,n,r;t[4]!==e||t[5]!==_.mimeType?(n=$q(e,_.mimeType),r=eJ(e,n),t[4]=e,t[5]=_.mimeType,t[6]=n,t[7]=r):(n=t[6],r=t[7]);let i=r,o=_.id?String(_.id):`${e}:${_.uri??``}`,s;t[8]!==_.uri||t[9]!==a?(s=_.uri?{kind:`media-uri`,uri:_.uri,sessionKey:a}:{kind:`inline`},t[8]=_.uri,t[9]=a,t[10]=s):s=t[10];let c;t[11]!==e||t[12]!==n||t[13]!==_.size||t[14]!==o||t[15]!==s||t[16]!==i?(c={id:o,context:`attachment`,fileName:e,mimeType:n,size:_.size,type:i,source:s},t[11]=e,t[12]=n,t[13]=_.size,t[14]=o,t[15]=s,t[16]=i,t[17]=c):c=t[17],v=c}let y=v,b;t[18]===_?b=t[19]:(b=_?FI(_):void 0,t[18]=_,t[19]=b);let x=b,S=_?.uri,C;t[20]===y.type?C=t[21]:(C=tJ(y.type),t[20]=y.type,t[21]=C);let w=C,T=!!(n&&S&&!x&&i&&w===`binary`),E;t[22]!==o||t[23]!==S||t[24]!==a?(E=async()=>{let e=m(o).chat,t=await rJ({uri:S,sessionKey:a});if(!t.ok)throw t.reason===`http`?Error(`${e.attachmentPreviewLoadError} (HTTP ${t.status})`):Error(t.message);return t.buffer},t[22]=o,t[23]=S,t[24]=a,t[25]=E):E=t[25];let D;t[26]!==i||t[27]!==x||t[28]!==o||t[29]!==S||t[30]!==n||t[31]!==w||t[32]!==a?(D=[n,S,i,o,x,a,w],t[26]=i,t[27]=x,t[28]=o,t[29]=S,t[30]=n,t[31]=w,t[32]=a,t[33]=D):D=t[33];let O;t[34]===T?O=t[35]:(O={enabled:T,initial:null,errorData:null},t[34]=T,t[35]=O);let k=lP(E,D,O),A;bb1:{if(w!==`binary`){A=null;break bb1}if(x)try{let e;t[36]===x?e=t[37]:(e=VI(x),t[36]=x,t[37]=e),A=e;break bb1}catch{A=null;break bb1}if(T&&k.loading){A=null;break bb1}A=k.data??null}let j=A,M;t[38]===_?M=t[39]:(M=_?RI(_)??``:``,t[38]=_,t[39]=M);let N=M,P;t[40]!==N||t[41]!==o||t[42]!==w?(P=w===`text`?N||m(o).chat.attachmentPreviewNoText:null,t[40]=N,t[41]=o,t[42]=w,t[43]=P):P=t[43];let F=P,I=!!_?.extractedText,L=y.type===`pptx`&&N.length>3e5,R;t[44]!==i||t[45]!==x||t[46]!==o||t[47]!==S||t[48]!==n||t[49]!==w?(R=n&&S&&!x&&!i&&w===`binary`?m(o).chat.attachmentPreviewMissingAuth:null,t[44]=i,t[45]=x,t[46]=o,t[47]=S,t[48]=n,t[49]=w,t[50]=R):R=t[50];let z=R,B=k.error?k.error instanceof Error?k.error.message:String(k.error):null,V=d?null:z??B,H=T?k.loading:!1,U;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>f(!0),t[51]=U):U=t[51];let W=N||null,G;return t[52]!==j||t[53]!==y||t[54]!==L||t[55]!==I||t[56]!==V||t[57]!==_||t[58]!==l||t[59]!==H||t[60]!==W||t[61]!==F?(G={preview:_,descriptor:y,fileType:y.type,fileName:y.fileName,loading:H,loadError:V,clearLoadError:U,textContent:F,binaryBuffer:j,hasExtractedText:I,extractedText:W,extractedTextTruncated:L,showExtractedText:l,setShowExtractedText:u},t[52]=j,t[53]=y,t[54]=L,t[55]=I,t[56]=V,t[57]=_,t[58]=l,t[59]=H,t[60]=W,t[61]=F,t[62]=G):G=t[62],G}function JQ(e,t,n,r){var i=this,a=(0,Z.useRef)(null),o=(0,Z.useRef)(0),s=(0,Z.useRef)(0),c=(0,Z.useRef)(null),l=(0,Z.useRef)([]),u=(0,Z.useRef)(),d=(0,Z.useRef)(),f=(0,Z.useRef)(e),p=(0,Z.useRef)(!0),m=(0,Z.useRef)(),h=(0,Z.useRef)();f.current=e;var g=typeof window<`u`,_=!t&&t!==0&&g;if(typeof e!=`function`)throw TypeError(`Expected a function`);t=+t||0;var v=!!(n||={}).leading,y=!(`trailing`in n)||!!n.trailing,b=!!n.flushOnExit&&y,x=`maxWait`in n,S=`debounceOnServer`in n&&!!n.debounceOnServer,C=x?Math.max(+n.maxWait||0,t):null,w=(0,Z.useMemo)(function(){var e=function(e){var t=l.current,n=u.current;return l.current=u.current=null,o.current=e,s.current=s.current||e,d.current=f.current.apply(n,t)},n=function(e,t){_&&cancelAnimationFrame(c.current),c.current=_?requestAnimationFrame(e):setTimeout(e,t)},w=function(e){if(!p.current)return!1;var n=e-a.current;return!a.current||n>=t||n<0||x&&e-o.current>=C},T=function(t){return c.current=null,y&&l.current?e(t):(l.current=u.current=null,d.current)},E=function e(){var r=Date.now();if(v&&s.current===o.current&&D(),w(r))return T(r);if(p.current){var i=t-(r-a.current);n(e,x?Math.min(i,C-(r-o.current)):i)}},D=function(){r&&r({})},O=function(){if(g||S){var r,s=Date.now(),f=w(s);if(l.current=[].slice.call(arguments),u.current=i,a.current=s,b&&!m.current&&(m.current=function(){globalThis.document?.visibilityState===`hidden`&&h.current.flush()},(r=globalThis.document)==null||r.addEventListener==null||r.addEventListener(`visibilitychange`,m.current)),f){if(!c.current&&p.current)return o.current=a.current,n(E,t),v?e(a.current):d.current;if(x)return n(E,t),e(a.current)}return c.current||n(E,t),d.current}};return O.cancel=function(){var e=c.current;e&&(_?cancelAnimationFrame(c.current):clearTimeout(c.current)),o.current=0,l.current=a.current=u.current=c.current=null,e&&r&&r({})},O.isPending=function(){return!!c.current},O.flush=function(){return c.current?T(Date.now()):d.current},O},[v,x,t,C,y,b,_,g,S,r]);return h.current=w,(0,Z.useEffect)(function(){return p.current=!0,function(){var e;b&&h.current.flush(),m.current&&=((e=globalThis.document)==null||e.removeEventListener==null||e.removeEventListener(`visibilitychange`,m.current),null),p.current=!1}},[b]),w}function YQ(e,t){return e===t}function XQ(e,t,n){var r=n&&n.equalityFn||YQ,i=(0,Z.useRef)(e),a=(0,Z.useState)({})[1],o=JQ((0,Z.useCallback)(function(e){i.current=e,a({})},[a]),t,n,a),s=(0,Z.useRef)(e);return r(s.current,e)||(o(e),s.current=e),[i.current,o]}function ZQ(e){let t=(0,Q.c)(12),{projectId:n,sessionKey:r,agentId:i}=e,a;bb0:{let e;t[0]===n?e=t[1]:(e=n?.trim(),t[0]=n,t[1]=e);let o=e;if(o){let e;t[2]===o?e=t[3]:(e={projectId:o},t[2]=o,t[3]=e),a=e;break bb0}let s;t[4]===r?s=t[5]:(s=r?.trim(),t[4]=r,t[5]=s);let c=s;if(c){let e;t[6]===c?e=t[7]:(e={sessionKey:c},t[6]=c,t[7]=e),a=e;break bb0}let l;t[8]===i?l=t[9]:(l=i?.trim(),t[8]=i,t[9]=l);let u=l,d;t[10]===u?d=t[11]:(d=u?{agentId:u}:void 0,t[10]=u,t[11]=d),a=d}return a}function QQ(e){return{descriptor:e,textContent:null,binaryBuffer:null,hostAbsolutePath:null,mtimeMs:null,loadError:null,loading:!1,pptxText:null,pptxTruncated:!1,pptxError:null}}function $Q(e,t){switch(t.type){case`clear`:return QQ(t.descriptor);case`loadStart`:return{...QQ(t.descriptor),loading:!0};case`loadSuccess`:return{...e,descriptor:t.payload.descriptor,textContent:t.payload.textContent??null,binaryBuffer:t.payload.binaryBuffer??null,hostAbsolutePath:t.payload.hostAbsolutePath??null,mtimeMs:t.payload.mtimeMs??null,loadError:null,loading:!1};case`loadError`:return{...QQ(t.descriptor),loadError:t.error};case`patchMtime`:return{...e,mtimeMs:t.mtimeMs};case`patchText`:return{...e,textContent:t.text};case`pptxClear`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:null};case`pptxSuccess`:return{...e,pptxText:t.text,pptxTruncated:t.truncated,pptxError:null};case`pptxError`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:t.error}}}function e$(e,t){switch(t.type){case`reset`:return{markdownEditMode:!1,htmlCodeMode:!1,saveStatus:`idle`};case`markdown`:return{...e,markdownEditMode:typeof t.value==`function`?t.value(e.markdownEditMode):t.value};case`html`:return{...e,htmlCodeMode:typeof t.value==`function`?t.value(e.htmlCodeMode):t.value};case`saveStatus`:return{...e,saveStatus:t.value}}}function t$({filePath:e,projectId:t,sessionKey:n,agentId:r}){let i=ZQ({projectId:t,sessionKey:n,agentId:r}),a=(0,Z.useMemo)(()=>{let t=e?Qq(e):``,i=$q(t,UI(t)),a=e?eJ(t,i):`unsupported`;return{id:e||`__empty__`,context:`workspace`,fileName:t,mimeType:i,type:a,source:{kind:`workspace`,path:e||``,sessionKey:n,agentId:r}}},[r,e,n]),[o,s]=(0,Z.useReducer)($Q,a,QQ),[l,u]=(0,Z.useReducer)(e$,{markdownEditMode:!1,htmlCodeMode:!1,saveStatus:`idle`}),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)([]),h=(0,Z.useRef)(void 0),g=(0,Z.useRef)(e);g.current!==e&&(g.current=e,u({type:`reset`})),(0,Z.useEffect)(()=>{if(!e){s({type:`clear`,descriptor:a});return}let t=!1;s({type:`loadStart`,descriptor:a});let n=tJ(a.type),r=e=>{t||s({type:`loadError`,descriptor:a,error:e instanceof Error?e.message:String(e)})};return n===`metadata`?(Fq(e,i).then(e=>{t||s({type:`loadSuccess`,payload:{descriptor:a,hostAbsolutePath:e?.absolutePath??null,mtimeMs:typeof e?.mtimeMs==`number`?e.mtimeMs:null}})}).catch(r),()=>{t=!0}):(n===`text`?Pq(e,i).then(({content:e,mtimeMs:n,absolutePath:r})=>{t||s({type:`loadSuccess`,payload:{descriptor:a,textContent:e,hostAbsolutePath:r??null,mtimeMs:typeof n==`number`?n:null}})}).catch(r):Promise.all([Lq(e,i),Fq(e,i).catch(()=>null)]).then(async([e,n])=>{let r=await e.arrayBuffer();t||s({type:`loadSuccess`,payload:{descriptor:a,binaryBuffer:r,hostAbsolutePath:n?.absolutePath??null,mtimeMs:typeof n?.mtimeMs==`number`?n.mtimeMs:null}})}).catch(r),()=>{t=!0})},[a,e,i]),(0,Z.useEffect)(()=>{if(!o.binaryBuffer||o.descriptor.type!==`pptx`){s({type:`pptxClear`});return}let e=!1;return s({type:`pptxClear`}),c(()=>import(`./attachment-process-heavy-RnGYy9bC.js`).then(e=>e.processPptx(o.binaryBuffer,o.descriptor.fileName)),__vite__mapDeps([91,1,20,92])).then(({extractedText:t})=>{if(e)return;let n=t.length>NI;s({type:`pptxSuccess`,text:n?t.slice(0,NI):t,truncated:n})}).catch(t=>{e||s({type:`pptxError`,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},[o.binaryBuffer,o.descriptor.fileName,o.descriptor.type]);let _=(0,Z.useCallback)(async t=>{if(e){h.current!==void 0&&clearTimeout(h.current),u({type:`saveStatus`,value:`saving`});try{let{mtimeMs:n}=await zq(e,t,i);typeof n==`number`&&s({type:`patchMtime`,mtimeMs:n}),u({type:`saveStatus`,value:`saved`}),h.current=setTimeout(()=>u({type:`saveStatus`,value:`idle`}),2e3)}catch{u({type:`saveStatus`,value:`idle`})}}},[e,i]),v=JQ(e=>void _(e),500),y=(0,Z.useCallback)(e=>{s({type:`patchText`,text:e}),v(e)},[v]),b=(0,Z.useCallback)(async()=>{if(!e)return;let t=Qq(e);if(o.binaryBuffer){Vq(t,o.binaryBuffer,o.descriptor.mimeType||`application/octet-stream`);return}if(o.textContent!=null){Bq(t,o.textContent);return}let n=await Lq(e,i);Vq(t,await n.arrayBuffer(),o.descriptor.mimeType||n.type||`application/octet-stream`)},[e,o.binaryBuffer,o.descriptor.mimeType,o.textContent,i]),x=!o.loading&&!!e,S=fM()&&!!o.hostAbsolutePath&&!!window.electronAPI?.shell?.openPath,C=fM()&&!!o.hostAbsolutePath&&!!window.electronAPI?.shell?.chooseAppAndOpenPath,w=(0,Z.useCallback)(async()=>{let e=o.hostAbsolutePath;if(!fM()||!e||!window.electronAPI?.shell){m([]),f([]);return}try{if(window.electronAPI.shell.getOpenWithAppsForPath){let t=await window.electronAPI.shell.getOpenWithAppsForPath(e);m(t.recommended.map(e=>({name:e.name,path:e.path}))),f(t.recent.map(e=>({name:e.name,path:e.path,lastUsedAt:e.lastUsedAt})))}}catch{m([]),f([])}},[o.hostAbsolutePath]);(0,Z.useEffect)(()=>{w()},[w]);let T=(0,Z.useCallback)(async()=>{let e=o.hostAbsolutePath;e&&window.electronAPI?.shell?.openPath&&await window.electronAPI.shell.openPath(e)},[o.hostAbsolutePath]),E=(0,Z.useCallback)(async()=>{let e=o.hostAbsolutePath;!e||!window.electronAPI?.shell?.chooseAppAndOpenPath||(await window.electronAPI.shell.chooseAppAndOpenPath(e)).ok&&w()},[o.hostAbsolutePath,w]),D=(0,Z.useCallback)(async e=>{let t=o.hostAbsolutePath;!t||!e||!window.electronAPI?.shell?.openPathWithApp||(await window.electronAPI.shell.openPathWithApp(t,e)).ok&&w()},[o.hostAbsolutePath,w]),O=fM()&&!!o.hostAbsolutePath&&!!window.electronAPI?.shell?.showItemInFolder,k=(0,Z.useCallback)(async()=>{let e=o.hostAbsolutePath;e&&window.electronAPI?.shell?.showItemInFolder&&await window.electronAPI.shell.showItemInFolder(e)},[o.hostAbsolutePath]);return{...o,extractedText:o.descriptor.type===`pptx`?o.pptxText:null,extractedTextTruncated:o.pptxTruncated,markdownEditMode:l.markdownEditMode,setMarkdownEditMode:e=>u({type:`markdown`,value:e}),htmlCodeMode:l.htmlCodeMode,setHtmlCodeMode:e=>u({type:`html`,value:e}),saveStatus:l.saveStatus,onSaveMarkdown:_,onHtmlChange:y,onDownload:b,canDownload:x,canOpenWithSystemApp:S,onOpenWithSystemApp:T,canChooseOpenWithApp:C,onChooseOpenWithApp:E,recommendedOpenWithApps:p,recentOpenWithApps:d,onOpenWithRecentApp:D,canRevealInFolder:O,onRevealInFolder:k}}var n$=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),r$=`VisuallyHidden`,i$=Z.forwardRef((e,t)=>(0,$.jsx)(k.span,{...e,ref:t,style:{...n$,...e.style}}));i$.displayName=r$;var a$=i$,[o$,Lse]=T(`Tooltip`,[H]),s$=H(),c$=`TooltipProvider`,l$=700,u$=`tooltip.open`,[d$,f$]=o$(c$),p$=e=>{let{__scopeTooltip:t,delayDuration:n=l$,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=Z.useRef(!0),s=Z.useRef(!1),c=Z.useRef(0);return Z.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,$.jsx)(d$,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:Z.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:Z.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:Z.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};p$.displayName=c$;var m$=`Tooltip`,[h$,g$]=o$(m$),_$=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=f$(m$,e.__scopeTooltip),l=s$(t),[u,d]=Z.useState(null),f=I(),p=Z.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=Z.useRef(!1),[_,v]=R({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(u$))):c.onClose(),a?.(e)},caller:m$}),y=Z.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return Z.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,$.jsx)(U,{...l,children:(0,$.jsx)(h$,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:Z.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:Z.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};_$.displayName=m$;var v$=`TooltipTrigger`,y$=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=g$(v$,n),a=f$(v$,n),o=s$(n),s=d(t,Z.useRef(null),i.onTriggerChange),c=Z.useRef(!1),l=Z.useRef(!1),u=Z.useCallback(()=>c.current=!1,[]);return Z.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,$.jsx)(K,{asChild:!0,...o,children:(0,$.jsx)(k.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:V(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:V(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:V(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:V(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:V(e.onBlur,i.onClose),onClick:V(e.onClick,i.onClose)})})});y$.displayName=v$;var b$=`TooltipPortal`,[x$,S$]=o$(b$,{forceMount:void 0}),C$=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=g$(b$,t);return(0,$.jsx)(x$,{scope:t,forceMount:n,children:(0,$.jsx)(M,{present:n||a.open,children:(0,$.jsx)(E,{asChild:!0,container:i,children:r})})})};C$.displayName=b$;var w$=`TooltipContent`,T$=Z.forwardRef((e,t)=>{let n=S$(w$,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=g$(w$,e.__scopeTooltip);return(0,$.jsx)(M,{present:r||o.open,children:o.disableHoverableContent?(0,$.jsx)(A$,{side:i,...a,ref:t}):(0,$.jsx)(E$,{side:i,...a,ref:t})})}),E$=Z.forwardRef((e,t)=>{let n=g$(w$,e.__scopeTooltip),r=f$(w$,e.__scopeTooltip),i=Z.useRef(null),a=d(t,i),[o,s]=Z.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:f}=r,p=Z.useCallback(()=>{s(null),f(!1)},[f]),m=Z.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=P$(r,N$(r,n.getBoundingClientRect())),a=F$(t.getBoundingClientRect());s(L$([...i,...a])),f(!0)},[f]);return Z.useEffect(()=>()=>p(),[p]),Z.useEffect(()=>{if(c&&u){let e=e=>m(e,u),t=e=>m(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,m,p]),Z.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!I$(n,o);r?p():i&&(p(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,p]),(0,$.jsx)(A$,{...e,ref:a})}),[D$,O$]=o$(m$,{isInside:!1}),k$=j(`TooltipContent`),A$=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=g$(w$,n),l=s$(n),{onClose:u}=c;return Z.useEffect(()=>(document.addEventListener(u$,u),()=>document.removeEventListener(u$,u)),[u]),Z.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,$.jsx)(B,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,$.jsxs)(G,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,$.jsx)(k$,{children:r}),(0,$.jsx)(D$,{scope:n,isInside:!0,children:(0,$.jsx)(a$,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});T$.displayName=w$;var j$=`TooltipArrow`,M$=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=s$(n);return O$(j$,n).isInside?null:(0,$.jsx)(W,{...i,...r,ref:t})});M$.displayName=j$;function N$(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function P$(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function F$(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function I$(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function L$(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),R$(t)}function R$(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var z$=p$,B$=_$,V$=y$,H$=C$,U$=T$,W$=M$,G$=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-snug text-fg shadow-lg`,K$=`block w-full min-w-0 truncate rounded border border-transparent bg-surface-hover px-2 py-1.5 font-mono text-xs text-fg focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`,q$=`inline-flex w-[5.25rem] shrink-0 items-center justify-center gap-1 px-2 py-1 text-xs`;function J$(e){let t=(0,Q.c)(38),{label:n,text:r,compact:i,labels:a,monospace:o}=e,s=o===void 0?!0:o,c=(0,Z.useRef)(null),[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m;t[0]===r?m=t[1]:(m=async()=>{if(p(!1),await mA(r)){d(!0),window.setTimeout(()=>d(!1),2e3);return}hA(c.current),p(!0),window.setTimeout(()=>p(!1),2500)},t[0]=r,t[1]=m);let h=m,g=i&&`gap-0.5`,_;t[2]===g?_=t[3]:(_=u(`flex min-w-0 flex-col gap-1`,g),t[2]=g,t[3]=_);let v;t[4]===n?v=t[5]:(v=n?(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}):null,t[4]=n,t[5]=v);let y=n??a.copy,b=!s&&`font-sans`,x;t[6]===b?x=t[7]:(x=u(K$,b),t[6]=b,t[7]=x);let S;t[8]!==y||t[9]!==x||t[10]!==r?(S=(0,$.jsx)(V$,{asChild:!0,children:(0,$.jsx)(`input`,{ref:c,readOnly:!0,type:`text`,value:r,"aria-label":y,className:x,onFocus:Y$})}),t[8]=y,t[9]=x,t[10]=r,t[11]=S):S=t[11];let C;t[12]===r?C=t[13]:(C=(0,$.jsx)(H$,{children:(0,$.jsx)(U$,{side:`top`,sideOffset:6,collisionPadding:12,className:G$,children:(0,$.jsx)(`span`,{className:`break-all`,children:r})})}),t[12]=r,t[13]=C);let w;t[14]!==C||t[15]!==S?(w=(0,$.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,$.jsxs)(B$,{children:[S,C]})}),t[14]=C,t[15]=S,t[16]=w):w=t[16];let T;t[17]===h?T=t[18]:(T=()=>void h(),t[17]=h,t[18]=T);let E;t[19]===l?E=t[20]:(E=l?(0,$.jsx)(Iu,{className:`size-3.5 shrink-0`}):(0,$.jsx)(Fp,{className:`size-3.5 shrink-0`}),t[19]=l,t[20]=E);let D=l?a.copied:a.copy,O;t[21]===D?O=t[22]:(O=(0,$.jsx)(`span`,{className:`truncate`,children:D}),t[21]=D,t[22]=O);let k;t[23]!==T||t[24]!==E||t[25]!==O?(k=(0,$.jsxs)(tA,{type:`button`,variant:`secondary`,className:q$,onClick:T,children:[E,O]}),t[23]=T,t[24]=E,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==w||t[28]!==k?(A=(0,$.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_5.25rem] items-center gap-2`,children:[w,k]}),t[27]=w,t[28]=k,t[29]=A):A=t[29];let j;t[30]!==f||t[31]!==a.copyFailed?(j=f?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:a.copyFailed}):null,t[30]=f,t[31]=a.copyFailed,t[32]=j):j=t[32];let M;return t[33]!==A||t[34]!==j||t[35]!==_||t[36]!==v?(M=(0,$.jsx)(z$,{delayDuration:300,children:(0,$.jsxs)(`div`,{className:_,children:[v,A,j]})}),t[33]=A,t[34]=j,t[35]=_,t[36]=v,t[37]=M):M=t[37],M}function Y$(e){return e.currentTarget.select()}function X$(e){let t=(0,Q.c)(12),{rows:n,compact:r,labels:i}=e,a=r&&`gap-1.5`,o;t[0]===a?o=t[1]:(o=u(`flex min-w-0 flex-col gap-2`,a),t[0]=a,t[1]=o);let s;if(t[2]!==r||t[3]!==i||t[4]!==n){let e;t[6]!==r||t[7]!==i?(e=e=>(0,$.jsx)(J$,{label:e.label,text:e.text,compact:r,labels:i},e.key),t[6]=r,t[7]=i,t[8]=e):e=t[8],s=n.map(e),t[2]=r,t[3]=i,t[4]=n,t[5]=s}else s=t[5];let c;return t[9]!==o||t[10]!==s?(c=(0,$.jsx)(`div`,{className:o,children:s}),t[9]=o,t[10]=s,t[11]=c):c=t[11],c}var Z$=new Intl.DateTimeFormat(`zh-CN`,{dateStyle:`medium`,timeStyle:`short`}),Q$=new Intl.DateTimeFormat(`en`,{dateStyle:`medium`,timeStyle:`short`});function $$(e,t,n,r){if(n===`public`){let n=[{key:`public`,label:r.publicUrlLabel,url:e}];return t&&n.push({key:`lan`,label:r.lanUrlLabel,url:t}),n}return n===`lan`?[{key:`lan`,label:r.lanUrlLabel,url:e}]:[{key:`local`,label:r.localUrlLabel,url:e}]}function e1(e){let t=(0,Q.c)(17),{shareUrl:n,lanUrl:r,reachability:i,compact:a}=e,o=_(n1),s;t[0]===o?s=t[1]:(s=m(o),t[0]=o,t[1]=s);let c=s.sharesSettings,l=r??null,u;t[2]!==i||t[3]!==n||t[4]!==c||t[5]!==l?(u=$$(n,l,i,c),t[2]=i,t[3]=n,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d=u,f;t[7]!==c.copied||t[8]!==c.copy||t[9]!==c.copyFailed?(f={copy:c.copy,copied:c.copied,copyFailed:c.copyFailed},t[7]=c.copied,t[8]=c.copy,t[9]=c.copyFailed,t[10]=f):f=t[10];let p=f,h;t[11]===d?h=t[12]:(h=d.map(t1),t[11]=d,t[12]=h);let g;return t[13]!==a||t[14]!==p||t[15]!==h?(g=(0,$.jsx)(X$,{rows:h,compact:a,labels:p}),t[13]=a,t[14]=p,t[15]=h,t[16]=g):g=t[16],g}function t1(e){return{key:e.key,label:e.label,text:e.url}}function n1(e){return e.language}function r1(e,t){return(t===`zh`?Z$:Q$).format(new Date(e))}function i1(e){let t=(0,Q.c)(23),{reachability:n,reachabilityHint:r}=e,i=_(a1),a;t[0]===i?a=t[1]:(a=m(i),t[0]=i,t[1]=a);let o=a.sharesSettings;if(n===`public`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ov,{className:`size-3`}),t[2]=e):e=t[2];let n;return t[3]===o.reachPublic?n=t[4]:(n=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400`,children:[e,o.reachPublic]}),t[3]=o.reachPublic,t[4]=n),n}if(n===`lan`){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(dk,{className:`size-3`}),t[5]=e):e=t[5];let n;t[6]===r?n=t[7]:(n=r?(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[` — `,r]}):null,t[6]=r,t[7]=n);let i;return t[8]!==o.reachLan||t[9]!==n?(i=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400`,children:[e,o.reachLan,n]}),t[8]=o.reachLan,t[9]=n,t[10]=i):i=t[10],i}let s;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(lk,{className:`size-3`}),t[11]=s):s=t[11];let c;t[12]===o.reachLocal?c=t[13]:(c=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-subtle`,children:[s,o.reachLocal]}),t[12]=o.reachLocal,t[13]=c);let l=r??o.reachLocalHint,u;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(gh,{className:`size-3`}),t[14]=u):u=t[14];let d;t[15]===o.openTunnel?d=t[16]:(d=(0,$.jsxs)(Hi,{to:`/settings/remote-access?tab=public`,className:`inline-flex items-center gap-0.5 text-accent hover:underline`,children:[o.openTunnel,u]}),t[15]=o.openTunnel,t[16]=d);let f;t[17]!==l||t[18]!==d?(f=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-muted`,children:[l,` `,d]}),t[17]=l,t[18]=d,t[19]=f):f=t[19];let p;return t[20]!==c||t[21]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,f]}),t[20]=c,t[21]=f,t[22]=p):p=t[22],p}function a1(e){return e.language}function o1(e){let t=(0,Q.c)(24),{result:n}=e,r=_(s1),i;t[0]===r?i=t[1]:(i=m(r),t[0]=r,t[1]=i);let a=i.sharesSettings,o;t[2]===n.fileName?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.fileName}),t[2]=n.fileName,t[3]=o);let s=a.expiresLabel,c;t[4]!==r||t[5]!==n.expiresAt?(c=r1(n.expiresAt,r),t[4]=r,t[5]=n.expiresAt,t[6]=c):c=t[6];let l;t[7]!==a.expiresLabel||t[8]!==c?(l=(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s,`: `,c]}),t[7]=a.expiresLabel,t[8]=c,t[9]=l):l=t[9];let u;t[10]!==o||t[11]!==l?(u=(0,$.jsxs)(`div`,{children:[o,l]}),t[10]=o,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.lanUrl||t[14]!==n.reachability||t[15]!==n.shareUrl?(d=(0,$.jsx)(e1,{shareUrl:n.shareUrl,lanUrl:n.lanUrl,reachability:n.reachability}),t[13]=n.lanUrl,t[14]=n.reachability,t[15]=n.shareUrl,t[16]=d):d=t[16];let f;t[17]!==n.reachability||t[18]!==n.reachabilityHint?(f=(0,$.jsx)(i1,{reachability:n.reachability,reachabilityHint:n.reachabilityHint}),t[17]=n.reachability,t[18]=n.reachabilityHint,t[19]=f):f=t[19];let p;return t[20]!==u||t[21]!==d||t[22]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[u,d,f]}),t[20]=u,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function s1(e){return e.language}function c1(e){let t=(0,Q.c)(26),{open:n,onOpenChange:r,loading:i,error:a,result:o}=e,s=_(l1),c;t[0]===s?c=t[1]:(c=m(s),t[0]=s,t[1]=c);let l=c.sharesSettings,d;t[2]===s?d=t[3]:(d=m(s),t[2]=s,t[3]=d);let f=d,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(RN,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[4]=p):p=t[4];let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=u(`fixed left-1/2 top-1/2 z-[71] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`overflow-hidden rounded-lg border border-edge bg-surface-panel p-4 shadow-popover outline-none`),t[5]=h):h=t[5];let g;t[6]===l.shareCreated?g=t[7]:(g=(0,$.jsx)(BN,{className:`text-base font-semibold text-fg`,children:l.shareCreated}),t[6]=l.shareCreated,t[7]=g);let v;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Sk,{className:`size-4`}),t[8]=v):v=t[8];let y;t[9]===l.cancel?y=t[10]:(y=(0,$.jsx)(HN,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,children:v})}),t[9]=l.cancel,t[10]=y);let b;t[11]!==g||t[12]!==y?(b=(0,$.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[g,y]}),t[11]=g,t[12]=y,t[13]=b):b=t[13];let x;t[14]!==a||t[15]!==i||t[16]!==f||t[17]!==o?(x=i?(0,$.jsxs)(`p`,{className:`flex items-center gap-2 py-4 text-sm text-fg-muted`,children:[(0,$.jsx)(Fv,{className:`size-4 animate-spin`}),f.workspace.sharing]}):a?(0,$.jsx)(`p`,{className:`py-2 text-sm text-red-600 dark:text-red-400`,children:a}):o?(0,$.jsx)(o1,{result:o}):null,t[14]=a,t[15]=i,t[16]=f,t[17]=o,t[18]=x):x=t[18];let S;t[19]!==b||t[20]!==x?(S=(0,$.jsxs)(LN,{children:[p,(0,$.jsxs)(zN,{className:h,children:[b,x]})]}),t[19]=b,t[20]=x,t[21]=S):S=t[21];let C;return t[22]!==r||t[23]!==n||t[24]!==S?(C=(0,$.jsx)(FN,{open:n,onOpenChange:r,children:S}),t[22]=r,t[23]=n,t[24]=S,t[25]=C):C=t[25],C}function l1(e){return e.language}async function u1(){return J(X(`/api/shares`))}async function d1(e){return J(X(`/api/shares`),{method:`POST`,body:JSON.stringify(e)})}async function f1(e){return J(X(`/api/shares/${e}`),{method:`DELETE`})}async function p1(){return J(X(`/api/shares`),{method:`DELETE`,body:JSON.stringify({expired:!0})})}async function m1(e,t){return J(X(`/api/shares/${e}`),{method:`PATCH`,body:JSON.stringify({extendTtlMs:t})})}function h1(){let[e,t]=(0,Z.useState)(!1),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),c=(0,Z.useCallback)(async e=>{t(!0),r(!0),a(null),s(null);try{let t=await d1(e);return a(t.payload),t.payload}catch(e){return s(e instanceof Error?e.message:String(e)),null}finally{r(!1)}},[]),l=(0,Z.useCallback)(()=>{a(null),s(null),r(!1)},[]);return{dialogOpen:e,loading:n,result:i,error:o,createShareLink:c,handleOpenChange:(0,Z.useCallback)(e=>{t(e),e||l()},[l])}}function g1(e){return e.map(e=>({name:e.name,path:e.path,absolutePath:e.absolutePath,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function _1(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:_1(e.children,t,n)}:e)}function v1(e,t){let[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(new Set),d=e.trim(),f=t?.trim()??``,p=f,m=f?``:d,h=(0,Z.useMemo)(()=>{if(p)return{sessionKey:p};if(m)return{agentId:m}},[p,m]);return{tree:n,loading:i,error:o,workspaceRoot:c,loadRoot:(0,Z.useCallback)(async()=>{a(!0),s(null),u.current.clear();try{let e=await jq(``,h);r(g1(e.entries)),l(e.root?.trim()||null),u.current.add(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[h]),loadChildren:(0,Z.useCallback)(async e=>{if(!u.current.has(e)){u.current.add(e);try{let t=g1(await Mq(e,h));r(n=>_1(n,e,t))}catch{u.current.delete(e)}}},[h]),reset:(0,Z.useCallback)(()=>{r([]),s(null),l(null),u.current.clear()},[])}}function y1({workspacePath:e,className:t}){let n=m(_(e=>e.language)).workspace,[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)([]),[l,d]=(0,Z.useState)(!1),f=fM()&&!!e.trim()&&!!window.electronAPI?.shell?.openPath,p=(0,Z.useCallback)(async()=>{let t=window.electronAPI?.shell;if(!t?.getOpenWithAppsForPath||!e.trim()){o([]),c([]);return}try{let n=await t.getOpenWithAppsForPath(e);o(n.recommended.map(e=>({name:e.name,path:e.path}))),c(n.recent.map(e=>({name:e.name,path:e.path})))}catch{o([]),c([])}},[e]);(0,Z.useEffect)(()=>{p()},[p]);let h=(0,Z.useCallback)(e=>{FK(`warning`,e||n.openLocationFailed,void 0,{duration:4e3})},[n.openLocationFailed]),g=(0,Z.useCallback)(async()=>{let t=window.electronAPI?.shell;if(!(!t?.openPath||!e)){d(!0);try{let n=await t.openPath(e);n.ok===!1&&h(n.error)}finally{d(!1),i(!1)}}},[h,e]),v=(0,Z.useCallback)(async t=>{let n=window.electronAPI?.shell;if(!(!n?.openPathWithApp||!e)){d(!0);try{let r=await n.openPathWithApp(e,t);r.ok===!1?h(r.error):p()}finally{d(!1),i(!1)}}},[p,h,e]),y=(0,Z.useCallback)(async()=>{let t=window.electronAPI?.shell;if(!(!t?.chooseAppAndOpenPath||!e)){d(!0);try{let n=await t.chooseAppAndOpenPath(e);n.ok===!1&&n.code!==`CANCELED`&&h(n.error),n.ok&&p()}finally{d(!1),i(!1)}}},[p,h,e]),b=(0,Z.useCallback)(async()=>{let t=await mA(e);FK(t?`success`:`warning`,t?n.pathCopied:n.copyPathFailed,void 0,{duration:t?2500:4e3}),i(!1)},[n.copyPathFailed,n.pathCopied,e]);if(!f)return null;let x=`flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm text-fg hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,S=a[0]??s[0],C=S?a.filter(e=>e.path!==S.path):a,w=S?s.filter(e=>e.path!==S.path):s;return(0,$.jsxs)(oj,{open:r,onOpenChange:e=>{i(e),e&&p()},children:[(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsxs)(tA,{variant:`ghost`,className:u(`min-w-0 max-w-40 shrink rounded-md px-2 py-1.5 text-xs`,t),"aria-label":n.openLocation,title:n.openLocation,children:[(0,$.jsx)(qv,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:S?.name??n.openLocation}),(0,$.jsx)(Gu,{className:`size-3.5 shrink-0`,"aria-hidden":!0})]})}),(0,$.jsx)(lj,{children:(0,$.jsxs)(uj,{align:`end`,side:`bottom`,sideOffset:6,className:`z-50 w-60 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover outline-none`,children:[S?(0,$.jsxs)(`button`,{type:`button`,disabled:l,className:x,title:S.path,onClick:()=>void v(S.path),children:[(0,$.jsx)(qv,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:S.name})]}):null,(0,$.jsx)(`div`,{className:u(S&&`border-t border-edge pt-1`),children:(0,$.jsxs)(`button`,{type:`button`,disabled:l,className:x,onClick:()=>void g(),children:[(0,$.jsx)(__,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),n.openInFileManager]})}),C.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`border-t border-edge px-2.5 pb-1 pt-2 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.recommendedApps}),C.map(e=>(0,$.jsxs)(`button`,{type:`button`,disabled:l,className:x,title:e.path,onClick:()=>void v(e.path),children:[(0,$.jsx)(qv,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))]}):null,w.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`border-t border-edge px-2.5 pb-1 pt-2 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.recentApps}),w.map(e=>(0,$.jsxs)(`button`,{type:`button`,disabled:l,className:x,title:e.path,onClick:()=>void v(e.path),children:[(0,$.jsx)(qv,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))]}):null,(0,$.jsxs)(`div`,{className:`mt-1 border-t border-edge pt-1`,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:l,className:x,onClick:()=>void y(),children:[(0,$.jsx)(qv,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),n.chooseApp]}),(0,$.jsxs)(`button`,{type:`button`,className:x,onClick:()=>void b(),children:[(0,$.jsx)(Fp,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),n.copyPath]})]})]})})]})}var b1=h(e=>({agentId:``,setAgentId:t=>e({agentId:t})})),x1=`xopc-web-workspace-panel-open`,S1=`xopc-web-workspace-panel-width-px`;function C1(){try{return globalThis.localStorage?.getItem(x1)===`1`}catch{return!1}}function w1(e){try{globalThis.localStorage?.setItem(x1,e?`1`:`0`)}catch{}}function T1(e){return Math.min(520,Math.max(200,Math.round(e)))}function E1(){try{let e=globalThis.localStorage?.getItem(S1);if(e==null)return 320;let t=Number.parseInt(e,10);return Number.isFinite(t)?T1(t):320}catch{return 320}}function D1(e){try{globalThis.localStorage?.setItem(S1,String(e))}catch{}}var O1=h((e,t)=>({open:C1(),setOpen:t=>{e({open:t}),queueMicrotask(()=>w1(t))},toggleOpen:()=>{t().setOpen(!t().open)},widthPx:E1(),setWidthPx:n=>{let r=T1(n);t().widthPx!==r&&(e({widthPx:r}),queueMicrotask(()=>D1(r)))}})),k1=h(e=>({path:null,line:null,setPath:(t,n)=>e({path:t,line:t&&typeof n==`number`&&Number.isFinite(n)&&n>0?Math.floor(n):null})})),A1=(0,Z.memo)(function(){let e=m(_(e=>e.language)),{pathname:t}=_r(),{sessionKey:n}=wr(),r=t.startsWith(`/chat`)&&n?decodeURIComponent(n):null,i=O1(e=>e.open),a=O1(e=>e.setOpen),o=O1(e=>e.widthPx),s=O1(e=>e.setWidthPx),[c,l]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,h]=(0,Z.useState)(``),[g,v]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),C=k1(e=>e.path),w=k1(e=>e.setPath),T=b1(e=>e.agentId),{tree:E,loading:D,error:O,workspaceRoot:k,loadRoot:A,loadChildren:j,reset:M}=v1(T,r),N=r??T,P=(0,Z.useMemo)(()=>r==null?T.trim()?{agentId:T.trim()}:void 0:{sessionKey:r},[r,T]),F=p.trim(),{dialogOpen:I,loading:L,result:R,error:z,createShareLink:B,handleOpenChange:V}=h1(),H=(0,Z.useCallback)(e=>{if(!i)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`#app-workspace-panel`);t.setPointerCapture(e.pointerId),l(!0);let r=e.clientX,a=O1.getState().widthPx,o=e.pointerId,c=0,u=a,d=a,f=()=>{c=0,d=u,n?.style.setProperty(`--workspace-panel-px`,`${d}px`)},p=e=>{u=T1(a+(r-e.clientX)),c===0&&(c=window.requestAnimationFrame(f))},m=()=>{c!==0&&(window.cancelAnimationFrame(c),f());try{t.releasePointerCapture(o)}catch{}l(!1),s(d),window.removeEventListener(`pointermove`,p),window.removeEventListener(`pointerup`,m),window.removeEventListener(`pointercancel`,m)};window.addEventListener(`pointermove`,p),window.addEventListener(`pointerup`,m),window.addEventListener(`pointercancel`,m)},[i,s]);(0,Z.useEffect)(()=>{t.startsWith(`/chat`)||a(!1)},[t,a]),(0,Z.useEffect)(()=>{if(!i){M(),w(null);return}w(null),A()},[i,N,A,M,w]),(0,Z.useEffect)(()=>{if(!i)return;let e=e=>{if(e.key===`Escape`){if(d){e.preventDefault(),e.stopPropagation(),h(``),f(!1);return}k1.getState().path||a(!1)}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[d,i,a]),(0,Z.useEffect)(()=>{if(!i||!d||!F){v([]),b(!1),S(null);return}let e=!1;b(!0),S(null),v([]);let t=window.setTimeout(()=>{Nq(F,P,50).then(t=>{e||v(t)}).catch(t=>{e||S(t instanceof Error?t.message:String(t))}).finally(()=>{e||b(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[d,F,i,P]),(0,Z.useEffect)(()=>{if(!i||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[i]);let U=(0,Z.useCallback)(e=>{j(e)},[j]),W=(0,Z.useCallback)(async(t,n,r)=>{switch(t){case`preview`:if(n.isDirectory)return;w(n.path);break;case`download`:if(n.isDirectory)return;try{let e=Qq(n.path);if(tJ(eJ(e))!==`text`)Vq(e,await(await Lq(n.path,P)).arrayBuffer(),UI(e)??`application/octet-stream`);else{let{content:t}=await Pq(n.path,P);Bq(e,t)}}catch{}break;case`copyPath`:try{await mA(n.absolutePath??n.path)&&FK(`success`,e.workspace.pathCopied,void 0,{duration:2500})}catch{}break;case`openDefault`:if(!n.absolutePath||!window.electronAPI?.shell?.openPath)return;await window.electronAPI.shell.openPath(n.absolutePath);break;case`openWith`:if(!n.absolutePath||!window.electronAPI?.shell?.chooseAppAndOpenPath)return;await window.electronAPI.shell.chooseAppAndOpenPath(n.absolutePath);break;case`openWithApp`:if(!n.absolutePath||!r||!window.electronAPI?.shell?.openPathWithApp)return;await window.electronAPI.shell.openPathWithApp(n.absolutePath,r);break;case`revealInFolder`:if(!n.absolutePath||!window.electronAPI?.shell?.showItemInFolder)return;await window.electronAPI.shell.showItemInFolder(n.absolutePath);break;case`share`:await B({path:n.path,...n.isDirectory?{kind:`directory`,directoryMode:`browse`}:{},...P});break;default:break}},[B,e.workspace.pathCopied,w,P]);return(0,$.jsxs)($.Fragment,{children:[i?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-scrim md:hidden`,"aria-label":e.closeMenu,onClick:()=>a(!1)}):null,(0,$.jsx)(`aside`,{id:`app-workspace-panel`,"aria-label":e.workspace.title,"aria-hidden":!i,className:u(`flex min-h-0 flex-col overflow-hidden bg-surface-base`,`max-md:fixed max-md:right-0 max-md:top-0 max-md:z-50 max-md:h-[100dvh] max-md:shadow-popover`,`max-md:transition-transform max-md:duration-200 max-md:ease-out`,`motion-reduce:max-md:transition-none`,`max-md:w-[min(20rem,92vw)]`,i?`max-md:translate-x-0`:`max-md:pointer-events-none max-md:translate-x-full`,`md:relative md:h-full md:translate-x-0`,`motion-reduce:md:transition-none`,!i&&`md:pointer-events-none md:w-0 md:min-w-0 md:max-w-0 md:overflow-hidden`,i&&`app-workspace-panel-expanded-width md:shrink-0`,i&&c&&`workspace-panel-rail-resizing`),style:i?{"--workspace-panel-px":`${o}px`}:void 0,children:i?(0,$.jsxs)(`div`,{className:u(`relative flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden overflow-y-hidden bg-surface-base`),children:[(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":e.workspace.resizeHandleAria,onPointerDown:H,className:u(`pointer-events-auto absolute left-0 top-0 z-20 hidden h-full w-2 cursor-col-resize md:block`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:z-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:bg-surface-hover/20 hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,c&&`bg-surface-hover/30 before:!bg-edge/80 dark:before:!bg-edge/85`,`transition-[background-color] duration-150`,`touch-none select-none`,uM)}),(0,$.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4 dark:border-edge`,children:[(0,$.jsx)(`h2`,{className:`sr-only`,children:e.workspace.title}),(0,$.jsx)(y1,{workspacePath:k??``}),(0,$.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:u(`size-9 shrink-0 rounded-md p-0`,d&&`bg-surface-hover text-fg`),"aria-label":e.workspace.search,title:e.workspace.search,"aria-pressed":d,onClick:()=>f(!0),children:(0,$.jsx)(Qx,{className:`size-4`,strokeWidth:1.75})}),(0,$.jsx)(gq,{className:`size-9 shrink-0 rounded-md p-0`,loading:D,label:e.cron.refresh,onClick:A}),(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-md p-0`,"aria-label":e.workspace.close,title:e.workspace.close,onClick:()=>a(!1),children:(0,$.jsx)(Sk,{className:`size-4`,strokeWidth:1.75})})]})]}),d?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge bg-surface-muted/40 px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/20`,children:[(0,$.jsx)(Qx,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`text`,role:`searchbox`,value:p,onChange:e=>h(e.target.value),placeholder:e.workspace.searchPlaceholder,"aria-label":e.workspace.searchPlaceholder,autoFocus:!0,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle`}),(0,$.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":e.workspace.clearSearch,title:e.workspace.clearSearch,onClick:()=>{h(``),f(!1)},children:(0,$.jsx)(Sk,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})]})}):null,O?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[e.workspace.loadError,`: `,O]}):null,F?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:y?(0,$.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,$.jsx)(uI,{className:`h-11 w-full`}),(0,$.jsx)(uI,{className:`h-11 w-full`}),(0,$.jsx)(uI,{className:`h-11 w-full`})]}):x?(0,$.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[e.workspace.loadError,`: `,x]}):g.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:e.workspace.noSearchResults}):g.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:u(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-surface-hover`,C===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>w(e.path),title:e.path,children:[(0,$.jsx)(_g,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):(0,$.jsx)(Oq,{tree:E,selectedPath:C,onSelectFile:e=>w(e),onExpandDir:U,onAction:W,actionLabels:{preview:e.workspace.preview,download:e.workspace.download,copyPath:e.workspace.copyPath,share:e.workspace.shareLink,...fM()?{openDefault:e.workspace.openSystemApp,openWith:e.workspace.chooseApp,revealInFolder:e.workspace.revealInFolder,recommendedApps:e.workspace.recommendedApps}:{}},emptyHint:e.workspace.emptyDir})]}):null}),(0,$.jsx)(c1,{open:I,onOpenChange:V,loading:L,error:z,result:R})]})});function j1(){let e=(0,Q.c)(28),t=(0,Z.useRef)(null),n=q(R1),r=q(L1),i=q(I1),a=q(F1),o=q(P1),s=q(N1),c=_(M1),l;e[0]===c?l=e[1]:(l=m(c),e[0]=c,e[1]=l);let d=l.token,f=!!s&&!i,p;e[2]!==f||e[3]!==o?(p=e=>{!e&&!f||e||o()},e[2]=f,e[3]=o,e[4]=p):p=e[4];let h;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(RN,{className:u(`fixed inset-0 bg-scrim backdrop-blur-[2px]`,hj)}),e[5]=h):h=e[5];let g,v;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=u(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,gj,`dark:border-edge`),v=e=>{e.preventDefault(),t.current?.focus()},e[6]=g,e[7]=v):(g=e[6],v=e[7]);let y;e[8]===d.title?y=e[9]:(y=(0,$.jsx)(BN,{className:`text-base font-semibold text-fg`,children:d.title}),e[8]=d.title,e[9]=y);let b;e[10]===d.description?b=e[11]:(b=(0,$.jsx)(VN,{className:`mt-1 text-sm text-fg-muted`,children:d.description}),e[10]=d.description,e[11]=b);let x;e[12]!==f||e[13]!==o||e[14]!==c?(x=f?(0,$.jsx)(tA,{type:`button`,variant:`ghost`,onClick:()=>o(),children:c===`zh`?`取消`:`Cancel`}):void 0,e[12]=f,e[13]=o,e[14]=c,e[15]=x):x=e[15];let S;e[16]!==r||e[17]!==a||e[18]!==x?(S=(0,$.jsx)(EA,{className:`mt-4`,baseUrl:r,tokenInputRef:t,onSubmit:a,footerLeft:x}),e[16]=r,e[17]=a,e[18]=x,e[19]=S):S=e[19];let C;e[20]!==y||e[21]!==b||e[22]!==S?(C=(0,$.jsxs)(LN,{children:[h,(0,$.jsxs)(zN,{className:g,onOpenAutoFocus:v,children:[y,b,S]})]}),e[20]=y,e[21]=b,e[22]=S,e[23]=C):C=e[23];let w;return e[24]!==n||e[25]!==p||e[26]!==C?(w=(0,$.jsx)(FN,{open:n,onOpenChange:p,children:C}),e[24]=n,e[25]=p,e[26]=C,e[27]=w):w=e[27],w}function M1(e){return e.language}function N1(e){return e.token}function P1(e){return e.closeTokenDialog}function F1(e){return e.setGatewayToken}function I1(e){return e.tokenExpired}function L1(e){return e.baseUrl}function R1(e){return e.tokenDialogOpen}function z1(e){let t=e+`CollectionProvider`,[n,r]=T(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=Z.useRef(null),a=Z.useRef(new Map).current;return(0,$.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=P(s),l=Z.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,$.jsx)(c,{ref:d(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=P(u),m=Z.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=Z.useRef(null),s=d(t,o),c=a(u,n);return Z.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,$.jsx)(p,{[f]:``,ref:s,children:r})});m.displayName=u;function h(t){let n=a(e+`CollectionConsumer`,t);return Z.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:m},h,r]}var B1=Z.createContext(void 0);function V1(e){let t=Z.useContext(B1);return e||t||`ltr`}var H1=`rovingFocusGroup.onEntryFocus`,U1={bubbles:!1,cancelable:!0},W1=`RovingFocusGroup`,[G1,K1,q1]=z1(W1),[J1,Y1]=T(W1,[q1]),[X1,Z1]=J1(W1),Q1=Z.forwardRef((e,t)=>(0,$.jsx)(G1.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,$.jsx)(G1.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,$.jsx)($1,{...e,ref:t})})}));Q1.displayName=W1;var $1=Z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...f}=e,p=Z.useRef(null),m=d(t,p),h=V1(a),[g,_]=R({prop:o,defaultProp:s??null,onChange:c,caller:W1}),[v,y]=Z.useState(!1),b=O(l),x=K1(n),S=Z.useRef(!1),[C,w]=Z.useState(0);return Z.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(H1,b),()=>e.removeEventListener(H1,b)},[b]),(0,$.jsx)(X1,{scope:n,orientation:r,dir:h,loop:i,currentTabStopId:g,onItemFocus:Z.useCallback(e=>_(e),[_]),onItemShiftTab:Z.useCallback(()=>y(!0),[]),onFocusableItemAdd:Z.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:Z.useCallback(()=>w(e=>e-1),[]),children:(0,$.jsx)(k.div,{tabIndex:v||C===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:`none`,...e.style},onMouseDown:V(e.onMouseDown,()=>{S.current=!0}),onFocus:V(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!v){let t=new CustomEvent(H1,U1);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);a0([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:V(e.onBlur,()=>y(!1))})})}),e0=`RovingFocusGroupItem`,t0=Z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=I(),l=a||c,u=Z1(e0,n),d=u.currentTabStopId===l,f=K1(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return Z.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,$.jsx)(G1.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,$.jsx)(k.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:V(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:V(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:V(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=i0(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?o0(n,r+1):n.slice(r+1)}setTimeout(()=>a0(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});t0.displayName=e0;var n0={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function r0(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function i0(e,t,n){let r=r0(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return n0[r]}function a0(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function o0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var s0=Q1,c0=t0,l0=[`Enter`,` `],u0=[`ArrowDown`,`PageUp`,`Home`],d0=[`ArrowUp`,`PageDown`,`End`],f0=[...u0,...d0],p0={ltr:[...l0,`ArrowRight`],rtl:[...l0,`ArrowLeft`]},m0={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},h0=`Menu`,[g0,_0,v0]=z1(h0),[y0,b0]=T(h0,[v0,H,Y1]),x0=H(),S0=Y1(),[C0,w0]=y0(h0),[T0,E0]=y0(h0),D0=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=x0(t),[c,l]=Z.useState(null),u=Z.useRef(!1),d=O(a),f=V1(i);return Z.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,$.jsx)(U,{...s,children:(0,$.jsx)(C0,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,$.jsx)(T0,{scope:t,onClose:Z.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};D0.displayName=h0;var O0=`MenuAnchor`,k0=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=x0(n);return(0,$.jsx)(K,{...i,...r,ref:t})});k0.displayName=O0;var A0=`MenuPortal`,[j0,M0]=y0(A0,{forceMount:void 0}),N0=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=w0(A0,t);return(0,$.jsx)(j0,{scope:t,forceMount:n,children:(0,$.jsx)(M,{present:n||a.open,children:(0,$.jsx)(E,{asChild:!0,container:i,children:r})})})};N0.displayName=A0;var P0=`MenuContent`,[F0,I0]=y0(P0),L0=Z.forwardRef((e,t)=>{let n=M0(P0,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=w0(P0,e.__scopeMenu),o=E0(P0,e.__scopeMenu);return(0,$.jsx)(g0.Provider,{scope:e.__scopeMenu,children:(0,$.jsx)(M,{present:r||a.open,children:(0,$.jsx)(g0.Slot,{scope:e.__scopeMenu,children:o.modal?(0,$.jsx)(R0,{...i,ref:t}):(0,$.jsx)(z0,{...i,ref:t})})})})}),R0=Z.forwardRef((e,t)=>{let n=w0(P0,e.__scopeMenu),r=Z.useRef(null),i=d(t,r);return Z.useEffect(()=>{let e=r.current;if(e)return F(e)},[]),(0,$.jsx)(V0,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:V(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),z0=Z.forwardRef((e,t)=>{let n=w0(P0,e.__scopeMenu);return(0,$.jsx)(V0,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),B0=P(`MenuContent.ScrollLock`),V0=Z.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=w0(P0,n),v=E0(P0,n),y=x0(n),b=S0(n),x=_0(n),[S,C]=Z.useState(null),w=Z.useRef(null),T=d(t,w,_.onContentChange),E=Z.useRef(0),O=Z.useRef(``),k=Z.useRef(0),A=Z.useRef(null),j=Z.useRef(`right`),M=Z.useRef(0),P=h?z:Z.Fragment,F=h?{as:B0,allowPinchZoom:!0}:void 0,I=e=>{let t=O.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Bse(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){O.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};Z.useEffect(()=>()=>window.clearTimeout(E.current),[]),N();let L=Z.useCallback(e=>j.current===A.current?.side&&Hse(e,A.current?.area),[]);return(0,$.jsx)(F0,{scope:n,searchRef:O,onItemEnter:Z.useCallback(e=>{L(e)&&e.preventDefault()},[L]),onItemLeave:Z.useCallback(e=>{L(e)||(w.current?.focus(),C(null))},[L]),onTriggerLeave:Z.useCallback(e=>{L(e)&&e.preventDefault()},[L]),pointerGraceTimerRef:k,onPointerGraceIntentChange:Z.useCallback(e=>{A.current=e},[]),children:(0,$.jsx)(P,{...F,children:(0,$.jsx)(D,{asChild:!0,trapped:i,onMountAutoFocus:V(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,$.jsx)(B,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:(0,$.jsx)(s0,{asChild:!0,...b,dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:V(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,$.jsx)(G,{role:`menu`,"aria-orientation":`vertical`,"data-state":b2(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...g,ref:T,style:{outline:`none`,...g.style},onKeyDown:V(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&I(e.key));let i=w.current;if(e.target!==i||!f0.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);d0.includes(e.key)&&a.reverse(),Rse(a)}),onBlur:V(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),O.current=``)}),onPointerMove:V(e.onPointerMove,C2(e=>{let t=e.target,n=M.current!==e.clientX;e.currentTarget.contains(t)&&n&&(j.current=e.clientX>M.current?`right`:`left`,M.current=e.clientX)}))})})})})})})});L0.displayName=P0;var H0=`MenuGroup`,U0=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,$.jsx)(k.div,{role:`group`,...r,ref:t})});U0.displayName=H0;var W0=`MenuLabel`,G0=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,$.jsx)(k.div,{...r,ref:t})});G0.displayName=W0;var K0=`MenuItem`,q0=`menu.itemSelect`,J0=Z.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=Z.useRef(null),o=E0(K0,e.__scopeMenu),s=I0(K0,e.__scopeMenu),c=d(t,a),l=Z.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(q0,{bubbles:!0,cancelable:!0});e.addEventListener(q0,e=>r?.(e),{once:!0}),L(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,$.jsx)(Y0,{...i,ref:c,disabled:n,onClick:V(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:V(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:V(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||l0.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});J0.displayName=K0;var Y0=Z.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=I0(K0,n),s=S0(n),c=Z.useRef(null),l=d(t,c),[u,f]=Z.useState(!1),[p,m]=Z.useState(``);return Z.useEffect(()=>{let e=c.current;e&&m((e.textContent??``).trim())},[a.children]),(0,$.jsx)(g0.ItemSlot,{scope:n,disabled:r,textValue:i??p,children:(0,$.jsx)(c0,{asChild:!0,...s,focusable:!r,children:(0,$.jsx)(k.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:V(e.onPointerMove,C2(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:V(e.onPointerLeave,C2(e=>o.onItemLeave(e))),onFocus:V(e.onFocus,()=>f(!0)),onBlur:V(e.onBlur,()=>f(!1))})})})}),X0=`MenuCheckboxItem`,Z0=Z.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,$.jsx)(a2,{scope:e.__scopeMenu,checked:n,children:(0,$.jsx)(J0,{role:`menuitemcheckbox`,"aria-checked":x2(n)?`mixed`:n,...i,ref:t,"data-state":S2(n),onSelect:V(i.onSelect,()=>r?.(x2(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Z0.displayName=X0;var Q0=`MenuRadioGroup`,[$0,e2]=y0(Q0,{value:void 0,onValueChange:()=>{}}),t2=Z.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=O(r);return(0,$.jsx)($0,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,$.jsx)(U0,{...i,ref:t})})});t2.displayName=Q0;var n2=`MenuRadioItem`,r2=Z.forwardRef((e,t)=>{let{value:n,...r}=e,i=e2(n2,e.__scopeMenu),a=n===i.value;return(0,$.jsx)(a2,{scope:e.__scopeMenu,checked:a,children:(0,$.jsx)(J0,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":S2(a),onSelect:V(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});r2.displayName=n2;var i2=`MenuItemIndicator`,[a2,o2]=y0(i2,{checked:!1}),s2=Z.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=o2(i2,n);return(0,$.jsx)(M,{present:r||x2(a.checked)||a.checked===!0,children:(0,$.jsx)(k.span,{...i,ref:t,"data-state":S2(a.checked)})})});s2.displayName=i2;var c2=`MenuSeparator`,l2=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,$.jsx)(k.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});l2.displayName=c2;var u2=`MenuArrow`,d2=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=x0(n);return(0,$.jsx)(W,{...i,...r,ref:t})});d2.displayName=u2;var f2=`MenuSub`,[p2,m2]=y0(f2),h2=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=w0(f2,t),o=x0(t),[s,c]=Z.useState(null),[l,u]=Z.useState(null),d=O(i);return Z.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,$.jsx)(U,{...o,children:(0,$.jsx)(C0,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,$.jsx)(p2,{scope:t,contentId:I(),triggerId:I(),trigger:s,onTriggerChange:c,children:n})})})};h2.displayName=f2;var g2=`MenuSubTrigger`,_2=Z.forwardRef((e,t)=>{let n=w0(g2,e.__scopeMenu),r=E0(g2,e.__scopeMenu),i=m2(g2,e.__scopeMenu),a=I0(g2,e.__scopeMenu),o=Z.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=Z.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return Z.useEffect(()=>u,[u]),Z.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,$.jsx)(k0,{asChild:!0,...l,children:(0,$.jsx)(Y0,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":b2(n.open),...e,ref:f(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:V(e.onPointerMove,C2(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:V(e.onPointerLeave,C2(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:V(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||p0[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});_2.displayName=g2;var v2=`MenuSubContent`,y2=Z.forwardRef((e,t)=>{let n=M0(P0,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=w0(P0,e.__scopeMenu),o=E0(P0,e.__scopeMenu),s=m2(v2,e.__scopeMenu),c=Z.useRef(null),l=d(t,c);return(0,$.jsx)(g0.Provider,{scope:e.__scopeMenu,children:(0,$.jsx)(M,{present:r||a.open,children:(0,$.jsx)(g0.Slot,{scope:e.__scopeMenu,children:(0,$.jsx)(V0,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:V(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:V(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:V(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=m0[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});y2.displayName=v2;function b2(e){return e?`open`:`closed`}function x2(e){return e===`indeterminate`}function S2(e){return x2(e)?`indeterminate`:e?`checked`:`unchecked`}function Rse(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function zse(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Bse(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=zse(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Vse(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Hse(e,t){return t?Vse({x:e.clientX,y:e.clientY},t):!1}function C2(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Use=D0,Wse=k0,Gse=N0,Kse=L0,qse=U0,Jse=G0,Yse=J0,Xse=Z0,Zse=t2,Qse=r2,$se=s2,ece=l2,tce=d2,nce=_2,rce=y2,w2=`DropdownMenu`,[ice,ace]=T(w2,[b0]),T2=b0(),[oce,E2]=ice(w2),D2=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=T2(t),l=Z.useRef(null),[u,d]=R({prop:i,defaultProp:a??!1,onChange:o,caller:w2});return(0,$.jsx)(oce,{scope:t,triggerId:I(),triggerRef:l,contentId:I(),open:u,onOpenChange:d,onOpenToggle:Z.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,$.jsx)(Use,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};D2.displayName=w2;var O2=`DropdownMenuTrigger`,k2=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=E2(O2,n),o=T2(n);return(0,$.jsx)(Wse,{asChild:!0,...o,children:(0,$.jsx)(k.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:f(t,a.triggerRef),onPointerDown:V(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:V(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});k2.displayName=O2;var sce=`DropdownMenuPortal`,A2=e=>{let{__scopeDropdownMenu:t,...n}=e,r=T2(t);return(0,$.jsx)(Gse,{...r,...n})};A2.displayName=sce;var j2=`DropdownMenuContent`,M2=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E2(j2,n),a=T2(n),o=Z.useRef(!1);return(0,$.jsx)(Kse,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:V(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:V(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});M2.displayName=j2;var cce=`DropdownMenuGroup`,lce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(qse,{...i,...r,ref:t})});lce.displayName=cce;var uce=`DropdownMenuLabel`,dce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(Jse,{...i,...r,ref:t})});dce.displayName=uce;var fce=`DropdownMenuItem`,N2=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(Yse,{...i,...r,ref:t})});N2.displayName=fce;var pce=`DropdownMenuCheckboxItem`,mce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(Xse,{...i,...r,ref:t})});mce.displayName=pce;var hce=`DropdownMenuRadioGroup`,gce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(Zse,{...i,...r,ref:t})});gce.displayName=hce;var _ce=`DropdownMenuRadioItem`,vce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(Qse,{...i,...r,ref:t})});vce.displayName=_ce;var yce=`DropdownMenuItemIndicator`,bce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)($se,{...i,...r,ref:t})});bce.displayName=yce;var xce=`DropdownMenuSeparator`,P2=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(ece,{...i,...r,ref:t})});P2.displayName=xce;var Sce=`DropdownMenuArrow`,Cce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(tce,{...i,...r,ref:t})});Cce.displayName=Sce;var wce=`DropdownMenuSubTrigger`,Tce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(nce,{...i,...r,ref:t})});Tce.displayName=wce;var Ece=`DropdownMenuSubContent`,Dce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(rce,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Dce.displayName=Ece;var F2=D2,I2=k2,L2=A2,R2=M2,z2=N2,B2=P2;function V2(){return fM()&&window.electronAPI?.platform===`win32`}function Oce(e){return e?e.replace(/CmdOrCtrl/g,`Ctrl`).replace(/Command/g,`Ctrl`).replace(/\+/g,` + `):null}function kce(e){let t=(0,Q.c)(15),{item:n,onInvoke:r}=e;if(n.type===`separator`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(B2,{className:`my-1 h-px bg-edge-subtle`}),t[0]=e):e=t[0],e}let i;t[1]===n.accelerator?i=t[2]:(i=Oce(n.accelerator),t[1]=n.accelerator,t[2]=i);let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=u(`flex min-h-7 cursor-default select-none items-center gap-6 rounded-md px-2 py-1.5 text-xs text-fg outline-none`,`data-[highlighted]:bg-surface-hover data-[highlighted]:text-fg`),t[3]=o):o=t[3];let s;t[4]!==n.id||t[5]!==r?(s=()=>r(n.id),t[4]=n.id,t[5]=r,t[6]=s):s=t[6];let c;t[7]===n.label?c=t[8]:(c=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.label}),t[7]=n.label,t[8]=c);let l;t[9]===a?l=t[10]:(l=a?(0,$.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-mono text-[11px] text-fg-subtle`,children:a}):null,t[9]=a,t[10]=l);let d;return t[11]!==s||t[12]!==c||t[13]!==l?(d=(0,$.jsxs)(z2,{className:o,onSelect:s,children:[c,l]}),t[11]=s,t[12]=c,t[13]=l,t[14]=d):d=t[14],d}function Ace(e){let t=(0,Q.c)(6),{groups:n}=e,r=jce,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=u(`windows-titlebar-interactive flex min-w-0 items-center gap-1`,uM),t[0]=i):i=t[0];let a;if(t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>(0,$.jsxs)(F2,{modal:!1,children:[(0,$.jsx)(I2,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex h-8 shrink-0 items-center rounded-md px-3 text-sm font-normal text-fg-muted`,`outline-none transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent/60 data-[state=open]:bg-surface-hover data-[state=open]:text-fg`,uM),role:`menuitem`,children:e.label})}),(0,$.jsx)(L2,{children:(0,$.jsx)(R2,{align:`start`,sideOffset:4,className:u(`windows-titlebar-interactive z-[90] min-w-52 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover outline-none`,uM),children:e.items.map((t,n)=>(0,$.jsx)(kce,{item:t,onInvoke:r},t.type===`item`?t.id:`${e.id}-separator-${n}`))})})]},e.id),t[3]=e):e=t[3],a=n.map(e),t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,$.jsx)(`div`,{className:i,role:`menubar`,children:a}),t[4]=a,t[5]=o),o}function jce(e){window.electronAPI?.menu?.invoke(e)}var H2=(0,Z.memo)(function(){let e=(0,Q.c)(11),t=_(Mce),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0];let[r,i]=(0,Z.useState)(n),a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{if(!V2())return;let e=!1;return window.electronAPI?.menu?.getModel().then(t=>{e||i(t)}).catch(()=>{e||i([])}),()=>{e=!0}},e[1]=a):a=e[1];let o;if(e[2]===t?o=e[3]:(o=[t],e[2]=t,e[3]=o),(0,Z.useEffect)(a,o),!V2())return null;let s,c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=u(`windows-titlebar flex h-9 min-w-0 shrink-0 items-center gap-2 border-b border-edge-subtle`),c=(0,$.jsx)(`div`,{className:u(`windows-titlebar-interactive flex shrink-0 items-center gap-0.5`,uM),children:(0,$.jsx)(BM,{sidebarToggleVariant:`main`,showHistory:!0})}),e[4]=s,e[5]=c):(s=e[4],c=e[5]);let l;e[6]===r?l=e[7]:(l=(0,$.jsx)(Ace,{groups:r}),e[6]=r,e[7]=l);let d;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`div`,{className:u(`min-w-8 flex-1 self-stretch`,lM),"aria-hidden":!0}),e[8]=d):d=e[8];let f;return e[9]===l?f=e[10]:(f=(0,$.jsxs)(`header`,{className:s,children:[c,l,d]}),e[9]=l,e[10]=f),f});function Mce(e){return e.language}var U2=`xopc:shell-prefs-changed`,W2={notifyEnabled:!0,notifySoundEnabled:!0};function Nce(){return W2}function Pce(){typeof window>`u`||window.dispatchEvent(new CustomEvent(U2))}async function G2(){if(!fM()||!window.electronAPI?.system)return W2;try{let e=await window.electronAPI.system.getBehavior();W2={notifyEnabled:e.notifyEnabled,notifySoundEnabled:e.notifySoundEnabled}}catch{}return W2}function Fce(){try{let e=new AudioContext,t=e.createOscillator(),n=e.createGain();t.type=`sine`,t.frequency.value=880,n.gain.value=.07,t.connect(n),n.connect(e.destination),t.start(),t.stop(e.currentTime+.15),e.close()}catch{}}function K2(e){if(typeof Notification>`u`)return!1;let t=Nce();if(!t.notifyEnabled&&!e.force||Notification.permission!==`granted`)return!1;let n=e.title.trim();if(!n||!e.force&&!e.urgent&&!document.hidden)return!1;try{let r=new Notification(n,{body:e.body?.trim()||void 0,tag:e.tag,silent:!t.notifySoundEnabled});return r.onclick=()=>{window.focus(),r.close()},t.notifySoundEnabled&&Fce(),!0}catch{return!1}}async function Ice(e,t){if(typeof Notification>`u`)return`unsupported`;if(fM()&&window.electronAPI?.system?.requestNotifications){let n=await window.electronAPI.system.requestNotifications();if(n.status!==`granted`)return n.outcome===`opened-settings`||n.status===`denied`?`denied`:`default`;if(Notification.permission==="default"){let e=await Notification.requestPermission();if(e!==`granted`)return e===`denied`?`denied`:`default`}else if(Notification.permission===`denied`)return`denied`;return W2={...W2,notifyEnabled:!0},K2({title:e,body:t,tag:`xopc-notify-test`,force:!0}),`enabled`}let n=Notification.permission;return n==="default"&&(n=await Notification.requestPermission()),n===`denied`?`denied`:n===`granted`?(W2={...W2,notifyEnabled:!0},K2({title:e,body:t,tag:`xopc-notify-test`,force:!0}),`enabled`):`default`}function Lce(){let e=(0,Q.c)(4),t=_(Vce),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0],(0,Z.useEffect)(zce,n);let r,i;return e[1]===t?(r=e[2],i=e[3]):(r=()=>{if(!fM())return;let e=m(t).systemSettings.desktopNotify,n=Rce,r=t=>{let n=t.detail,r=n?.event;if(!r||r.type!==`error`)return;let i=typeof r.content==`string`?r.content.trim():``;K2({title:e.agentErrorTitle,body:i||e.agentErrorBody,tag:`xopc-agent-error-${n?.sessionKey??`unknown`}`,urgent:!0})};return window.addEventListener(ne,n),window.addEventListener(`agent-stream-event`,r),()=>{window.removeEventListener(ne,n),window.removeEventListener(`agent-stream-event`,r)}},i=[t],e[1]=t,e[2]=r,e[3]=i),(0,Z.useEffect)(r,i),null}function Rce(e){let t=e.detail,n=typeof t?.title==`string`?t.title.trim():``;if(!n)return;let r=typeof t?.message==`string`?t.message.trim():void 0,i=t?.type===`error`||t?.type===`warning`;K2({title:n,body:r,tag:`xopc-toast-${t?.type??`info`}`,urgent:i})}function zce(){if(!fM())return;G2();let e=Bce;return window.addEventListener(U2,e),()=>window.removeEventListener(U2,e)}function Bce(){G2()}function Vce(e){return e.language}function Hce(){let e=(0,Q.c)(16),t=_(Uce),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n.electron,[i,a]=(0,Z.useState)(null),o,s;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{if(!fM())return;let e=window.electronAPI?.gateway;if(e?.onExited)return e.onExited(e=>a(e))},s=[],e[2]=o,e[3]=s):(o=e[2],s=e[3]),(0,Z.useEffect)(o,s),!i)return null;let c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=u(`shrink-0 border-b border-danger/35 bg-danger/10 px-4 py-3 text-sm text-fg shadow-surface`),e[4]=c):c=e[4];let l;e[5]===r.gatewayExitTitle?l=e[6]:(l=(0,$.jsx)(`p`,{className:`font-semibold`,children:r.gatewayExitTitle}),e[5]=r.gatewayExitTitle,e[6]=l);let d;e[7]===r.gatewayExitBody?d=e[8]:(d=(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:r.gatewayExitBody}),e[7]=r.gatewayExitBody,e[8]=d);let f=i.code??`—`,p=i.signal??`—`,h;e[9]!==f||e[10]!==p?(h=(0,$.jsxs)(`p`,{className:`mt-2 font-mono text-xs text-fg-muted`,children:[`exit `,f,` · signal `,p]}),e[9]=f,e[10]=p,e[11]=h):h=e[11];let g;return e[12]!==l||e[13]!==d||e[14]!==h?(g=(0,$.jsxs)(`div`,{className:c,role:`alert`,children:[l,d,h]}),e[12]=l,e[13]=d,e[14]=h,e[15]=g):g=e[15],g}function Uce(e){return e.language}function q2(){let e=(0,Q.c)(3),t=br(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{if(!fM())return;let e=window.electronAPI;if(!e?.menu)return;let n=e.menu.onNavigate(e=>{t(e)}),r=e.menu.onTogglePalette(Kce),i=e.menu.onQuickCapture(Gce),a=e.menu.onToggleSidebar(Wce),o=e.menu.onHistoryNavigate(e=>{t(e)});return()=>{n(),r(),i(),a(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function Wce(){FM.getState().toggleCollapsed()}function Gce(){window.dispatchEvent(new CustomEvent(`open-quick-capture`))}function Kce(){window.dispatchEvent(new CustomEvent(`toggle-command-palette`))}var qce=1500,Jce=9e4;function Yce(){let e=(0,Q.c)(16),t=_(Qce),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n.updatePanel,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(0),l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=c.current+=1;a(!0),s(!1),(async()=>{await new Promise(Zce);let t=Date.now()+Jce;for(;e===c.current&&Date.now()<t;){try{if((await fetch(X(`/api/health`),{signal:AbortSignal.timeout(3e3)})).ok){window.location.reload();return}}catch{}await new Promise(Xce)}e===c.current&&s(!0)})()},e[2]=l):l=e[2];let d=l,f,p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=()=>d();return window.addEventListener(`gateway-restart-initiated`,e),()=>{c.current+=1,window.removeEventListener(`gateway-restart-initiated`,e)}},p=[d],e[3]=f,e[4]=p):(f=e[3],p=e[4]),(0,Z.useEffect)(f,p);let h;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{d()},e[5]=h):h=e[5];let g=h;if(!i)return null;let v=o?`border-red-500/20 bg-red-500/10 text-red-800 dark:text-red-200`:`border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-100`,y;e[6]===v?y=e[7]:(y=u(`flex min-h-10 w-full items-center justify-center gap-2 border-b px-4 py-2 text-sm`,v),e[6]=v,e[7]=y);let b;e[8]!==r.restartPollRetry||e[9]!==r.restartPollTimeout||e[10]!==r.restartPolling||e[11]!==o?(b=o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{children:r.restartPollTimeout}),(0,$.jsx)(`button`,{type:`button`,onClick:g,className:`ml-2 rounded bg-accent px-2 py-0.5 text-xs font-medium text-white hover:bg-accent/90`,children:r.restartPollRetry})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Fv,{className:`size-4 animate-spin`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.restartPolling})]}),e[8]=r.restartPollRetry,e[9]=r.restartPollTimeout,e[10]=r.restartPolling,e[11]=o,e[12]=b):b=e[12];let x;return e[13]!==y||e[14]!==b?(x=(0,$.jsx)(`div`,{className:y,children:b}),e[13]=y,e[14]=b,e[15]=x):x=e[15],x}function Xce(e){return setTimeout(e,qce)}function Zce(e){return setTimeout(e,2e3)}function Qce(e){return e.language}async function J2(){return J(X(`/api/tunnel/pair/context`))}async function $ce(){return J(X(`/api/tunnel/pair/enable-lan`),{method:`POST`,body:JSON.stringify({})})}async function ele(){return J(X(`/api/tunnel/status`))}async function tle(){await J(X(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function nle(){return J(X(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function rle(e){return J(X(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function ile(){return J(X(`/api/tunnel/qr`))}async function ale(){return J(X(`/api/tunnel/pair`),{method:`POST`,body:JSON.stringify({})})}async function ole(){let e=(await J(X(`/api/tunnel/reveal-registration-secret`),{method:`POST`,body:JSON.stringify({})})).payload;if(!e)throw Error(`Missing reveal payload`);return{registrationSecret:e.registrationSecret??null,source:e.source===`config`?`config`:`none`}}async function sle(e){await J(X(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}async function Y2(){if(fM()&&window.electronAPI?.gateway?.restart){let e=await window.electronAPI.gateway.restart();return e.ok&&e.token&&q.getState().setGatewayToken(e.token),e}let e=await J(X(`/api/gateway/restart`),{method:`POST`,body:JSON.stringify({})});return e.ok===!1?{ok:!1,message:e.message??e.error??`Gateway restart failed`}:{ok:!0}}async function cle(e,t={}){let n=t.timeoutMs??9e4,r=t.intervalMs??500,i=Date.now()+n,a=async()=>{if(Date.now()>=i)return!1;try{if((await fetch(X(`/api/tunnel/pair/context`),{headers:{Authorization:`Bearer ${e}`}})).ok)return!0}catch{}return await new Promise(e=>setTimeout(e,r)),a()};return a()}async function lle(e={}){let t=e.timeoutMs??9e4,n=e.intervalMs??500,r=Date.now()+t,i=async()=>{if(Date.now()>=r)return null;try{let e=await J2();if(e.pairingReady)return e}catch{}return await new Promise(e=>setTimeout(e,n)),i()};return i()}function ule({reminder:e,compact:t}){let n=_(e=>e.language),r=m(n).updatePanel,{show:i,dismiss:a,electronQuitAndInstall:o,runNpmUpdate:s,npmUpdateRunning:c}=e,[l,d]=(0,Z.useState)(!1),f=(0,Z.useCallback)(async()=>{let e=m(n).updatePanel;d(!0);try{let t=await Y2();if(t.ok){window.dispatchEvent(new Event(`gateway-restart-initiated`));return}re({type:`error`,title:e.updateErrorFailed,message:t.message??`Gateway restart failed`})}catch(t){re({type:`error`,title:e.updateErrorFailed,message:t instanceof Error?t.message:String(t)})}finally{d(!1)}},[n]),p=(0,Z.useCallback)(async()=>{let e=m(n).updatePanel,t=await s();if(t.ok){re({type:`success`,title:e.updateSuccess,message:e.updateSuccessDetail});return}re({type:`error`,title:t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed,message:t.message})},[s,n]);if(i.kind===`none`)return null;let h=`absolute right-2 top-1/2 z-[1] flex -translate-y-1/2 items-center gap-1 sm:right-3`;return i.kind===`electron-ready`?(0,$.jsxs)(`div`,{className:u(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 px-10 py-2 text-sm sm:px-12`,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-[min(100%,48rem)] items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(Bm,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0`,children:r.reminderElectronReady.replace(`{{version}}`,i.version)})]}),(0,$.jsxs)(`div`,{className:h,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:`rounded bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90`,children:[(0,$.jsx)(Lb,{className:`mr-1 inline size-3`}),r.restartToUpdate]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`rounded p-1 text-fg-muted hover:text-fg`,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(Sk,{className:`size-4`})})]})]}):i.kind===`electron-error`?(0,$.jsxs)(`div`,{className:u(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-red-500/20 bg-red-500/10 px-10 py-2 text-sm text-fg sm:px-12`,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-[min(100%,52rem)] items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(ld,{className:`size-4 shrink-0 text-red-500 dark:text-red-400`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:r.reminderElectronUpdateError.replace(`{{detail}}`,i.message)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:h,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(Sk,{className:`size-4`})})]}):i.kind===`electron-downloading`?(0,$.jsxs)(`div`,{className:u(`relative flex min-h-10 w-full min-w-0 flex-col items-center justify-center gap-2 border-b border-edge bg-surface-secondary px-10 py-2 text-sm text-fg-muted sm:flex-row sm:gap-4 sm:px-12`,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-full items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(Bm,{className:`size-4 shrink-0 animate-pulse`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.reminderDownloading.replace(`{{percent}}`,String(i.percent))})]}),(0,$.jsx)(`div`,{className:`h-1.5 w-full max-w-xs rounded-full bg-surface-tertiary sm:max-w-[12rem]`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${i.percent}%`}})}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:u(h,`sm:right-2`),"aria-label":r.dismissAria,children:(0,$.jsx)(Sk,{className:`size-4`})})]}):i.kind===`npm-restart-required`?(0,$.jsxs)(`div`,{className:u(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-amber-500/25 bg-amber-500/10 py-2 text-sm`,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`,children:[(0,$.jsx)(`span`,{children:r.restartRequired.replace(`{{version}}`,i.version)}),(0,$.jsxs)(`button`,{type:`button`,onClick:f,disabled:l,className:`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,children:[l?(0,$.jsx)(Fv,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Lb,{className:`size-3 shrink-0`,"aria-hidden":!0}),r.restartGateway]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:h,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(Sk,{className:`size-4`})})]}):i.kind===`npm`?(0,$.jsxs)(`div`,{className:u(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 py-2 text-sm`,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:u(`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`),children:[(0,$.jsxs)(`span`,{children:[r.reminderNpm.replace(`{{version}}`,i.version),i.channel&&i.channel!==`latest`?` (${i.channel})`:``]}),(0,$.jsxs)(`button`,{type:`button`,onClick:p,disabled:c,className:`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,children:[c?(0,$.jsx)(Fv,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Lb,{className:`size-3 shrink-0`,"aria-hidden":!0}),c?r.updateRunning:r.updateNow]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:h,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(Sk,{className:`size-4`})})]}):null}function dle(e,t,n){let r=m(e),i=r.commandPalette.actions,a=r.commandPalette.groups.actions;return[{kind:`action`,id:`action:automation:create`,title:`Create automation`,subtitle:`Open automations to create a trigger and action`,groupLabel:a,keywords:[`automation`,`schedule`,`trigger`,`action`,`timer`],run:()=>{n(),t(`/automations?action=create`)}},{kind:`action`,id:`action:automation:manage`,title:`Manage automations`,subtitle:`View automations and run history`,groupLabel:a,keywords:[`automation`,`schedule`,`tasks`,`runs`],run:()=>{n(),t(`/automations`)}},{kind:`action`,id:`action:skills:manage`,title:i.manageSkills,subtitle:i.manageSkillsSubtitle,groupLabel:a,keywords:[`skills`,`skill`,`catalog`],run:()=>{n(),t(`/skills`)}},{kind:`action`,id:`action:skills:reload`,title:i.reloadSkills,subtitle:i.reloadSkillsSubtitle,groupLabel:a,keywords:[`skills`,`reload`,`refresh`],run:()=>{n(),c(async()=>{let{reloadSkills:e}=await import(`./skill-reload-api-C44tGvK7.js`).then(e=>e.n);return{reloadSkills:e}},__vite__mapDeps([22,1,11,3,2,4,12])).then(({reloadSkills:e})=>e())}}]}function X2(e){return m(e).commandPalette.groups}function fle(e){let t=X2(e);return{[t.navigate]:0,[t.projects]:1,[t.quickSettings]:2,[t.extensions]:3,[t.sessions]:4,[t.files]:5,[t.commands]:6,[t.skills]:7,[t.actions]:8}}function ple(e){let t=X2(e);return{[t.navigate]:12,[t.projects]:8,[t.quickSettings]:12,[t.actions]:8,[t.extensions]:8,[t.sessions]:8,[t.files]:10,[t.commands]:6,[t.skills]:6}}function Z2(e,t){return fle(e)[t]??10}function Q2(e){return e.trim().toLowerCase()}function mle(e,t){let n=Q2(e),r=Q2(t);if(!r)return 0;if(!n)return null;if(n===r)return 0;if(n.startsWith(r))return 1;let i=n.indexOf(r);return i>=0?2+Math.min(i,50)/100:null}function hle(e,t){let n=t.trim();if(!n)return 0;let r=[{text:e.title,weight:1},{text:e.subtitle??``,weight:1.75}];for(let t of e.keywords??[])r.push({text:t,weight:1.25});let i=null;for(let e of r){let t=mle(e.text,n);if(t===null)continue;let r=t*e.weight;i=i===null?r:Math.min(i,r)}if(i===null)return null;let a=e.kind===`route`?-.15:e.kind===`project`?-.12:e.kind===`file`?-.1:e.kind===`session`?-.05:e.kind===`setting`||e.kind===`action`?-.02:0;return Math.max(0,i+a)}function gle(e){return e.toSorted((e,t)=>e.rank===t.rank?e.groupLabel===t.groupLabel?e.title.localeCompare(t.title):e.groupLabel.localeCompare(t.groupLabel):e.rank-t.rank)}var _le=new Set([`settingsTunnel`,`settingsShares`,`settingsHeartbeat`,`settingsGoals`,`settingsDreams`,`logs`]),vle=[`/settings/remote-access`,`/settings/tunnel`,`/settings/shares`,`/settings/heartbeat`,`/settings/goals`,`/settings/dreams`,`/settings/logs`,`/settings/extensions/debug`,`/settings/ext/`];function $2(e,t){return t===`advanced`?!0:!_le.has(e)}function e4(e,t){return t===`advanced`?!0:!vle.some(t=>e===t||e.startsWith(t))}var t4=`/channels`;function n4(e){return`${t4}/${encodeURIComponent(e.trim().toLowerCase())}`}function yle(e){return e?.trim().toLowerCase()||null}var r4=h(b(e=>({mode:`simple`,setMode:t=>e({mode:t}),setShowAdvanced:t=>e({mode:t?`advanced`:`simple`})}),{name:`xopc-web-settings-mode`}));function ble(){return r4(xle)}function xle(e){return e.mode===`advanced`}var Sle=[`settingsUserProfile`,`settingsAgentBrowser`],Cle={settingsUserProfile:[`user`,`profile`,`preferences`,`timezone`],settingsAgentBrowser:[`browser`,`playwright`,`automation`]};function wle(e,t){let n=m(e).commandPalette.routes.agentsSubtitle;return Sle.filter(e=>$2(e,t)).map(t=>({id:`route:settings:agent:${t}`,title:p(e,t),subtitle:n,path:Zj(t),keywords:[`agent`,`manifest`,`preset`,`config`,...Cle[t]??[]]}))}function Tle(e,t){return e.filter(e=>e4(e.path.split(`?`)[0]??e.path,t))}function Ele(e){let t=m(e),n=t.commandPalette.routes,r=t.channelsSettings,i=r4.getState().mode;return Tle([{id:`route:chat`,title:t.nav.chat,subtitle:n.chatSubtitle,path:`/chat`,keywords:[`chat`,`new`,`compose`,`assistant`]},{id:`route:agents`,title:t.nav.agents,subtitle:n.agentsSubtitle,path:`/agents`,keywords:[`agent`,`persona`,`switch`]},{id:`route:extensions`,title:t.nav.extensions,subtitle:n.extensionsSubtitle,path:`/extensions`,keywords:[`extension`,`plugin`,`addon`]},{id:`route:sessions`,title:t.nav.sessions,subtitle:n.sessionsSubtitle,path:`/settings/sessions`,keywords:[`history`,`archive`,`pin`]},{id:`route:logs`,title:t.nav.logs,subtitle:n.logsSubtitle,path:`/settings/logs`,keywords:[`debug`,`errors`]},{id:`route:skills`,title:t.nav.skills,subtitle:n.skillsSubtitle,path:`/skills`,keywords:[`tools`,`catalog`]},{id:`route:connectors`,title:t.nav.connectors,subtitle:n.connectorsSubtitle,path:`/connectors`,keywords:[`connector`,`mcp`,`registry`,`integration`,`tools`]},{id:`route:channels`,title:t.nav.channels,subtitle:n.channelsSubtitle,path:`/channels`,keywords:[`telegram`,`weixin`,`feishu`,`channel`]},{id:`route:channels:telegram`,title:`Telegram`,subtitle:n.channelsSubtitle,path:n4(`telegram`),keywords:[`telegram`,`bot`,`channel`,`pairing`]},{id:`route:channels:weixin`,title:`Weixin`,subtitle:n.channelsSubtitle,path:n4(`weixin`),keywords:[`weixin`,`wechat`,`channel`,`qr`]},{id:`route:channels:feishu`,title:`Feishu/Lark`,subtitle:n.channelsSubtitle,path:n4(`feishu`),keywords:[`feishu`,`lark`,`channel`]},{id:`route:channels:telegram:pairing`,title:`Telegram — ${r.hubPairingButton}`,subtitle:n.channelsSubtitle,path:n4(`telegram`),keywords:[`telegram`,`pairing`,`approve`,`dm`]},{id:`route:automations`,title:`Automations`,subtitle:`Triggers, actions, and run history`,path:`/automations`,keywords:[`automation`,`automations`,`schedule`,`tasks`,`history`,`scheduler`]},{id:`route:settings:goals`,title:t.nav.settingsGoals,subtitle:n.goalsSettingsSubtitle,path:`/settings/goals`,keywords:[`goal`,`checklist`,`judge`,`/goal`,`automation`]},{id:`route:settings:dreams`,title:t.nav.settingsDreams,subtitle:n.dreamsSettingsSubtitle,path:`/settings/dreams`,keywords:[`dream`,`memory`,`consolidation`,`automation`]},{id:`route:settings`,title:t.nav.settings,subtitle:n.settingsSubtitle,path:`/settings/overview`,keywords:[`config`,`status`,`providers`,`models`,`agents`,`search`,`preferences`]},{id:`route:settings:credentials`,title:t.nav.settingsCredentials,subtitle:n.credentialsSubtitle,path:`/settings/credentials`,keywords:[`api`,`key`,`credentials`,`oauth`,`token`,`models`,`providers`]},{id:`route:settings:providers`,title:t.nav.settingsProviders,subtitle:n.providersSubtitle,path:`/settings/credentials?tab=services`,keywords:[`api`,`key`,`openai`,`anthropic`,`google`]},{id:`route:settings:models`,title:t.nav.settingsModels,subtitle:n.modelsSubtitle,path:`/settings/credentials?tab=services`,keywords:[`gpt`,`claude`,`gemini`,`llm`]},{id:`route:settings:image-models`,title:t.nav.settingsImageModels,subtitle:n.imageModelsSubtitle,path:`/settings/credentials?tab=image-models`,keywords:[`image`,`vision`,`generate`,`picture`]},{id:`route:settings:voice`,title:t.nav.settingsVoice,subtitle:n.voiceSubtitle,path:`/settings/credentials?tab=voice`,keywords:[`tts`,`stt`,`speech`,`microphone`]},{id:`route:settings:search`,title:t.nav.settingsSearch,subtitle:n.searchSubtitle,path:`/settings/credentials?tab=search`,keywords:[`search`,`web`,`tavily`,`serper`,`brave`]},{id:`route:settings:gateway`,title:t.nav.settingsGateway,subtitle:n.gatewaySubtitle,path:`/settings/gateway`,keywords:[`server`,`port`,`auth`,`token`]},...wle(e,i)],i)}async function Dle(e,t={}){let n=new URLSearchParams;return n.set(`q`,e.trim()),t.types?.length&&n.set(`types`,t.types.join(`,`)),t.limit&&n.set(`limit`,String(t.limit)),(await J(X(`/api/search?${n.toString()}`))).hits}function i4(e){x.getState().setPreference(e)}function a4(e){_.getState().setLanguage(e)}function Ole(e,t){let n=m(e),r=n.commandPalette.quickSettings,i=n.commandPalette.groups.quickSettings;return[{kind:`setting`,id:`setting:model`,title:r.switchModel,subtitle:r.switchModelSubtitle,groupLabel:i,keywords:[`model`,`default model`,`默认模型`,`gpt`,`claude`,`gemini`,`llm`,`模型`],run:()=>t.openModelPalette()},{kind:`setting`,id:`setting:agent`,title:r.switchAgent,subtitle:r.switchAgentSubtitle,groupLabel:i,keywords:[`agent`,`persona`,`bot`],run:()=>t.openAgentPalette()},{kind:`setting`,id:`setting:theme:light`,title:r.themeLight,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`light`,`appearance`],run:()=>{i4(`light`),t.closePalette()}},{kind:`setting`,id:`setting:theme:dark`,title:r.themeDark,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`dark`,`night`],run:()=>{i4(`dark`),t.closePalette()}},{kind:`setting`,id:`setting:theme:system`,title:r.themeSystem,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`system`,`auto`],run:()=>{i4(`system`),t.closePalette()}},{kind:`setting`,id:`setting:lang:en`,title:r.languageEn,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`english`,`language`,`locale`],run:()=>{a4(`en`),t.closePalette()}},{kind:`setting`,id:`setting:lang:zh`,title:r.languageZh,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`chinese`,`中文`,`language`],run:()=>{a4(`zh`),t.closePalette()}}]}function kle(e){let t=e===`zh`;return[{id:`field:gateway:port`,title:t?`网关端口`:`Gateway Port`,subtitle:t?`设置 HTTP 网关监听端口`:`HTTP gateway listen port`,path:`/settings/gateway`,keywords:[`port`,`listen`,`http`,`server`,`端口`]},{id:`field:gateway:host`,title:t?`网关绑定地址`:`Gateway Host`,subtitle:t?`设置绑定的网络接口`:`Network interface to bind`,path:`/settings/gateway`,keywords:[`host`,`bind`,`interface`,`localhost`,`地址`]},{id:`field:gateway:auth`,title:t?`网关认证令牌`:`Gateway Auth Token`,subtitle:t?`访问网关所需的 Bearer token`:`Bearer token for gateway access`,path:`/settings/gateway`,keywords:[`auth`,`token`,`bearer`,`password`,`security`,`认证`,`令牌`]},{id:`field:agent:model`,title:t?`Agent 模型配置`:`Agent model configuration`,subtitle:t?`配置智能体的模型角色与回退模型`:`Configure agent model roles and fallbacks`,path:`/agents`,keywords:[`agent model`,`model roles`,`llm`,`gpt`,`claude`,`gemini`,`智能体模型`,`模型角色`]},{id:`field:agent:temperature`,title:t?`温度 (Temperature)`:`Temperature`,subtitle:t?`控制回复的随机性`:`Controls response randomness`,path:`/agents`,keywords:[`temperature`,`sampling`,`randomness`,`creative`,`温度`,`随机`]},{id:`field:agent:maxTokens`,title:t?`最大输出 Tokens`:`Max Output Tokens`,subtitle:t?`单次回复的最大 token 数`:`Maximum tokens per response`,path:`/agents`,keywords:[`max`,`tokens`,`output`,`length`,`limit`,`最大`]},{id:`field:agent:workspace`,title:t?`工作目录`:`Workspace Directory`,subtitle:t?`代理的默认工作目录`:`Default working directory for the agent`,path:`/agents`,keywords:[`workspace`,`directory`,`folder`,`path`,`cwd`,`工作目录`]},{id:`field:agent:browser`,title:t?`浏览器自动化`:`Browser automation`,subtitle:t?`启用 browser_use 工具`:`Enable browser_use tools`,path:`/agents`,keywords:[`browser`,`browser_use`,`automation`,`浏览器`]},{id:`field:agent:browser-extension`,title:t?`Chrome 扩展连接`:`Chrome extension bridge`,subtitle:t?`安装扩展并启动 WebSocket 桥接`:`Install extension and start the bridge`,path:`/agents`,keywords:[`extension`,`chrome`,`bridge`,`websocket`,`扩展`,`桥接`]},{id:`field:agent:browser-playwright`,title:t?`安装 Playwright Chromium`:`Install Playwright Chromium`,subtitle:t?`本地 Playwright 后端就绪检查`:`Local Playwright backend setup`,path:`/agents`,keywords:[`playwright`,`chromium`,`install`,`local`,`安装`]},{id:`field:agent:browser-cloak`,title:t?`CloakBrowser 配置`:`CloakBrowser settings`,subtitle:t?`反指纹浏览器下载与高级选项`:`Stealth browser download and fingerprint options`,path:`/agents`,keywords:[`cloak`,`cloakbrowser`,`fingerprint`,`stealth`,`反指纹`]},{id:`field:agent:browser-headless`,title:t?`浏览器无头模式`:`Browser headless mode`,subtitle:t?`隐藏浏览器窗口`:`Run without a visible window`,path:`/agents`,keywords:[`headless`,`window`,`visible`,`无头`]},{id:`field:agent:browser-private-urls`,title:t?`允许内网 URL`:`Allow private URLs`,subtitle:t?`浏览器导航安全限制`:`Browser navigation security policy`,path:`/agents`,keywords:[`private`,`internal`,`localhost`,`security`,`内网`,`安全`]},{id:`field:agent:turnLimit`,title:t?`轮次限制`:`Turn Limit`,subtitle:t?`单次会话最大对话轮次`:`Maximum turns per session run`,path:`/agents`,keywords:[`turn`,`limit`,`iterations`,`max`,`轮次`,`限制`]},{id:`field:agent:timeout`,title:t?`超时时间`:`Timeout`,subtitle:t?`单次工具调用的超时`:`Tool execution timeout`,path:`/agents`,keywords:[`timeout`,`duration`,`seconds`,`超时`]},{id:`field:agent:compaction`,title:t?`上下文压缩`:`Context Compaction`,subtitle:t?`长对话自动压缩策略`:`Auto-compact strategy for long conversations`,path:`/agents`,keywords:[`compaction`,`context`,`pruning`,`tokens`,`window`,`压缩`,`上下文`]},{id:`field:agent:memory`,title:t?`记忆设置`:`Memory Settings`,subtitle:t?`会话记忆与回顾配置`:`Session memory and review configuration`,path:`/agents`,keywords:[`memory`,`review`,`session`,`recall`,`记忆`]},{id:`field:agent:systemPrompt`,title:t?`系统提示词`:`System Prompt`,subtitle:t?`自定义系统指令`:`Custom system instructions`,path:`/agents`,keywords:[`system`,`prompt`,`instructions`,`persona`,`系统提示词`,`指令`]},{id:`field:voice:sttProvider`,title:t?`STT 语音识别提供商`:`STT Provider`,subtitle:t?`语音转文字服务商`:`Speech-to-text service provider`,path:`/settings/credentials?tab=voice`,keywords:[`stt`,`speech`,`recognition`,`whisper`,`deepgram`,`语音识别`]},{id:`field:voice:ttsProvider`,title:t?`TTS 语音合成提供商`:`TTS Provider`,subtitle:t?`文字转语音服务商`:`Text-to-speech service provider`,path:`/settings/credentials?tab=voice`,keywords:[`tts`,`speech`,`synthesis`,`voice`,`elevenlabs`,`语音合成`]},{id:`field:search:engine`,title:t?`搜索引擎`:`Web Search Engine`,subtitle:t?`联网搜索使用的引擎`:`Engine for web search tool`,path:`/settings/credentials?tab=search`,keywords:[`search`,`engine`,`tavily`,`serper`,`brave`,`bing`,`搜索引擎`]},{id:`field:automations:enabled`,title:t?`自动化`:`Automations`,subtitle:t?`创建和管理自动化`:`Create and manage automations`,path:`/automations`,keywords:[`automation`,`automations`,`scheduler`,`timer`,`自动化`,`调度`]},{id:`field:automations:runs`,title:t?`自动化运行记录`:`Automation Runs`,subtitle:t?`查看自动化执行历史`:`Review automation run history`,path:`/automations`,keywords:[`automation`,`runs`,`history`,`自动化`,`历史`]},{id:`field:channels:telegram`,title:`Telegram Bot Token`,subtitle:t?`配置 Telegram 频道连接`:`Configure Telegram channel connection`,path:`/channels`,keywords:[`telegram`,`bot`,`token`,`channel`,`频道`]},{id:`field:channels:dmPolicy`,title:t?`私聊接入策略`:`DM Access Policy`,subtitle:t?`Telegram 私聊白名单/配对策略`:`Telegram DM allowlist/pairing policy`,path:`/channels`,keywords:[`dm`,`policy`,`pairing`,`allowlist`,`access`,`私聊`,`策略`]},{id:`field:mcp:servers`,title:t?`MCP 服务器配置`:`MCP Servers`,subtitle:t?`外部 MCP 工具服务器列表`:`External MCP tool server registry`,path:`/connectors`,keywords:[`mcp`,`server`,`tools`,`external`,`stdio`,`服务器`,`connector`]},{id:`field:heartbeat:interval`,title:t?`心跳间隔`:`Heartbeat Interval`,subtitle:t?`网关存活检测频率`:`Gateway keep-alive check frequency`,path:`/settings/heartbeat`,keywords:[`heartbeat`,`interval`,`keepalive`,`alive`,`心跳`]},{id:`field:tunnel:enabled`,title:t?`公网隧道`:`Public Tunnel`,subtitle:t?`FRP 远程访问隧道开关`:`FRP remote access tunnel toggle`,path:`/settings/remote-access`,keywords:[`tunnel`,`frp`,`remote`,`public`,`ngrok`,`隧道`,`远程`]}]}function Ale(e,t,n,r){return kle(e).map(e=>({kind:`setting`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:r,keywords:e.keywords,run:()=>{n(),t(e.path)}}))}async function o4(e){let t=await e.json().catch(()=>({}));if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;if(typeof e==`string`)return e}return`HTTP ${e.status}`}async function s4(){let e=await Y(X(`/api/skills`),{cache:`no-store`});if(!e.ok)throw Error(await o4(e));let t=await e.json();if(!t.payload)throw Error(`Invalid response`);return t.payload}var c4=`[a-zA-Z0-9](?:[a-zA-Z0-9._-]{0,62})`,jle=RegExp(`\\/skill:(${c4})`,`g`);function l4(){return new RegExp(jle.source,`g`)}var Mle=RegExp(`(\\/skill:${c4})$`),Nle=RegExp(`(\\/skill:${c4})([ \\t\\f\\v]*)$`),Ple=RegExp(`^${c4}$`);function Fle(e){return Ple.test(e.trim())}var Ile=RegExp(`^\\/skill:(${c4})`),u4=[],d4=new Map;function f4(e){let t=new Set;for(let n of e??[]){n?.name&&t.add(n.name);for(let e of n.aliases??[])typeof e==`string`&&e.length>0&&t.add(e)}u4=Array.from(t).toSorted((e,t)=>t.length-e.length).map(e=>({key:e})),d4.clear()}function Lle(e,t){if(t>=e.length)return!0;let n=e[t];return!/[a-zA-Z0-9_-]/.test(n)}function Rle(e,t){return!(e[t]!==`/`||t>0&&!/\s/.test(e[t-1]))}function p4(e,t){if(!Rle(e,t)||u4.length===0)return null;let n=e.slice(t);if(n.startsWith(`/skill:`))return null;for(let{key:e}of u4){let t=`/${e}`;if(n.startsWith(t)&&Lle(n,t.length))return{len:t.length,matchedKey:e}}return null}function m4(e){let t=[],n=0;for(;n<e.length;){if(e[n]!==`/`){n+=1;continue}let r=e.slice(n).match(Ile);if(r?.[0]){n+=r[0].length;continue}let i=p4(e,n);i?(t.push({start:n,end:n+i.len}),n+=i.len):n+=1}return t}function zle(e){for(let t=e.length-1;t>=0;--t){if(e[t]!==`/`||e.startsWith(`/skill:`,t))continue;let n=p4(e,t);if(n&&t+n.len===e.length)return!0}return!1}function Ble(e){if(!e.startsWith(`/`)||u4.length===0||e.startsWith(`/skill:`))return!1;let t=p4(e,0);return t?e.length===t.len||!/[a-zA-Z0-9_-]/.test(e[t.len]):!1}function Vle(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Hle(e){let t=d4.get(e);return t||(t=RegExp(`(${Vle(e)})([ \\t\\f\\v]*)$`),d4.set(e,t)),t}function Ule(e){for(let{key:t}of u4){let n=`/${t}`;if(!e.endsWith(n))continue;let r=e.length-n.length;if(p4(e,r))return{tokenStart:r}}return null}function Wle(e){for(let{key:t}of u4){let n=`/${t}`,r=e.match(Hle(n));if(!r)continue;let i=e.length-r[0].length;if(p4(e,i))return{tokenStart:i}}return null}async function h4(e){let t=await e.json().catch(()=>({}));if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;if(typeof e==`string`)return e}return`HTTP ${e.status}`}async function Gle(){let e=await Y(X(`/api/commands`));if(!e.ok)throw Error(await h4(e));return(await e.json()).payload?.commands??[]}var g4=6e4,_4=null,v4=0,y4=null,b4=null,x4=0,S4=null,C4=0,w4=new Map,T4=new Map,E4=0;async function D4(e=!1){return!e&&_4&&Date.now()<v4?(f4(_4),_4):y4||(y4=Gle().then(e=>(_4=e,v4=Date.now()+g4,f4(e),e)).catch(e=>{throw f4([]),e}).finally(()=>{y4=null}),y4)}async function O4(e,t=!1){let n=e?.trim()||`main`,r=Date.now(),i=w4.get(n);if(!t&&i&&r<i.expiry)return i.payload;let a=T4.get(n);if(a)return a;let o=E4,s=Y(X(`/api/chat/skills?agentId=${encodeURIComponent(n)}`)).then(async e=>{if(!e.ok)throw Error(await h4(e));let t=await e.json();if(!t.payload||!Array.isArray(t.payload.skills))throw Error(`Invalid /api/chat/skills response`);return o===E4&&w4.set(n,{payload:t.payload,expiry:Date.now()+g4}),t.payload}).finally(()=>{T4.delete(n)});return T4.set(n,s),s}async function Kle(e,t){let n=e?.trim()||`main`,r=await O4(n,!0),i=new Set(r.effectiveAllowlist??r.agentAllowlist??[]);i.add(t);let a=await Y(X(`/api/agents/${encodeURIComponent(n)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skills:[...i].sort((e,t)=>e.localeCompare(t))})});if(!a.ok)throw Error(await h4(a));k4(n)}function k4(e){if(E4+=1,e){w4.delete(e),T4.delete(e);return}w4.clear(),T4.clear()}function qle(e){k4(e),e||(C4+=1,b4=null,x4=0,S4=null)}async function Jle(e=!1){if(!e&&b4&&Date.now()<x4)return b4;if(S4)return S4;let t=C4;return S4=s4().then(e=>(t===C4&&(b4=e,x4=Date.now()+g4),e)).finally(()=>{S4=null}),S4}var A4=`fill-chat-composer`;function j4(e){window.dispatchEvent(new CustomEvent(A4,{detail:{text:e}}))}function M4(e){return e.acceptsArgs?`/${e.name} `:`/${e.name}`}var Yle=3e4,N4=null;function P4(e){return e.trim()}function Xle(e){return e.map(e=>({name:e.name,relativePath:e.path,isDirectory:e.isDirectory}))}async function F4(e,t){let n=t.sessionKey?.trim(),r=t.agentId?.trim(),i=t.limit??15,a=e.trim(),o=new URLSearchParams;if(o.set(`q`,a),o.set(`limit`,String(i)),n?o.set(`sessionKey`,n):r&&o.set(`agentId`,r),n&&a.length===0){let e=P4(n),t=Date.now();if(N4&&N4.key===e&&t-N4.at<Yle)return N4.items}let s=Xle((await J(X(`/api/workspace/editor/files/search?${o.toString()}`))).payload.entries??[]);return n&&a.length===0&&(N4={key:P4(n),at:Date.now(),items:s}),s}async function Zle(e,t){return Mq(e,{sessionKey:t.sessionKey,agentId:t.agentId})}function I4(e){let t=typeof e.profileDir==`string`?e.profileDir.trim():``,n=e.typedModels?.preset??[],r=e.typedModels?.entry,i=e.typedModels?.effective??n;return{...e,profileDir:t,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{},skills:e.skills?{...e.skills,preset:e.skills.preset??[]}:{preset:[]},tools:e.tools?{...e.tools,presetDenied:e.tools.presetDenied??[]}:{presetDenied:[],entryDisable:[],effectiveDisable:[]},typedModels:{defaultRole:e.typedModels.defaultRole,preset:n,...r===void 0?{}:{entry:r},effective:i},extends:Array.isArray(e.extends)?e.extends:[]}}async function L4(){let e=(await J(X(`/api/agents`))).payload;if(!e?.defaultId||!Array.isArray(e.agents))throw Error(`Invalid /api/agents response`);let t=Array.isArray(e.builtinToolIds)?e.builtinToolIds:[];return{defaultId:e.defaultId,agents:e.agents.map(I4),builtinToolIds:t}}async function Qle(e){let t=await J(X(`/api/agents/${encodeURIComponent(e)}/effective-manifest`));if(!t.payload?.manifest||typeof t.payload.sources!=`object`||t.payload.sources===null)throw Error(`Invalid /api/agents/:id/effective-manifest response`);return t.payload}async function $le(e){let t=await J(X(`/api/agents`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=typeof t.payload?.agentId==`string`?t.payload.agentId.trim():``,r=t.payload?.agents;if(!n||!r?.defaultId||!Array.isArray(r.agents))throw Error(`Invalid create agent response`);return{createdAgentId:n,defaultId:r.defaultId,agents:r.agents.map(I4),builtinToolIds:Array.isArray(r.builtinToolIds)?r.builtinToolIds:[]}}async function eue(e,t){let n=(await J(X(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).payload;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid update agent response`);return{defaultId:n.defaultId,agents:n.agents.map(I4),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}async function tue(e,t){let n=(await J(X(`/api/agents/${encodeURIComponent(e)}${t?`?purge=true`:``}`),{method:`DELETE`})).payload?.agents;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid delete agent response`);return{defaultId:n.defaultId,agents:n.agents.map(I4),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}async function nue(e){await J(X(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({tui:{defaultAgent:e}})}),hI()}function rue(e){if(!e||typeof e!=`object`||!(`bindings`in e))return[];let t=e.bindings;return Array.isArray(t)?t:[]}async function iue(e){await J(X(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({bindings:e})}),hI()}async function aue(){let e=(await J(X(`/api/skills`))).payload?.catalog;return Array.isArray(e)?e:[]}async function oue(e){let t=(await J(X(`/api/agents/${encodeURIComponent(e)}/files`))).payload,n=typeof t?.profileDir==`string`?t.profileDir.trim():``;if(!t?.files||!n)throw Error(`Invalid files list response`);return{agentId:t.agentId,profileDir:n,files:t.files}}async function sue(e,t){let n=(await J(X(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`))).payload?.content;if(typeof n!=`string`)throw Error(`Invalid file content response`);return n}async function cue(e,t,n){await J(X(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})}async function R4(){let e=(await J(X(`/api/user-profile`))).payload?.content;if(typeof e!=`string`)throw Error(`Invalid user profile response`);return e}async function z4(e){await J(X(`/api/user-profile`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:e})})}function lue(e){let t=e.type.toLowerCase();return t===`image/png`||t===`image/jpeg`||t===`image/jpg`||t===`image/webp`?t===`image/jpg`?`image/jpeg`:t:null}function uue(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=String(r.result??``),n=e.indexOf(`,`);t(n>=0?e.slice(n+1):``)},r.onerror=()=>n(r.error??Error(`read failed`)),r.readAsDataURL(e)})}async function due(e,t){let n=lue(t);if(!n)throw Error(`unsupported_image_type`);if(t.size===0||t.size>512*1024)throw Error(`avatar_too_large`);let r=await uue(t);if(!r)throw Error(`empty_file`);await J(X(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({base64:r,mimeType:n})})}async function fue(e){await J(X(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`DELETE`})}var B4=`main`;function V4(e,t){return e.name?.trim()||(e.id.trim().toLowerCase()===B4?t.defaultMainAgentName:e.id)}function H4(e,t){return e.description?.trim()||(e.id.trim().toLowerCase()===B4?t.defaultMainAgentDescription:``)}var pue=500,U4=null,W4;function G4(e){W4=e,U4!==null&&clearTimeout(U4),U4=setTimeout(()=>{U4=null;let e=W4;W4=void 0,window.dispatchEvent(new CustomEvent(`config-reload`,{detail:e}))},pue)}function mue(){let{pathname:e}=_r(),{sessionKey:t}=wr();if(!e.startsWith(`/chat`)||!t)return;let n=decodeURIComponent(t);return n&&n!==`new`?n:void 0}function K4(e){return{models:{defaultRole:`deep`,roles:{deep:{model:e}}}}}function q4(e,t,n,r){let i=e.trim().toLowerCase();if(i){try{globalThis.localStorage?.setItem(GL,i)}catch{}t.startsWith(`/chat`)?window.dispatchEvent(new CustomEvent(`xopc-set-chat-agent`,{detail:{agentId:i}})):n(`/chat/new`,{state:{agentId:i}}),r()}}function hue(e){switch(e.kind){case`extension`:return(0,$.jsx)($y,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`route`:return(0,$.jsx)(__,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`project`:return(0,$.jsx)(p_,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`session`:return(0,$.jsx)(__,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`file`:return(0,$.jsx)(Eg,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`command`:return(0,$.jsx)(sE,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`skill`:return(0,$.jsx)(SC,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});case`setting`:return(0,$.jsx)(uS,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`action`:return(0,$.jsx)(wk,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});default:return null}}function J4(e,t,n,r){if(r(),t.startsWith(`/chat`)){j4(e);return}let i=e.match(/^\/skill:(\S+)\s*$/),a=e.match(/^\/(\S+)\s*$/);i?n(`/chat/new?skill=${encodeURIComponent(i[1])}`):a?n(`/chat/new?slash=${encodeURIComponent(a[1])}`):(n(`/chat/new`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{j4(e)})}))}function gue(e){let t=[];for(let n of e.uiExtensions){let r=n.ui?.contributions?.commands;if(Array.isArray(r))for(let i of r)!i||typeof i.id!=`string`||typeof i.title!=`string`||t.push({kind:`extension`,id:`ext:${n.id}:${i.id}`,title:i.title,subtitle:n.name,groupLabel:e.extensionsGroupLabel,keywords:[n.id,n.name,i.id],run:()=>{e.close(),i.opensPanel!==void 0&&i.opensPanel!==``?e.navigate(`/extensions/${encodeURIComponent(n.id)}`):window.dispatchEvent(new CustomEvent(`extension-command`,{detail:{extensionId:n.id,commandId:i.id}}))}})}return t}function _ue(e,t){switch(t.type){case`setQuery`:return{...e,query:t.value};case`setSelectedIndex`:{let n=typeof t.value==`function`?t.value(e.selectedIndex):t.value;return{...e,selectedIndex:n}}case`setLayer`:return{...e,paletteLayer:t.layer,query:``,selectedIndex:0};case`resetMain`:return{query:``,selectedIndex:0,paletteLayer:`main`}}}var vue={query:``,selectedIndex:0,paletteLayer:`main`};async function yue(){let e=await J(X(`/api/registry`)),t=[];for(let n of e.payload?.providers??[])for(let e of n.models??[])e.available!==!1&&t.push({id:e.ref,title:e.name||e.ref,subtitle:e.ref});return t.sort((e,t)=>e.title.localeCompare(t.title)),t}async function bue(e){let t=await L4(),n=m(e).agentsSettings;return t.agents.map(e=>({id:e.id,title:V4(e,n),subtitle:e.id}))}function xue({onClose:e}){let t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),r=br(),{pathname:i}=_r(),a=_(e=>e.language),o=BF(),s=mue(),c=b1(e=>e.agentId),l=k1(e=>e.setPath),[u,d]=(0,Z.useReducer)(_ue,vue),[f,p]=(0,Z.useState)(0),{query:h,selectedIndex:g,paletteLayer:v}=u,y=(0,Z.useMemo)(()=>Ele(a),[a]),[b]=XQ(h,120);(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&t.section===`skills`&&p(e=>e+1)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[]);let x=(0,Z.useCallback)(()=>{d({type:`setLayer`,layer:`models`})},[]),S=(0,Z.useCallback)(()=>{d({type:`setLayer`,layer:`agents`})},[]),C=lP(async()=>v===`models`?yue():v===`agents`?bue(a):[],[v,a],{enabled:v===`models`||v===`agents`,initial:[],errorData:[]}),w=lP(async()=>{let t=b.trim(),n=e,u=m(a).commandPalette.groups,d=y.map(e=>({kind:`route`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:u.navigate,keywords:[...e.keywords??[],e.path],run:()=>{n(),r(e.path)}})),f=Ole(a,{closePalette:n,openModelPalette:x,openAgentPalette:S}),p=dle(a,r,n),h=gue({query:t,close:n,navigate:r,uiExtensions:o,extensionsGroupLabel:u.extensions}),[g,_,v,C,w]=await Promise.all([D4(),Jle(),t?Dle(t,{types:[`project`],limit:8}).catch(()=>[]):[],CK({search:t||void 0,limit:8,offset:0}).catch(()=>({items:[]})),(async()=>{let e=s?.trim(),n=c.trim();return!e&&!n?[]:await F4(t,{sessionKey:e||void 0,agentId:e?void 0:n||void 0,limit:10}).catch(()=>[])})()]),T=v.map(e=>({kind:`project`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:u.projects,keywords:[e.payload.project.slug,e.payload.project.workspaceRoot??``,e.payload.project.defaultAgentId??``,e.payload.project.brief??``],run:()=>{n(),r(e.href)}})),E=g.map(e=>({kind:`command`,id:`cmd:${e.id}`,title:`/${e.name}`,subtitle:e.description,groupLabel:u.commands,keywords:[e.id,...e.aliases??[],e.category??``],run:()=>{J4(M4(e),i,r,n)}})),D=_.catalog.flatMap(e=>!e.enabled||e.disableModelInvocation?[]:[{kind:`skill`,id:`skill:${e.name}`,title:`/skill:${e.name}`,subtitle:e.description,groupLabel:u.skills,keywords:[e.source??``,`skill`],run:()=>{J4(`/skill:${e.name} `,i,r,n)}}]),O=(C.items??[]).map(e=>({kind:`session`,id:`session:${e.key}`,title:e.name?.trim()||e.key,subtitle:e.key,groupLabel:u.sessions,keywords:[e.key,...e.tags??[],e.sourceChannel??``],run:()=>{n(),r(`/chat/${encodeURIComponent(e.key)}`)}})),k=w.flatMap(e=>e.isDirectory?[]:[{kind:`file`,id:`file:${e.relativePath}`,title:e.name,subtitle:e.relativePath,groupLabel:u.files,keywords:[e.relativePath],run:()=>{n();let t=e.relativePath.replace(/\\/g,`/`).replace(/^\/+/,``),a=()=>l(t);if(i.startsWith(`/chat`)){a();return}r(`/chat`),window.setTimeout(()=>a(),0)}}]),A=Ale(a,r,n,u.navigate),j=[...d,...f,...p,...h,...A,...T,...O,...k,...E,...D],M=[];for(let e of j){let n=hle(e,t);n!==null&&M.push({...e,rank:n})}let N=ple(a),P=gle(M),F=[],I={};for(let e of P){let t=(I[e.groupLabel]??0)+1;if(!(t>(N[e.groupLabel]??6))&&(I[e.groupLabel]=t,F.push(e),F.length>=36))break}return F.sort((e,t)=>Z2(a,e.groupLabel)-Z2(a,t.groupLabel)||e.rank-t.rank||e.title.localeCompare(t.title)),F},[b,y,o,r,s,c,i,l,a,x,S,e,f],{enabled:v===`main`,initial:[],errorData:[]}),T=w.data,E=w.loading,D=w.error,O=(0,Z.useMemo)(()=>{let e=h.trim().toLowerCase(),t=C.data;return e?t.filter(t=>t.title.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||(t.subtitle?.toLowerCase().includes(e)??!1)):t},[C.data,h]),k=`${v}|${h}|${String(O.length)}|${String(T.length)}`,A=(0,Z.useRef)(k);if(A.current!==k){A.current=k;let e=v===`main`?Math.max(0,T.length-1):Math.max(0,O.length);g>e&&d({type:`setSelectedIndex`,value:e})}(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>t.current?.focus(),50);return()=>window.clearTimeout(e)},[]);let j=(0,Z.useEffectEvent)(t=>{if(t.key===`Escape`){if(t.preventDefault(),v!==`main`){d({type:`resetMain`});return}e();return}let n=v===`main`?Math.max(0,T.length-1):Math.max(0,O.length);if(t.key===`ArrowDown`){t.preventDefault(),d({type:`setSelectedIndex`,value:e=>Math.min(e+1,n)});return}if(t.key===`ArrowUp`){t.preventDefault(),d({type:`setSelectedIndex`,value:e=>Math.max(0,e-1)});return}if(t.key===`Enter`){if(t.preventDefault(),v===`models`){if(g===0){d({type:`resetMain`});return}let t=O[g-1];if(!t)return;(async()=>{await J(X(`/api/global-defaults`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(K4(t.id))}),hI(),G4(),e(),d({type:`resetMain`})})();return}if(v===`agents`){if(g===0){d({type:`resetMain`});return}let t=O[g-1];if(!t)return;q4(t.id,i,r,e),d({type:`resetMain`});return}let n=T[g];n&&n.run()}});(0,Z.useEffect)(()=>{let e=e=>{j(e)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,Z.useLayoutEffect)(()=>{let e=n.current;e&&e.querySelector(`[data-global-palette-index="${String(g)}"]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[g,T,v,O.length]);let M=a===`zh`?`返回`:`Back`;if(v===`models`||v===`agents`){let o=O,s=C.loading;return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":a===`zh`?`选择模型或智能体`:`Model or agent picker`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,$.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,$.jsx)(`input`,{ref:t,type:`search`,value:h,onChange:e=>d({type:`setQuery`,value:e.target.value}),placeholder:v===`models`?a===`zh`?`搜索模型…`:`Search models…`:a===`zh`?`搜索智能体…`:`Search agents…`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,$.jsxs)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,children:[(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"data-global-palette-index":0,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-fg-muted`,g===0?`bg-surface-hover`:`hover:bg-surface-muted`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:0}),onClick:()=>d({type:`resetMain`}),children:[`← `,M]})}),s?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`加载中…`:`Loading…`}):o.length===0?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`无结果`:`No results`}):o.map((t,n)=>{let a=n+1;return(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,"data-global-palette-index":a,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,g===a?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-muted`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:a}),onClick:()=>{v===`models`?(async()=>{await J(X(`/api/global-defaults`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(K4(t.id))}),hI(),G4(),e(),d({type:`resetMain`})})():(q4(t.id,i,r,e),d({type:`resetMain`}))},children:(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:t.title}),t.subtitle?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:t.subtitle}):null]})})},t.id)})]})]})})}let N=``;return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Global search`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,$.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,$.jsx)(`input`,{ref:t,type:`search`,value:h,onChange:e=>d({type:`setQuery`,value:e.target.value}),placeholder:a===`zh`?`搜索…(会话 / 文件 / 设置 / 命令)`:`Search… (sessions, files, settings, commands)`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,$.jsx)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,"aria-activedescendant":T[g]?`global-hit-${T[g].id}`:void 0,children:T.length===0?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:E?a===`zh`?`搜索中…`:`Searching…`:D?D instanceof Error?D.message:String(D):a===`zh`?`无结果`:`No results`}):T.map((e,t)=>{let n=e.groupLabel===N?``:e.groupLabel;return N=e.groupLabel,(0,$.jsxs)(`li`,{children:[n?(0,$.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-fg-muted`,children:n}):null,(0,$.jsxs)(`button`,{id:`global-hit-${e.id}`,"data-global-palette-index":t,type:`button`,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,t===g?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-muted`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:t}),onClick:()=>e.run(),children:[(0,$.jsx)(`span`,{className:`mt-0.5`,children:hue(e)}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:e.title}),e.subtitle?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:e.subtitle}):null]})]})]},e.id)})})]})})}function Sue(){let e=(0,Q.c)(7),[t,n]=(0,Z.useState)(!1),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),n(wue))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i);let a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=()=>n(!0);return window.addEventListener(`open-command-palette`,e),()=>window.removeEventListener(`open-command-palette`,e)},o=[],e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,Z.useEffect)(a,o);let s,c;if(e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=()=>n(Cue);return window.addEventListener(`toggle-command-palette`,e),()=>window.removeEventListener(`toggle-command-palette`,e)},c=[],e[4]=s,e[5]=c):(s=e[4],c=e[5]),(0,Z.useEffect)(s,c),!t)return null;let l;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(xue,{onClose:()=>n(!1)}),e[6]=l):l=e[6],l}function Cue(e){return!e}function wue(e){return!e}var Tue=`meta+.`,Eue=h(b(e=>({shortcut:Tue,setShortcut:t=>e({shortcut:t})}),{name:`xopc-quick-capture-shortcut`})),Due={cmd:`meta`,command:`meta`,ctrl:`control`,ctl:`control`,opt:`alt`,option:`alt`};function Oue(e){let t=e.toLowerCase().trim();return Due[t]??t}function kue(e,t){let n=t.split(`+`).map(Oue),r=new Set(n.filter(e=>[`meta`,`control`,`alt`,`shift`].includes(e))),i=n.find(e=>!r.has(e));return!i||r.has(`meta`)!==e.metaKey||r.has(`control`)!==e.ctrlKey||r.has(`alt`)!==e.altKey||r.has(`shift`)!==e.shiftKey?!1:e.key.toLowerCase()===i||e.code.toLowerCase()===i}var Aue=`xopc-attachment`,jue=/^xopc-attachment:\/\/notes\/([^/]+)\/([^/?#]+)$/i,Mue=/^\/api\/notes\/([^/]+)\/media\/([^/?#]+)$/i;function Y4(e,t){return`${Aue}://notes/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function X4(e,t){let n=e.trim();if(!n)return null;let r=n.split(`?`)[0],i=r.match(jue),a=r.match(Mue),o=i??a;if(!o)return null;let s=decodeURIComponent(o[1]),c=decodeURIComponent(o[2]);return t&&s!==t?null:{noteId:s,attachmentId:c}}function Nue(e,t){return`/api/notes/${encodeURIComponent(e)}/media/${encodeURIComponent(t)}`}function Z4(e,t){return Y4(e,t)}function Pue(e){if(e<60)return`Voice · ${e}s`;let t=Math.floor(e/60),n=e%60;return`Voice · ${t}:${String(n).padStart(2,`0`)}`}async function Fue(e){let t=await e.json().catch(()=>({}));return typeof t.error==`string`?t.error:`HTTP ${e.status}`}async function Q4(e,t){let n=q.getState().token,r=new Headers;n&&r.set(`Authorization`,`Bearer ${n}`);let i=await fetch(e,{method:`POST`,headers:r,body:t});if(i.status===401&&q.getState().onUnauthorized(),!i.ok)throw Error(await Fue(i));return i.json()}var $4=new Map,e3=``;function t3(e,t,n){return`${n}:${e}:${t}`}function n3(){let e=q.getState().token??``;if(e!==e3){for(let e of $4.values())e.objectUrl&&URL.revokeObjectURL(e.objectUrl);$4.clear(),e3=e}}async function Iue(e,t){n3();let n=t3(e,t,q.getState().token??``),r=$4.get(n);return r||(r={blob:(async()=>{let n=await Y(X(Nue(e,t)));if(n.status===401&&q.getState().onUnauthorized(),!n.ok)throw Error(`HTTP ${n.status}`);return n.blob()})(),objectUrl:null,refCount:0},$4.set(n,r)),r.blob}async function r3(e,t){n3();let n=t3(e,t,q.getState().token??``),r=$4.get(n);if(r||(r={blob:Iue(e,t),objectUrl:null,refCount:0},$4.set(n,r)),!r.objectUrl){let e=await r.blob;r.objectUrl=URL.createObjectURL(e)}return r.refCount+=1,r.objectUrl}function i3(e,t){n3();let n=t3(e,t,q.getState().token??``),r=$4.get(n);r&&(r.refCount=Math.max(0,r.refCount-1),r.refCount===0&&r.objectUrl&&(URL.revokeObjectURL(r.objectUrl),r.objectUrl=null,$4.delete(n)))}function Lue(e){let t=(0,Q.c)(39),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({src:s,expectedNoteId:r,alt:c,className:n,onClick:i,onLoadFailed:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?``:c,d;t[8]!==r||t[9]!==s?(d=X4(s,r),t[8]=r,t[9]=s,t[10]=d):d=t[10];let f=d,[p,m]=(0,Z.useState)(f?null:s),[h,g]=(0,Z.useState)(!1),_,v;if(t[11]!==a||t[12]!==f||t[13]!==s?(_=()=>{if(g(!1),!f){m(s);return}let e=!1;return m(null),r3(f.noteId,f.attachmentId).then(t=>{e||m(t)}).catch(()=>{e||(g(!0),a?.())}),()=>{e=!0,i3(f.noteId,f.attachmentId)}},v=[s,f,a],t[11]=a,t[12]=f,t[13]=s,t[14]=_,t[15]=v):(_=t[14],v=t[15]),(0,Z.useEffect)(_,v),h){let e;t[16]===n?e=t[17]:(e=u(`flex items-center justify-center bg-surface-hover text-fg-muted`,n),t[16]=n,t[17]=e);let r=!l,i;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(hv,{className:`h-5 w-5`}),t[18]=i):i=t[18];let a;return t[19]!==e||t[20]!==r?(a=(0,$.jsx)(`div`,{className:e,"aria-hidden":r,children:i}),t[19]=e,t[20]=r,t[21]=a):a=t[21],a}if(!p){let e;t[22]===n?e=t[23]:(e=u(`animate-pulse bg-surface-hover`,n),t[22]=n,t[23]=e);let r=!l,i;return t[24]!==e||t[25]!==r?(i=(0,$.jsx)(`div`,{className:e,"aria-hidden":r}),t[24]=e,t[25]=r,t[26]=i):i=t[26],i}let y;t[27]!==p||t[28]!==i?(y=i?()=>i(p):void 0,t[27]=p,t[28]=i,t[29]=y):y=t[29];let b;t[30]===a?b=t[31]:(b=()=>{g(!0),a?.()},t[30]=a,t[31]=b);let x;return t[32]!==l||t[33]!==n||t[34]!==p||t[35]!==o||t[36]!==y||t[37]!==b?(x=(0,$.jsx)(`img`,{...o,src:p,alt:l,className:n,onClick:y,onError:b}),t[32]=l,t[33]=n,t[34]=p,t[35]=o,t[36]=y,t[37]=b,t[38]=x):x=t[38],x}function Rue(e){return e.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^)\s]+)/gi,`/api/notes/$1/media/$2`)}function zue(e,t){let n=[];return e.querySelectorAll(`.markdown-body img`).forEach(e=>{let r=X4(e.getAttribute(`src`)??``,t);if(!r)return;let i=!1;r3(r.noteId,r.attachmentId).then(t=>{i||(e.src=t)}).catch(()=>{e.classList.add(`note-media-load-failed`)}),n.push(()=>{i=!0,i3(r.noteId,r.attachmentId)})}),e.querySelectorAll(`.markdown-body a`).forEach(e=>{let r=X4(e.getAttribute(`href`)??``,t);if(!r)return;let i=document.createElement(`audio`);i.controls=!0,i.className=`note-media-audio mt-2 w-full max-w-md`,e.replaceWith(i);let a=!1;r3(r.noteId,r.attachmentId).then(e=>{a||(i.src=e)}).catch(()=>{i.remove()}),n.push(()=>{a=!0,i3(r.noteId,r.attachmentId)})}),()=>{for(let e of n)e()}}function Bue(e){let t=(0,Q.c)(17),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({content:n,noteId:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(0,Z.useRef)(null),o;t[4]===r?o=t[5]:(o=()=>{let e=a.current;if(e)return zue(e,r)},t[4]=r,t[5]=o);let s;t[6]!==n||t[7]!==r?(s=[n,r],t[6]=n,t[7]=r,t[8]=s):s=t[8],(0,Z.useLayoutEffect)(o,s);let c;t[9]===n?c=t[10]:(c=Rue(n),t[9]=n,t[10]=c);let l;t[11]===i.className?l=t[12]:(l=[`markdown-note`,i.className].filter(Boolean),t[11]=i.className,t[12]=l);let u=l.join(` `),d;return t[13]!==i||t[14]!==c||t[15]!==u?(d=(0,$.jsx)(`div`,{ref:a,children:(0,$.jsx)(gQ,{content:c,...i,className:u})}),t[13]=i,t[14]=c,t[15]=u,t[16]=d):d=t[16],d}async function Vue(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.kind&&t.set(`kind`,e.kind),e.tag&&t.set(`tag`,e.tag),e.pinned!==void 0&&t.set(`pinned`,String(e.pinned)),e.search&&t.set(`search`,e.search),e.limit&&t.set(`limit`,String(e.limit)),e.offset&&t.set(`offset`,String(e.offset)),e.sortBy&&t.set(`sortBy`,e.sortBy),e.sortOrder&&t.set(`sortOrder`,e.sortOrder);let n=t.toString();return J(X(`/api/notes${n?`?${n}`:``}`))}async function a3(e,t=`web`){return(await J(X(`/api/notes/quick-capture`),{method:`POST`,body:JSON.stringify({text:e,channel:t})})).note}async function Hue(e){return(await J(X(`/api/notes`),{method:`POST`,body:JSON.stringify({markdown:e.markdown,title:e.title,kind:e.kind,tags:e.tags,pinned:e.pinned,channel:e.channel??`web`})})).note}async function o3(e){let t=await Y(X(`/api/notes/${encodeURIComponent(e)}`));if(t.status===404)return null;let n=await t.json();if(!t.ok)throw Error(n.error||`HTTP ${t.status}`);return n.note??null}async function s3(e,t){return(await J(X(`/api/notes/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)})).note}async function Uue(e){await J(X(`/api/notes/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Wue(e){return J(X(`/api/notes/${encodeURIComponent(e)}/catalyze`),{method:`POST`})}async function Gue(e,t){return(await J(X(`/api/notes/${encodeURIComponent(e)}/catalysis-feedback`),{method:`POST`,body:JSON.stringify({feedback:t})})).note}async function Kue(e,t={}){return J(X(`/api/notes/${encodeURIComponent(e)}/chat`),{method:`POST`,body:JSON.stringify(t.forceNew?{forceNew:!0}:{})})}async function que(e){return(await J(X(`/api/notes/${encodeURIComponent(e)}/threads`))).items}async function Jue(e){return J(X(`/api/notes/${encodeURIComponent(e)}/context-status`))}async function Yue(e){return J(X(`/api/notes/${encodeURIComponent(e)}/context-rebuild`),{method:`POST`})}async function Xue(e,t,n){return(await J(X(`/api/notes/${encodeURIComponent(e)}/append`),{method:`POST`,body:JSON.stringify({content:t,heading:n})})).note}async function Zue(e,t={}){return(await J(X(`/api/notes/task`),{method:`POST`,body:JSON.stringify({title:e,channel:`web`,priority:t.priority,sourceSessionKey:t.sourceSessionKey||void 0,sourceNoteId:t.sourceNoteId||void 0})})).note}async function Que(e,t){let n=new FormData;return n.append(`file`,t),(await Q4(X(`/api/notes/${encodeURIComponent(e)}/media`),n)).attachment}async function c3(e,t){let n=new FormData;return n.append(`file`,e),t?.markdown&&n.append(`markdown`,t.markdown),n.append(`channel`,t?.channel??`web`),t?.kind&&n.append(`kind`,t.kind),t?.duration!==void 0&&n.append(`duration`,String(t.duration)),(await Q4(X(`/api/notes`),n)).note}async function $ue(e,t=`web`){let n=await c3(e,{channel:t}),r=n.attachments?.find(e=>e.type===`image`)??n.attachments?.[0];if(!r)return n;let i=`![${r.fileName}](${Z4(n.id,r.id)})`;return n.markdown!==i&&(n=await s3(n.id,{markdown:i})),n}async function ede(e,t,n=`web`){let r=await c3(e,{channel:n,kind:`voice`,duration:t}),i=r.attachments?.find(e=>e.type===`audio`)??r.attachments?.[0];if(!i)return r;let a=`[${Pue(t)}](${Z4(r.id,i.id)})`;return r.markdown!==a&&(r=await s3(r.id,{markdown:a,kind:`voice`})),r}async function tde(e){return(await J(X(`/api/notes/${encodeURIComponent(e)}/history`))).entries}async function nde(e,t){return(await J(X(`/api/notes/${encodeURIComponent(e)}/history/${t}`))).snapshot}async function rde(e,t){return(await J(X(`/api/notes/${encodeURIComponent(e)}/history/restore`),{method:`POST`,body:JSON.stringify({timestamp:t})})).note}function ide(e){let t=(0,Q.c)(50),{onClose:n}=e,r=br(),i=_(ade),a;t[0]===i?a=t[1]:(a=m(i),t[0]=i,t[1]=a);let o=a.notes,[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=window.setTimeout(()=>d.current?.focus(),50);return()=>window.clearTimeout(e)},p=[],t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Z.useEffect)(f,p);let h;t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==s?(h=async e=>{let t=s.trim();if(!(!t||l)){u(!0);try{let i=await a3(t,`web`);n(),e&&r(`/notes/${i.id}`)}catch{u(!1)}}},t[4]=r,t[5]=n,t[6]=l,t[7]=s,t[8]=h):h=t[8];let g=h,v;t[9]!==g||t[10]!==n?(v=e=>{if(e.key===`Escape`){e.preventDefault(),n();return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),g(!0);return}e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),g(!1))},t[9]=g,t[10]=n,t[11]=v):v=t[11];let y=v,b;t[12]===n?b=t[13]:(b=e=>{e.target===e.currentTarget&&n()},t[12]=n,t[13]=b);let x;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(hT,{className:`h-4 w-4 text-accent`}),t[14]=x):x=t[14];let S;t[15]===o.quickCapturePlaceholder?S=t[16]:(S=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge px-4 py-3`,children:[x,(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.quickCapturePlaceholder})]}),t[15]=o.quickCapturePlaceholder,t[16]=S);let C;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>c(e.target.value),t[17]=C):C=t[17];let w;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(w={fieldSizing:`content`,minHeight:`6rem`,maxHeight:`40vh`},t[18]=w):w=t[18];let T;t[19]!==y||t[20]!==o.quickCapturePlaceholder||t[21]!==l||t[22]!==s?(T=(0,$.jsx)(`textarea`,{ref:d,value:s,onChange:C,onKeyDown:y,placeholder:o.quickCapturePlaceholder,disabled:l,rows:4,className:`resize-none border-none bg-transparent px-4 py-3 text-sm leading-relaxed text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:w}),t[19]=y,t[20]=o.quickCapturePlaceholder,t[21]=l,t[22]=s,t[23]=T):T=t[23];let E;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Enter`}),t[24]=E):E=t[24];let D;t[25]===o.quickCaptureHintEnter?D=t[26]:(D=(0,$.jsxs)(`span`,{children:[E,` `,o.quickCaptureHintEnter]}),t[25]=o.quickCaptureHintEnter,t[26]=D);let O;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Shift+Enter`}),t[27]=O):O=t[27];let k;t[28]===o.quickCaptureHintShift?k=t[29]:(k=(0,$.jsxs)(`span`,{children:[O,` `,o.quickCaptureHintShift]}),t[28]=o.quickCaptureHintShift,t[29]=k);let A;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Esc`}),t[30]=A):A=t[30];let j;t[31]===o.quickCaptureHintEsc?j=t[32]:(j=(0,$.jsxs)(`span`,{children:[A,` `,o.quickCaptureHintEsc]}),t[31]=o.quickCaptureHintEsc,t[32]=j);let M;t[33]!==D||t[34]!==k||t[35]!==j?(M=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-[11px] text-fg-muted`,children:[D,k,j]}),t[33]=D,t[34]=k,t[35]=j,t[36]=M):M=t[36];let N;t[37]===l?N=t[38]:(N=l&&(0,$.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-accent border-t-transparent`}),t[37]=l,t[38]=N);let P;t[39]!==M||t[40]!==N?(P=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-4 py-2`,children:[M,N]}),t[39]=M,t[40]=N,t[41]=P):P=t[41];let F;t[42]!==T||t[43]!==P||t[44]!==S?(F=(0,$.jsxs)(`div`,{className:`flex w-full max-w-lg flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[S,T,P]}),t[42]=T,t[43]=P,t[44]=S,t[45]=F):F=t[45];let I;return t[46]!==o.quickCapturePlaceholder||t[47]!==F||t[48]!==b?(I=(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":o.quickCapturePlaceholder,onMouseDown:b,children:F}),t[46]=o.quickCapturePlaceholder,t[47]=F,t[48]=b,t[49]=I):I=t[49],I}function ade(e){return e.language}function ode(){let e=(0,Q.c)(8),[t,n]=(0,Z.useState)(!1),r=q(lde),i=Eue(cde),a,o;e[0]!==i||e[1]!==r?(a=()=>{let e=e=>{kue(e,i)&&(e.preventDefault(),r&&n(sde))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},o=[i,r],e[0]=i,e[1]=r,e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,Z.useEffect)(a,o);let s,c;if(e[4]===r?(s=e[5],c=e[6]):(s=()=>{let e=()=>{r&&n(!0)};return window.addEventListener(`open-quick-capture`,e),()=>window.removeEventListener(`open-quick-capture`,e)},c=[r],e[4]=r,e[5]=s,e[6]=c),(0,Z.useEffect)(s,c),!t)return null;let l;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(ide,{onClose:()=>n(!1)}),e[7]=l):l=e[7],l}function sde(e){return!e}function cde(e){return e.shortcut}function lde(e){return e.token}var ude=class{_config;_callbacks;_eventSource;_shouldReconnect=!0;_reconnectCount=0;constructor(e,t){this._config=e,this._callbacks=t}get maxReconnectAttempts(){return this._config.maxReconnectAttempts??10}get autoReconnect(){return this._config.autoReconnect??!0}connect(){if(this._eventSource)return;let e=new URL(X(`/api/events`));this._config.token&&e.searchParams.set(`token`,this._config.token),this._eventSource=new EventSource(e.toString()),this._eventSource.onopen=()=>{this._reconnectCount=0},this._eventSource.addEventListener(`connected`,()=>{this._callbacks.onConnected()});for(let e of[`agent.stream`,`config.reload`,`channels.status`,`message.sent`,`session.updated`,`session.transcript_updated`,`session.created`,`dreaming.phase.start`,`dreaming.phase.end`])this._eventSource.addEventListener(e,t=>{this._callbacks.onEvent(e,t.data)});this._eventSource.onerror=()=>{this._eventSource?.readyState===EventSource.CLOSED?this._handlePermanentDisconnect():this._callbacks.onReconnecting()}}_handlePermanentDisconnect(){this._callbacks.onDisconnected(),!(!this._shouldReconnect||!this.autoReconnect)&&(this._reconnectCount++,this._reconnectCount>this.maxReconnectAttempts&&this._callbacks.onError(`Connection failed after max retries`))}disconnect(){this._shouldReconnect=!1,this._eventSource?.close(),this._eventSource=void 0}reconnect(){this._shouldReconnect=!0,this._reconnectCount=0,this.disconnect(),this._shouldReconnect=!0,setTimeout(()=>this.connect(),100)}};function dde(e,t){if(e!==`goal.queue.updated`||!t||typeof t!=`object`)return;let n=t.item;if(!(!n||typeof n.status!=`string`)){if(n.status===`failed`){re({type:`error`,title:`Goal run failed`,message:n.error||n.goalId,duration:0});return}if(n.status===`retry_waiting`){re({type:`warning`,title:`Goal run retry scheduled`,message:n.error||n.goalId});return}if(n.status===`succeeded`){re({type:`success`,title:`Goal run finished`,message:n.goalId});return}n.status===`skipped`&&re({type:`info`,title:`Goal run skipped`,message:n.error||n.goalId})}}function fde(e,t){let n=t;try{n=JSON.parse(t)}catch{}if(e===`config.reload`){G4(n);return}dde(e,n);let r=e.replace(/[._]/g,`-`);window.dispatchEvent(new CustomEvent(r,{detail:n}));let i=e.replace(/\./g,`-`);if(i!==r&&window.dispatchEvent(new CustomEvent(i,{detail:n})),e===`agent.stream`&&n&&typeof n==`object`&&n){let e=n;typeof e.sessionKey==`string`&&e.sessionKey.length>0&&window.dispatchEvent(new CustomEvent(`agent-stream-event`,{detail:{sessionKey:e.sessionKey,event:e.event===void 0?e:e.event}}))}}var l3=null;function u3(e){l3=e}function pde(){l3?.reconnect()}var d3=h(()=>({connectionState:`idle`,error:null,reconnectAttempt:0}));function f3(e){d3.setState(e)}function mde(e){let t=new ude({token:e,autoReconnect:!0,maxReconnectAttempts:10},{onConnected:()=>{f3({connectionState:`connected`,error:null,reconnectAttempt:0})},onReconnecting:()=>{f3({connectionState:`reconnecting`})},onDisconnected:()=>{f3({connectionState:`disconnected`})},onError:e=>{f3({connectionState:`error`,error:e})},onEvent:(e,t)=>{fde(e,t)}});return u3(t),f3({connectionState:`connecting`,error:null}),t.connect(),()=>{t.disconnect(),u3(null),f3({connectionState:`disconnected`,error:null})}}function hde(){u3(null),f3({connectionState:`disconnected`,error:null,reconnectAttempt:0})}function gde(){let e=(0,Q.c)(3),t=q(_de),n,r;e[0]===t?(n=e[1],r=e[2]):(n=()=>{if(!t){hde();return}return mde(t)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r)}function _de(e){return e.token}function vde(){let e=(0,Q.c)(1);gde();let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(yde,t),null}function yde(){let e=bde;return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)}function bde(e){let t=le(e.detail);t===`skills`?qle():t===`agents`&&k4()}var p3=new Set([`light`,`deep`,`rem`]),xde=3e3,Sde=1200,Cde=800,wde=800;function m3(e,t){return`${t?.agentId?.trim()||`unknown`}:${e}`}function Tde(e){return e[0]?.phase??`deep`}function h3(e){if(typeof e!=`object`||!e)return{};let t=e;return{...typeof t.agentId==`string`&&t.agentId.trim()?{agentId:t.agentId.trim()}:{},...typeof t.agentName==`string`&&t.agentName.trim()?{agentName:t.agentName.trim()}:{},...typeof t.avatar==`string`&&t.avatar.trim()?{avatar:t.avatar.trim()}:{}}}function g3(e,t=`running`){let n=[...e.values()];return n.length===0?{status:`idle`}:{status:t,phase:Tde(n),agents:n}}function Ede(){let e=(0,Q.c)(15),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={status:`idle`},e[0]=t):t=e[0];let[n,r]=(0,Z.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=new Map,e[1]=i):i=e[1];let a=(0,Z.useRef)(i),o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=new Set,e[2]=o):o=e[2];let s=(0,Z.useRef)(o),c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{let n=setTimeout(()=>{s.current.delete(n),e()},t);return s.current.add(n),n},e[3]=c):c=e[3];let l=c,u;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{for(let e of s.current)clearTimeout(e);s.current.clear()},e[4]=u):u=e[4];let d=u,f;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(e,t)=>{let n=m3(e,t),i=a.current.get(n);a.current.set(n,{key:n,phase:e,status:`sleeping`,startedAt:i?.startedAt??Date.now(),...i,...t??{}}),r(g3(a.current))},e[5]=f):f=e[5];let p=f,m;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{if(a.current.size>0){r(g3(a.current));return}r(Ode),l(()=>r({status:`idle`}),Cde)},e[6]=m):m=e[6];let h=m,g;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=(e,t)=>{let n=m3(e,t),i=a.current.get(n);if(!i)return;let o={...i,...t??{},status:`waking`},s=Date.now()-o.startedAt;l(()=>{a.current.set(n,o),r(g3(a.current)),l(()=>{a.current.delete(n),h()},Sde)},Math.max(0,xde-s))},e[7]=g):g=e[7];let _=g,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{d(),a.current.clear(),r(Dde),l(()=>r({status:`idle`}),wde)},e[8]=v):v=e[8];let y=v,b,x;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{let e=e=>{let t=e.detail,n=typeof t==`object`&&t&&typeof t.phase==`string`?t.phase:typeof t==`string`?t:null;n&&p3.has(n)&&p(n,h3(t))},t=e=>{let t=e.detail,n=typeof t==`object`&&t&&typeof t.phase==`string`?t.phase:null;!n||!p3.has(n)||_(n,h3(t))};return window.addEventListener(`dreaming-phase-start`,e),window.addEventListener(`dreaming-phase-end`,t),()=>{window.removeEventListener(`dreaming-phase-start`,e),window.removeEventListener(`dreaming-phase-end`,t),d()}},b=[p,_,d],e[9]=b,e[10]=x):(b=e[9],x=e[10]),(0,Z.useEffect)(x,b);let S,C;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>d,C=[d],e[11]=S,e[12]=C):(S=e[11],C=e[12]),(0,Z.useEffect)(S,C);let w;return e[13]===n?w=e[14]:(w={state:n,triggerPhase:p,dismiss:y},e[13]=n,e[14]=w),w}function Dde(e){return e.status===`idle`?e:{...e,status:`fading-out`}}function Ode(e){return e.status===`idle`?e:{...e,status:`fading-out`}}var _3={light:`💤 Light Sleep — scanning memories…`,deep:`🌙 Deep Sleep — promoting memories…`,rem:`🌈 REM Sleep — discovering patterns…`};function kde(){return typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Ade(){let e=(0,Z.useRef)(null),t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),r=(0,Z.useRef)(null),{state:i,dismiss:a}=Ede(),o=(0,Z.useCallback)(async()=>{if(t.current)return t.current;if(n.current)return n.current;let i=e.current;return i?(n.current=c(async()=>{let{DreamingScene:e}=await import(`./dreaming-scene-BHMRVEUS.js`);return{DreamingScene:e}},[]).then(({DreamingScene:e})=>{if(!i.isConnected)return null;let n=new e(i);t.current=n;let a=r.current;return a&&n.resize(a.clientWidth,a.clientHeight),n}).finally(()=>{n.current=null}),n.current):null},[]);(0,Z.useEffect)(()=>()=>{t.current?.dispose(),t.current=null},[]),(0,Z.useEffect)(()=>{let e=()=>{let e=r.current;!e||!t.current||t.current.resize(e.clientWidth,e.clientHeight)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,Z.useEffect)(()=>{if(i.status===`running`){if(kde())return;let e=!1;return o().then(t=>{e||!t||t.startPhase(i.phase)}),()=>{e=!0}}else i.status===`fading-out`&&t.current?.fadeOut()},[o,i]),(0,Z.useEffect)(()=>{let e=r.current;!e||!t.current||t.current.resize(e.clientWidth,e.clientHeight)},[]);let s=i.status!==`idle`,l=i.status===`idle`?null:i.phase,d=i.status===`fading-out`,f=i.status===`idle`?[]:i.agents,p=(0,Z.useCallback)(()=>{a()},[a]);return!s&&!d?(0,$.jsx)(`div`,{ref:r,className:`pointer-events-none fixed inset-0 z-[90] opacity-0`,"aria-hidden":!0,children:(0,$.jsx)(`canvas`,{ref:e,className:`size-full`})}):(0,$.jsxs)(`div`,{ref:r,className:u(`fixed inset-0 z-[90] bg-[#1c1c1e]/70 transition-opacity`,d?`dreaming-overlay-exit pointer-events-none`:`dreaming-overlay-enter`),role:`status`,"aria-live":`polite`,"aria-label":l?_3[l]:void 0,children:[(0,$.jsx)(`canvas`,{ref:e,className:`pointer-events-none size-full`}),f.length>0?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-4 top-[15%] flex justify-center sm:inset-x-10`,children:(0,$.jsxs)(`div`,{className:`grid max-w-4xl grid-cols-2 gap-x-6 gap-y-6 sm:grid-cols-3 lg:grid-cols-4`,children:[f.slice(0,12).map((e,t)=>(0,$.jsxs)(`div`,{className:u(`dreaming-agent-sleeper flex flex-col items-center gap-2`,e.status===`waking`&&`dreaming-agent-wake`),style:{animationDelay:`${t*90}ms`},children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute inset-[-18px] rounded-full bg-white/10 blur-2xl`}),(0,$.jsx)(dz,{agentId:e.agentId||`dreaming-${t}`,avatar:e.avatar,size:78,className:`relative size-[78px] border border-white/20 shadow-float ring-4 ring-white/10`}),e.status===`sleeping`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`dreaming-agent-z dreaming-agent-z-a`,children:`Z`}),(0,$.jsx)(`span`,{className:`dreaming-agent-z dreaming-agent-z-b`,children:`Z`}),(0,$.jsx)(`span`,{className:`dreaming-agent-z dreaming-agent-z-c`,children:`Z`})]}):null]}),(0,$.jsx)(`div`,{className:`max-w-28 truncate rounded-full border border-white/10 bg-black/30 px-3 py-1 text-xs font-medium text-white/80 shadow-elevated backdrop-blur-md`,children:e.agentName||e.agentId})]},e.key)),f.length>12?(0,$.jsxs)(`div`,{className:`flex items-center justify-center rounded-full border border-white/10 bg-black/30 px-3 py-2 text-sm font-semibold text-white/75 backdrop-blur-md`,children:[`+`,f.length-12]}):null]})}):null,(0,$.jsxs)(`div`,{className:`pointer-events-auto absolute bottom-6 left-1/2 flex -translate-x-1/2 items-center gap-3`,children:[l?(0,$.jsxs)(`div`,{className:u(`flex items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium shadow-elevated backdrop-blur-sm`,`dreaming-pill-enter`,l===`light`&&`border-emerald-400/30 bg-emerald-950/60 text-emerald-300`,l===`deep`&&`border-indigo-400/30 bg-indigo-950/60 text-indigo-300`,l===`rem`&&`border-purple-400/30 bg-purple-950/60 text-purple-300`),children:[(0,$.jsx)(`span`,{className:`dreaming-pulse-dot`}),(0,$.jsx)(`span`,{children:_3[l]})]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:p,className:`rounded-full border border-edge-subtle bg-surface-panel/80 px-3 py-1.5 text-xs text-fg-muted shadow-elevated backdrop-blur-sm transition-colors hover:bg-surface-hover hover:text-fg`,"aria-label":`Dismiss dreaming animation`,children:`✕`})]})]})}function v3(e){let t=e;return e.fullscreenElement??t.webkitFullscreenElement??t.msFullscreenElement??null}async function jde(e){let t=e;try{if(typeof e.requestFullscreen==`function`){await e.requestFullscreen();return}}catch{}if(typeof t.webkitRequestFullscreen==`function`){await Promise.resolve(t.webkitRequestFullscreen());return}if(typeof t.msRequestFullscreen==`function`){await Promise.resolve(t.msRequestFullscreen());return}throw Error(`fullscreen_unavailable`)}async function Mde(e){let t=e;if(typeof e.exitFullscreen==`function`){await e.exitFullscreen();return}if(typeof t.webkitExitFullscreen==`function`){await Promise.resolve(t.webkitExitFullscreen());return}typeof t.msExitFullscreen==`function`&&await Promise.resolve(t.msExitFullscreen())}function Nde(){return typeof window<`u`&&typeof window.electronAPI?.fullscreen?.enter==`function`}function y3(){let e=(0,Q.c)(11),t=(0,Z.useRef)(null),[n,r]=(0,Z.useState)(!1),i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=Nde(),e[0]=i):i=e[0];let a=i,o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=t.current,n=v3(document);r(!!(e&&n===e))},e[1]=o):o=e[1];let s=o,c,l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{if(a)return;let e=()=>s();return document.addEventListener(`fullscreenchange`,e),document.addEventListener(`webkitfullscreenchange`,e),()=>{document.removeEventListener(`fullscreenchange`,e),document.removeEventListener(`webkitfullscreenchange`,e)}},l=[s,a],e[2]=c,e[3]=l):(c=e[2],l=e[3]),(0,Z.useEffect)(c,l);let u,d;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{if(!a)return;let e=window.electronAPI.fullscreen,t=e.onChange(e=>r(e));return e.isFullscreen().then(r),t},d=[a],e[4]=u,e[5]=d):(u=e[4],d=e[5]),(0,Z.useEffect)(u,d);let f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=async()=>{if(a){await window.electronAPI.fullscreen.enter();return}let e=t.current;if(e&&v3(document)!==e)try{await jde(e)}catch{}},e[6]=f):f=e[6];let p=f,m;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=async()=>{if(a){await window.electronAPI.fullscreen.exit();return}if(v3(document)===t.current)try{await Mde(document)}catch{}},e[7]=m):m=e[7];let h=m,g;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=async()=>{if(a){await window.electronAPI.fullscreen.toggle();return}v3(document)===t.current?await h():await p()},e[8]=g):g=e[8];let _=g,v;return e[9]===n?v=e[10]:(v={rootRef:t,active:n,enter:p,exit:h,toggle:_},e[9]=n,e[10]=v),v}var Pde=new Intl.DateTimeFormat(`zh-CN`,{dateStyle:`medium`,timeStyle:`short`}),Fde=new Intl.DateTimeFormat(`en`,{dateStyle:`medium`,timeStyle:`short`});function Ide(e,t){return(t===`zh`?Pde:Fde).format(new Date(e))}function b3(e){let t=(0,Q.c)(163),{filePath:n,onClose:r,targetLine:i,projectId:a,sessionKey:o,agentId:s}=e,c=_(Wde),l;t[0]===c?l=t[1]:(l=m(c),t[0]=c,t[1]=l);let d=l,f=x(Ude),p;t[2]!==s||t[3]!==n||t[4]!==a||t[5]!==o?(p={filePath:n,projectId:a,sessionKey:o,agentId:s},t[2]=s,t[3]=n,t[4]=a,t[5]=o,t[6]=p):p=t[6];let h=t$(p),g=RQ(h.descriptor),{rootRef:v,active:y,enter:b,exit:S}=y3(),{dialogOpen:C,loading:w,result:T,error:E,createShareLink:D,handleOpenChange:O}=h1(),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),F;t[7]===n?F=t[8]:(F=n?Zq(n):``,t[7]=n,t[8]=F);let I=F,L;t[9]===n?L=t[10]:(L=n?Qq(n):``,t[9]=n,t[10]=L);let R=L,z=I===`.md`,B=I===`.html`||I===`.htm`,V;t[11]!==n||t[12]!==d.clipboard.copyFailed||t[13]!==d.workspace.pathCopied?(V=async()=>{if(n){if(await mA(n)){A(!0),window.setTimeout(()=>A(!1),2e3),FK(`success`,d.workspace.pathCopied,void 0,{duration:2e3});return}FK(`warning`,d.clipboard.copyFailed,void 0,{duration:4e3})}},t[11]=n,t[12]=d.clipboard.copyFailed,t[13]=d.workspace.pathCopied,t[14]=V):V=t[14];let H=V,U;t[15]!==s||t[16]!==D||t[17]!==n||t[18]!==a||t[19]!==o?(U=()=>{!n||a||D({path:n,...o==null?s?.trim()?{agentId:s.trim()}:{}:{sessionKey:o}})},t[15]=s,t[16]=D,t[17]=n,t[18]=a,t[19]=o,t[20]=U):U=t[20];let W=U,G=!!(n&&!h.loading&&!h.loadError),K;t[21]===h?K=t[22]:(K=()=>void h.onDownload(),t[21]=h,t[22]=K);let q;t[23]===h?q=t[24]:(q=()=>void h.onOpenWithSystemApp(),t[23]=h,t[24]=q);let ee;t[25]===h?ee=t[26]:(ee=()=>void h.onChooseOpenWithApp(),t[25]=h,t[26]=ee);let J;t[27]!==h.canChooseOpenWithApp||t[28]!==h.canDownload||t[29]!==h.canOpenWithSystemApp||t[30]!==K||t[31]!==q||t[32]!==ee?(J={onDownload:K,canDownload:h.canDownload,onOpenWithSystemApp:q,canOpenWithSystemApp:h.canOpenWithSystemApp,onChooseOpenWithApp:ee,canChooseOpenWithApp:h.canChooseOpenWithApp},t[27]=h.canChooseOpenWithApp,t[28]=h.canDownload,t[29]=h.canOpenWithSystemApp,t[30]=K,t[31]=q,t[32]=ee,t[33]=J):J=t[33];let te=J,Y;t[34]!==S||t[35]!==r?(Y=()=>{S(),r()},t[34]=S,t[35]=r,t[36]=Y):Y=t[36];let ne=Y;if(!n)return null;let re;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(re=u(`flex shrink-0 items-start gap-2 border-b border-edge px-4 py-2 dark:border-edge`,uM),t[37]=re):re=t[37];let X;t[38]===R?X=t[39]:(X=(0,$.jsx)(`h2`,{className:`truncate text-base font-semibold leading-tight tracking-tight text-fg`,title:R,children:R}),t[38]=R,t[39]=X);let ie;t[40]!==c||t[41]!==d.workspace.lastModified||t[42]!==h.loading||t[43]!==h.mtimeMs||t[44]!==i?(ie=!h.loading&&h.mtimeMs!=null?(0,$.jsxs)(`p`,{suppressHydrationWarning:!0,className:`mt-0.5 truncate text-xs leading-tight text-fg-muted`,title:new Date(h.mtimeMs).toISOString(),children:[d.workspace.lastModified,`: `,Ide(h.mtimeMs,c),i?` · Line ${i}`:``]}):null,t[40]=c,t[41]=d.workspace.lastModified,t[42]=h.loading,t[43]=h.mtimeMs,t[44]=i,t[45]=ie):ie=t[45];let ae;t[46]!==X||t[47]!==ie?(ae=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[X,ie]}),t[46]=X,t[47]=ie,t[48]=ae):ae=t[48];let oe;t[49]===h.loading?oe=t[50]:(oe=h.loading?(0,$.jsx)(Fv,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[49]=h.loading,t[50]=oe);let se;t[51]!==B||t[52]!==z||t[53]!==d.workspace.saved||t[54]!==d.workspace.saving||t[55]!==h.htmlCodeMode||t[56]!==h.saveStatus?(se=(z||B&&h.htmlCodeMode)&&h.saveStatus!==`idle`?(0,$.jsx)(`span`,{className:`shrink-0 text-xs leading-tight text-fg-muted`,children:h.saveStatus===`saving`?d.workspace.saving:d.workspace.saved}):null,t[51]=B,t[52]=z,t[53]=d.workspace.saved,t[54]=d.workspace.saving,t[55]=h.htmlCodeMode,t[56]=h.saveStatus,t[57]=se):se=t[57];let ce;t[58]!==te||t[59]!==g?(ce=(0,$.jsx)(HQ,{controller:g,actions:te}),t[58]=te,t[59]=g,t[60]=ce):ce=t[60];let le;t[61]!==B||t[62]!==z||t[63]!==d.workspace.edit||t[64]!==d.workspace.preview||t[65]!==d.workspace.viewing||t[66]!==h?(le=z?(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:h.markdownEditMode?d.workspace.viewing:d.workspace.edit,"aria-label":h.markdownEditMode?d.workspace.viewing:d.workspace.edit,onClick:()=>h.setMarkdownEditMode(Hde),children:h.markdownEditMode?(0,$.jsx)(bh,{className:`size-4`}):(0,$.jsx)(oy,{className:`size-4`})}):B?(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:h.htmlCodeMode?d.workspace.preview:d.workspace.edit,"aria-label":h.htmlCodeMode?d.workspace.preview:d.workspace.edit,onClick:()=>h.setHtmlCodeMode(Vde),children:h.htmlCodeMode?(0,$.jsx)(bh,{className:`size-4`}):(0,$.jsx)(oy,{className:`size-4`})}):null,t[61]=B,t[62]=z,t[63]=d.workspace.edit,t[64]=d.workspace.preview,t[65]=d.workspace.viewing,t[66]=h,t[67]=le):le=t[67];let ue;t[68]!==z||t[69]!==d.workspace.wordWrap||t[70]!==N||t[71]!==h.markdownEditMode?(ue=z&&h.markdownEditMode?(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,N&&`bg-surface-hover text-fg`,lA.focusRingPanel),title:`${d.workspace.wordWrap} (Option+Z)`,"aria-label":d.workspace.wordWrap,"aria-pressed":N,onClick:()=>P(Bde),children:(0,$.jsx)(bE,{className:`size-4`})}):null,t[68]=z,t[69]=d.workspace.wordWrap,t[70]=N,t[71]=h.markdownEditMode,t[72]=ue):ue=t[72];let de;t[73]!==y||t[74]!==G||t[75]!==b||t[76]!==S||t[77]!==d.chat?(de=G?(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,lA.focusRingPanel),title:y?d.chat.attachmentPreviewExitFullscreen:d.chat.attachmentPreviewFullscreen,"aria-label":y?d.chat.attachmentPreviewExitFullscreen:d.chat.attachmentPreviewFullscreen,onClick:()=>void(y?S():b()),children:y?(0,$.jsx)(Wv,{className:`size-4`,strokeWidth:1.75}):(0,$.jsx)(Rv,{className:`size-4`,strokeWidth:1.75})}):null,t[73]=y,t[74]=G,t[75]=b,t[76]=S,t[77]=d.chat,t[78]=de):de=t[78];let fe;t[79]!==d.workspace.openSystemApp||t[80]!==h?(fe=h.canOpenWithSystemApp?(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,lA.focusRingPanel),title:d.workspace.openSystemApp,"aria-label":d.workspace.openSystemApp,onClick:()=>void h.onOpenWithSystemApp(),children:(0,$.jsx)(gh,{className:`size-4`})}):null,t[79]=d.workspace.openSystemApp,t[80]=h,t[81]=fe):fe=t[81];let pe;t[82]!==d.workspace.chooseApp||t[83]!==d.workspace.openWith||t[84]!==d.workspace.recentApps||t[85]!==d.workspace.recommendedApps||t[86]!==j||t[87]!==h?(pe=h.canChooseOpenWithApp||h.recommendedOpenWithApps.length>0||h.recentOpenWithApps.length>0?(0,$.jsxs)(`div`,{className:`relative shrink-0`,children:[j?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 cursor-default bg-transparent`,"aria-hidden":!0,tabIndex:-1,onPointerDown:e=>{e.preventDefault(),M(!1)}}):null,(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,lA.focusRingPanel),title:d.workspace.openWith,"aria-label":d.workspace.openWith,"aria-haspopup":`menu`,"aria-expanded":j,onClick:()=>M(zde),children:(0,$.jsx)(sh,{className:`size-4`})}),j?(0,$.jsxs)(`div`,{role:`menu`,className:`absolute right-0 top-full z-50 mt-1 min-w-[13rem] rounded-md border border-edge bg-surface-panel py-1 shadow-popover`,children:[h.canChooseOpenWithApp?(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,className:`block w-full px-3 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>{M(!1),h.onChooseOpenWithApp()},children:d.workspace.chooseApp}):null,h.recommendedOpenWithApps.length>0?(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle py-1 dark:border-edge`,children:[(0,$.jsx)(`p`,{className:`px-3 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-normal text-fg-subtle`,children:d.workspace.recommendedApps}),h.recommendedOpenWithApps.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,className:`block w-full min-w-0 px-3 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,title:e.path,onClick:()=>{M(!1),h.onOpenWithRecentApp(e.path)},children:(0,$.jsx)(`span`,{className:`block truncate`,children:e.name})},e.path))]}):null,h.recentOpenWithApps.length>0?(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle py-1 dark:border-edge`,children:[(0,$.jsx)(`p`,{className:`px-3 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-normal text-fg-subtle`,children:d.workspace.recentApps}),h.recentOpenWithApps.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,className:`block w-full min-w-0 px-3 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,title:e.path,onClick:()=>{M(!1),h.onOpenWithRecentApp(e.path)},children:(0,$.jsx)(`span`,{className:`block truncate`,children:e.name})},e.path))]}):null]}):null]}):null,t[82]=d.workspace.chooseApp,t[83]=d.workspace.openWith,t[84]=d.workspace.recentApps,t[85]=d.workspace.recommendedApps,t[86]=j,t[87]=h,t[88]=pe):pe=t[88];let me;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(me=u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,lA.focusRingPanel),t[89]=me):me=t[89];let he;t[90]===H?he=t[91]:(he=()=>void H(),t[90]=H,t[91]=he);let ge;t[92]===k?ge=t[93]:(ge=k?(0,$.jsx)(Iu,{className:`size-4`}):(0,$.jsx)(Fp,{className:`size-4`}),t[92]=k,t[93]=ge);let _e;t[94]!==d.workspace.copyPath||t[95]!==he||t[96]!==ge?(_e=(0,$.jsx)(`button`,{type:`button`,className:me,title:d.workspace.copyPath,"aria-label":d.workspace.copyPath,onClick:he,children:ge}),t[94]=d.workspace.copyPath,t[95]=he,t[96]=ge,t[97]=_e):_e=t[97];let ve;t[98]!==d.workspace.revealInFolder||t[99]!==h?(ve=h.canRevealInFolder?(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,lA.focusRingPanel),title:d.workspace.revealInFolder,"aria-label":d.workspace.revealInFolder,onClick:()=>void h.onRevealInFolder(),children:(0,$.jsx)(__,{className:`size-4`})}):null,t[98]=d.workspace.revealInFolder,t[99]=h,t[100]=ve):ve=t[100];let ye;t[101]!==W||t[102]!==w||t[103]!==d.workspace.shareLink||t[104]!==a?(ye=a?null:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:d.workspace.shareLink,"aria-label":d.workspace.shareLink,onClick:W,disabled:w,children:w?(0,$.jsx)(Fv,{className:`size-4 animate-spin`}):(0,$.jsx)(Ov,{className:`size-4`})}),t[101]=W,t[102]=w,t[103]=d.workspace.shareLink,t[104]=a,t[105]=ye):ye=t[105];let be;t[106]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,$.jsx)(Sk,{className:`size-4`,strokeWidth:1.75}),t[106]=be):be=t[106];let xe;t[107]!==ne||t[108]!==d.workspace.close?(xe=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:d.workspace.close,"aria-label":d.workspace.close,onClick:ne,children:be}),t[107]=ne,t[108]=d.workspace.close,t[109]=xe):xe=t[109];let Se;t[110]!==oe||t[111]!==se||t[112]!==ce||t[113]!==le||t[114]!==ue||t[115]!==de||t[116]!==fe||t[117]!==pe||t[118]!==_e||t[119]!==ve||t[120]!==ye||t[121]!==xe?(Se=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[oe,se,ce,le,ue,de,fe,pe,_e,ve,ye,xe]}),t[110]=oe,t[111]=se,t[112]=ce,t[113]=le,t[114]=ue,t[115]=de,t[116]=fe,t[117]=pe,t[118]=_e,t[119]=ve,t[120]=ye,t[121]=xe,t[122]=Se):Se=t[122];let Ce;t[123]!==ae||t[124]!==Se?(Ce=(0,$.jsxs)(`div`,{className:re,children:[ae,Se]}),t[123]=ae,t[124]=Se,t[125]=Ce):Ce=t[125];let we;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(we=()=>P(Rde),t[126]=we):we=t[126];let Te=f===`dark`,Ee;t[127]!==N||t[128]!==h.htmlCodeMode||t[129]!==h.markdownEditMode||t[130]!==h.onHtmlChange||t[131]!==h.onSaveMarkdown||t[132]!==Te?(Ee={markdownEditMode:h.markdownEditMode,onSaveMarkdown:h.onSaveMarkdown,markdownWordWrap:N,onToggleMarkdownWordWrap:we,htmlCodeMode:h.htmlCodeMode,onHtmlChange:h.onHtmlChange,isDark:Te},t[127]=N,t[128]=h.htmlCodeMode,t[129]=h.markdownEditMode,t[130]=h.onHtmlChange,t[131]=h.onSaveMarkdown,t[132]=Te,t[133]=Ee):Ee=t[133];let De;t[134]!==c||t[135]!==te||t[136]!==g||t[137]!==f||t[138]!==h.binaryBuffer||t[139]!==h.descriptor||t[140]!==h.extractedText||t[141]!==h.extractedTextTruncated||t[142]!==h.hostAbsolutePath||t[143]!==h.loadError||t[144]!==h.loading||t[145]!==h.mtimeMs||t[146]!==h.textContent||t[147]!==Ee||t[148]!==i?(De=(0,$.jsx)(UQ,{language:c,resolvedTheme:f,descriptor:h.descriptor,loading:h.loading,loadError:h.loadError,textContent:h.textContent,binaryBuffer:h.binaryBuffer,hostAbsolutePath:h.hostAbsolutePath,mtimeMs:h.mtimeMs,targetLine:i,extractedText:h.extractedText,extractedTextTruncated:h.extractedTextTruncated,workspaceEditing:Ee,actions:te,controller:g,renderToolbar:Lde}),t[134]=c,t[135]=te,t[136]=g,t[137]=f,t[138]=h.binaryBuffer,t[139]=h.descriptor,t[140]=h.extractedText,t[141]=h.extractedTextTruncated,t[142]=h.hostAbsolutePath,t[143]=h.loadError,t[144]=h.loading,t[145]=h.mtimeMs,t[146]=h.textContent,t[147]=Ee,t[148]=i,t[149]=De):De=t[149];let Oe;t[150]!==v||t[151]!==Ce||t[152]!==De?(Oe=(0,$.jsxs)(`div`,{ref:v,className:`flex h-full min-h-0 flex-col bg-surface-panel`,children:[Ce,De]}),t[150]=v,t[151]=Ce,t[152]=De,t[153]=Oe):Oe=t[153];let ke;t[154]!==C||t[155]!==E||t[156]!==O||t[157]!==w||t[158]!==T?(ke=(0,$.jsx)(c1,{open:C,onOpenChange:O,loading:w,error:E,result:T}),t[154]=C,t[155]=E,t[156]=O,t[157]=w,t[158]=T,t[159]=ke):ke=t[159];let Ae;return t[160]!==Oe||t[161]!==ke?(Ae=(0,$.jsxs)($.Fragment,{children:[Oe,ke]}),t[160]=Oe,t[161]=ke,t[162]=Ae):Ae=t[162],Ae}function Lde(){return null}function Rde(e){return!e}function zde(e){return!e}function Bde(e){return!e}function Vde(e){return!e}function Hde(e){return!e}function Ude(e){return e.resolved}function Wde(e){return e.language}var Gde=(0,Z.memo)(function(){let e=(0,Q.c)(21),{pathname:t}=_r(),{sessionKey:n}=wr(),r;e[0]!==t||e[1]!==n?(r=t.startsWith(`/chat`)&&n?decodeURIComponent(n):void 0,e[0]=t,e[1]=n,e[2]=r):r=e[2];let i=r,a=k1(Kde),o=k1(qde),s=k1(Jde),c=b1(Yde),l,u;e[3]!==t||e[4]!==s?(l=()=>{t.startsWith(`/chat`)||s(null)},u=[t,s],e[3]=t,e[4]=s,e[5]=l,e[6]=u):(l=e[5],u=e[6]),(0,Z.useEffect)(l,u);let d,f;if(e[7]!==a||e[8]!==s?(d=()=>{if(!a)return;let e=e=>{e.key===`Escape`&&(s(null),e.stopPropagation())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},f=[a,s],e[7]=a,e[8]=s,e[9]=d,e[10]=f):(d=e[9],f=e[10]),(0,Z.useEffect)(d,f),!a)return null;let p;e[11]===c?p=e[12]:(p=c.trim()||void 0,e[11]=c,e[12]=p);let m;e[13]===s?m=e[14]:(m=()=>s(null),e[13]=s,e[14]=m);let h;return e[15]!==i||e[16]!==o||e[17]!==a||e[18]!==p||e[19]!==m?(h=(0,$.jsx)(`div`,{role:`region`,"aria-label":`File preview`,className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden border border-edge bg-surface-panel dark:border-edge`,children:(0,$.jsx)(b3,{filePath:a,targetLine:o,sessionKey:i,agentId:p,onClose:m})}),e[15]=i,e[16]=o,e[17]=a,e[18]=p,e[19]=m,e[20]=h):h=e[20],h});function Kde(e){return e.path}function qde(e){return e.line}function Jde(e){return e.setPath}function Yde(e){return e.agentId}async function x3(){let e=await ue(X(`/api/models`));if(!e.ok)throw Error(`Models: HTTP ${e.status}`);return(await e.json()).payload?.models??[]}var S3=null,C3=0,w3=null,T3=6e4,E3=`gateway-configured-models`;async function D3(){S3=null,C3=0;let{mutate:e}=await c(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([6,1,2]));await e(E3)}async function O3(e=!1){if(!e&&S3&&Date.now()<C3)return S3;if(e){let e=await x3();return S3=e,C3=Date.now()+T3,e}return w3||(w3=x3().then(e=>(S3=e,C3=Date.now()+T3,e)).finally(()=>{w3=null}),w3)}function Xde(e){let t=(0,Q.c)(9),{models:n,selectedId:r,onSelectedChange:i}=e;if(n.length===0)return null;let a;if(t[0]!==n||t[1]!==i||t[2]!==r){let e;t[4]!==i||t[5]!==r?(e=e=>{let t=r===e.id;return(0,$.jsxs)(`label`,{className:u(`flex cursor-pointer items-start gap-3 rounded-xl border border-edge px-3 py-2.5 transition-colors`,t?`border-accent bg-accent-soft`:`hover:bg-surface-hover`),children:[(0,$.jsx)(`input`,{type:`radio`,name:`onboarding-model`,className:`mt-1`,checked:t,onChange:()=>i(e.id),"aria-label":e.name||e.id}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e.name||e.id}),e.recommended?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-1.5 py-0.5 text-[10px] font-semibold text-accent-fg`,children:`Recommended`}):null]}),(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:e.id})]})]},e.id)},t[4]=i,t[5]=r,t[6]=e):e=t[6],a=n.slice().sort(Zde).map(e),t[0]=n,t[1]=i,t[2]=r,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,$.jsx)(`div`,{className:`flex max-h-[min(50vh,22rem)] flex-col gap-2 overflow-y-auto pr-1`,role:`radiogroup`,children:a}),t[7]=a,t[8]=o),o}function Zde(e,t){return e.recommended===t.recommended?(e.name||e.id).localeCompare(t.name||t.id,void 0,{sensitivity:`base`}):e.recommended?-1:1}function k3(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=u(`shrink-0`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,className:a,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function Qde(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`#5786FE`,d:`M23.748 4.651c-.254-.124-.364.113-.512.233-.051.04-.094.09-.137.137-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.155-.708-.311-.955-.65-.172-.24-.219-.509-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.094.172.187.129.323-.082.28-.18.553-.266.833-.055.179-.137.218-.328.14a5.5 5.5 0 0 1-1.737-1.179c-.857-.828-1.631-1.743-2.597-2.46a12 12 0 0 0-.689-.47c-.985-.957.13-1.743.387-1.836.27-.098.094-.433-.778-.428-.872.003-1.67.295-2.687.685a3 3 0 0 1-.465.136 9.6 9.6 0 0 0-2.883-.101c-1.885.21-3.39 1.1-4.497 2.622C.082 8.776-.231 10.854.152 13.02c.403 2.284 1.568 4.175 3.36 5.653 1.857 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.132-.284 4.994-1.86.47.234.962.328 1.78.398.629.058 1.235-.031 1.705-.129.735-.155.684-.836.418-.961-2.155-1.004-1.682-.595-2.112-.926 1.095-1.295 2.768-3.598 3.284-6.733.05-.346.115-.834.108-1.114-.004-.171.035-.238.23-.257a4.2 4.2 0 0 0 1.545-.475c1.397-.763 1.96-2.016 2.093-3.517.02-.23-.004-.467-.247-.588M11.58 18.168c-2.088-1.642-3.101-2.183-3.52-2.16-.39.024-.32.472-.234.763.09.288.207.487.371.74.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.168-1.361-.801-2.5-1.86-3.301-3.306-.775-1.393-1.225-2.888-1.299-4.482-.02-.385.094-.522.477-.592a4.7 4.7 0 0 1 1.53-.038c2.131.311 3.946 1.264 5.467 2.774.868.86 1.525 1.887 2.202 2.89.72 1.066 1.494 2.082 2.48 2.915.348.291.626.513.892.677-.802.09-2.14.109-3.055-.615zm1.001-6.44a.306.306 0 0 1 .415-.287.3.3 0 0 1 .113.074.3.3 0 0 1 .086.214c0 .17-.136.307-.308.307a.303.303 0 0 1-.306-.307m3.11 1.596c-.2.081-.4.151-.591.16a1.25 1.25 0 0 1-.798-.254c-.274-.23-.47-.358-.551-.758a1.7 1.7 0 0 1 .015-.588c.07-.327-.007-.537-.238-.727-.188-.156-.426-.199-.689-.199a.6.6 0 0 1-.254-.078.253.253 0 0 1-.114-.358 1 1 0 0 1 .192-.21c.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.392.451.462.576.685.915.176.264.336.536.446.848.066.194-.02.353-.25.45`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(k3,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function $de(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`#E73562`,d:`M11.43 3.92a.86.86 0 1 0-1.718 0v14.236a1.999 1.999 0 0 1-3.997 0V9.022a.86.86 0 1 0-1.718 0v3.87a1.999 1.999 0 0 1-3.997 0V11.49a.57.57 0 0 1 1.139 0v1.404a.86.86 0 0 0 1.719 0V9.022a1.999 1.999 0 0 1 3.997 0v9.134a.86.86 0 0 0 1.719 0V3.92a1.998 1.998 0 1 1 3.996 0v11.788a.57.57 0 1 1-1.139 0zm10.572 3.105a2 2 0 0 0-1.999 1.997v7.63a.86.86 0 0 1-1.718 0V3.923a1.999 1.999 0 0 0-3.997 0v16.16a.86.86 0 0 1-1.719 0V18.08a.57.57 0 1 0-1.138 0v2a1.998 1.998 0 0 0 3.996 0V3.92a.86.86 0 0 1 1.719 0v12.73a1.999 1.999 0 0 0 3.996 0V9.023a.86.86 0 1 1 1.72 0v6.686a.57.57 0 0 0 1.138 0V9.022a2 2 0 0 0-1.998-1.997`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(k3,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function A3(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`currentColor`,d:`m1.053 16.91 9.538 2.55a21 20.981 0 0 0 .06 2.031l5.956 1.592a12 11.99 0 0 1-15.554-6.172m-1.02-5.79 11.352 3.035a21 20.981 0 0 0-.469 2.01l10.817 2.89a12 11.99 0 0 1-1.845 2.004L.658 15.918a12 11.99 0 0 1-.625-4.796m1.593-5.146L13.573 9.17a21 20.981 0 0 0-1.01 1.874l11.297 3.02a21 20.981 0 0 1-.67 2.362l-11.55-3.087L.125 10.26a12 11.99 0 0 1 1.499-4.285ZM6.067 1.58l11.285 3.016a21 20.981 0 0 0-1.688 1.719l7.824 2.091a21 20.981 0 0 1 .513 2.664L2.107 5.218a12 11.99 0 0 1 3.96-3.638M21.68 4.866 7.222 1.003A12 11.99 0 0 1 21.68 4.866`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(k3,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function efe(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`currentColor`,d:`M22.28 9.82a5.98 5.98 0 0 0-.516-4.91 6.04 6.04 0 0 0-6.51-2.9A6.06 6.06 0 0 0 4.98 4.18a5.98 5.98 0 0 0-3.99 2.9 6.04 6.04 0 0 0 .743 7.09 5.98 5.98 0 0 0 .511 4.91 6.05 6.05 0 0 0 6.51 2.9A5.98 5.98 0 0 0 13.26 24a6.05 6.05 0 0 0 5.77-4.20 5.98 5.98 0 0 0 3.99-2.9 6.05 6.05 0 0 0-.748-7.07zm-9.02 12.60a4.47 4.47 0 0 1-2.87-1.04l.142-.08 4.77-2.75a.795.79 0 0 0 .393-.681v-6.73l2.02 1.16a.071.07 0 0 1 .038.05v5.58a4.50 4.50 0 0 1-4.49 4.49zm-9.66-4.12a4.47 4.47 0 0 1-.535-3.01l.142.08 4.78 2.75a.771.77 0 0 0 .781 0l5.84-3.36v2.33a.08.08 0 0 1-.033.06L9.74 19.95a4.49 4.49 0 0 1-6.14-1.64zM2.34 7.89a4.48 4.48 0 0 1 2.36-1.97V11.6a.766.76 0 0 0 .388.67l5.81 3.35-2.02 1.16a.076.07 0 0 1-.071 0l-4.83-2.78A4.50 4.50 0 0 1 2.34 7.87zm16.59 3.85L13.10 8.36 15.11 7.2a.076.07 0 0 1 .071 0l4.83 2.79a4.49 4.49 0 0 1-.677 8.10v-5.67a.79.79 0 0 0-.407-.667zm2.01-3.02-.142-.085-4.77-2.78a.776.77 0 0 0-.785 0L9.40 9.23V6.89a.066.06 0 0 1 .028-.062l4.83-2.78a4.49 4.49 0 0 1 6.68 4.66zM8.30 12.86l-2.02-1.16a.08.08 0 0 1-.038-.057V6.07a4.49 4.49 0 0 1 7.37-3.45l-.142.08L8.70 5.45a.795.79 0 0 0-.393.68zm1.09-2.36 2.60-1.5 2.60 1.5v2.99l-2.59 1.5-2.60-1.5Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(k3,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function tfe(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`#D4A27F`,d:`M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(k3,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function nfe(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i,a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`gemini-grad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`#4285F4`}),(0,$.jsx)(`stop`,{offset:`50%`,stopColor:`#9B72CB`}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`#D96570`})]})}),a=(0,$.jsx)(`path`,{fill:`url(#gemini-grad)`,d:`M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81`}),t[3]=i,t[4]=a):(i=t[3],a=t[4]);let o;return t[5]!==n||t[6]!==r?(o=(0,$.jsxs)(k3,{className:n,...r,children:[i,a]}),t[5]=n,t[6]=r,t[7]=o):o=t[7],o}function rfe(e){let t=(0,Q.c)(20),{providerId:n,className:r}=e,i;t[0]===r?i=t[1]:(i={className:r,"aria-hidden":!0},t[0]=r,t[1]=i);let a=i;switch(n){case`deepseek`:{let e;return t[2]===a?e=t[3]:(e=(0,$.jsx)(Qde,{...a}),t[2]=a,t[3]=e),e}case`minimax`:{let e;return t[4]===a?e=t[5]:(e=(0,$.jsx)($de,{...a}),t[4]=a,t[5]=e),e}case`kimi-coding`:{let e;return t[6]===a?e=t[7]:(e=(0,$.jsx)(A3,{...a}),t[6]=a,t[7]=e),e}case`moonshotai`:case`moonshotai-cn`:{let e;return t[8]===a?e=t[9]:(e=(0,$.jsx)(A3,{...a}),t[8]=a,t[9]=e),e}case`openai`:{let e;return t[10]===a?e=t[11]:(e=(0,$.jsx)(efe,{...a}),t[10]=a,t[11]=e),e}case`anthropic`:{let e;return t[12]===a?e=t[13]:(e=(0,$.jsx)(tfe,{...a}),t[12]=a,t[13]=e),e}case`google`:{let e;return t[14]===a?e=t[15]:(e=(0,$.jsx)(nfe,{...a}),t[14]=a,t[15]=e),e}default:{let e;t[16]===r?e=t[17]:(e=u(`flex items-center justify-center text-2xl`,r),t[16]=r,t[17]=e);let n;return t[18]===e?n=t[19]:(n=(0,$.jsx)(`span`,{className:e,children:`🤖`}),t[18]=e,t[19]=n),n}}}var j3=`models-json-config`;async function M3(){await Promise.all([hI(),oe(X(`/api/providers/meta`)),oe(j3),D3()])}function ife(e){return dA(e)}async function N3(){return(await J(X(`/api/providers/meta`))).payload?.providers??[]}function afe(e){if(!e||typeof e!=`object`||!(`providers`in e))return{};let t=e.providers;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`string`&&(n[e]=r);return n}function ofe(e,t,n){let r=new Set(n.map(e=>e.provider));return e.map(e=>({...e,configured:e.configured||r.has(e.id),apiKey:t[e.id]??(e.activeKeySource===`extension`?``:e.configured||r.has(e.id)?`••••••••••••`:``)}))}async function P3(e){await J(X(`/api/config`),{method:`PATCH`,body:JSON.stringify({providers:e})}),await M3()}async function sfe(e){await J(X(`/api/providers/${encodeURIComponent(e)}/key`),{method:`DELETE`}),await M3()}async function cfe(e){let t=await J(X(`/api/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}var F3=[{id:`openai`,name:`OpenAI`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`anthropic`,name:`Anthropic`,category:`common`,supportsOAuth:!0,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`xai`,name:`xAI`,category:`specialty`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`google`,name:`Google AI`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`openrouter`,name:`OpenRouter`,category:`specialty`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`deepseek`,name:`DeepSeek`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0}],I3=new Map(F3.map((e,t)=>[e.id,t]));function lfe(e){let t=e.recommendedModels?.map(e=>e.name||e.id).filter(Boolean).slice(0,2);return t?.length?t.join(`, `):e.hint}function ufe(e){let t=(0,Q.c)(14),{onSelect:n}=e,r=_(pfe),i;t[0]===r?i=t[1]:(i=m(r),t[0]=r,t[1]=i);let a=i.onboarding.providerRecommended,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[2]=o):o=t[2];let{data:s}=ie(`onboarding-provider-meta`,N3,o),c,l;if(t[3]!==s||t[4]!==n||t[5]!==a){let e=(s?.filter(ffe)??F3).slice().sort(dfe);c=`grid grid-cols-2 gap-2 sm:grid-cols-3`;let r;t[8]!==n||t[9]!==a?(r=(e,t)=>{let r=lfe(e),i=t===0;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:u(`relative flex min-h-32 flex-col items-center gap-1.5 rounded-xl border border-edge p-4 text-center transition-colors`,`hover:border-accent hover:bg-accent-soft`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,i&&`border-accent/50 bg-accent-soft/30`),children:[i&&(0,$.jsx)(`span`,{className:`absolute -top-2 right-2 rounded-full bg-accent px-2 py-0.5 text-[10px] font-semibold text-white`,children:a}),(0,$.jsx)(rfe,{providerId:e.id,className:`size-8`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name}),r?(0,$.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-muted`,children:r}):null]},e.id)},t[8]=n,t[9]=a,t[10]=r):r=t[10],l=e.map(r),t[3]=s,t[4]=n,t[5]=a,t[6]=c,t[7]=l}else c=t[6],l=t[7];let d;return t[11]!==c||t[12]!==l?(d=(0,$.jsx)(`div`,{className:c,children:l}),t[11]=c,t[12]=l,t[13]=d):d=t[13],d}function dfe(e,t){return(I3.get(e.id)??999)-(I3.get(t.id)??999)}function ffe(e){return e.onboardingFeatured}function pfe(e){return e.language}var mfe=[{value:`openai-completions`,label:`OpenAI Completions`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic-messages`,label:`Anthropic Messages`},{value:`google-generative-ai`,label:`Google Generative AI`},{value:`azure-openai-responses`,label:`Azure OpenAI`},{value:`bedrock-converse-stream`,label:`AWS Bedrock`},{value:`openai-codex-responses`,label:`OpenAI Codex`},{value:`google-gemini-cli`,label:`Google Gemini CLI`},{value:`google-vertex`,label:`Google Vertex AI`}];function L3(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;return typeof e==`string`?e:void 0}}function R3(e){if(!e||typeof e!=`object`)return{providers:{}};let t=e,n=t.providers;return n&&typeof n==`object`&&!Array.isArray(n)?e:{...t,providers:{}}}async function z3(){let e=await Y(X(`/api/models-json`)),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok||!t.payload)throw Error(L3(t)||`HTTP ${e.status}`);return{...t.payload,config:R3(t.payload.config)}}async function B3(e){let t=await Y(X(`/api/models-json`),{method:`PATCH`,body:JSON.stringify({config:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(L3(n)||`HTTP ${t.status}`);return await M3(),n.payload}async function hfe(e){let t=await Y(X(`/api/models-json/discover-models`),{method:`POST`,body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(L3(n)||`HTTP ${t.status}`);return n.payload.models}function gfe(e,t,n){return{id:e,name:t||e,input:[`text`],contextWindow:128e3,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},...n}}var V3={ollama:{label:`Ollama`,providerId:`ollama`,config:{baseUrl:`http://localhost:11434/v1`,api:`openai-completions`,apiKey:`ollama`}},lmstudio:{label:`LM Studio`,providerId:`lmstudio`,config:{baseUrl:`http://localhost:1234/v1`,api:`openai-completions`,apiKey:`lmstudio`}},openrouter:{label:`OpenRouter`,providerId:`openrouter`,config:{baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`,apiKey:``}},zhipuCn:{label:`Zhipu GLM China`,providerId:`zhipu-cn`,config:{baseUrl:`https://open.bigmodel.cn/api/paas/v4`,api:`openai-completions`,apiKey:`ZHIPU_API_KEY`,models:[{id:`glm-5.2`,name:`GLM 5.2`,contextWindow:1e6,maxTokens:65536,reasoning:!0,input:[`text`]}]}},zaiGeneral:{label:`Zhipu GLM International`,providerId:`zai`,config:{baseUrl:`https://api.z.ai/api/paas/v4`,api:`openai-completions`,apiKey:`ZAI_API_KEY`,models:[{id:`glm-5.2`,name:`GLM 5.2`,contextWindow:1e6,maxTokens:65536,reasoning:!0,input:[`text`]}]}},dashscopeCn:{label:`Alibaba Bailian / DashScope China`,providerId:`dashscope-cn`,description:`China OpenAI-compatible Qwen endpoint`,config:{baseUrl:`https://dashscope.aliyuncs.com/compatible-mode/v1`,api:`openai-completions`,apiKey:`DASHSCOPE_API_KEY`,models:[{id:`qwen3.7-max`,name:`Qwen3.7 Max`,contextWindow:1e6,input:[`text`,`image`]},{id:`qwen3.7-plus`,name:`Qwen3.7 Plus`,contextWindow:1e6,input:[`text`,`image`]},{id:`qwen3.6-flash`,name:`Qwen3.6 Flash`,contextWindow:1e6,input:[`text`]}]}},dashscopeIntl:{label:`Alibaba Bailian / DashScope International`,providerId:`dashscope-intl`,description:`International OpenAI-compatible Qwen endpoint`,config:{baseUrl:`https://dashscope-intl.aliyuncs.com/compatible-mode/v1`,api:`openai-completions`,apiKey:`DASHSCOPE_API_KEY`,models:[{id:`qwen3.7-max`,name:`Qwen3.7 Max`,contextWindow:1e6,input:[`text`,`image`]},{id:`qwen3.7-plus`,name:`Qwen3.7 Plus`,contextWindow:1e6,input:[`text`,`image`]},{id:`qwen3.6-flash`,name:`Qwen3.6 Flash`,contextWindow:1e6,input:[`text`]}]}},volcengineArk:{label:`Volcengine Ark`,providerId:`volcengine-ark`,description:`Use your Ark endpoint id as the model id`,config:{baseUrl:`https://ark.cn-beijing.volces.com/api/v3`,api:`openai-completions`,apiKey:`ARK_API_KEY`,models:[{id:`ep-your-endpoint-id`,name:`Ark endpoint ID`,contextWindow:128e3,input:[`text`]}]}},volcenginePlan:{label:`Volcengine Doubao Coding Plan`,providerId:`volcengine-plan`,description:`Doubao coding-plan endpoint on Volcengine Ark`,config:{baseUrl:`https://ark.cn-beijing.volces.com/api/coding/v3`,api:`openai-completions`,apiKey:`ARK_API_KEY`,models:[{id:`ark-code-latest`,name:`Ark Coding Plan`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-code`,name:`Doubao Seed 2.0 Code`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-pro`,name:`Doubao Seed 2.0 Pro`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-lite`,name:`Doubao Seed 2.0 Lite`,contextWindow:256e3,maxTokens:4096,input:[`text`]}]}},byteplusPlan:{label:`BytePlus Doubao Coding Plan`,providerId:`byteplus-plan`,description:`Doubao coding-plan endpoint on BytePlus`,config:{baseUrl:`https://ark.ap-southeast.bytepluses.com/api/coding/v3`,api:`openai-completions`,apiKey:`BYTEPLUS_API_KEY`,models:[{id:`ark-code-latest`,name:`Ark Coding Plan`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-code`,name:`Doubao Seed 2.0 Code`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-pro`,name:`Doubao Seed 2.0 Pro`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-lite`,name:`Doubao Seed 2.0 Lite`,contextWindow:256e3,maxTokens:4096,input:[`text`]}]}},deepseek:{label:`DeepSeek`,providerId:`deepseek`,config:{baseUrl:`https://api.deepseek.com`,api:`openai-completions`,apiKey:`DEEPSEEK_API_KEY`,models:[{id:`deepseek-v4-pro`,name:`DeepSeek V4 Pro`,contextWindow:1e6,maxTokens:393216,reasoning:!0,input:[`text`]},{id:`deepseek-v4-flash`,name:`DeepSeek V4 Flash`,contextWindow:1e6,maxTokens:393216,reasoning:!0,input:[`text`]}]}},moonshotCn:{label:`Kimi / Moonshot China`,providerId:`moonshotai-cn`,config:{baseUrl:`https://api.moonshot.cn/v1`,api:`openai-completions`,apiKey:`MOONSHOT_API_KEY`,models:[{id:`kimi-k2.7-code`,name:`Kimi K2.7 Code`,contextWindow:262144,maxTokens:32768,reasoning:!0,input:[`text`,`image`]},{id:`kimi-k2.6`,name:`Kimi K2.6`,contextWindow:128e3,input:[`text`]},{id:`kimi-k2.5`,name:`Kimi K2.5`,contextWindow:128e3,input:[`text`]}]}},moonshotIntl:{label:`Kimi / Moonshot International`,providerId:`moonshotai`,config:{baseUrl:`https://api.moonshot.ai/v1`,api:`openai-completions`,apiKey:`MOONSHOT_API_KEY`,models:[{id:`kimi-k2.7-code`,name:`Kimi K2.7 Code`,contextWindow:262144,maxTokens:32768,reasoning:!0,input:[`text`,`image`]},{id:`kimi-k2.6`,name:`Kimi K2.6`,contextWindow:128e3,input:[`text`]},{id:`kimi-k2.5`,name:`Kimi K2.5`,contextWindow:128e3,input:[`text`]}]}},kimiCoding:{label:`Kimi Coding`,providerId:`kimi-coding`,description:`Dedicated Kimi coding endpoint`,config:{baseUrl:`https://api.kimi.com/coding/`,api:`anthropic-messages`,apiKey:`KIMI_API_KEY`,headers:{"User-Agent":`claude-code/0.1.0`},models:[{id:`kimi-k2.7-code`,name:`Kimi K2.7 Code`,contextWindow:262144,maxTokens:32768,reasoning:!0,input:[`text`,`image`]},{id:`kimi-for-coding`,name:`Kimi Code`,contextWindow:262144,maxTokens:32768,reasoning:!0,input:[`text`,`image`]}]}},stepfunIntl:{label:`StepFun International`,providerId:`stepfun-intl`,config:{baseUrl:`https://api.stepfun.ai/v1`,api:`openai-completions`,apiKey:`STEPFUN_API_KEY`,models:[{id:`step-3.7-flash`,name:`Step 3.7 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash-2603`,name:`Step 3.5 Flash 2603`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash`,name:`Step 3.5 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`]}]}},stepfunCn:{label:`StepFun China`,providerId:`stepfun-cn`,config:{baseUrl:`https://api.stepfun.com/v1`,api:`openai-completions`,apiKey:`STEPFUN_API_KEY`,models:[{id:`step-3.7-flash`,name:`Step 3.7 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash-2603`,name:`Step 3.5 Flash 2603`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash`,name:`Step 3.5 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`]}]}},stepfunPlanIntl:{label:`StepFun Step Plan International`,providerId:`stepfun-plan-intl`,config:{baseUrl:`https://api.stepfun.ai/step_plan/v1`,api:`openai-completions`,apiKey:`STEPFUN_API_KEY`,models:[{id:`step-3.7-flash`,name:`Step 3.7 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash-2603`,name:`Step 3.5 Flash 2603`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash`,name:`Step 3.5 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`]}]}},stepfunPlanCn:{label:`StepFun Step Plan China`,providerId:`stepfun-plan-cn`,config:{baseUrl:`https://api.stepfun.com/step_plan/v1`,api:`openai-completions`,apiKey:`STEPFUN_API_KEY`,models:[{id:`step-3.7-flash`,name:`Step 3.7 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash-2603`,name:`Step 3.5 Flash 2603`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash`,name:`Step 3.5 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`]}]}},xiaomi:{label:`Xiaomi MiMo`,providerId:`xiaomi`,config:{baseUrl:`https://api.xiaomimimo.com/v1`,api:`openai-completions`,apiKey:`XIAOMI_API_KEY`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5-pro-ultraspeed`,name:`MiMo V2.5 Pro UltraSpeed`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5`,name:`MiMo V2.5`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]}]}},xiaomiTokenPlanCn:{label:`Xiaomi MiMo Token Plan China`,providerId:`xiaomi-token-plan-cn`,config:{baseUrl:`https://token-plan-cn.xiaomimimo.com/v1`,api:`openai-completions`,apiKey:`XIAOMI_TOKEN_PLAN_CN_API_KEY`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5-pro-ultraspeed`,name:`MiMo V2.5 Pro UltraSpeed`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5`,name:`MiMo V2.5`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]}]}},xiaomiTokenPlanAms:{label:`Xiaomi MiMo Token Plan Amsterdam`,providerId:`xiaomi-token-plan-ams`,config:{baseUrl:`https://token-plan-ams.xiaomimimo.com/v1`,api:`openai-completions`,apiKey:`XIAOMI_TOKEN_PLAN_AMS_API_KEY`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5-pro-ultraspeed`,name:`MiMo V2.5 Pro UltraSpeed`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5`,name:`MiMo V2.5`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]}]}},xiaomiTokenPlanSgp:{label:`Xiaomi MiMo Token Plan Singapore`,providerId:`xiaomi-token-plan-sgp`,config:{baseUrl:`https://token-plan-sgp.xiaomimimo.com/v1`,api:`openai-completions`,apiKey:`XIAOMI_TOKEN_PLAN_SGP_API_KEY`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5-pro-ultraspeed`,name:`MiMo V2.5 Pro UltraSpeed`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5`,name:`MiMo V2.5`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]}]}},minimax:{label:`MiniMax`,providerId:`minimax`,description:`Anthropic-compatible endpoint preferred for agent workflows`,config:{baseUrl:`https://api.minimax.io/anthropic`,api:`anthropic-messages`,apiKey:`MINIMAX_API_KEY`,authHeader:!0,models:[{id:`MiniMax-M3`,name:`MiniMax M3`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`MiniMax-M2.7-highspeed`,name:`MiniMax M2.7 Highspeed`,contextWindow:204800,input:[`text`]},{id:`MiniMax-M2.7`,name:`MiniMax M2.7`,contextWindow:204800,input:[`text`]}]}},zhipuCodingCn:{label:`Zhipu GLM Coding Plan China`,providerId:`zhipu-coding-cn`,config:{baseUrl:`https://open.bigmodel.cn/api/coding/paas/v4`,api:`openai-completions`,apiKey:`ZHIPU_API_KEY`,models:[{id:`glm-5.2`,name:`GLM 5.2`,contextWindow:1e6,maxTokens:65536,reasoning:!0,input:[`text`]}]}},zaiCodingGlobal:{label:`Zhipu GLM Coding Plan International`,providerId:`zai-coding-global`,config:{baseUrl:`https://api.z.ai/api/coding/paas/v4`,api:`openai-completions`,apiKey:`ZAI_API_KEY`,models:[{id:`glm-5.2`,name:`GLM 5.2`,contextWindow:1e6,maxTokens:65536,reasoning:!0,input:[`text`]}]}},minimaxCn:{label:`MiniMax China`,providerId:`minimax-cn`,config:{baseUrl:`https://api.minimaxi.com/anthropic`,api:`anthropic-messages`,apiKey:`MINIMAX_CN_API_KEY`,authHeader:!0,models:[{id:`MiniMax-M3`,name:`MiniMax M3`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`MiniMax-M2.7-highspeed`,name:`MiniMax M2.7 Highspeed`,contextWindow:204800,input:[`text`]},{id:`MiniMax-M2.7`,name:`MiniMax M2.7`,contextWindow:204800,input:[`text`]}]}}},H3=Object.entries(V3).map(([e,t])=>({key:e,...t}));function _fe(e){return V3[e]?.providerId??e}function vfe(e){return H3.find(t=>t.providerId===e)?.key}var yfe=new Set([`dashscope-cn`,`dashscope-intl`,`volcengine-ark`,`volcengine-plan`,`byteplus-plan`,`stepfun-cn`,`stepfun-intl`,`stepfun-plan-cn`,`stepfun-plan-intl`,`zhipu-cn`,`zai-coding-global`,`zhipu-coding-cn`]);function U3(e){if(yfe.has(e))return vfe(e)}function bfe(e,t){let n=U3(e);if(!n)return;let r=V3[n];if(r)return{providerId:r.providerId,config:{...r.config,apiKey:t?.trim()||r.config.apiKey,models:r.config.models?.map(e=>({...e}))}}}var xfe=[{value:`text`,labelKey:`inputTextOnly`},{value:`text,image`,labelKey:`inputTextVision`}];function Sfe(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,oA,`dark:border-edge`)}function Cfe(){return u(rA,nA)}function wfe(e){return(e.input||[`text`]).includes(`image`)?`text,image`:`text`}function Tfe(e){return e===`text,image`?[`text`,`image`]:[`text`]}function Efe(e,t){return e===`single`?t.getApiKey:e===`intl`?t.getApiKeyIntl:t.getApiKeyCn}var W3={openai:{apiKeyUrl:`https://platform.openai.com/api-keys`,pricingUrl:`https://openai.com/pricing`,docsUrl:`https://platform.openai.com/docs`,description:`The most widely used LLM provider. Powers ChatGPT.`,descriptionZh:`最广泛使用的 LLM 服务商,ChatGPT 背后的技术。`,bestFor:[`general`,`coding`,`vision`],freeTier:!1,freeTierNote:`Pay-as-you-go; new accounts may receive trial credits.`,aliases:[`chatgpt`,`gpt`,`gpt-4`,`gpt4`,`gpt-4o`,`gpt4o`],envVars:[`OPENAI_API_KEY`]},anthropic:{apiKeyUrl:`https://console.anthropic.com/settings/keys`,pricingUrl:`https://www.anthropic.com/pricing`,docsUrl:`https://docs.anthropic.com`,description:`Anthropic model access. Available models are loaded from the gateway catalog.`,descriptionZh:`Anthropic 模型服务。可用模型由网关目录动态加载。`,bestFor:[`long context`,`coding`,`reasoning`],freeTier:!1,aliases:[`claude`,`claude 3`,`claude sonnet`,`claude opus`,`claude haiku`],envVars:[`ANTHROPIC_OAUTH_TOKEN`,`ANTHROPIC_API_KEY`]},google:{apiKeyUrl:`https://aistudio.google.com/app/apikey`,pricingUrl:`https://ai.google.dev/pricing`,docsUrl:`https://ai.google.dev/docs`,description:`Google AI model access. Available models are loaded from the gateway catalog.`,descriptionZh:`Google AI 模型服务。可用模型由网关目录动态加载。`,bestFor:[`multimodal`,`long context`,`general`],freeTier:!0,freeTierNote:`Free tier available via Google AI Studio.`,aliases:[`gemini`,`google gemini`,`bard`,`google ai`],envVars:[`GEMINI_API_KEY`,`GOOGLE_API_KEY`]},"google-vertex":{apiKeyUrl:`https://console.cloud.google.com/apis/credentials`,pricingUrl:`https://cloud.google.com/vertex-ai/pricing`,docsUrl:`https://cloud.google.com/vertex-ai/docs`,description:`Google Vertex AI — enterprise-grade model hosting on GCP.`,descriptionZh:`Google Vertex AI,企业级 GCP 托管模型服务。`,bestFor:[`enterprise`,`multimodal`,`compliance`],freeTier:!1,aliases:[`vertex`,`vertex ai`,`gcp`,`google cloud`],envVars:[`GOOGLE_CLOUD_API_KEY`,`GOOGLE_CLOUD_PROJECT`,`GOOGLE_CLOUD_LOCATION`]},"google-gemini-cli":{apiKeyUrl:`https://aistudio.google.com/app/apikey`,pricingUrl:`https://ai.google.dev/pricing`,docsUrl:`https://ai.google.dev/docs`,description:`Gemini via CLI token — for users authenticated with the Gemini CLI tool.`,descriptionZh:`通过 Gemini CLI 令牌访问 Gemini,适合已安装 CLI 工具的用户。`,bestFor:[`general`,`multimodal`],freeTier:!0,freeTierNote:`Uses your existing Gemini CLI authentication.`,aliases:[`gemini cli`,`gemini-cli`],envVars:[`GEMINI_CLI_TOKEN`,`GOOGLE_TOKEN`]},"google-antigravity":{apiKeyUrl:`https://console.cloud.google.com/apis/credentials`,pricingUrl:`https://cloud.google.com/pricing`,docsUrl:`https://cloud.google.com/docs`,description:`Google Antigravity — internal/experimental Google AI endpoint.`,descriptionZh:`Google Antigravity,Google 内部/实验性 AI 端点。`,bestFor:[`experimental`],freeTier:!1,aliases:[`antigravity`,`google antigravity`],envVars:[`ANTIGRAVITY_API_KEY`]},groq:{apiKeyUrl:`https://console.groq.com/keys`,pricingUrl:`https://groq.com/pricing/`,docsUrl:`https://console.groq.com/docs`,description:`Extremely fast inference — ideal for latency-sensitive applications.`,descriptionZh:`推理速度极快,适合对延迟敏感的场景。`,bestFor:[`speed`,`cheap`],freeTier:!0,freeTierNote:`Generous free tier with rate limits.`,aliases:[`groq`,`llama on groq`,`mixtral on groq`],envVars:[`GROQ_API_KEY`]},deepseek:{apiKeyUrl:`https://platform.deepseek.com/api_keys`,pricingUrl:`https://api-docs.deepseek.com/quick_start/pricing/`,docsUrl:`https://platform.deepseek.com/api-docs/`,description:`DeepSeek model access through an OpenAI-compatible API.`,descriptionZh:`通过 OpenAI 兼容 API 访问 DeepSeek 模型。`,bestFor:[`reasoning`,`cheap`,`coding`],freeTier:!0,freeTierNote:`Free credits may be available for new accounts.`,aliases:[`deepseek`,`deep seek`,`deepseek v4`,`deepseek-v4`,`r1`],envVars:[`DEEPSEEK_API_KEY`]},"volcengine-ark":{apiKeyUrl:`https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey`,pricingUrl:`https://www.volcengine.com/docs/82379/1099320`,docsUrl:`https://www.volcengine.com/docs/82379/1302008`,description:`Volcengine Ark — OpenAI-compatible access to Doubao and custom Ark endpoints.`,descriptionZh:`火山方舟,通过 OpenAI 兼容接口访问豆包与自定义方舟 endpoint。`,bestFor:[`chinese`,`general`,`enterprise`],aliases:[`volcengine`,`ark`,`doubao`,`volces`,`火山方舟`,`豆包`],envVars:[`ARK_API_KEY`,`VOLCENGINE_API_KEY`]},"volcengine-plan":{apiKeyUrl:`https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey`,pricingUrl:`https://www.volcengine.com/docs/82379/1099320`,docsUrl:`https://www.volcengine.com/docs/82379/1302008`,description:`Volcengine Doubao Coding Plan — Ark coding endpoint.`,descriptionZh:`火山方舟豆包 Coding Plan,使用 Ark coding endpoint。`,bestFor:[`coding`,`chinese`],aliases:[`volcengine plan`,`ark coding`,`doubao coding`,`火山方舟 coding`],envVars:[`ARK_API_KEY`,`VOLCENGINE_API_KEY`]},"byteplus-plan":{apiKeyUrl:`https://console.byteplus.com/ark/region:ark+ap-southeast-1/apiKey`,pricingUrl:`https://docs.byteplus.com/en/docs/ModelArk`,docsUrl:`https://docs.byteplus.com/en/docs/ModelArk/OpenAI`,description:`BytePlus Doubao Coding Plan — international Ark coding endpoint.`,descriptionZh:`BytePlus 豆包 Coding Plan,国际区 Ark coding endpoint。`,bestFor:[`coding`,`chinese`],aliases:[`byteplus`,`byteplus plan`,`doubao coding international`],envVars:[`BYTEPLUS_API_KEY`,`ARK_API_KEY`]},xai:{apiKeyUrl:`https://console.x.ai/`,pricingUrl:`https://x.ai/api`,docsUrl:`https://docs.x.ai/`,description:`xAI model access. Available models are loaded from the gateway catalog.`,descriptionZh:`xAI 模型服务。可用模型由网关目录动态加载。`,bestFor:[`reasoning`,`real-time`],freeTier:!1,aliases:[`grok`,`xai`,`x.ai`],envVars:[`XAI_API_KEY`]},cerebras:{apiKeyUrl:`https://cloud.cerebras.ai/platform/`,pricingUrl:`https://cloud.cerebras.ai/platform/`,docsUrl:`https://inference-docs.cerebras.ai/`,description:`Ultra-fast inference on custom AI chips. Fastest Llama inference available.`,descriptionZh:`基于专用 AI 芯片的超快推理,Llama 推理速度业界最快。`,bestFor:[`speed`],freeTier:!0,freeTierNote:`Free tier available.`,aliases:[`cerebras`],envVars:[`CEREBRAS_API_KEY`]},mistral:{apiKeyUrl:`https://console.mistral.ai/api-keys/`,pricingUrl:`https://mistral.ai/technology/#pricing`,docsUrl:`https://docs.mistral.ai/`,description:`European open-weight models. Good balance of quality and cost.`,descriptionZh:`欧洲开源模型,质量与成本平衡好。`,bestFor:[`general`,`cheap`,`coding`],freeTier:!1,aliases:[`mistral`,`mixtral`,`codestral`],envVars:[`MISTRAL_API_KEY`]},openrouter:{apiKeyUrl:`https://openrouter.ai/keys`,pricingUrl:`https://openrouter.ai/models`,docsUrl:`https://openrouter.ai/docs`,description:`API gateway to 100+ models from many providers with a single key.`,descriptionZh:`统一 API 网关,一个 Key 访问 100+ 模型。`,bestFor:[`general`,`flexibility`],freeTier:!0,freeTierNote:`Some models are free; pay-per-use for others.`,aliases:[`openrouter`,`open router`],envVars:[`OPENROUTER_API_KEY`]},"azure-openai-responses":{apiKeyUrl:`https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI`,pricingUrl:`https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/`,docsUrl:`https://learn.microsoft.com/en-us/azure/ai-services/openai/`,description:`OpenAI models hosted on Azure. Enterprise SLA and data residency.`,descriptionZh:`Azure 托管的 OpenAI 模型,企业级 SLA 和数据合规。`,bestFor:[`enterprise`,`compliance`,`coding`],freeTier:!1,aliases:[`azure`,`azure openai`,`aoai`],envVars:[`AZURE_OPENAI_API_KEY`,`AZURE_OPENAI_BASE_URL`]},"amazon-bedrock":{apiKeyUrl:`https://console.aws.amazon.com/iam/home#/security_credentials`,pricingUrl:`https://aws.amazon.com/bedrock/pricing/`,docsUrl:`https://docs.aws.amazon.com/bedrock/`,description:`AWS Bedrock hosted model access with enterprise controls.`,descriptionZh:`AWS Bedrock 托管模型服务,提供企业级控制能力。`,bestFor:[`enterprise`,`compliance`],freeTier:!1,aliases:[`bedrock`,`aws`,`amazon`],envVars:[`AWS_ACCESS_KEY_ID`,`AWS_SECRET_ACCESS_KEY`,`AWS_REGION`]},minimax:{apiKeyUrl:`https://platform.minimax.io/user-center/basic-information/interface-key`,pricingUrl:`https://platform.minimax.io/docs/guides/models-intro`,docsUrl:`https://platform.minimax.io/docs/guides/quickstart-preparation`,description:`MiniMax — Chinese multimodal model with strong text and audio capabilities.`,descriptionZh:`MiniMax,国产多模态模型,文本和音频能力强。`,bestFor:[`multimodal`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`minimax`,`mini max`,`abab`],envVars:[`MINIMAX_API_KEY`]},"minimax-cn":{apiKeyUrl:`https://platform.minimaxi.com/user-center/basic-information/interface-key`,pricingUrl:`https://platform.minimaxi.com/document/Price`,docsUrl:`https://platform.minimaxi.com/document/Announcement`,description:`MiniMax (China endpoint) — domestic access for Chinese users.`,descriptionZh:`MiniMax 国内端点,国内用户直连访问。`,bestFor:[`multimodal`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`minimax cn`,`minimax china`,`abab`],envVars:[`MINIMAX_CN_API_KEY`,`MINIMAX_API_KEY`]},stepfun:{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun OpenAI-compatible endpoint.`,descriptionZh:`阶跃星辰 StepFun OpenAI 兼容端点。`,bestFor:[`chinese`,`reasoning`,`general`],aliases:[`stepfun`,`step`,`阶跃星辰`],envVars:[`STEPFUN_API_KEY`]},"stepfun-cn":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun China — OpenAI-compatible chat endpoint.`,descriptionZh:`阶跃星辰 StepFun 中国区 OpenAI 兼容对话端点。`,bestFor:[`chinese`,`reasoning`,`general`],aliases:[`stepfun cn`,`step cn`,`阶跃星辰`],envVars:[`STEPFUN_API_KEY`]},"stepfun-intl":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun International — OpenAI-compatible chat endpoint.`,descriptionZh:`阶跃星辰 StepFun 国际区 OpenAI 兼容对话端点。`,bestFor:[`chinese`,`reasoning`,`general`],aliases:[`stepfun intl`,`step international`],envVars:[`STEPFUN_API_KEY`]},"stepfun-plan":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun Step Plan coding/planning endpoint.`,descriptionZh:`阶跃星辰 Step Plan coding/planning 专用端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`stepfun plan`,`step plan`,`阶跃 plan`],envVars:[`STEPFUN_API_KEY`]},"stepfun-plan-cn":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun Step Plan China — coding/planning endpoint.`,descriptionZh:`阶跃星辰 Step Plan 中国区 coding/planning 专用端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`stepfun plan cn`,`step plan cn`,`阶跃 plan`],envVars:[`STEPFUN_API_KEY`]},"stepfun-plan-intl":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun Step Plan International — coding/planning endpoint.`,descriptionZh:`阶跃星辰 Step Plan 国际区 coding/planning 专用端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`stepfun plan intl`,`step plan international`],envVars:[`STEPFUN_API_KEY`]},"kimi-coding":{apiKeyUrl:`https://platform.kimi.com/console/api-keys`,pricingUrl:`https://platform.kimi.com/docs/pricing/chat`,docsUrl:`https://platform.kimi.com/docs`,description:`Kimi Coding — dedicated Anthropic-compatible coding endpoint.`,descriptionZh:`Kimi Coding,Anthropic 兼容的专用 coding 端点。`,bestFor:[`coding`,`chinese`,`vision`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`kimi coding`,`moonshot coding`,`kimi code`],envVars:[`KIMI_API_KEY`,`MOONSHOT_API_KEY`]},moonshotai:{apiKeyUrl:`https://platform.moonshot.ai/console/api-keys`,pricingUrl:`https://platform.moonshot.ai/docs/pricing`,docsUrl:`https://platform.moonshot.ai/docs`,description:`Moonshot Kimi — international API (api.moonshot.ai).`,descriptionZh:`月之暗面 Kimi 国际版 API(api.moonshot.ai)。`,bestFor:[`coding`,`chinese`,`long context`],freeTier:!0,aliases:[`moonshot`,`kimi`,`moonshot ai`],envVars:[`MOONSHOT_API_KEY`]},"moonshotai-cn":{apiKeyUrl:`https://platform.moonshot.cn/console/api-keys`,pricingUrl:`https://platform.moonshot.cn/docs/pricing/chat`,docsUrl:`https://platform.moonshot.cn/docs`,description:`Moonshot Kimi — China region endpoint.`,descriptionZh:`月之暗面 Kimi 中国区域端点。`,bestFor:[`coding`,`chinese`,`long context`],freeTier:!0,aliases:[`moonshot cn`,`kimi cn`],envVars:[`MOONSHOT_API_KEY`]},fal:{apiKeyUrl:`https://fal.ai/dashboard/keys`,pricingUrl:`https://fal.ai/pricing`,docsUrl:`https://fal.ai/docs`,description:`fal — serverless image and media generation APIs.`,descriptionZh:`fal:无服务器图像与媒体生成 API。`,bestFor:[`image`,`video`],freeTier:!0,aliases:[`fal ai`,`fal.ai`],envVars:[`FAL_KEY`,`FAL_API_KEY`]},fireworks:{apiKeyUrl:`https://fireworks.ai/account/api-keys`,pricingUrl:`https://fireworks.ai/pricing`,docsUrl:`https://docs.fireworks.ai`,description:`Fireworks AI — fast inference for open and proprietary models.`,descriptionZh:`Fireworks AI,多种开源与商业模型的高速推理服务。`,bestFor:[`speed`,`coding`,`open weights`],freeTier:!0,aliases:[`fireworks ai`,`fireworks`],envVars:[`FIREWORKS_API_KEY`]},together:{apiKeyUrl:`https://api.together.xyz/settings/api-keys`,pricingUrl:`https://www.together.ai/pricing`,docsUrl:`https://docs.together.ai`,description:`Together AI — hosted Llama, Qwen, DeepSeek, and more.`,descriptionZh:`Together AI,托管 Llama、Qwen、DeepSeek 等模型。`,bestFor:[`open source`,`flexibility`],freeTier:!0,aliases:[`together ai`,`together.xyz`],envVars:[`TOGETHER_API_KEY`]},"cloudflare-workers-ai":{apiKeyUrl:`https://dash.cloudflare.com/?to=/:account/ai/workers-ai`,pricingUrl:`https://developers.cloudflare.com/workers-ai/platform/pricing/`,docsUrl:`https://developers.cloudflare.com/workers-ai/`,description:`Cloudflare Workers AI — models at the edge via Cloudflare API.`,descriptionZh:`Cloudflare Workers AI,通过 Cloudflare API 在边缘运行模型。`,bestFor:[`edge`,`latency`],freeTier:!0,aliases:[`workers ai`,`cf workers ai`],envVars:[`CLOUDFLARE_API_KEY`]},"cloudflare-ai-gateway":{apiKeyUrl:`https://dash.cloudflare.com/?to=/:account/ai/ai-gateway`,pricingUrl:`https://developers.cloudflare.com/ai-gateway/pricing/`,docsUrl:`https://developers.cloudflare.com/ai-gateway/`,description:`Cloudflare AI Gateway — unified OpenAI/Anthropic-compatible routing.`,descriptionZh:`Cloudflare AI Gateway,统一 OpenAI/Anthropic 兼容路由。`,bestFor:[`routing`,`observability`,`enterprise`],freeTier:!0,aliases:[`cf ai gateway`,`cloudflare gateway`],envVars:[`CLOUDFLARE_API_KEY`]},xiaomi:{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo — API billing through the MiMo open platform; endpoint api.xiaomimimo.com.`,descriptionZh:`小米 MiMo 按量计费线路,在开放平台创建密钥;接口域名为 api.xiaomimimo.com。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi`,`mimo`,`小米`,`xiaomimimo`],envVars:[`XIAOMI_API_KEY`]},"xiaomi-token-plan-cn":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — China region (token-plan-cn.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 中国区(token-plan-cn.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token cn`,`mimo token cn`],envVars:[`XIAOMI_TOKEN_PLAN_CN_API_KEY`,`XIAOMI_TOKEN_PLAN_API_KEY`]},"xiaomi-token-plan-ams":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — Amsterdam region (token-plan-ams.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 阿姆斯特丹(token-plan-ams.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token ams`,`mimo token ams`],envVars:[`XIAOMI_TOKEN_PLAN_AMS_API_KEY`,`XIAOMI_TOKEN_PLAN_API_KEY`]},"xiaomi-token-plan-sgp":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — Singapore region (token-plan-sgp.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 新加坡(token-plan-sgp.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token sgp`,`mimo token sgp`],envVars:[`XIAOMI_TOKEN_PLAN_SGP_API_KEY`,`XIAOMI_TOKEN_PLAN_API_KEY`]},"ant-ling":{apiKeyUrl:`https://ling.tbox.cn/`,docsUrl:`https://ling.tbox.cn/`,description:`Ant Ling — domestic OpenAI-compatible access to Ling and Ring models.`,descriptionZh:`蚂蚁 Ling,国内 OpenAI 兼容服务,提供 Ling 与 Ring 系列模型。`,bestFor:[`chinese`,`reasoning`,`coding`],aliases:[`ant ling`,`ling`,`ring`,`蚂蚁 ling`,`蚂蚁灵`],envVars:[`ANT_LING_API_KEY`,`LING_API_KEY`]},"zai-coding-global":{apiKeyUrl:`https://z.ai/manage-apikey/apikey-list`,pricingUrl:`https://z.ai/manage-apikey/billing`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,description:`Zhipu GLM Coding Plan — international z.ai endpoint.`,descriptionZh:`智谱 GLM Coding Plan 国际区 z.ai 端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`zai coding`,`zhipu coding global`,`glm coding global`],envVars:[`ZAI_API_KEY`,`Z_AI_API_KEY`]},"zai-coding-cn":{apiKeyUrl:`https://bigmodel.cn/usercenter/proj-mgmt/apikeys`,pricingUrl:`https://bigmodel.cn/pricing`,docsUrl:`https://docs.bigmodel.cn/cn/guide/start/model-overview`,description:`Zhipu GLM Coding Plan — China endpoint from the pi-ai provider catalog.`,descriptionZh:`智谱 GLM Coding Plan 中国区,来自 pi-ai 内置 provider 目录。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`zai coding cn`,`zhipu coding cn`,`glm coding cn`,`智谱 coding`],envVars:[`ZHIPU_API_KEY`,`BIGMODEL_API_KEY`,`ZAI_API_KEY`]},"zhipu-coding-cn":{apiKeyUrl:`https://bigmodel.cn/usercenter/proj-mgmt/apikeys`,pricingUrl:`https://bigmodel.cn/pricing`,docsUrl:`https://docs.bigmodel.cn/cn/guide/start/model-overview`,description:`Zhipu GLM Coding Plan — China BigModel endpoint.`,descriptionZh:`智谱 GLM Coding Plan 中国区 BigModel 端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`zhipu coding`,`glm coding cn`,`智谱 coding`],envVars:[`ZHIPU_API_KEY`,`BIGMODEL_API_KEY`,`ZAI_API_KEY`]},"zhipu-cn":{apiKeyUrl:`https://bigmodel.cn/usercenter/proj-mgmt/apikeys`,pricingUrl:`https://bigmodel.cn/pricing`,docsUrl:`https://docs.bigmodel.cn/cn/guide/start/model-overview`,description:`Zhipu GLM China — BigModel OpenAI-compatible endpoint.`,descriptionZh:`智谱 GLM 中国区,通过 BigModel OpenAI 兼容接口访问。`,bestFor:[`chinese`,`reasoning`,`general`],freeTier:!0,aliases:[`zhipu`,`glm`,`bigmodel`,`智谱`,`z.ai cn`],envVars:[`ZHIPU_API_KEY`,`BIGMODEL_API_KEY`]},huggingface:{apiKeyUrl:`https://huggingface.co/settings/tokens`,pricingUrl:`https://huggingface.co/pricing`,docsUrl:`https://huggingface.co/docs/api-inference/`,description:`Access thousands of open-source models via Hugging Face Inference API.`,descriptionZh:`通过 Hugging Face 访问数千个开源模型。`,bestFor:[`open source`,`flexibility`],freeTier:!0,freeTierNote:`Free tier with rate limits.`,aliases:[`huggingface`,`hugging face`,`hf`],envVars:[`HF_TOKEN`,`HUGGINGFACE_TOKEN`]},opencode:{apiKeyUrl:`https://opencode.ai/auth`,pricingUrl:`https://opencode.ai/docs`,docsUrl:`https://opencode.ai/docs/providers/`,description:`OpenCode — AI coding assistant provider.`,descriptionZh:`OpenCode,AI 代码助手服务商。`,bestFor:[`coding`],freeTier:!1,aliases:[`opencode`,`open code`],envVars:[`OPENCODE_API_KEY`]},"opencode-go":{apiKeyUrl:`https://opencode.ai/auth`,pricingUrl:`https://opencode.ai/docs`,docsUrl:`https://opencode.ai/docs/providers/`,description:`OpenCode Go — AI coding assistant provider (Go variant).`,descriptionZh:`OpenCode Go,AI 代码助手服务商(Go 版本)。`,bestFor:[`coding`],freeTier:!1,aliases:[`opencode go`,`opencode-go`],envVars:[`OPENCODE_API_KEY`]},zai:{apiKeyUrl:`https://z.ai/manage-apikey/apikey-list`,pricingUrl:`https://z.ai/manage-apikey/billing`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,description:`Zhipu GLM International — z.ai OpenAI-compatible endpoint.`,descriptionZh:`智谱 GLM 国际区,通过 z.ai OpenAI 兼容接口访问。`,bestFor:[`general`,`reasoning`,`chinese`],freeTier:!1,aliases:[`zai`,`z.ai`,`zhipu global`,`glm global`,`智谱`],envVars:[`ZAI_API_KEY`,`Z_AI_API_KEY`]},dashscope:{apiKeyUrl:`https://dashscope.console.aliyun.com/apiKey`,pricingUrl:`https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-thousand-questions-metering-and-billing`,docsUrl:`https://help.aliyun.com/zh/model-studio/developer-reference/compatibility-of-openai-with-dashscope`,description:`Alibaba Bailian / DashScope service provider.`,descriptionZh:`阿里百炼 / DashScope 服务 provider。`,bestFor:[`chinese`,`coding`,`image`,`speech`],freeTier:!0,aliases:[`dash scope`,`alibaba dashscope`,`qwen`,`tongyi`,`阿里百炼`,`通义千问`],envVars:[`DASHSCOPE_API_KEY`,`QWEN_API_KEY`]},"dashscope-cn":{apiKeyUrl:`https://dashscope.console.aliyun.com/apiKey`,pricingUrl:`https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-thousand-questions-metering-and-billing`,docsUrl:`https://help.aliyun.com/zh/model-studio/developer-reference/compatibility-of-openai-with-dashscope`,description:`Alibaba Bailian / DashScope China — Qwen LLMs through the China endpoint.`,descriptionZh:`阿里百炼 / DashScope 中国区:通过国内端点访问通义千问 LLM。`,bestFor:[`chinese`,`coding`,`image`],freeTier:!0,aliases:[`dash scope cn`,`alibaba dashscope cn`,`qwen cn`,`tongyi cn`,`阿里百炼`,`通义千问`],envVars:[`DASHSCOPE_API_KEY`,`QWEN_API_KEY`]},"dashscope-intl":{apiKeyUrl:`https://modelstudio.console.alibabacloud.com/`,pricingUrl:`https://www.alibabacloud.com/help/en/model-studio/billing-for-tongyi-qianwen`,docsUrl:`https://www.alibabacloud.com/help/en/model-studio/compatibility-of-openai-with-dashscope`,description:`Alibaba Bailian / DashScope International — Qwen LLMs through the international endpoint.`,descriptionZh:`阿里百炼 / DashScope 国际区:通过国际端点访问通义千问 LLM。`,bestFor:[`chinese`,`coding`,`image`],freeTier:!0,aliases:[`dash scope intl`,`alibaba cloud dashscope`,`qwen intl`,`tongyi intl`],envVars:[`DASHSCOPE_API_KEY`,`QWEN_API_KEY`]},"vercel-ai-gateway":{apiKeyUrl:`https://vercel.com/account/tokens`,pricingUrl:`https://vercel.com/pricing`,docsUrl:`https://vercel.com/docs/ai/ai-gateway`,description:`Vercel AI Gateway — route requests to multiple LLM providers via Vercel.`,descriptionZh:`Vercel AI Gateway,通过 Vercel 路由请求到多个 LLM 服务商。`,bestFor:[`flexibility`,`enterprise`],freeTier:!1,aliases:[`vercel gateway`,`vercel ai gateway`],envVars:[`AI_GATEWAY_API_KEY`,`VERCEL_AI_GATEWAY_API_KEY`]},"github-copilot":{apiKeyUrl:`https://github.com/settings/tokens`,pricingUrl:`https://github.com/features/copilot#pricing`,docsUrl:`https://docs.github.com/en/copilot`,description:`GitHub Copilot — use your GitHub token to access Copilot models.`,descriptionZh:`使用 GitHub 令牌访问 Copilot 模型。`,bestFor:[`coding`],freeTier:!0,freeTierNote:`Free for verified students and open-source maintainers.`,aliases:[`github copilot`,`copilot`,`github`],envVars:[`COPILOT_GITHUB_TOKEN`,`GH_TOKEN`,`GITHUB_TOKEN`,`GITHUB_COPILOT_TOKEN`]}};function Dfe(e,t){let n=W3[e];return n&&n.apiKeyUrl?[{href:n.apiKeyUrl,kind:`single`}]:[]}async function G3(){let e=await J(X(`/api/global-defaults`));if(!e.payload||typeof e.payload.presetId!=`string`)throw Error(`Invalid global defaults response`);return e.payload}async function K3(e){let t=await J(X(`/api/global-defaults`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({models:e})});if(!t.payload||typeof t.payload.presetId!=`string`)throw Error(`Invalid global defaults response`);return t.payload}var Ofe={name:``,description:``,language:``,creature:``,emoji:``,avatar:``};function kfe(e){let t={...Ofe};if(!e.trim())return t;let n={name:`name`,description:`description`,language:`language`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
154
+ `,1;if(L>1e5&&L>r.index*3)throw Error(`potential infinite loop, way more iterations than matches`);return P+=a,a.length}let D=N(e);if(!D)throw X(s.replace(`{}`,e)),Error(`Unknown language: "`+e+`"`);let O=de(D),k=``,A=a||O,j={},M=new l.__emitter(l);w();let P=``,F=0,I=0,L=0,R=!1;try{if(D.__emitTokens)D.__emitTokens(n,M);else{for(A.matcher.considerAll();;){L++,R?R=!1:A.matcher.considerAll(),A.matcher.lastIndex=I;let e=A.matcher.exec(n);if(!e)break;let t=E(n.substring(I,e.index),e);I=e.index+t}E(n.substring(I))}return M.finalize(),k=M.toHTML(),{language:e,value:k,relevance:F,illegal:!1,_emitter:M,_top:A}}catch(t){if(t.message&&t.message.includes(`Illegal`))return{language:e,value:ge(n),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:I,context:n.slice(I-100,I+100),mode:t.mode,resultSoFar:k},_emitter:M};if(o)return{language:e,value:ge(n),illegal:!1,relevance:0,errorRaised:t,_emitter:M,_top:A};throw t}}function b(e){let t={value:ge(e),illegal:!1,relevance:0,_top:c,_emitter:new l.__emitter(l)};return t._emitter.addText(e),t}function S(e,n){n=n||l.languages||Object.keys(t);let r=b(e),i=n.filter(N).filter(F).map(t=>v(t,e,!1));i.unshift(r);let[a,o]=i.sort((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(N(e.language).supersetOf===t.language)return 1;if(N(t.language).supersetOf===e.language)return-1}return 0}),s=a;return s.secondBest=o,s}function C(e,t,n){let r=t&&i[t]||n;e.classList.add(`hljs`),e.classList.add(`language-${r}`)}function w(e){let t=null,n=d(e);if(u(n))return;if(z(`before:highlightElement`,{el:e,language:n}),e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);return}if(e.children.length>0&&(l.ignoreUnescapedHTML||(console.warn(`One of your code blocks includes unescaped HTML. This is a potentially serious security risk.`),console.warn(`https://github.com/highlightjs/highlight.js/wiki/security`),console.warn(`The element with unescaped HTML:`),console.warn(e)),l.throwUnescapedHTML))throw new he(`One of your code blocks includes unescaped HTML.`,e.innerHTML);t=e;let r=t.textContent,i=n?p(r,{language:n,ignoreIllegals:!0}):S(r);e.innerHTML=i.value,e.dataset.highlighted=`yes`,C(e,n,i.language),e.result={language:i.language,re:i.relevance,relevance:i.relevance},i.secondBest&&(e.secondBest={language:i.secondBest.language,relevance:i.secondBest.relevance}),z(`after:highlightElement`,{el:e,result:i,text:r})}function T(e){l=_e(l,e)}let E=()=>{k(),ae(`10.6.0`,`initHighlighting() deprecated. Use highlightAll() now.`)};function D(){k(),ae(`10.6.0`,`initHighlightingOnLoad() deprecated. Use highlightAll() now.`)}let O=!1;function k(){function e(){k()}if(document.readyState===`loading`){O||window.addEventListener(`DOMContentLoaded`,e,!1),O=!0;return}document.querySelectorAll(l.cssSelector).forEach(w)}function A(n,r){let i=null;try{i=r(e)}catch(e){if(X(`Language definition for '{}' could not be registered.`.replace(`{}`,n)),o)X(e);else throw e;i=c}i.name||=n,t[n]=i,i.rawDefinition=r.bind(null,e),i.aliases&&P(i.aliases,{languageName:n})}function j(e){delete t[e];for(let t of Object.keys(i))i[t]===e&&delete i[t]}function M(){return Object.keys(t)}function N(e){return e=(e||``).toLowerCase(),t[e]||t[i[e]]}function P(e,{languageName:t}){typeof e==`string`&&(e=[e]),e.forEach(e=>{i[e.toLowerCase()]=t})}function F(e){let t=N(e);return t&&!t.disableAutodetect}function I(e){e[`before:highlightBlock`]&&!e[`before:highlightElement`]&&(e[`before:highlightElement`]=t=>{e[`before:highlightBlock`](Object.assign({block:t.el},t))}),e[`after:highlightBlock`]&&!e[`after:highlightElement`]&&(e[`after:highlightElement`]=t=>{e[`after:highlightBlock`](Object.assign({block:t.el},t))})}function L(e){I(e),a.push(e)}function R(e){let t=a.indexOf(e);t!==-1&&a.splice(t,1)}function z(e,t){let n=e;a.forEach(function(e){e[n]&&e[n](t)})}function V(e){return ae(`10.7.0`,`highlightBlock will be removed entirely in v12.0`),ae(`10.7.0`,`Please use highlightElement now.`),w(e)}Object.assign(e,{highlight:p,highlightAuto:S,highlightAll:k,highlightElement:w,highlightBlock:V,configure:T,initHighlighting:E,initHighlightingOnLoad:D,registerLanguage:A,unregisterLanguage:j,listLanguages:M,getLanguage:N,registerAliases:P,autoDetection:F,inherit:_e,addPlugin:L,removePlugin:R}),e.debugMode=function(){o=!1},e.safeMode=function(){o=!0},e.versionString=me,e.regex={concat:_,lookahead:m,either:y,optional:g,anyNumberOfTimes:h};for(let e in B)typeof B[e]==`object`&&n(B[e]);return Object.assign(e,B),e},xe=be({});xe.newInstance=()=>be({}),t.exports=xe,xe.HighlightJS=xe,xe.default=xe}))()).default;function dZ(e){let t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:[`self`,{begin:/:-/,contains:[n]}]};Object.assign(n,{className:`variable`,variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,`(?![\\w\\d])(?![$])`)},r]});let i={className:`subst`,begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},a=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:`comment`}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:`string`})]}},s={className:`string`,begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(s);let c={match:/\\"/},l={className:`string`,begin:/'/,end:/'/},u={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:`number`},e.NUMBER_MODE,n]},f=e.SHEBANG({binary:`(${[`fish`,`bash`,`zsh`,`sh`,`csh`,`ksh`,`tcsh`,`dash`,`scsh`].join(`|`)})`,relevance:10}),p={className:`function`,begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=[`if`,`then`,`else`,`elif`,`fi`,`time`,`for`,`while`,`until`,`in`,`do`,`done`,`case`,`esac`,`coproc`,`function`,`select`],h=[`true`,`false`],g={match:/(\/[a-z._-]+)+/},_=[`break`,`cd`,`continue`,`eval`,`exec`,`exit`,`export`,`getopts`,`hash`,`pwd`,`readonly`,`return`,`shift`,`test`,`times`,`trap`,`umask`,`unset`],v=[`alias`,`bind`,`builtin`,`caller`,`command`,`declare`,`echo`,`enable`,`help`,`let`,`local`,`logout`,`mapfile`,`printf`,`read`,`readarray`,`source`,`sudo`,`type`,`typeset`,`ulimit`,`unalias`],y=`autoload.bg.bindkey.bye.cap.chdir.clone.comparguments.compcall.compctl.compdescribe.compfiles.compgroups.compquote.comptags.comptry.compvalues.dirs.disable.disown.echotc.echoti.emulate.fc.fg.float.functions.getcap.getln.history.integer.jobs.kill.limit.log.noglob.popd.print.pushd.pushln.rehash.sched.setcap.setopt.stat.suspend.ttyctl.unfunction.unhash.unlimit.unsetopt.vared.wait.whence.where.which.zcompile.zformat.zftp.zle.zmodload.zparseopts.zprof.zpty.zregexparse.zsocket.zstyle.ztcp`.split(`.`),b=`chcon.chgrp.chown.chmod.cp.dd.df.dir.dircolors.ln.ls.mkdir.mkfifo.mknod.mktemp.mv.realpath.rm.rmdir.shred.sync.touch.truncate.vdir.b2sum.base32.base64.cat.cksum.comm.csplit.cut.expand.fmt.fold.head.join.md5sum.nl.numfmt.od.paste.ptx.pr.sha1sum.sha224sum.sha256sum.sha384sum.sha512sum.shuf.sort.split.sum.tac.tail.tr.tsort.unexpand.uniq.wc.arch.basename.chroot.date.dirname.du.echo.env.expr.factor.groups.hostid.id.link.logname.nice.nohup.nproc.pathchk.pinky.printenv.printf.pwd.readlink.runcon.seq.sleep.stat.stdbuf.stty.tee.test.timeout.tty.uname.unlink.uptime.users.who.whoami.yes`.split(`.`);return{name:`Bash`,aliases:[`sh`,`zsh`],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:h,built_in:[..._,...v,`set`,`shopt`,...y,...b]},contains:[f,e.SHEBANG(),p,d,a,o,g,s,c,l,u,n]}}var fZ=e=>({IMPORTANT:{scope:`meta`,begin:`!important`},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:`number`,begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:`built_in`,begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:`selector-attr`,begin:/\[/,end:/\]/,illegal:`$`,contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:`number`,begin:e.NUMBER_RE+`(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?`,relevance:0},CSS_VARIABLE:{className:`attr`,begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),pZ=`a.abbr.address.article.aside.audio.b.blockquote.body.button.canvas.caption.cite.code.dd.del.details.dfn.div.dl.dt.em.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.html.i.iframe.img.input.ins.kbd.label.legend.li.main.mark.menu.nav.object.ol.optgroup.option.p.picture.q.quote.samp.section.select.source.span.strong.summary.sup.table.tbody.td.textarea.tfoot.th.thead.time.tr.ul.var.video`.split(`.`),mZ=`defs.g.marker.mask.pattern.svg.switch.symbol.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feFlood.feGaussianBlur.feImage.feMerge.feMorphology.feOffset.feSpecularLighting.feTile.feTurbulence.linearGradient.radialGradient.stop.circle.ellipse.image.line.path.polygon.polyline.rect.text.use.textPath.tspan.foreignObject.clipPath`.split(`.`),hZ=[...pZ,...mZ],gZ=`any-hover.any-pointer.aspect-ratio.color.color-gamut.color-index.device-aspect-ratio.device-height.device-width.display-mode.forced-colors.grid.height.hover.inverted-colors.monochrome.orientation.overflow-block.overflow-inline.pointer.prefers-color-scheme.prefers-contrast.prefers-reduced-motion.prefers-reduced-transparency.resolution.scan.scripting.update.width.min-width.max-width.min-height.max-height`.split(`.`).sort().reverse(),_Z=`active.any-link.blank.checked.current.default.defined.dir.disabled.drop.empty.enabled.first.first-child.first-of-type.fullscreen.future.focus.focus-visible.focus-within.has.host.host-context.hover.indeterminate.in-range.invalid.is.lang.last-child.last-of-type.left.link.local-link.not.nth-child.nth-col.nth-last-child.nth-last-col.nth-last-of-type.nth-of-type.only-child.only-of-type.optional.out-of-range.past.placeholder-shown.read-only.read-write.required.right.root.scope.target.target-within.user-invalid.valid.visited.where`.split(`.`).sort().reverse(),vZ=[`after`,`backdrop`,`before`,`cue`,`cue-region`,`first-letter`,`first-line`,`grammar-error`,`marker`,`part`,`placeholder`,`selection`,`slotted`,`spelling-error`].sort().reverse(),yZ=`accent-color.align-content.align-items.align-self.alignment-baseline.all.anchor-name.animation.animation-composition.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-range.animation-range-end.animation-range-start.animation-timeline.animation-timing-function.appearance.aspect-ratio.backdrop-filter.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.baseline-shift.block-size.border.border-block.border-block-color.border-block-end.border-block-end-color.border-block-end-style.border-block-end-width.border-block-start.border-block-start-color.border-block-start-style.border-block-start-width.border-block-style.border-block-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-end-end-radius.border-end-start-radius.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline.border-inline-color.border-inline-end.border-inline-end-color.border-inline-end-style.border-inline-end-width.border-inline-start.border-inline-start-color.border-inline-start-style.border-inline-start-width.border-inline-style.border-inline-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-start-end-radius.border-start-start-radius.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-align.box-decoration-break.box-direction.box-flex.box-flex-group.box-lines.box-ordinal-group.box-orient.box-pack.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.color-scheme.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.column-span.column-width.columns.contain.contain-intrinsic-block-size.contain-intrinsic-height.contain-intrinsic-inline-size.contain-intrinsic-size.contain-intrinsic-width.container.container-name.container-type.content.content-visibility.counter-increment.counter-reset.counter-set.cue.cue-after.cue-before.cursor.cx.cy.direction.display.dominant-baseline.empty-cells.enable-background.field-sizing.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.flow.font.font-display.font-family.font-feature-settings.font-kerning.font-language-override.font-optical-sizing.font-palette.font-size.font-size-adjust.font-smooth.font-smoothing.font-stretch.font-style.font-synthesis.font-synthesis-position.font-synthesis-small-caps.font-synthesis-style.font-synthesis-weight.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-emoji.font-variant-ligatures.font-variant-numeric.font-variant-position.font-variation-settings.font-weight.forced-color-adjust.gap.glyph-orientation-horizontal.glyph-orientation-vertical.grid.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.hanging-punctuation.height.hyphenate-character.hyphenate-limit-chars.hyphens.icon.image-orientation.image-rendering.image-resolution.ime-mode.initial-letter.initial-letter-align.inline-size.inset.inset-area.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.isolation.justify-content.justify-items.justify-self.kerning.left.letter-spacing.lighting-color.line-break.line-height.line-height-step.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.margin-trim.marker.marker-end.marker-mid.marker-start.marks.mask.mask-border.mask-border-mode.mask-border-outset.mask-border-repeat.mask-border-slice.mask-border-source.mask-border-width.mask-clip.mask-composite.mask-image.mask-mode.mask-origin.mask-position.mask-repeat.mask-size.mask-type.masonry-auto-flow.math-depth.math-shift.math-style.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.nav-down.nav-index.nav-left.nav-right.nav-up.none.normal.object-fit.object-position.offset.offset-anchor.offset-distance.offset-path.offset-position.offset-rotate.opacity.order.orphans.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-anchor.overflow-block.overflow-clip-margin.overflow-inline.overflow-wrap.overflow-x.overflow-y.overlay.overscroll-behavior.overscroll-behavior-block.overscroll-behavior-inline.overscroll-behavior-x.overscroll-behavior-y.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page.page-break-after.page-break-before.page-break-inside.paint-order.pause.pause-after.pause-before.perspective.perspective-origin.place-content.place-items.place-self.pointer-events.position.position-anchor.position-visibility.print-color-adjust.quotes.r.resize.rest.rest-after.rest-before.right.rotate.row-gap.ruby-align.ruby-position.scale.scroll-behavior.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.scroll-snap-align.scroll-snap-stop.scroll-snap-type.scroll-timeline.scroll-timeline-axis.scroll-timeline-name.scrollbar-color.scrollbar-gutter.scrollbar-width.shape-image-threshold.shape-margin.shape-outside.shape-rendering.speak.speak-as.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.table-layout.text-align.text-align-all.text-align-last.text-anchor.text-combine-upright.text-decoration.text-decoration-color.text-decoration-line.text-decoration-skip.text-decoration-skip-ink.text-decoration-style.text-decoration-thickness.text-emphasis.text-emphasis-color.text-emphasis-position.text-emphasis-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-size-adjust.text-transform.text-underline-offset.text-underline-position.text-wrap.text-wrap-mode.text-wrap-style.timeline-scope.top.touch-action.transform.transform-box.transform-origin.transform-style.transition.transition-behavior.transition-delay.transition-duration.transition-property.transition-timing-function.translate.unicode-bidi.user-modify.user-select.vector-effect.vertical-align.view-timeline.view-timeline-axis.view-timeline-inset.view-timeline-name.view-transition-name.visibility.voice-balance.voice-duration.voice-family.voice-pitch.voice-range.voice-rate.voice-stress.voice-volume.white-space.white-space-collapse.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.x.y.z-index.zoom`.split(`.`).sort().reverse();function bZ(e){let t=e.regex,n=fZ(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i=/@-?\w[\w]*(-\w+)*/,a=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:`CSS`,case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:`from to`},classNameAliases:{keyframePosition:`selector-tag`},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:`selector-id`,begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:`selector-class`,begin:`\\.[a-zA-Z-][a-zA-Z0-9_-]*`,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:`selector-pseudo`,variants:[{begin:`:(`+_Z.join(`|`)+`)`},{begin:`:(:)?(`+vZ.join(`|`)+`)`}]},n.CSS_VARIABLE,{className:`attribute`,begin:`\\b(`+yZ.join(`|`)+`)\\b`},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:`url data-uri`},contains:[...a,{className:`string`,begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:`[{;]`,relevance:0,illegal:/:/,contains:[{className:`keyword`,begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:`and or not only`,attribute:gZ.join(` `)},contains:[{begin:/[a-z-]+(?=:)/,className:`attribute`},...a,n.CSS_NUMBER_MODE]}]},{className:`selector-tag`,begin:`\\b(`+hZ.join(`|`)+`)\\b`}]}}var xZ=`[A-Za-z$_][0-9A-Za-z$_]*`,SZ=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),CZ=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],wZ=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),TZ=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],EZ=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],DZ=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],OZ=[].concat(EZ,wZ,TZ);function kZ(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=xZ,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:xZ,keyword:SZ,literal:CZ,built_in:OZ,"variable.language":DZ},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:`[A-Za-z$_][0-9A-Za-z$_]*(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...wZ,...TZ]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...EZ,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},j=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,M={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},M,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:j,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$[A-Za-z$_][0-9A-Za-z$_]*`,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function AZ(e){let t={className:`attr`,begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:`punctuation`,relevance:0},r=[`true`,`false`,`null`],i={scope:`literal`,beginKeywords:r.join(` `)};return{name:`JSON`,aliases:[`jsonc`],keywords:{literal:r},contains:[t,n,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:`\\S`}}function jZ(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:`>`,subLanguage:`xml`,relevance:0},r={begin:`^[-\\*]{3,}`,end:`$`},i={className:`code`,variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:`(~{3,})[^~](.|\\n)*?\\1~*[ ]*`},{begin:"```",end:"```+[ ]*$"},{begin:`~~~`,end:`~~~+[ ]*$`},{begin:"`.+?`"},{begin:`(?=^( {4}|\\t))`,contains:[{begin:`^( {4}|\\t)`,end:`(\\n)$`}],relevance:0}]},a={className:`bullet`,begin:`^[ ]*([*+-]|(\\d+\\.))(?=\\s+)`,end:`\\s+`,excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:`symbol`,begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:`link`,begin:/:\s*/,end:/$/,excludeBegin:!0}]},s={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:`string`,relevance:0,begin:`\\[`,end:`\\]`,excludeBegin:!0,returnEnd:!0},{className:`link`,relevance:0,begin:`\\]\\(`,end:`\\)`,excludeBegin:!0,excludeEnd:!0},{className:`symbol`,relevance:0,begin:`\\]\\[`,end:`\\]`,excludeBegin:!0,excludeEnd:!0}]},c={className:`strong`,contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},l={className:`emphasis`,contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},u=e.inherit(c,{contains:[]}),d=e.inherit(l,{contains:[]});c.contains.push(d),l.contains.push(u);let f=[n,s];return[c,l,u,d].forEach(e=>{e.contains=e.contains.concat(f)}),f=f.concat(c,l),{name:`Markdown`,aliases:[`md`,`mkdown`,`mkd`],contains:[{className:`section`,variants:[{begin:`^#{1,6}`,end:`$`,contains:f},{begin:`(?=^.+?\\n[=-]{2,}$)`,contains:[{begin:`^[=-]*$`},{begin:`^`,end:`\\n`,contains:f}]}]},n,a,c,l,{className:`quote`,begin:`^>\\s+`,contains:f,end:`$`},i,r,s,o,{scope:`literal`,match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function MZ(e){return{name:`Plain text`,aliases:[`text`,`txt`],disableAutodetect:!0}}var NZ=`[A-Za-z$_][0-9A-Za-z$_]*`,PZ=`as.in.of.if.for.while.finally.var.new.function.do.return.void.else.break.catch.instanceof.with.throw.case.default.try.switch.continue.typeof.delete.let.yield.const.class.debugger.async.await.static.import.from.export.extends.using`.split(`.`),FZ=[`true`,`false`,`null`,`undefined`,`NaN`,`Infinity`],IZ=`Object.Function.Boolean.Symbol.Math.Date.Number.BigInt.String.RegExp.Array.Float32Array.Float64Array.Int8Array.Uint8Array.Uint8ClampedArray.Int16Array.Int32Array.Uint16Array.Uint32Array.BigInt64Array.BigUint64Array.Set.Map.WeakSet.WeakMap.ArrayBuffer.SharedArrayBuffer.Atomics.DataView.JSON.Promise.Generator.GeneratorFunction.AsyncFunction.Reflect.Proxy.Intl.WebAssembly`.split(`.`),LZ=[`Error`,`EvalError`,`InternalError`,`RangeError`,`ReferenceError`,`SyntaxError`,`TypeError`,`URIError`],RZ=[`setInterval`,`setTimeout`,`clearInterval`,`clearTimeout`,`require`,`exports`,`eval`,`isFinite`,`isNaN`,`parseFloat`,`parseInt`,`decodeURI`,`decodeURIComponent`,`encodeURI`,`encodeURIComponent`,`escape`,`unescape`],zZ=[`arguments`,`this`,`super`,`console`,`window`,`document`,`localStorage`,`sessionStorage`,`module`,`global`],BZ=[].concat(RZ,IZ,LZ);function VZ(e){let t=e.regex,n=(e,{after:t})=>{let n=`</`+e[0].slice(1);return e.input.indexOf(n,t)!==-1},r=NZ,i={begin:`<>`,end:`</>`},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{let r=e[0].length+e.index,i=e.input[r];if(i===`<`||i===`,`){t.ignoreMatch();return}i===`>`&&(n(e,{after:r})||t.ignoreMatch());let a,o=e.input.substring(r);if(a=o.match(/^\s*=/)){t.ignoreMatch();return}if((a=o.match(/^\s+extends\s+/))&&a.index===0){t.ignoreMatch();return}}},s={$pattern:NZ,keyword:PZ,literal:FZ,built_in:BZ,"variable.language":zZ},c=`[0-9](_?[0-9])*`,l=`\\.(${c})`,u=`0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*`,d={className:`number`,variants:[{begin:`(\\b(${u})((${l})|\\.)?|(${l}))[eE][+-]?(${c})\\b`},{begin:`\\b(${u})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:`\\b(0|[1-9](_?[0-9])*)n\\b`},{begin:`\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b`},{begin:`\\b0[bB][0-1](_?[0-1])*n?\\b`},{begin:`\\b0[oO][0-7](_?[0-7])*n?\\b`},{begin:`\\b0[0-7]+n?\\b`}],relevance:0},f={className:`subst`,begin:`\\$\\{`,end:`\\}`,keywords:s,contains:[]},p={begin:".?html`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`xml`}},m={begin:".?css`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`css`}},h={begin:".?gql`",end:``,starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,f],subLanguage:`graphql`}},g={className:`string`,begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,f]},_={className:`comment`,variants:[e.COMMENT(/\/\*\*(?!\/)/,`\\*/`,{relevance:0,contains:[{begin:`(?=@[A-Za-z]+)`,relevance:0,contains:[{className:`doctag`,begin:`@[A-Za-z]+`},{className:`type`,begin:`\\{`,end:`\\}`,excludeEnd:!0,excludeBegin:!0,relevance:0},{className:`variable`,begin:`[A-Za-z$_][0-9A-Za-z$_]*(?=\\s*(-)|$)`,endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},v=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,{match:/\$\d+/},d];f.contains=v.concat({begin:/\{/,end:/\}/,keywords:s,contains:[`self`].concat(v)});let y=[].concat(_,f.contains),b=y.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:[`self`].concat(y)}]),x={className:`params`,begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b},S={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,`(`,t.concat(/\./,r),`)*`)],scope:{1:`keyword`,3:`title.class`,5:`keyword`,7:`title.class.inherited`}},{match:[/class/,/\s+/,r],scope:{1:`keyword`,3:`title.class`}}]},C={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:`title.class`,keywords:{_:[...IZ,...LZ]}},w={label:`use_strict`,className:`meta`,relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:`keyword`,3:`title.function`},label:`func.def`,contains:[x],illegal:/%/},E={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:`variable.constant`};function D(e){return t.concat(`(?!`,e.join(`|`),`)`)}let O={match:t.concat(/\b/,D([...RZ,`super`,`import`].map(e=>`${e}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:`title.function`,relevance:0},k={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:`prototype`,className:`property`,relevance:0},A={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:`keyword`,3:`title.function`},contains:[{begin:/\(\)/},x]},j=`(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|`+e.UNDERSCORE_IDENT_RE+`)\\s*=>`,M={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(j)],keywords:`async`,className:{1:`keyword`,3:`title.function`},contains:[x]};return{name:`JavaScript`,aliases:[`js`,`jsx`,`mjs`,`cjs`],keywords:s,exports:{PARAMS_CONTAINS:b,CLASS_REFERENCE:C},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:`shebang`,binary:`node`,relevance:5}),w,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,h,g,_,{match:/\$\d+/},d,C,{scope:`attr`,match:r+t.lookahead(`:`),relevance:0},M,{begin:`(`+e.RE_STARTERS_RE+`|\\b(case|return|throw)\\b)\\s*`,keywords:`return throw case`,relevance:0,contains:[_,e.REGEXP_MODE,{className:`function`,begin:j,returnBegin:!0,end:`\\s*=>`,contains:[{className:`params`,variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:b}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:`xml`,contains:[{begin:o.begin,end:o.end,skip:!0,contains:[`self`]}]}]},T,{beginKeywords:`while if switch catch for`},{begin:`\\b(?!function)`+e.UNDERSCORE_IDENT_RE+`\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{`,returnBegin:!0,label:`func.def`,contains:[x,e.inherit(e.TITLE_MODE,{begin:r,className:`title.function`})]},{match:/\.\.\./,relevance:0},k,{match:`\\$[A-Za-z$_][0-9A-Za-z$_]*`,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:`title.function`},contains:[x]},O,E,S,A,{match:/\$[(.]/}]}}function HZ(e){let t=e.regex,n=VZ(e),r=NZ,i=[`any`,`void`,`number`,`boolean`,`string`,`object`,`never`,`symbol`,`bigint`,`unknown`],a={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:`keyword`,3:`title.class`}},o={beginKeywords:`interface`,end:/\{/,excludeEnd:!0,keywords:{keyword:`interface extends`,built_in:i},contains:[n.exports.CLASS_REFERENCE]},s={className:`meta`,relevance:10,begin:/^\s*['"]use strict['"]/},c={$pattern:NZ,keyword:PZ.concat([`type`,`interface`,`public`,`private`,`protected`,`implements`,`declare`,`abstract`,`readonly`,`enum`,`override`,`satisfies`]),literal:FZ,built_in:BZ.concat(i),"variable.language":zZ},l={className:`meta`,begin:`@[A-Za-z$_][0-9A-Za-z$_]*`},u=(e,t,n)=>{let r=e.contains.findIndex(e=>e.label===t);if(r===-1)throw Error(`can not find mode to replace`);e.contains.splice(r,1,n)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(l);let d=n.contains.find(e=>e.scope===`attr`),f=Object.assign({},d,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,d,f]),n.contains=n.contains.concat([l,a,o,f]),u(n,`shebang`,e.SHEBANG()),u(n,`use_strict`,s);let p=n.contains.find(e=>e.label===`func.def`);return p.relevance=0,Object.assign(n,{name:`TypeScript`,aliases:[`ts`,`tsx`,`mts`,`cts`]}),n}function UZ(e){let t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:`symbol`,begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},a={begin:/\s/,contains:[{className:`keyword`,begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(a,{begin:/\(/,end:/\)/}),s=e.inherit(e.APOS_STRING_MODE,{className:`string`}),c=e.inherit(e.QUOTE_STRING_MODE,{className:`string`}),l={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:`attr`,begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:`string`,endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:`HTML, XML`,aliases:[`html`,`xhtml`,`rss`,`atom`,`xjb`,`xsd`,`xsl`,`plist`,`wsf`,`svg`],case_insensitive:!0,unicodeRegex:!0,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,relevance:10,contains:[a,c,s,o,{begin:/\[/,end:/\]/,contains:[{className:`meta`,begin:/<![a-z]/,end:/>/,contains:[a,o,c,s]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:`meta`,end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:`tag`,begin:/<style(?=\s|>)/,end:/>/,keywords:{name:`style`},contains:[l],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:[`css`,`xml`]}},{className:`tag`,begin:/<script(?=\s|>)/,end:/>/,keywords:{name:`script`},contains:[l],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:[`javascript`,`handlebars`,`xml`]}},{className:`tag`,begin:/<>|<\/>/},{className:`tag`,begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:`name`,begin:n,relevance:0,starts:l}]},{className:`tag`,begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:`name`,begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}uZ.registerLanguage(`bash`,dZ),uZ.registerLanguage(`css`,bZ),uZ.registerLanguage(`html`,UZ),uZ.registerLanguage(`javascript`,kZ),uZ.registerLanguage(`json`,AZ),uZ.registerLanguage(`markdown`,jZ),uZ.registerLanguage(`md`,jZ),uZ.registerLanguage(`plaintext`,MZ),uZ.registerLanguage(`typescript`,HZ),uZ.registerLanguage(`xml`,UZ),uZ.registerAliases([`js`,`jsx`],{languageName:`javascript`}),uZ.registerAliases([`ts`,`tsx`],{languageName:`typescript`}),uZ.registerAliases([`sh`,`shell`,`zsh`],{languageName:`bash`}),$X.use(eZ({emptyLangClass:`hljs`,langPrefix:`hljs language-`,highlight(e,t){let n=(t??``).trim()||`plaintext`,r=uZ.getLanguage(n)?n:`plaintext`;return uZ.highlight(e,{language:r}).value}}));var WZ={gfm:!0,breaks:!1,async:!1};function GZ(e,t){return $X.parse(e,{...WZ,...t,async:!1})}var KZ=`png|jpe?g|gif|webp|bmp|svg|pdf|docx?|xlsx?|pptx?|txt|md|json|html?|css|mjs?|cjs|js|ts|tsx|jsx|yaml|yml|toml|xml`,qZ=new RegExp(String.raw`((?:\.\/)?(?:[A-Za-z0-9_.-]+\/)+[A-Za-z0-9_.-]+\.(?:${KZ})(?::\d+|#L\d+)?)`,`gi`),JZ=new RegExp(String.raw`(\/(?:Users|usr|var|opt|tmp|home|root|System|private|dev|media|mnt|Volumes|data)\/[^\s"'<>()|*?\n]+?\.(?:${KZ})(?::\d+|#L\d+)?)`,`gi`),YZ=new RegExp(String.raw`([A-Za-z]:[\\/][^"'<>()\n|*?=]+?\.(?:${KZ})(?::\d+|#L\d+)?)`,`gi`);function XZ(e){try{let t=new URL(e);return t.protocol!==`xopc:`||t.hostname!==`settings`?null:`/settings${t.pathname===`/`?``:t.pathname}${t.search}${t.hash}`}catch{return null}}function ZZ(e){try{let t=new URL(e);return t.protocol!==`xopc:`||t.hostname!==`workspace`||t.pathname!==`/file`||!t.searchParams.get(`path`)?.trim()?null:`/xopc/workspace/file${t.search}${t.hash}`}catch{return null}}function QZ(e){return e.replace(/xopc:\/\/(?:settings|workspace\/file)[^\s)<>"']*/gi,e=>XZ(e)??ZZ(e)??e)}function $Z(e){let t=e.trim();if(!t)return null;if(t.startsWith(`xopc://workspace/file`)||t.startsWith(`/xopc/workspace/file`))try{let e=t.startsWith(`/xopc/`)?new URL(t,`https://xopc.local`):new URL(t),n=e.searchParams.get(`path`)?.trim()??``;if(!n)return null;t=n;let r=Number(e.searchParams.get(`line`)??``);return eQ(t,Number.isFinite(r)&&r>0?Math.floor(r):void 0)}catch{return null}return tQ(t)||(/^[a-z][a-z0-9+.-]*:/i.test(t)||t.startsWith(`/`)||t.startsWith(`\\`)||t.includes(`..`)?null:eQ(t))}function eQ(e,t){let n=e.trim().replace(/\\/g,`/`);if(!n||n.includes(`..`))return null;let r=t,i=n.match(/#L(\d+)$/i);if(i?.[1])r=Number(i[1]),n=n.slice(0,-i[0].length);else{let e=n.match(/:(\d+)$/);e?.[1]&&(r=Number(e[1]),n=n.slice(0,-e[0].length))}return n=n.replace(/^\.\//,``),!n||n.startsWith(`/`)||/^[A-Za-z]:/.test(n)||!new RegExp(String.raw`\.(?:${KZ})$`,`i`).test(n)?null:{path:n,line:Number.isFinite(r)&&r&&r>0?Math.floor(r):void 0,kind:`workspace-relative`}}function tQ(e){let t=e.trim().replace(/\\/g,`/`);if(!t||/^[A-Za-z]:\/{2,}/.test(t)||!(t.startsWith(`/`)||/^[A-Za-z]:\//.test(t)))return null;let n,r=t.match(/#L(\d+)$/i);if(r?.[1])n=Number(r[1]),t=t.slice(0,-r[0].length);else{let e=t.match(/:(\d+)$/);e?.[1]&&(n=Number(e[1]),t=t.slice(0,-e[0].length))}return new RegExp(String.raw`\.(?:${KZ})$`,`i`).test(t)?{path:t,line:Number.isFinite(n)&&n&&n>0?Math.floor(n):void 0,kind:`absolute`}:null}function nQ(e){let t=[],n=[JZ,YZ,qZ];for(let r of n){r.lastIndex=0;let n;for(;(n=r.exec(e))!==null;){let r=n[1];if(!r)continue;let i=n.index,a=i+r.length,o=e[i-1]??``;if(o===`:`||o===`@`)continue;let s=$Z(r);s&&(s.kind===`workspace-relative`&&o===`/`||t.push({raw:r,start:i,end:a,target:s}))}}t.sort((e,t)=>e.start-t.start||t.end-e.end);let r=[],i=-1;for(let e of t)e.start<i||(r.push(e),i=e.end);return r}function rQ(e){let t=e.parentElement;return t?!!t.closest(`a, code, pre, kbd, samp, textarea, script, style, [data-xopc-inline-file]`):!0}function iQ(e){let t=e.ownerDocument,n=t.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){return!(e instanceof Text)||rQ(e)?NodeFilter.FILTER_REJECT:nQ(e.data).length>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),r=[],i;for(;i=n.nextNode();)r.push(i);for(let e of r){let n=e.data,r=nQ(n);if(r.length===0)continue;let i=t.createDocumentFragment(),a=0;for(let e of r){e.start>a&&i.appendChild(t.createTextNode(n.slice(a,e.start)));let r=t.createElement(`a`);r.href=`#`,r.className=`markdown-file-link`,r.dataset.xopcFilePath=e.target.path,r.dataset.xopcFileKind=e.target.kind,e.target.line&&(r.dataset.xopcLine=String(e.target.line)),r.textContent=e.raw,i.appendChild(r),a=e.end}a!==0&&(a<n.length&&i.appendChild(t.createTextNode(n.slice(a))),e.parentNode?.replaceChild(i,e))}}var aQ=!1;function oQ(){aQ||typeof window>`u`||(aQ=!0,xY.addHook(`afterSanitizeAttributes`,e=>{if(e.tagName!==`A`||!e.hasAttribute(`href`))return;let t=e.getAttribute(`href`)??``;try{let n=new URL(t,window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`||n.origin===window.location.origin)return;e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)}catch{}}))}oQ();var sQ=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,cQ=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>`;function lQ(e){return e.querySelector(`code`)?.textContent??e.textContent??``}function uQ(e){let t=e.querySelector(`code`);if(!t?.className)return`plaintext`;for(let e of t.className.split(/\s+/))if(e.startsWith(`language-`))return e.slice(9).trim()||`plaintext`;return`plaintext`}function dQ(e,t){let n=document.createDocumentFragment(),r=document.createElement(`span`);r.className=`markdown-code-copy-inner`,r.innerHTML=e===`idle`?sQ:cQ;let i=document.createElement(`span`);return i.className=`markdown-code-copy-label`,i.textContent=e===`idle`?t.copy:t.copied,n.appendChild(r),n.appendChild(i),n}function fQ(e){e.querySelectorAll(`[data-md-code-block]`).forEach(e=>{let t=e.querySelector(`:scope > pre`),n=e.parentNode;t&&n&&(n.insertBefore(t,e),e.remove())})}function pQ(e,t){let n=e.querySelectorAll(`.markdown-body pre`),r=[];for(let e of n){if(e.closest(`[data-md-code-block]`)||e.closest(`[data-mermaid-fallback]`))continue;let n=e.parentNode;if(!n)continue;let i=document.createElement(`div`);i.className=`markdown-code-block`,i.setAttribute(`data-md-code-block`,``);let a=document.createElement(`div`);a.className=`markdown-code-block-header`;let o=document.createElement(`span`);o.className=`markdown-code-block-lang`,o.textContent=uQ(e);let s=document.createElement(`button`);s.type=`button`,s.className=`markdown-code-copy-btn`,s.dataset.mdCodeCopy=``,s.title=t.copy,s.setAttribute(`aria-label`,t.copy),s.replaceChildren(dQ(`idle`,t));let c=n=>{n.preventDefault(),n.stopPropagation(),mA(lQ(e)).then(e=>{!e||!s.isConnected||(s.replaceChildren(dQ(`copied`,t)),s.title=t.copied,s.setAttribute(`aria-label`,t.copied),window.setTimeout(()=>{s.isConnected&&(s.replaceChildren(dQ(`idle`,t)),s.title=t.copy,s.setAttribute(`aria-label`,t.copy))},2e3))})};s.addEventListener(`click`,c),a.appendChild(o),a.appendChild(s),i.appendChild(a),n.insertBefore(i,e),i.appendChild(e),r.push(()=>{s.removeEventListener(`click`,c);let t=e.parentElement;t?.matches(`[data-md-code-block]`)&&t.parentNode&&(t.parentNode.insertBefore(e,t),t.remove())})}return()=>{for(let e of r)e()}}function mQ(e){return Array.from(e.querySelectorAll(`pre code.language-mermaid, pre code.hljs.language-mermaid`))}function hQ({content:e,compact:t=!1,breaks:n=!1,className:r,codeCopy:i=!0,onWorkspaceFileOpen:a}){let o=_(e=>e.language),s=(0,Z.useMemo)(()=>{let e=m(o).chat;return{copy:e.codeBlockCopy,copied:e.messageCopied}},[o]),l=(0,Z.useMemo)(()=>{if(!e.trim())return``;let t=GZ(QZ(e),n?{breaks:!0}:void 0);return xY.sanitize(t,{USE_PROFILES:{html:!0,svg:!0},ADD_ATTR:`viewBox.xmlns.d.fill.stroke.transform.stroke-width.stroke-linecap.stroke-linejoin.stroke-dasharray.x.y.width.height.rx.ry.cx.cy.r.x1.y1.x2.y2.offset.stop-color.stop-opacity.points.text-anchor.dominant-baseline.font-size.font-family.font-weight.font-style.class.id.style.markerWidth.markerHeight.refX.refY.orient.markerUnits.text-decoration.opacity.clip-path.mask.filter.preserveAspectRatio.xmlns:xlink.xlink:href.xml:space`.split(`.`)})},[e,n]),u=(0,Z.useRef)(null);return(0,Z.useLayoutEffect)(()=>{let e=u.current;if(e&&(fQ(e),a&&iQ(e),!(!i||!l)))return pQ(e,s)},[i,l,s,a]),(0,Z.useLayoutEffect)(()=>{let e=u.current;if(!e||!l)return;let t=mQ(e);if(t.length===0)return;let n=!1;return c(async()=>{let{renderMermaidBlock:e}=await import(`./mermaid-render-BbqDc_LQ.js`);return{renderMermaidBlock:e}},__vite__mapDeps([82,1])).then(({renderMermaidBlock:e})=>{if(!n)for(let n of t){if(!n.isConnected)continue;let t=n.closest(`pre`);if(!t)continue;let r=t.closest(`[data-md-code-block]`)??t,i=e(n.textContent??``),a=document.createElement(`template`);a.innerHTML=i.html.trim();let o=a.content.firstElementChild;o&&r.replaceWith(o)}}),()=>{n=!0}},[l]),(0,Z.useLayoutEffect)(()=>{let e=u.current;if(!e)return;let t=t=>{let n=(t.target instanceof Element?t.target:null)?.closest(`a[href]`);if(!n||!e.contains(n))return;let r=n.dataset.xopcFilePath;if(r&&a){t.preventDefault();let e=Number(n.dataset.xopcLine??``);a({path:r,line:Number.isFinite(e)&&e>0?Math.floor(e):void 0,kind:n.dataset.xopcFileKind===`absolute`?`absolute`:`workspace-relative`});return}let i=n.getAttribute(`href`)??``,o=a?$Z(i):null;if(o&&a){t.preventDefault(),a(o);return}i.startsWith(`/settings/`)&&(t.preventDefault(),window.location.hash=`#${i}`)};return e.addEventListener(`click`,t),()=>e.removeEventListener(`click`,t)},[a]),(0,$.jsx)(`div`,{ref:u,children:(0,$.jsx)(`div`,{className:[`markdown-body`,t?`markdown-compact`:``,r??``].filter(Boolean).join(` `),dangerouslySetInnerHTML:{__html:l}})})}var gQ=(0,Z.memo)(hQ);gQ.displayName=`MarkdownView`;var _Q=()=>c(()=>import(`./markdown-split-BYF4ReGM.js`),__vite__mapDeps([83,1,2,41,20,42,43])),vQ=()=>c(()=>import(`./html-workspace-editor-COqmtESs.js`),__vite__mapDeps([84,1,42,2,43])),yQ=(0,Z.lazy)(()=>_Q().then(e=>({default:e.MarkdownSplit}))),bQ=(0,Z.lazy)(()=>vQ().then(e=>({default:e.HtmlWorkspaceEditor})));function xQ(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-4 py-3`,"aria-busy":!0,children:[(0,$.jsx)(`div`,{className:`h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function SQ(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t).toLowerCase():``}function CQ(e){return{".ts":`typescript`,".tsx":`tsx`,".js":`javascript`,".jsx":`jsx`,".json":`json`,".css":`css`,".yml":`yaml`,".yaml":`yaml`,".py":`python`,".go":`go`,".rs":`rust`,".sh":`bash`}[SQ(e)]??`plaintext`}function wQ(e){let t=(0,Q.c)(12),{text:n,targetLine:r}=e,i=(0,Z.useRef)(null),a;if(t[0]!==n){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\r\n|\n|\r/,t[2]=e):e=t[2],a=n.split(e),t[0]=n,t[1]=a}else a=t[1];let o=a,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{i.current?.scrollIntoView({block:`center`})},t[3]=s):s=t[3];let c;t[4]!==r||t[5]!==n?(c=[r,n],t[4]=r,t[5]=n,t[6]=c):c=t[6],(0,Z.useEffect)(s,c);let l;t[7]!==o||t[8]!==r?(l=o.map((e,t)=>{let n=t+1,a=n===r;return(0,$.jsxs)(`div`,{ref:a?i:void 0,className:a?`flex bg-accent-soft/60 text-fg`:`flex`,"data-line":n,children:[(0,$.jsx)(`span`,{className:`w-12 shrink-0 select-none pr-3 text-right text-fg-subtle`,children:n}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words`,children:e||` `})]},n)}),t[7]=o,t[8]=r,t[9]=l):l=t[9];let u;return t[10]===l?u=t[11]:(u=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:(0,$.jsx)(`div`,{className:`min-w-max font-mono text-xs leading-relaxed text-fg`,children:l})}),t[10]=l,t[11]=u),u}function TQ(e,t){let n=e.textContent??``,r=e.descriptor.context===`workspace`,i=e.workspaceEditing;return t===`markdown`?r&&i?.markdownEditMode?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(xQ,{}),children:(0,$.jsx)(yQ,{initialContent:n,onSave:e=>void i?.onSaveMarkdown?.(e),isDark:(i?.isDark??e.resolvedTheme===`dark`)===!0,wordWrap:i?.markdownWordWrap===!0,onToggleWordWrap:i?.onToggleMarkdownWordWrap},e.descriptor.id)})}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsx)(gQ,{content:n})}):t===`html`?r&&i?.htmlCodeMode?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(xQ,{}),children:(0,$.jsx)(bQ,{initialContent:n,onChange:e=>i?.onHtmlChange?.(e),isDark:(i?.isDark??e.resolvedTheme===`dark`)===!0},e.descriptor.id)})}):(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:(0,$.jsx)(`iframe`,{title:e.descriptor.fileName,className:`min-h-0 w-full flex-1 rounded-lg border border-edge-subtle bg-white dark:border-edge dark:bg-[#1e1e1e]`,srcDoc:n,sandbox:`allow-scripts allow-popups allow-popups-to-escape-sandbox allow-downloads allow-forms allow-modals`})}):e.targetLine&&e.targetLine>0?(0,$.jsx)(wQ,{text:n,targetLine:e.targetLine}):t===`code`?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsx)(gQ,{content:`\`\`\`${CQ(e.descriptor.fileName)}\n${n}\n\`\`\``})}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-fg`,children:n})})}var EQ={id:`text`,readMode:`text`,capabilities:[`download`],render:e=>TQ(e,`text`)},DQ={id:`markdown`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>TQ(e,`markdown`)},OQ={id:`code`,readMode:`text`,capabilities:[`download`],render:e=>TQ(e,`code`)},kQ={id:`html`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>TQ(e,`html`)};function AQ(){return(0,$.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:`Loading preview...`})}function jQ(e,t,n,r=`binary`){let i=(0,Z.lazy)(n);return{id:e,readMode:r,capabilities:t,render:e=>(0,$.jsx)(Z.Suspense,{fallback:AQ(),children:(0,$.jsx)(i,{...e})})}}var MQ={text:EQ,markdown:DQ,code:OQ,html:kQ,image:jQ(`image`,[`download`,`zoom`,`rotate`],()=>c(()=>import(`./binary-plugins-DJvi_thc.js`).then(e=>({default:e.InteractiveImagePreview})),__vite__mapDeps([85,1,20,2,86,87,7,4]))),pdf:jQ(`pdf`,[`download`,`zoom`,`rotate`,`pageNavigation`,`print`],()=>c(()=>import(`./binary-plugins-DJvi_thc.js`).then(e=>({default:e.PdfPreviewPluginView})),__vite__mapDeps([85,1,20,2,86,87,7,4]))),docx:jQ(`docx`,[`download`],()=>c(()=>import(`./binary-plugins-DJvi_thc.js`).then(e=>({default:e.DocxPreviewPluginView})),__vite__mapDeps([85,1,20,2,86,87,7,4]))),spreadsheet:jQ(`spreadsheet`,[`download`],()=>c(()=>import(`./binary-plugins-DJvi_thc.js`).then(e=>({default:e.SpreadsheetPreviewPluginView})),__vite__mapDeps([85,1,20,2,86,87,7,4]))),pptx:jQ(`pptx`,[`download`],()=>c(()=>import(`./binary-plugins-DJvi_thc.js`).then(e=>({default:e.PptxPreviewPluginView})),__vite__mapDeps([85,1,20,2,86,87,7,4]))),audio:jQ(`audio`,[`download`],()=>c(()=>import(`./media-plugins-CpQDz-QJ.js`).then(e=>({default:e.AudioPreviewPluginView})),__vite__mapDeps([88,1,2,86,87,7,4]))),video:jQ(`video`,[`download`],()=>c(()=>import(`./media-plugins-CpQDz-QJ.js`).then(e=>({default:e.VideoPreviewPluginView})),__vite__mapDeps([88,1,2,86,87,7,4]))),archive:jQ(`archive`,[`download`],()=>c(()=>import(`./archive-plugin-Dy6lsTHw.js`).then(e=>({default:e.ArchivePreviewPluginView})),__vite__mapDeps([89,1,2,90,87,7,4]))),unsupported:jQ(`unsupported`,[`download`],()=>c(()=>import(`./media-plugins-CpQDz-QJ.js`).then(e=>({default:e.UnsupportedPreviewPluginView})),__vite__mapDeps([88,1,2,86,87,7,4])),`metadata`)};function NQ(e){return MQ[e]??MQ.unsupported}function PQ(e){let t=(0,Q.c)(81),{plugin:n,actions:r,controls:i,onZoomIn:a,onZoomOut:o,onZoomReset:s,onRotate:c,onSearchChange:l}=e,[u,d]=(0,Z.useState)(!1),f;t[0]===n.capabilities?f=t[1]:(f=n.capabilities.includes(`zoom`),t[0]=n.capabilities,t[1]=f);let p=f,m;t[2]===n.capabilities?m=t[3]:(m=n.capabilities.includes(`search`),t[2]=n.capabilities,t[3]=m);let h=m,g;t[4]===n.capabilities?g=t[5]:(g=n.capabilities.includes(`rotate`),t[4]=n.capabilities,t[5]=g);let _=g,v;t[6]!==i||t[7]!==n.capabilities?(v=n.capabilities.includes(`pageNavigation`)&&i.pageCount!=null&&i.pageCount>1,t[6]=i,t[7]=n.capabilities,t[8]=v):v=t[8];let y=v;if(!(p||h||_||y||r.canDownload))return null;let b;if(t[9]!==r||t[10]!==y||t[11]!==_||t[12]!==h||t[13]!==p||t[14]!==i||t[15]!==c||t[16]!==l||t[17]!==a||t[18]!==o||t[19]!==s){if(b=[],y){let e=i.page<=1,n;t[21]===i?n=t[22]:(n=()=>i.setPage(Math.max(1,i.page-1)),t[21]=i,t[22]=n);let r;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(cT,{className:`size-3.5`}),t[23]=r):r=t[23];let a;t[24]!==e||t[25]!==n?(a=(0,$.jsx)(LQ,{label:`Previous page`,disabled:e,onClick:n,children:r}),t[24]=e,t[25]=n,t[26]=a):a=t[26];let o;t[27]!==i.page||t[28]!==i.pageCount?(o=(0,$.jsxs)(`span`,{className:`min-w-16 px-1 text-center text-xs text-fg-muted`,children:[i.page,` / `,i.pageCount]}),t[27]=i.page,t[28]=i.pageCount,t[29]=o):o=t[29];let s=i.page>=(i.pageCount??1),c;t[30]===i?c=t[31]:(c=()=>i.setPage(Math.min(i.pageCount??i.page,i.page+1)),t[30]=i,t[31]=c);let l;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(sT,{className:`size-3.5`}),t[32]=l):l=t[32];let u;t[33]!==s||t[34]!==c?(u=(0,$.jsx)(LQ,{label:`Next page`,disabled:s,onClick:c,children:l}),t[33]=s,t[34]=c,t[35]=u):u=t[35];let d;t[36]!==u||t[37]!==a||t[38]!==o?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-edge-subtle bg-surface-base p-0.5 dark:border-edge`,children:[a,o,u]},`page`),t[36]=u,t[37]=a,t[38]=o,t[39]=d):d=t[39],b.push(d)}if(p){let e;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Gv,{className:`size-3.5`}),t[40]=e):e=t[40];let n;t[41]===o?n=t[42]:(n=(0,$.jsx)(LQ,{label:`Zoom out`,onClick:o,children:e}),t[41]=o,t[42]=n);let r;t[43]===i.zoom?r=t[44]:(r=Math.round(i.zoom*100),t[43]=i.zoom,t[44]=r);let c;t[45]!==s||t[46]!==r?(c=(0,$.jsxs)(`button`,{type:`button`,className:`min-w-14 rounded px-1.5 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:s,title:`Reset zoom`,children:[r,`%`]}),t[45]=s,t[46]=r,t[47]=c):c=t[47];let l;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ly,{className:`size-3.5`}),t[48]=l):l=t[48];let u;t[49]===a?u=t[50]:(u=(0,$.jsx)(LQ,{label:`Zoom in`,onClick:a,children:l}),t[49]=a,t[50]=u);let d;t[51]!==u||t[52]!==n||t[53]!==c?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-edge-subtle bg-surface-base p-0.5 dark:border-edge`,children:[n,c,u]},`zoom`),t[51]=u,t[52]=n,t[53]=c,t[54]=d):d=t[54],b.push(d)}if(_){let e;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(cx,{className:`size-3.5`}),t[55]=e):e=t[55];let n;t[56]===c?n=t[57]:(n=(0,$.jsx)(LQ,{label:`Rotate`,onClick:c,children:e}),t[56]=c,t[57]=n),b.push(n)}if(h){let e;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Qx,{className:`size-3.5`,"aria-hidden":!0}),t[58]=e):e=t[58];let n;t[59]===l?n=t[60]:(n=e=>l(e.target.value),t[59]=l,t[60]=n);let r;t[61]!==i.searchQuery||t[62]!==n?(r=(0,$.jsxs)(`label`,{className:`flex min-w-40 items-center gap-1 rounded-md border border-edge-subtle bg-surface-base px-2 py-1 text-xs text-fg-muted dark:border-edge`,children:[e,(0,$.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:i.searchQuery,onChange:n,placeholder:`Search`})]},`search`),t[61]=i.searchQuery,t[62]=n,t[63]=r):r=t[63],b.push(r)}if(r.canDownload){let e;t[64]===r?e=t[65]:(e=()=>void r.onDownload(),t[64]=r,t[65]=e);let n;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Bm,{className:`size-3.5`}),t[66]=n):n=t[66];let i;t[67]===e?i=t[68]:(i=(0,$.jsx)(LQ,{label:`Download`,onClick:e,children:n},`download`),t[67]=e,t[68]=i),b.push(i)}t[9]=r,t[10]=y,t[11]=_,t[12]=h,t[13]=p,t[14]=i,t[15]=c,t[16]=l,t[17]=a,t[18]=o,t[19]=s,t[20]=b}else b=t[20];let x=b.length>4,S;t[69]!==x||t[70]!==b?(S=x?b.slice(0,3):b,t[69]=x,t[70]=b,t[71]=S):S=t[71];let C=S,w;t[72]!==x||t[73]!==b?(w=x?b.slice(3):[],t[72]=x,t[73]=b,t[74]=w):w=t[74];let T=w,E;t[75]!==u||t[76]!==T?(E=T.length>0?(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 cursor-default bg-transparent`,"aria-hidden":!0,tabIndex:-1,onPointerDown:e=>{e.preventDefault(),d(!1)}}):null,(0,$.jsx)(LQ,{label:`More actions`,onClick:()=>d(IQ),children:(0,$.jsx)(sh,{className:`size-3.5`})}),u?(0,$.jsx)(`div`,{role:`menu`,className:`absolute right-0 top-full z-50 mt-1 flex min-w-52 flex-col gap-1 rounded-md border border-edge bg-surface-panel p-1 shadow-popover`,children:T.map(FQ)}):null]}):null,t[75]=u,t[76]=T,t[77]=E):E=t[77];let D;return t[78]!==E||t[79]!==C?(D=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center gap-1`,children:[C,E]}),t[78]=E,t[79]=C,t[80]=D):D=t[80],D}function FQ(e,t){return(0,$.jsx)(`div`,{className:`flex min-w-0 items-center justify-end`,children:e},t)}function IQ(e){return!e}function LQ(e){let t=(0,Q.c)(6),{label:n,disabled:r,onClick:i,children:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-40`),t[0]=o):o=t[0];let s;return t[1]!==a||t[2]!==r||t[3]!==n||t[4]!==i?(s=(0,$.jsx)(`button`,{type:`button`,className:o,title:n,"aria-label":n,disabled:r,onClick:i,children:a}),t[1]=a,t[2]=r,t[3]=n,t[4]=i,t[5]=s):s=t[5],s}function RQ(e){let t=(0,Q.c)(22),n;t[0]===e.type?n=t[1]:(n=NQ(e.type),t[0]=e.type,t[1]=n);let r=n,[i,a]=(0,Z.useState)(1),[o,s]=(0,Z.useState)(0),[c,l]=(0,Z.useState)(1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(``),m;t[2]===u?m=t[3]:(m=e=>{l(Math.max(1,Math.min(u??e,Math.floor(e))))},t[2]=u,t[3]=m);let h=m,g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{a(1),s(0),l(1),d(null),p(``)},t[4]=g):g=t[4];let _;t[5]!==e.id||t[6]!==e.type?(_=[e.id,e.type],t[5]=e.id,t[6]=e.type,t[7]=_):_=t[7],(0,Z.useEffect)(g,_);let v;t[8]!==c||t[9]!==u||t[10]!==o||t[11]!==f||t[12]!==h||t[13]!==i?(v={zoom:i,rotation:o,page:c,pageCount:u,searchQuery:f,setPageCount:d,setPage:h},t[8]=c,t[9]=u,t[10]=o,t[11]=f,t[12]=h,t[13]=i,t[14]=v):v=t[14];let y=v,b,x,S,C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>a(VQ),x=()=>a(BQ),S=()=>{a(1),s(0)},C=()=>s(zQ),t[15]=b,t[16]=x,t[17]=S,t[18]=C):(b=t[15],x=t[16],S=t[17],C=t[18]);let w;return t[19]!==y||t[20]!==r?(w={plugin:r,controls:y,onZoomIn:b,onZoomOut:x,onZoomReset:S,onRotate:C,onSearchChange:p},t[19]=y,t[20]=r,t[21]=w):w=t[21],w}function zQ(e){return(e+90)%360}function BQ(e){return Math.max(.25,Number((e-.15).toFixed(2)))}function VQ(e){return Math.min(4,Number((e+.15).toFixed(2)))}function HQ(e){let t=(0,Q.c)(9),{controller:n,actions:r}=e,i;return t[0]!==r||t[1]!==n.controls||t[2]!==n.onRotate||t[3]!==n.onSearchChange||t[4]!==n.onZoomIn||t[5]!==n.onZoomOut||t[6]!==n.onZoomReset||t[7]!==n.plugin?(i=(0,$.jsx)(PQ,{plugin:n.plugin,actions:r,controls:n.controls,onZoomIn:n.onZoomIn,onZoomOut:n.onZoomOut,onZoomReset:n.onZoomReset,onRotate:n.onRotate,onSearchChange:n.onSearchChange}),t[0]=r,t[1]=n.controls,t[2]=n.onRotate,t[3]=n.onSearchChange,t[4]=n.onZoomIn,t[5]=n.onZoomOut,t[6]=n.onZoomReset,t[7]=n.plugin,t[8]=i):i=t[8],i}function UQ(e){let t=(0,Q.c)(23),n;t[0]===e.language?n=t[1]:(n=m(e.language),t[0]=e.language,t[1]=n);let r=n,i=RQ(e.descriptor),a=e.controller??i,o;t[2]!==a||t[3]!==e.actions?(o=(0,$.jsx)(HQ,{controller:a,actions:e.actions}),t[2]=a,t[3]=e.actions,t[4]=o):o=t[4];let s=o;if(e.loading){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-4 py-6`,"aria-busy":`true`,children:[(0,$.jsx)(uI,{className:`h-5 w-48 max-w-full`}),(0,$.jsx)(uI,{className:`h-4 w-full`}),(0,$.jsx)(uI,{className:`h-4 w-11/12`}),(0,$.jsx)(uI,{className:`h-4 w-3/4`}),(0,$.jsx)(uI,{className:`mt-3 min-h-48 flex-1 rounded-lg`})]}),t[5]=e):e=t[5],e}if(e.loadError){let n=(e.descriptor.context===`workspace`?r.workspace.loadError:r.chat.attachmentPreviewLoadError)+`: `+e.loadError,i;return t[6]===n?i=t[7]:(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:n})}),t[6]=n,t[7]=i),i}if(e.descriptor.context===`attachment`&&e.showExtractedText&&e.descriptor.type!==`image`){let n=e.extractedText||r.chat.attachmentPreviewNoText,i;return t[8]===n?i=t[9]:(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-hover/40 p-4 dark:border-edge`,children:(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg-muted`,children:n})})}),t[8]=n,t[9]=i),i}let c;t[10]!==e.renderToolbar||t[11]!==s?(c=e.renderToolbar?e.renderToolbar(s):s,t[10]=e.renderToolbar,t[11]=s,t[12]=c):c=t[12];let l=`${e.descriptor.id}:${a.plugin.id}`,u;t[13]!==a.controls||t[14]!==e?(u={...e,controls:a.controls},t[13]=a.controls,t[14]=e,t[15]=u):u=t[15];let d;t[16]!==a.plugin.render||t[17]!==l||t[18]!==u?(d=(0,$.jsx)(WQ,{pluginRender:a.plugin.render,props:u},l),t[16]=a.plugin.render,t[17]=l,t[18]=u,t[19]=d):d=t[19];let f;return t[20]!==c||t[21]!==d?(f=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[c,d]}),t[20]=c,t[21]=d,t[22]=f):f=t[22],f}function WQ(e){let t=(0,Q.c)(5),{pluginRender:n,props:r}=e,i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),t[3]=i,t[4]=a),a}function GQ(e){return e.id?String(e.id):`${e.name}:${e.uri??``}`}function KQ(){return{id:`__empty__`,context:`attachment`,fileName:``,mimeType:`application/octet-stream`,type:`unsupported`,source:{kind:`inline`}}}function qQ(e){let t=(0,Q.c)(63),{open:n,attachment:r,authToken:i,sessionKey:a,language:o}=e,[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),p;t[0]!==r||t[1]!==n?(p=n&&r?GQ(r):null,t[0]=r,t[1]=n,t[2]=p):p=t[2];let h=p,g=(0,Z.useRef)(h);h!==g.current&&(g.current=h,c(n&&r?r:null),u(!1),f(!1));let _=s,v;bb0:{if(!_){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=KQ(),t[3]=e):e=t[3],v=e;break bb0}let e=_.name??`attachment`,n,r;t[4]!==e||t[5]!==_.mimeType?(n=$q(e,_.mimeType),r=eJ(e,n),t[4]=e,t[5]=_.mimeType,t[6]=n,t[7]=r):(n=t[6],r=t[7]);let i=r,o=_.id?String(_.id):`${e}:${_.uri??``}`,s;t[8]!==_.uri||t[9]!==a?(s=_.uri?{kind:`media-uri`,uri:_.uri,sessionKey:a}:{kind:`inline`},t[8]=_.uri,t[9]=a,t[10]=s):s=t[10];let c;t[11]!==e||t[12]!==n||t[13]!==_.size||t[14]!==o||t[15]!==s||t[16]!==i?(c={id:o,context:`attachment`,fileName:e,mimeType:n,size:_.size,type:i,source:s},t[11]=e,t[12]=n,t[13]=_.size,t[14]=o,t[15]=s,t[16]=i,t[17]=c):c=t[17],v=c}let y=v,b;t[18]===_?b=t[19]:(b=_?FI(_):void 0,t[18]=_,t[19]=b);let x=b,S=_?.uri,C;t[20]===y.type?C=t[21]:(C=tJ(y.type),t[20]=y.type,t[21]=C);let w=C,T=!!(n&&S&&!x&&i&&w===`binary`),E;t[22]!==o||t[23]!==S||t[24]!==a?(E=async()=>{let e=m(o).chat,t=await rJ({uri:S,sessionKey:a});if(!t.ok)throw t.reason===`http`?Error(`${e.attachmentPreviewLoadError} (HTTP ${t.status})`):Error(t.message);return t.buffer},t[22]=o,t[23]=S,t[24]=a,t[25]=E):E=t[25];let D;t[26]!==i||t[27]!==x||t[28]!==o||t[29]!==S||t[30]!==n||t[31]!==w||t[32]!==a?(D=[n,S,i,o,x,a,w],t[26]=i,t[27]=x,t[28]=o,t[29]=S,t[30]=n,t[31]=w,t[32]=a,t[33]=D):D=t[33];let O;t[34]===T?O=t[35]:(O={enabled:T,initial:null,errorData:null},t[34]=T,t[35]=O);let k=lP(E,D,O),A;bb1:{if(w!==`binary`){A=null;break bb1}if(x)try{let e;t[36]===x?e=t[37]:(e=VI(x),t[36]=x,t[37]=e),A=e;break bb1}catch{A=null;break bb1}if(T&&k.loading){A=null;break bb1}A=k.data??null}let j=A,M;t[38]===_?M=t[39]:(M=_?RI(_)??``:``,t[38]=_,t[39]=M);let N=M,P;t[40]!==N||t[41]!==o||t[42]!==w?(P=w===`text`?N||m(o).chat.attachmentPreviewNoText:null,t[40]=N,t[41]=o,t[42]=w,t[43]=P):P=t[43];let F=P,I=!!_?.extractedText,L=y.type===`pptx`&&N.length>3e5,R;t[44]!==i||t[45]!==x||t[46]!==o||t[47]!==S||t[48]!==n||t[49]!==w?(R=n&&S&&!x&&!i&&w===`binary`?m(o).chat.attachmentPreviewMissingAuth:null,t[44]=i,t[45]=x,t[46]=o,t[47]=S,t[48]=n,t[49]=w,t[50]=R):R=t[50];let z=R,B=k.error?k.error instanceof Error?k.error.message:String(k.error):null,V=d?null:z??B,H=T?k.loading:!1,U;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>f(!0),t[51]=U):U=t[51];let W=N||null,G;return t[52]!==j||t[53]!==y||t[54]!==L||t[55]!==I||t[56]!==V||t[57]!==_||t[58]!==l||t[59]!==H||t[60]!==W||t[61]!==F?(G={preview:_,descriptor:y,fileType:y.type,fileName:y.fileName,loading:H,loadError:V,clearLoadError:U,textContent:F,binaryBuffer:j,hasExtractedText:I,extractedText:W,extractedTextTruncated:L,showExtractedText:l,setShowExtractedText:u},t[52]=j,t[53]=y,t[54]=L,t[55]=I,t[56]=V,t[57]=_,t[58]=l,t[59]=H,t[60]=W,t[61]=F,t[62]=G):G=t[62],G}function JQ(e,t,n,r){var i=this,a=(0,Z.useRef)(null),o=(0,Z.useRef)(0),s=(0,Z.useRef)(0),c=(0,Z.useRef)(null),l=(0,Z.useRef)([]),u=(0,Z.useRef)(),d=(0,Z.useRef)(),f=(0,Z.useRef)(e),p=(0,Z.useRef)(!0),m=(0,Z.useRef)(),h=(0,Z.useRef)();f.current=e;var g=typeof window<`u`,_=!t&&t!==0&&g;if(typeof e!=`function`)throw TypeError(`Expected a function`);t=+t||0;var v=!!(n||={}).leading,y=!(`trailing`in n)||!!n.trailing,b=!!n.flushOnExit&&y,x=`maxWait`in n,S=`debounceOnServer`in n&&!!n.debounceOnServer,C=x?Math.max(+n.maxWait||0,t):null,w=(0,Z.useMemo)(function(){var e=function(e){var t=l.current,n=u.current;return l.current=u.current=null,o.current=e,s.current=s.current||e,d.current=f.current.apply(n,t)},n=function(e,t){_&&cancelAnimationFrame(c.current),c.current=_?requestAnimationFrame(e):setTimeout(e,t)},w=function(e){if(!p.current)return!1;var n=e-a.current;return!a.current||n>=t||n<0||x&&e-o.current>=C},T=function(t){return c.current=null,y&&l.current?e(t):(l.current=u.current=null,d.current)},E=function e(){var r=Date.now();if(v&&s.current===o.current&&D(),w(r))return T(r);if(p.current){var i=t-(r-a.current);n(e,x?Math.min(i,C-(r-o.current)):i)}},D=function(){r&&r({})},O=function(){if(g||S){var r,s=Date.now(),f=w(s);if(l.current=[].slice.call(arguments),u.current=i,a.current=s,b&&!m.current&&(m.current=function(){globalThis.document?.visibilityState===`hidden`&&h.current.flush()},(r=globalThis.document)==null||r.addEventListener==null||r.addEventListener(`visibilitychange`,m.current)),f){if(!c.current&&p.current)return o.current=a.current,n(E,t),v?e(a.current):d.current;if(x)return n(E,t),e(a.current)}return c.current||n(E,t),d.current}};return O.cancel=function(){var e=c.current;e&&(_?cancelAnimationFrame(c.current):clearTimeout(c.current)),o.current=0,l.current=a.current=u.current=c.current=null,e&&r&&r({})},O.isPending=function(){return!!c.current},O.flush=function(){return c.current?T(Date.now()):d.current},O},[v,x,t,C,y,b,_,g,S,r]);return h.current=w,(0,Z.useEffect)(function(){return p.current=!0,function(){var e;b&&h.current.flush(),m.current&&=((e=globalThis.document)==null||e.removeEventListener==null||e.removeEventListener(`visibilitychange`,m.current),null),p.current=!1}},[b]),w}function YQ(e,t){return e===t}function XQ(e,t,n){var r=n&&n.equalityFn||YQ,i=(0,Z.useRef)(e),a=(0,Z.useState)({})[1],o=JQ((0,Z.useCallback)(function(e){i.current=e,a({})},[a]),t,n,a),s=(0,Z.useRef)(e);return r(s.current,e)||(o(e),s.current=e),[i.current,o]}function ZQ(e){let t=(0,Q.c)(12),{projectId:n,sessionKey:r,agentId:i}=e,a;bb0:{let e;t[0]===n?e=t[1]:(e=n?.trim(),t[0]=n,t[1]=e);let o=e;if(o){let e;t[2]===o?e=t[3]:(e={projectId:o},t[2]=o,t[3]=e),a=e;break bb0}let s;t[4]===r?s=t[5]:(s=r?.trim(),t[4]=r,t[5]=s);let c=s;if(c){let e;t[6]===c?e=t[7]:(e={sessionKey:c},t[6]=c,t[7]=e),a=e;break bb0}let l;t[8]===i?l=t[9]:(l=i?.trim(),t[8]=i,t[9]=l);let u=l,d;t[10]===u?d=t[11]:(d=u?{agentId:u}:void 0,t[10]=u,t[11]=d),a=d}return a}function QQ(e){return{descriptor:e,textContent:null,binaryBuffer:null,hostAbsolutePath:null,mtimeMs:null,loadError:null,loading:!1,pptxText:null,pptxTruncated:!1,pptxError:null}}function $Q(e,t){switch(t.type){case`clear`:return QQ(t.descriptor);case`loadStart`:return{...QQ(t.descriptor),loading:!0};case`loadSuccess`:return{...e,descriptor:t.payload.descriptor,textContent:t.payload.textContent??null,binaryBuffer:t.payload.binaryBuffer??null,hostAbsolutePath:t.payload.hostAbsolutePath??null,mtimeMs:t.payload.mtimeMs??null,loadError:null,loading:!1};case`loadError`:return{...QQ(t.descriptor),loadError:t.error};case`patchMtime`:return{...e,mtimeMs:t.mtimeMs};case`patchText`:return{...e,textContent:t.text};case`pptxClear`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:null};case`pptxSuccess`:return{...e,pptxText:t.text,pptxTruncated:t.truncated,pptxError:null};case`pptxError`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:t.error}}}function e$(e,t){switch(t.type){case`reset`:return{markdownEditMode:!1,htmlCodeMode:!1,saveStatus:`idle`};case`markdown`:return{...e,markdownEditMode:typeof t.value==`function`?t.value(e.markdownEditMode):t.value};case`html`:return{...e,htmlCodeMode:typeof t.value==`function`?t.value(e.htmlCodeMode):t.value};case`saveStatus`:return{...e,saveStatus:t.value}}}function t$({filePath:e,projectId:t,sessionKey:n,agentId:r}){let i=ZQ({projectId:t,sessionKey:n,agentId:r}),a=(0,Z.useMemo)(()=>{let t=e?Qq(e):``,i=$q(t,UI(t)),a=e?eJ(t,i):`unsupported`;return{id:e||`__empty__`,context:`workspace`,fileName:t,mimeType:i,type:a,source:{kind:`workspace`,path:e||``,sessionKey:n,agentId:r}}},[r,e,n]),[o,s]=(0,Z.useReducer)($Q,a,QQ),[l,u]=(0,Z.useReducer)(e$,{markdownEditMode:!1,htmlCodeMode:!1,saveStatus:`idle`}),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)([]),h=(0,Z.useRef)(void 0),g=(0,Z.useRef)(e);g.current!==e&&(g.current=e,u({type:`reset`})),(0,Z.useEffect)(()=>{if(!e){s({type:`clear`,descriptor:a});return}let t=!1;s({type:`loadStart`,descriptor:a});let n=tJ(a.type),r=e=>{t||s({type:`loadError`,descriptor:a,error:e instanceof Error?e.message:String(e)})};return n===`metadata`?(Fq(e,i).then(e=>{t||s({type:`loadSuccess`,payload:{descriptor:a,hostAbsolutePath:e?.absolutePath??null,mtimeMs:typeof e?.mtimeMs==`number`?e.mtimeMs:null}})}).catch(r),()=>{t=!0}):(n===`text`?Pq(e,i).then(({content:e,mtimeMs:n,absolutePath:r})=>{t||s({type:`loadSuccess`,payload:{descriptor:a,textContent:e,hostAbsolutePath:r??null,mtimeMs:typeof n==`number`?n:null}})}).catch(r):Promise.all([Lq(e,i),Fq(e,i).catch(()=>null)]).then(async([e,n])=>{let r=await e.arrayBuffer();t||s({type:`loadSuccess`,payload:{descriptor:a,binaryBuffer:r,hostAbsolutePath:n?.absolutePath??null,mtimeMs:typeof n?.mtimeMs==`number`?n.mtimeMs:null}})}).catch(r),()=>{t=!0})},[a,e,i]),(0,Z.useEffect)(()=>{if(!o.binaryBuffer||o.descriptor.type!==`pptx`){s({type:`pptxClear`});return}let e=!1;return s({type:`pptxClear`}),c(()=>import(`./attachment-process-heavy-RnGYy9bC.js`).then(e=>e.processPptx(o.binaryBuffer,o.descriptor.fileName)),__vite__mapDeps([91,1,20,92])).then(({extractedText:t})=>{if(e)return;let n=t.length>NI;s({type:`pptxSuccess`,text:n?t.slice(0,NI):t,truncated:n})}).catch(t=>{e||s({type:`pptxError`,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},[o.binaryBuffer,o.descriptor.fileName,o.descriptor.type]);let _=(0,Z.useCallback)(async t=>{if(e){h.current!==void 0&&clearTimeout(h.current),u({type:`saveStatus`,value:`saving`});try{let{mtimeMs:n}=await zq(e,t,i);typeof n==`number`&&s({type:`patchMtime`,mtimeMs:n}),u({type:`saveStatus`,value:`saved`}),h.current=setTimeout(()=>u({type:`saveStatus`,value:`idle`}),2e3)}catch{u({type:`saveStatus`,value:`idle`})}}},[e,i]),v=JQ(e=>void _(e),500),y=(0,Z.useCallback)(e=>{s({type:`patchText`,text:e}),v(e)},[v]),b=(0,Z.useCallback)(async()=>{if(!e)return;let t=Qq(e);if(o.binaryBuffer){Vq(t,o.binaryBuffer,o.descriptor.mimeType||`application/octet-stream`);return}if(o.textContent!=null){Bq(t,o.textContent);return}let n=await Lq(e,i);Vq(t,await n.arrayBuffer(),o.descriptor.mimeType||n.type||`application/octet-stream`)},[e,o.binaryBuffer,o.descriptor.mimeType,o.textContent,i]),x=!o.loading&&!!e,S=fM()&&!!o.hostAbsolutePath&&!!window.electronAPI?.shell?.openPath,C=fM()&&!!o.hostAbsolutePath&&!!window.electronAPI?.shell?.chooseAppAndOpenPath,w=(0,Z.useCallback)(async()=>{let e=o.hostAbsolutePath;if(!fM()||!e||!window.electronAPI?.shell){m([]),f([]);return}try{if(window.electronAPI.shell.getOpenWithAppsForPath){let t=await window.electronAPI.shell.getOpenWithAppsForPath(e);m(t.recommended.map(e=>({name:e.name,path:e.path}))),f(t.recent.map(e=>({name:e.name,path:e.path,lastUsedAt:e.lastUsedAt})))}}catch{m([]),f([])}},[o.hostAbsolutePath]);(0,Z.useEffect)(()=>{w()},[w]);let T=(0,Z.useCallback)(async()=>{let e=o.hostAbsolutePath;e&&window.electronAPI?.shell?.openPath&&await window.electronAPI.shell.openPath(e)},[o.hostAbsolutePath]),E=(0,Z.useCallback)(async()=>{let e=o.hostAbsolutePath;!e||!window.electronAPI?.shell?.chooseAppAndOpenPath||(await window.electronAPI.shell.chooseAppAndOpenPath(e)).ok&&w()},[o.hostAbsolutePath,w]),D=(0,Z.useCallback)(async e=>{let t=o.hostAbsolutePath;!t||!e||!window.electronAPI?.shell?.openPathWithApp||(await window.electronAPI.shell.openPathWithApp(t,e)).ok&&w()},[o.hostAbsolutePath,w]),O=fM()&&!!o.hostAbsolutePath&&!!window.electronAPI?.shell?.showItemInFolder,k=(0,Z.useCallback)(async()=>{let e=o.hostAbsolutePath;e&&window.electronAPI?.shell?.showItemInFolder&&await window.electronAPI.shell.showItemInFolder(e)},[o.hostAbsolutePath]);return{...o,extractedText:o.descriptor.type===`pptx`?o.pptxText:null,extractedTextTruncated:o.pptxTruncated,markdownEditMode:l.markdownEditMode,setMarkdownEditMode:e=>u({type:`markdown`,value:e}),htmlCodeMode:l.htmlCodeMode,setHtmlCodeMode:e=>u({type:`html`,value:e}),saveStatus:l.saveStatus,onSaveMarkdown:_,onHtmlChange:y,onDownload:b,canDownload:x,canOpenWithSystemApp:S,onOpenWithSystemApp:T,canChooseOpenWithApp:C,onChooseOpenWithApp:E,recommendedOpenWithApps:p,recentOpenWithApps:d,onOpenWithRecentApp:D,canRevealInFolder:O,onRevealInFolder:k}}var n$=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),r$=`VisuallyHidden`,i$=Z.forwardRef((e,t)=>(0,$.jsx)(k.span,{...e,ref:t,style:{...n$,...e.style}}));i$.displayName=r$;var a$=i$,[o$,Lse]=T(`Tooltip`,[H]),s$=H(),c$=`TooltipProvider`,l$=700,u$=`tooltip.open`,[d$,f$]=o$(c$),p$=e=>{let{__scopeTooltip:t,delayDuration:n=l$,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=Z.useRef(!0),s=Z.useRef(!1),c=Z.useRef(0);return Z.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,$.jsx)(d$,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:Z.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:Z.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:Z.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};p$.displayName=c$;var m$=`Tooltip`,[h$,g$]=o$(m$),_$=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=f$(m$,e.__scopeTooltip),l=s$(t),[u,d]=Z.useState(null),f=I(),p=Z.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=Z.useRef(!1),[_,v]=R({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(u$))):c.onClose(),a?.(e)},caller:m$}),y=Z.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return Z.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,$.jsx)(U,{...l,children:(0,$.jsx)(h$,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:Z.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:Z.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};_$.displayName=m$;var v$=`TooltipTrigger`,y$=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=g$(v$,n),a=f$(v$,n),o=s$(n),s=d(t,Z.useRef(null),i.onTriggerChange),c=Z.useRef(!1),l=Z.useRef(!1),u=Z.useCallback(()=>c.current=!1,[]);return Z.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,$.jsx)(K,{asChild:!0,...o,children:(0,$.jsx)(k.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:V(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:V(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:V(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:V(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:V(e.onBlur,i.onClose),onClick:V(e.onClick,i.onClose)})})});y$.displayName=v$;var b$=`TooltipPortal`,[x$,S$]=o$(b$,{forceMount:void 0}),C$=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=g$(b$,t);return(0,$.jsx)(x$,{scope:t,forceMount:n,children:(0,$.jsx)(M,{present:n||a.open,children:(0,$.jsx)(E,{asChild:!0,container:i,children:r})})})};C$.displayName=b$;var w$=`TooltipContent`,T$=Z.forwardRef((e,t)=>{let n=S$(w$,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=g$(w$,e.__scopeTooltip);return(0,$.jsx)(M,{present:r||o.open,children:o.disableHoverableContent?(0,$.jsx)(A$,{side:i,...a,ref:t}):(0,$.jsx)(E$,{side:i,...a,ref:t})})}),E$=Z.forwardRef((e,t)=>{let n=g$(w$,e.__scopeTooltip),r=f$(w$,e.__scopeTooltip),i=Z.useRef(null),a=d(t,i),[o,s]=Z.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:f}=r,p=Z.useCallback(()=>{s(null),f(!1)},[f]),m=Z.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=P$(r,N$(r,n.getBoundingClientRect())),a=F$(t.getBoundingClientRect());s(L$([...i,...a])),f(!0)},[f]);return Z.useEffect(()=>()=>p(),[p]),Z.useEffect(()=>{if(c&&u){let e=e=>m(e,u),t=e=>m(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,m,p]),Z.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!I$(n,o);r?p():i&&(p(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,p]),(0,$.jsx)(A$,{...e,ref:a})}),[D$,O$]=o$(m$,{isInside:!1}),k$=j(`TooltipContent`),A$=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=g$(w$,n),l=s$(n),{onClose:u}=c;return Z.useEffect(()=>(document.addEventListener(u$,u),()=>document.removeEventListener(u$,u)),[u]),Z.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,$.jsx)(B,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,$.jsxs)(G,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,$.jsx)(k$,{children:r}),(0,$.jsx)(D$,{scope:n,isInside:!0,children:(0,$.jsx)(a$,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});T$.displayName=w$;var j$=`TooltipArrow`,M$=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=s$(n);return O$(j$,n).isInside?null:(0,$.jsx)(W,{...i,...r,ref:t})});M$.displayName=j$;function N$(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function P$(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function F$(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function I$(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function L$(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),R$(t)}function R$(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var z$=p$,B$=_$,V$=y$,H$=C$,U$=T$,W$=M$,G$=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-snug text-fg shadow-lg`,K$=`block w-full min-w-0 truncate rounded border border-transparent bg-surface-hover px-2 py-1.5 font-mono text-xs text-fg focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`,q$=`inline-flex w-[5.25rem] shrink-0 items-center justify-center gap-1 px-2 py-1 text-xs`;function J$(e){let t=(0,Q.c)(38),{label:n,text:r,compact:i,labels:a,monospace:o}=e,s=o===void 0?!0:o,c=(0,Z.useRef)(null),[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m;t[0]===r?m=t[1]:(m=async()=>{if(p(!1),await mA(r)){d(!0),window.setTimeout(()=>d(!1),2e3);return}hA(c.current),p(!0),window.setTimeout(()=>p(!1),2500)},t[0]=r,t[1]=m);let h=m,g=i&&`gap-0.5`,_;t[2]===g?_=t[3]:(_=u(`flex min-w-0 flex-col gap-1`,g),t[2]=g,t[3]=_);let v;t[4]===n?v=t[5]:(v=n?(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}):null,t[4]=n,t[5]=v);let y=n??a.copy,b=!s&&`font-sans`,x;t[6]===b?x=t[7]:(x=u(K$,b),t[6]=b,t[7]=x);let S;t[8]!==y||t[9]!==x||t[10]!==r?(S=(0,$.jsx)(V$,{asChild:!0,children:(0,$.jsx)(`input`,{ref:c,readOnly:!0,type:`text`,value:r,"aria-label":y,className:x,onFocus:Y$})}),t[8]=y,t[9]=x,t[10]=r,t[11]=S):S=t[11];let C;t[12]===r?C=t[13]:(C=(0,$.jsx)(H$,{children:(0,$.jsx)(U$,{side:`top`,sideOffset:6,collisionPadding:12,className:G$,children:(0,$.jsx)(`span`,{className:`break-all`,children:r})})}),t[12]=r,t[13]=C);let w;t[14]!==C||t[15]!==S?(w=(0,$.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,$.jsxs)(B$,{children:[S,C]})}),t[14]=C,t[15]=S,t[16]=w):w=t[16];let T;t[17]===h?T=t[18]:(T=()=>void h(),t[17]=h,t[18]=T);let E;t[19]===l?E=t[20]:(E=l?(0,$.jsx)(Iu,{className:`size-3.5 shrink-0`}):(0,$.jsx)(Fp,{className:`size-3.5 shrink-0`}),t[19]=l,t[20]=E);let D=l?a.copied:a.copy,O;t[21]===D?O=t[22]:(O=(0,$.jsx)(`span`,{className:`truncate`,children:D}),t[21]=D,t[22]=O);let k;t[23]!==T||t[24]!==E||t[25]!==O?(k=(0,$.jsxs)(tA,{type:`button`,variant:`secondary`,className:q$,onClick:T,children:[E,O]}),t[23]=T,t[24]=E,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==w||t[28]!==k?(A=(0,$.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_5.25rem] items-center gap-2`,children:[w,k]}),t[27]=w,t[28]=k,t[29]=A):A=t[29];let j;t[30]!==f||t[31]!==a.copyFailed?(j=f?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:a.copyFailed}):null,t[30]=f,t[31]=a.copyFailed,t[32]=j):j=t[32];let M;return t[33]!==A||t[34]!==j||t[35]!==_||t[36]!==v?(M=(0,$.jsx)(z$,{delayDuration:300,children:(0,$.jsxs)(`div`,{className:_,children:[v,A,j]})}),t[33]=A,t[34]=j,t[35]=_,t[36]=v,t[37]=M):M=t[37],M}function Y$(e){return e.currentTarget.select()}function X$(e){let t=(0,Q.c)(12),{rows:n,compact:r,labels:i}=e,a=r&&`gap-1.5`,o;t[0]===a?o=t[1]:(o=u(`flex min-w-0 flex-col gap-2`,a),t[0]=a,t[1]=o);let s;if(t[2]!==r||t[3]!==i||t[4]!==n){let e;t[6]!==r||t[7]!==i?(e=e=>(0,$.jsx)(J$,{label:e.label,text:e.text,compact:r,labels:i},e.key),t[6]=r,t[7]=i,t[8]=e):e=t[8],s=n.map(e),t[2]=r,t[3]=i,t[4]=n,t[5]=s}else s=t[5];let c;return t[9]!==o||t[10]!==s?(c=(0,$.jsx)(`div`,{className:o,children:s}),t[9]=o,t[10]=s,t[11]=c):c=t[11],c}var Z$=new Intl.DateTimeFormat(`zh-CN`,{dateStyle:`medium`,timeStyle:`short`}),Q$=new Intl.DateTimeFormat(`en`,{dateStyle:`medium`,timeStyle:`short`});function $$(e,t,n,r){if(n===`public`){let n=[{key:`public`,label:r.publicUrlLabel,url:e}];return t&&n.push({key:`lan`,label:r.lanUrlLabel,url:t}),n}return n===`lan`?[{key:`lan`,label:r.lanUrlLabel,url:e}]:[{key:`local`,label:r.localUrlLabel,url:e}]}function e1(e){let t=(0,Q.c)(17),{shareUrl:n,lanUrl:r,reachability:i,compact:a}=e,o=_(n1),s;t[0]===o?s=t[1]:(s=m(o),t[0]=o,t[1]=s);let c=s.sharesSettings,l=r??null,u;t[2]!==i||t[3]!==n||t[4]!==c||t[5]!==l?(u=$$(n,l,i,c),t[2]=i,t[3]=n,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d=u,f;t[7]!==c.copied||t[8]!==c.copy||t[9]!==c.copyFailed?(f={copy:c.copy,copied:c.copied,copyFailed:c.copyFailed},t[7]=c.copied,t[8]=c.copy,t[9]=c.copyFailed,t[10]=f):f=t[10];let p=f,h;t[11]===d?h=t[12]:(h=d.map(t1),t[11]=d,t[12]=h);let g;return t[13]!==a||t[14]!==p||t[15]!==h?(g=(0,$.jsx)(X$,{rows:h,compact:a,labels:p}),t[13]=a,t[14]=p,t[15]=h,t[16]=g):g=t[16],g}function t1(e){return{key:e.key,label:e.label,text:e.url}}function n1(e){return e.language}function r1(e,t){return(t===`zh`?Z$:Q$).format(new Date(e))}function i1(e){let t=(0,Q.c)(23),{reachability:n,reachabilityHint:r}=e,i=_(a1),a;t[0]===i?a=t[1]:(a=m(i),t[0]=i,t[1]=a);let o=a.sharesSettings;if(n===`public`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ov,{className:`size-3`}),t[2]=e):e=t[2];let n;return t[3]===o.reachPublic?n=t[4]:(n=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400`,children:[e,o.reachPublic]}),t[3]=o.reachPublic,t[4]=n),n}if(n===`lan`){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(dk,{className:`size-3`}),t[5]=e):e=t[5];let n;t[6]===r?n=t[7]:(n=r?(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[` — `,r]}):null,t[6]=r,t[7]=n);let i;return t[8]!==o.reachLan||t[9]!==n?(i=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400`,children:[e,o.reachLan,n]}),t[8]=o.reachLan,t[9]=n,t[10]=i):i=t[10],i}let s;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(lk,{className:`size-3`}),t[11]=s):s=t[11];let c;t[12]===o.reachLocal?c=t[13]:(c=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-subtle`,children:[s,o.reachLocal]}),t[12]=o.reachLocal,t[13]=c);let l=r??o.reachLocalHint,u;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(gh,{className:`size-3`}),t[14]=u):u=t[14];let d;t[15]===o.openTunnel?d=t[16]:(d=(0,$.jsxs)(Hi,{to:`/settings/remote-access?tab=public`,className:`inline-flex items-center gap-0.5 text-accent hover:underline`,children:[o.openTunnel,u]}),t[15]=o.openTunnel,t[16]=d);let f;t[17]!==l||t[18]!==d?(f=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-muted`,children:[l,` `,d]}),t[17]=l,t[18]=d,t[19]=f):f=t[19];let p;return t[20]!==c||t[21]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,f]}),t[20]=c,t[21]=f,t[22]=p):p=t[22],p}function a1(e){return e.language}function o1(e){let t=(0,Q.c)(24),{result:n}=e,r=_(s1),i;t[0]===r?i=t[1]:(i=m(r),t[0]=r,t[1]=i);let a=i.sharesSettings,o;t[2]===n.fileName?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.fileName}),t[2]=n.fileName,t[3]=o);let s=a.expiresLabel,c;t[4]!==r||t[5]!==n.expiresAt?(c=r1(n.expiresAt,r),t[4]=r,t[5]=n.expiresAt,t[6]=c):c=t[6];let l;t[7]!==a.expiresLabel||t[8]!==c?(l=(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s,`: `,c]}),t[7]=a.expiresLabel,t[8]=c,t[9]=l):l=t[9];let u;t[10]!==o||t[11]!==l?(u=(0,$.jsxs)(`div`,{children:[o,l]}),t[10]=o,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.lanUrl||t[14]!==n.reachability||t[15]!==n.shareUrl?(d=(0,$.jsx)(e1,{shareUrl:n.shareUrl,lanUrl:n.lanUrl,reachability:n.reachability}),t[13]=n.lanUrl,t[14]=n.reachability,t[15]=n.shareUrl,t[16]=d):d=t[16];let f;t[17]!==n.reachability||t[18]!==n.reachabilityHint?(f=(0,$.jsx)(i1,{reachability:n.reachability,reachabilityHint:n.reachabilityHint}),t[17]=n.reachability,t[18]=n.reachabilityHint,t[19]=f):f=t[19];let p;return t[20]!==u||t[21]!==d||t[22]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[u,d,f]}),t[20]=u,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function s1(e){return e.language}function c1(e){let t=(0,Q.c)(26),{open:n,onOpenChange:r,loading:i,error:a,result:o}=e,s=_(l1),c;t[0]===s?c=t[1]:(c=m(s),t[0]=s,t[1]=c);let l=c.sharesSettings,d;t[2]===s?d=t[3]:(d=m(s),t[2]=s,t[3]=d);let f=d,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(RN,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[4]=p):p=t[4];let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=u(`fixed left-1/2 top-1/2 z-[71] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`overflow-hidden rounded-lg border border-edge bg-surface-panel p-4 shadow-popover outline-none`),t[5]=h):h=t[5];let g;t[6]===l.shareCreated?g=t[7]:(g=(0,$.jsx)(BN,{className:`text-base font-semibold text-fg`,children:l.shareCreated}),t[6]=l.shareCreated,t[7]=g);let v;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Sk,{className:`size-4`}),t[8]=v):v=t[8];let y;t[9]===l.cancel?y=t[10]:(y=(0,$.jsx)(HN,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,children:v})}),t[9]=l.cancel,t[10]=y);let b;t[11]!==g||t[12]!==y?(b=(0,$.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-2`,children:[g,y]}),t[11]=g,t[12]=y,t[13]=b):b=t[13];let x;t[14]!==a||t[15]!==i||t[16]!==f||t[17]!==o?(x=i?(0,$.jsxs)(`p`,{className:`flex items-center gap-2 py-4 text-sm text-fg-muted`,children:[(0,$.jsx)(Fv,{className:`size-4 animate-spin`}),f.workspace.sharing]}):a?(0,$.jsx)(`p`,{className:`py-2 text-sm text-red-600 dark:text-red-400`,children:a}):o?(0,$.jsx)(o1,{result:o}):null,t[14]=a,t[15]=i,t[16]=f,t[17]=o,t[18]=x):x=t[18];let S;t[19]!==b||t[20]!==x?(S=(0,$.jsxs)(LN,{children:[p,(0,$.jsxs)(zN,{className:h,children:[b,x]})]}),t[19]=b,t[20]=x,t[21]=S):S=t[21];let C;return t[22]!==r||t[23]!==n||t[24]!==S?(C=(0,$.jsx)(FN,{open:n,onOpenChange:r,children:S}),t[22]=r,t[23]=n,t[24]=S,t[25]=C):C=t[25],C}function l1(e){return e.language}async function u1(){return J(X(`/api/shares`))}async function d1(e){return J(X(`/api/shares`),{method:`POST`,body:JSON.stringify(e)})}async function f1(e){return J(X(`/api/shares/${e}`),{method:`DELETE`})}async function p1(){return J(X(`/api/shares`),{method:`DELETE`,body:JSON.stringify({expired:!0})})}async function m1(e,t){return J(X(`/api/shares/${e}`),{method:`PATCH`,body:JSON.stringify({extendTtlMs:t})})}function h1(){let[e,t]=(0,Z.useState)(!1),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),c=(0,Z.useCallback)(async e=>{t(!0),r(!0),a(null),s(null);try{let t=await d1(e);return a(t.payload),t.payload}catch(e){return s(e instanceof Error?e.message:String(e)),null}finally{r(!1)}},[]),l=(0,Z.useCallback)(()=>{a(null),s(null),r(!1)},[]);return{dialogOpen:e,loading:n,result:i,error:o,createShareLink:c,handleOpenChange:(0,Z.useCallback)(e=>{t(e),e||l()},[l])}}function g1(e){return e.map(e=>({name:e.name,path:e.path,absolutePath:e.absolutePath,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function _1(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:_1(e.children,t,n)}:e)}function v1(e,t){let[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(new Set),d=e.trim(),f=t?.trim()??``,p=f,m=f?``:d,h=(0,Z.useMemo)(()=>{if(p)return{sessionKey:p};if(m)return{agentId:m}},[p,m]);return{tree:n,loading:i,error:o,workspaceRoot:c,loadRoot:(0,Z.useCallback)(async()=>{a(!0),s(null),u.current.clear();try{let e=await jq(``,h);r(g1(e.entries)),l(e.root?.trim()||null),u.current.add(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[h]),loadChildren:(0,Z.useCallback)(async e=>{if(!u.current.has(e)){u.current.add(e);try{let t=g1(await Mq(e,h));r(n=>_1(n,e,t))}catch{u.current.delete(e)}}},[h]),reset:(0,Z.useCallback)(()=>{r([]),s(null),l(null),u.current.clear()},[])}}function y1({workspacePath:e,className:t}){let n=m(_(e=>e.language)).workspace,[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)([]),[l,d]=(0,Z.useState)(!1),f=fM()&&!!e.trim()&&!!window.electronAPI?.shell?.openPath,p=(0,Z.useCallback)(async()=>{let t=window.electronAPI?.shell;if(!t?.getOpenWithAppsForPath||!e.trim()){o([]),c([]);return}try{let n=await t.getOpenWithAppsForPath(e);o(n.recommended.map(e=>({name:e.name,path:e.path}))),c(n.recent.map(e=>({name:e.name,path:e.path})))}catch{o([]),c([])}},[e]);(0,Z.useEffect)(()=>{p()},[p]);let h=(0,Z.useCallback)(e=>{FK(`warning`,e||n.openLocationFailed,void 0,{duration:4e3})},[n.openLocationFailed]),g=(0,Z.useCallback)(async()=>{let t=window.electronAPI?.shell;if(!(!t?.openPath||!e)){d(!0);try{let n=await t.openPath(e);n.ok===!1&&h(n.error)}finally{d(!1),i(!1)}}},[h,e]),v=(0,Z.useCallback)(async t=>{let n=window.electronAPI?.shell;if(!(!n?.openPathWithApp||!e)){d(!0);try{let r=await n.openPathWithApp(e,t);r.ok===!1?h(r.error):p()}finally{d(!1),i(!1)}}},[p,h,e]),y=(0,Z.useCallback)(async()=>{let t=window.electronAPI?.shell;if(!(!t?.chooseAppAndOpenPath||!e)){d(!0);try{let n=await t.chooseAppAndOpenPath(e);n.ok===!1&&n.code!==`CANCELED`&&h(n.error),n.ok&&p()}finally{d(!1),i(!1)}}},[p,h,e]),b=(0,Z.useCallback)(async()=>{let t=await mA(e);FK(t?`success`:`warning`,t?n.pathCopied:n.copyPathFailed,void 0,{duration:t?2500:4e3}),i(!1)},[n.copyPathFailed,n.pathCopied,e]);if(!f)return null;let x=`flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm text-fg hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,S=a[0]??s[0],C=S?a.filter(e=>e.path!==S.path):a,w=S?s.filter(e=>e.path!==S.path):s;return(0,$.jsxs)(oj,{open:r,onOpenChange:e=>{i(e),e&&p()},children:[(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsxs)(tA,{variant:`ghost`,className:u(`min-w-0 max-w-40 shrink rounded-md px-2 py-1.5 text-xs`,t),"aria-label":n.openLocation,title:n.openLocation,children:[(0,$.jsx)(qv,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:S?.name??n.openLocation}),(0,$.jsx)(Gu,{className:`size-3.5 shrink-0`,"aria-hidden":!0})]})}),(0,$.jsx)(lj,{children:(0,$.jsxs)(uj,{align:`end`,side:`bottom`,sideOffset:6,className:`z-50 w-60 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover outline-none`,children:[S?(0,$.jsxs)(`button`,{type:`button`,disabled:l,className:x,title:S.path,onClick:()=>void v(S.path),children:[(0,$.jsx)(qv,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:S.name})]}):null,(0,$.jsx)(`div`,{className:u(S&&`border-t border-edge pt-1`),children:(0,$.jsxs)(`button`,{type:`button`,disabled:l,className:x,onClick:()=>void g(),children:[(0,$.jsx)(__,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),n.openInFileManager]})}),C.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`border-t border-edge px-2.5 pb-1 pt-2 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.recommendedApps}),C.map(e=>(0,$.jsxs)(`button`,{type:`button`,disabled:l,className:x,title:e.path,onClick:()=>void v(e.path),children:[(0,$.jsx)(qv,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))]}):null,w.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`border-t border-edge px-2.5 pb-1 pt-2 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.recentApps}),w.map(e=>(0,$.jsxs)(`button`,{type:`button`,disabled:l,className:x,title:e.path,onClick:()=>void v(e.path),children:[(0,$.jsx)(qv,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))]}):null,(0,$.jsxs)(`div`,{className:`mt-1 border-t border-edge pt-1`,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:l,className:x,onClick:()=>void y(),children:[(0,$.jsx)(qv,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),n.chooseApp]}),(0,$.jsxs)(`button`,{type:`button`,className:x,onClick:()=>void b(),children:[(0,$.jsx)(Fp,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),n.copyPath]})]})]})})]})}var b1=h(e=>({agentId:``,setAgentId:t=>e({agentId:t})})),x1=`xopc-web-workspace-panel-open`,S1=`xopc-web-workspace-panel-width-px`;function C1(){try{return globalThis.localStorage?.getItem(x1)===`1`}catch{return!1}}function w1(e){try{globalThis.localStorage?.setItem(x1,e?`1`:`0`)}catch{}}function T1(e){return Math.min(520,Math.max(200,Math.round(e)))}function E1(){try{let e=globalThis.localStorage?.getItem(S1);if(e==null)return 320;let t=Number.parseInt(e,10);return Number.isFinite(t)?T1(t):320}catch{return 320}}function D1(e){try{globalThis.localStorage?.setItem(S1,String(e))}catch{}}var O1=h((e,t)=>({open:C1(),setOpen:t=>{e({open:t}),queueMicrotask(()=>w1(t))},toggleOpen:()=>{t().setOpen(!t().open)},widthPx:E1(),setWidthPx:n=>{let r=T1(n);t().widthPx!==r&&(e({widthPx:r}),queueMicrotask(()=>D1(r)))}})),k1=h(e=>({path:null,line:null,setPath:(t,n)=>e({path:t,line:t&&typeof n==`number`&&Number.isFinite(n)&&n>0?Math.floor(n):null})})),A1=(0,Z.memo)(function(){let e=m(_(e=>e.language)),{pathname:t}=_r(),{sessionKey:n}=wr(),r=t.startsWith(`/chat`)&&n?decodeURIComponent(n):null,i=O1(e=>e.open),a=O1(e=>e.setOpen),o=O1(e=>e.widthPx),s=O1(e=>e.setWidthPx),[c,l]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,h]=(0,Z.useState)(``),[g,v]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),C=k1(e=>e.path),w=k1(e=>e.setPath),T=b1(e=>e.agentId),{tree:E,loading:D,error:O,workspaceRoot:k,loadRoot:A,loadChildren:j,reset:M}=v1(T,r),N=r??T,P=(0,Z.useMemo)(()=>r==null?T.trim()?{agentId:T.trim()}:void 0:{sessionKey:r},[r,T]),F=p.trim(),{dialogOpen:I,loading:L,result:R,error:z,createShareLink:B,handleOpenChange:V}=h1(),H=(0,Z.useCallback)(e=>{if(!i)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`#app-workspace-panel`);t.setPointerCapture(e.pointerId),l(!0);let r=e.clientX,a=O1.getState().widthPx,o=e.pointerId,c=0,u=a,d=a,f=()=>{c=0,d=u,n?.style.setProperty(`--workspace-panel-px`,`${d}px`)},p=e=>{u=T1(a+(r-e.clientX)),c===0&&(c=window.requestAnimationFrame(f))},m=()=>{c!==0&&(window.cancelAnimationFrame(c),f());try{t.releasePointerCapture(o)}catch{}l(!1),s(d),window.removeEventListener(`pointermove`,p),window.removeEventListener(`pointerup`,m),window.removeEventListener(`pointercancel`,m)};window.addEventListener(`pointermove`,p),window.addEventListener(`pointerup`,m),window.addEventListener(`pointercancel`,m)},[i,s]);(0,Z.useEffect)(()=>{t.startsWith(`/chat`)||a(!1)},[t,a]),(0,Z.useEffect)(()=>{if(!i){M(),w(null);return}w(null),A()},[i,N,A,M,w]),(0,Z.useEffect)(()=>{if(!i)return;let e=e=>{if(e.key===`Escape`){if(d){e.preventDefault(),e.stopPropagation(),h(``),f(!1);return}k1.getState().path||a(!1)}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[d,i,a]),(0,Z.useEffect)(()=>{if(!i||!d||!F){v([]),b(!1),S(null);return}let e=!1;b(!0),S(null),v([]);let t=window.setTimeout(()=>{Nq(F,P,50).then(t=>{e||v(t)}).catch(t=>{e||S(t instanceof Error?t.message:String(t))}).finally(()=>{e||b(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[d,F,i,P]),(0,Z.useEffect)(()=>{if(!i||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[i]);let U=(0,Z.useCallback)(e=>{j(e)},[j]),W=(0,Z.useCallback)(async(t,n,r)=>{switch(t){case`preview`:if(n.isDirectory)return;w(n.path);break;case`download`:if(n.isDirectory)return;try{let e=Qq(n.path);if(tJ(eJ(e))!==`text`)Vq(e,await(await Lq(n.path,P)).arrayBuffer(),UI(e)??`application/octet-stream`);else{let{content:t}=await Pq(n.path,P);Bq(e,t)}}catch{}break;case`copyPath`:try{await mA(n.absolutePath??n.path)&&FK(`success`,e.workspace.pathCopied,void 0,{duration:2500})}catch{}break;case`openDefault`:if(!n.absolutePath||!window.electronAPI?.shell?.openPath)return;await window.electronAPI.shell.openPath(n.absolutePath);break;case`openWith`:if(!n.absolutePath||!window.electronAPI?.shell?.chooseAppAndOpenPath)return;await window.electronAPI.shell.chooseAppAndOpenPath(n.absolutePath);break;case`openWithApp`:if(!n.absolutePath||!r||!window.electronAPI?.shell?.openPathWithApp)return;await window.electronAPI.shell.openPathWithApp(n.absolutePath,r);break;case`revealInFolder`:if(!n.absolutePath||!window.electronAPI?.shell?.showItemInFolder)return;await window.electronAPI.shell.showItemInFolder(n.absolutePath);break;case`share`:await B({path:n.path,...n.isDirectory?{kind:`directory`,directoryMode:`browse`}:{},...P});break;default:break}},[B,e.workspace.pathCopied,w,P]);return(0,$.jsxs)($.Fragment,{children:[i?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-scrim md:hidden`,"aria-label":e.closeMenu,onClick:()=>a(!1)}):null,(0,$.jsx)(`aside`,{id:`app-workspace-panel`,"aria-label":e.workspace.title,"aria-hidden":!i,className:u(`flex min-h-0 flex-col overflow-hidden bg-surface-base`,`max-md:fixed max-md:right-0 max-md:top-0 max-md:z-50 max-md:h-[100dvh] max-md:shadow-popover`,`max-md:transition-transform max-md:duration-200 max-md:ease-out`,`motion-reduce:max-md:transition-none`,`max-md:w-[min(20rem,92vw)]`,i?`max-md:translate-x-0`:`max-md:pointer-events-none max-md:translate-x-full`,`md:relative md:h-full md:translate-x-0`,`motion-reduce:md:transition-none`,!i&&`md:pointer-events-none md:w-0 md:min-w-0 md:max-w-0 md:overflow-hidden`,i&&`app-workspace-panel-expanded-width md:shrink-0`,i&&c&&`workspace-panel-rail-resizing`),style:i?{"--workspace-panel-px":`${o}px`}:void 0,children:i?(0,$.jsxs)(`div`,{className:u(`relative flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden overflow-y-hidden bg-surface-base`),children:[(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":e.workspace.resizeHandleAria,onPointerDown:H,className:u(`pointer-events-auto absolute left-0 top-0 z-20 hidden h-full w-2 cursor-col-resize md:block`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:z-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:bg-surface-hover/20 hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,c&&`bg-surface-hover/30 before:!bg-edge/80 dark:before:!bg-edge/85`,`transition-[background-color] duration-150`,`touch-none select-none`,uM)}),(0,$.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4 dark:border-edge`,children:[(0,$.jsx)(`h2`,{className:`sr-only`,children:e.workspace.title}),(0,$.jsx)(y1,{workspacePath:k??``}),(0,$.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:u(`size-9 shrink-0 rounded-md p-0`,d&&`bg-surface-hover text-fg`),"aria-label":e.workspace.search,title:e.workspace.search,"aria-pressed":d,onClick:()=>f(!0),children:(0,$.jsx)(Qx,{className:`size-4`,strokeWidth:1.75})}),(0,$.jsx)(gq,{className:`size-9 shrink-0 rounded-md p-0`,loading:D,label:e.cron.refresh,onClick:A}),(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-md p-0`,"aria-label":e.workspace.close,title:e.workspace.close,onClick:()=>a(!1),children:(0,$.jsx)(Sk,{className:`size-4`,strokeWidth:1.75})})]})]}),d?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge bg-surface-muted/40 px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/20`,children:[(0,$.jsx)(Qx,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`text`,role:`searchbox`,value:p,onChange:e=>h(e.target.value),placeholder:e.workspace.searchPlaceholder,"aria-label":e.workspace.searchPlaceholder,autoFocus:!0,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle`}),(0,$.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":e.workspace.clearSearch,title:e.workspace.clearSearch,onClick:()=>{h(``),f(!1)},children:(0,$.jsx)(Sk,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})]})}):null,O?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[e.workspace.loadError,`: `,O]}):null,F?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:y?(0,$.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,$.jsx)(uI,{className:`h-11 w-full`}),(0,$.jsx)(uI,{className:`h-11 w-full`}),(0,$.jsx)(uI,{className:`h-11 w-full`})]}):x?(0,$.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[e.workspace.loadError,`: `,x]}):g.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:e.workspace.noSearchResults}):g.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:u(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-surface-hover`,C===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>w(e.path),title:e.path,children:[(0,$.jsx)(_g,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):(0,$.jsx)(Oq,{tree:E,selectedPath:C,onSelectFile:e=>w(e),onExpandDir:U,onAction:W,actionLabels:{preview:e.workspace.preview,download:e.workspace.download,copyPath:e.workspace.copyPath,share:e.workspace.shareLink,...fM()?{openDefault:e.workspace.openSystemApp,openWith:e.workspace.chooseApp,revealInFolder:e.workspace.revealInFolder,recommendedApps:e.workspace.recommendedApps}:{}},emptyHint:e.workspace.emptyDir})]}):null}),(0,$.jsx)(c1,{open:I,onOpenChange:V,loading:L,error:z,result:R})]})});function j1(){let e=(0,Q.c)(28),t=(0,Z.useRef)(null),n=q(R1),r=q(L1),i=q(I1),a=q(F1),o=q(P1),s=q(N1),c=_(M1),l;e[0]===c?l=e[1]:(l=m(c),e[0]=c,e[1]=l);let d=l.token,f=!!s&&!i,p;e[2]!==f||e[3]!==o?(p=e=>{!e&&!f||e||o()},e[2]=f,e[3]=o,e[4]=p):p=e[4];let h;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(RN,{className:u(`fixed inset-0 bg-scrim backdrop-blur-[2px]`,hj)}),e[5]=h):h=e[5];let g,v;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=u(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,gj,`dark:border-edge`),v=e=>{e.preventDefault(),t.current?.focus()},e[6]=g,e[7]=v):(g=e[6],v=e[7]);let y;e[8]===d.title?y=e[9]:(y=(0,$.jsx)(BN,{className:`text-base font-semibold text-fg`,children:d.title}),e[8]=d.title,e[9]=y);let b;e[10]===d.description?b=e[11]:(b=(0,$.jsx)(VN,{className:`mt-1 text-sm text-fg-muted`,children:d.description}),e[10]=d.description,e[11]=b);let x;e[12]!==f||e[13]!==o||e[14]!==c?(x=f?(0,$.jsx)(tA,{type:`button`,variant:`ghost`,onClick:()=>o(),children:c===`zh`?`取消`:`Cancel`}):void 0,e[12]=f,e[13]=o,e[14]=c,e[15]=x):x=e[15];let S;e[16]!==r||e[17]!==a||e[18]!==x?(S=(0,$.jsx)(EA,{className:`mt-4`,baseUrl:r,tokenInputRef:t,onSubmit:a,footerLeft:x}),e[16]=r,e[17]=a,e[18]=x,e[19]=S):S=e[19];let C;e[20]!==y||e[21]!==b||e[22]!==S?(C=(0,$.jsxs)(LN,{children:[h,(0,$.jsxs)(zN,{className:g,onOpenAutoFocus:v,children:[y,b,S]})]}),e[20]=y,e[21]=b,e[22]=S,e[23]=C):C=e[23];let w;return e[24]!==n||e[25]!==p||e[26]!==C?(w=(0,$.jsx)(FN,{open:n,onOpenChange:p,children:C}),e[24]=n,e[25]=p,e[26]=C,e[27]=w):w=e[27],w}function M1(e){return e.language}function N1(e){return e.token}function P1(e){return e.closeTokenDialog}function F1(e){return e.setGatewayToken}function I1(e){return e.tokenExpired}function L1(e){return e.baseUrl}function R1(e){return e.tokenDialogOpen}function z1(e){let t=e+`CollectionProvider`,[n,r]=T(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=Z.useRef(null),a=Z.useRef(new Map).current;return(0,$.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=P(s),l=Z.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,$.jsx)(c,{ref:d(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=P(u),m=Z.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=Z.useRef(null),s=d(t,o),c=a(u,n);return Z.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,$.jsx)(p,{[f]:``,ref:s,children:r})});m.displayName=u;function h(t){let n=a(e+`CollectionConsumer`,t);return Z.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:m},h,r]}var B1=Z.createContext(void 0);function V1(e){let t=Z.useContext(B1);return e||t||`ltr`}var H1=`rovingFocusGroup.onEntryFocus`,U1={bubbles:!1,cancelable:!0},W1=`RovingFocusGroup`,[G1,K1,q1]=z1(W1),[J1,Y1]=T(W1,[q1]),[X1,Z1]=J1(W1),Q1=Z.forwardRef((e,t)=>(0,$.jsx)(G1.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,$.jsx)(G1.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,$.jsx)($1,{...e,ref:t})})}));Q1.displayName=W1;var $1=Z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...f}=e,p=Z.useRef(null),m=d(t,p),h=V1(a),[g,_]=R({prop:o,defaultProp:s??null,onChange:c,caller:W1}),[v,y]=Z.useState(!1),b=O(l),x=K1(n),S=Z.useRef(!1),[C,w]=Z.useState(0);return Z.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(H1,b),()=>e.removeEventListener(H1,b)},[b]),(0,$.jsx)(X1,{scope:n,orientation:r,dir:h,loop:i,currentTabStopId:g,onItemFocus:Z.useCallback(e=>_(e),[_]),onItemShiftTab:Z.useCallback(()=>y(!0),[]),onFocusableItemAdd:Z.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:Z.useCallback(()=>w(e=>e-1),[]),children:(0,$.jsx)(k.div,{tabIndex:v||C===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:`none`,...e.style},onMouseDown:V(e.onMouseDown,()=>{S.current=!0}),onFocus:V(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!v){let t=new CustomEvent(H1,U1);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);a0([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:V(e.onBlur,()=>y(!1))})})}),e0=`RovingFocusGroupItem`,t0=Z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=I(),l=a||c,u=Z1(e0,n),d=u.currentTabStopId===l,f=K1(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return Z.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,$.jsx)(G1.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,$.jsx)(k.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:V(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:V(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:V(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=i0(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?o0(n,r+1):n.slice(r+1)}setTimeout(()=>a0(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});t0.displayName=e0;var n0={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function r0(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function i0(e,t,n){let r=r0(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return n0[r]}function a0(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function o0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var s0=Q1,c0=t0,l0=[`Enter`,` `],u0=[`ArrowDown`,`PageUp`,`Home`],d0=[`ArrowUp`,`PageDown`,`End`],f0=[...u0,...d0],p0={ltr:[...l0,`ArrowRight`],rtl:[...l0,`ArrowLeft`]},m0={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},h0=`Menu`,[g0,_0,v0]=z1(h0),[y0,b0]=T(h0,[v0,H,Y1]),x0=H(),S0=Y1(),[C0,w0]=y0(h0),[T0,E0]=y0(h0),D0=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=x0(t),[c,l]=Z.useState(null),u=Z.useRef(!1),d=O(a),f=V1(i);return Z.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,$.jsx)(U,{...s,children:(0,$.jsx)(C0,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,$.jsx)(T0,{scope:t,onClose:Z.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};D0.displayName=h0;var O0=`MenuAnchor`,k0=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=x0(n);return(0,$.jsx)(K,{...i,...r,ref:t})});k0.displayName=O0;var A0=`MenuPortal`,[j0,M0]=y0(A0,{forceMount:void 0}),N0=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=w0(A0,t);return(0,$.jsx)(j0,{scope:t,forceMount:n,children:(0,$.jsx)(M,{present:n||a.open,children:(0,$.jsx)(E,{asChild:!0,container:i,children:r})})})};N0.displayName=A0;var P0=`MenuContent`,[F0,I0]=y0(P0),L0=Z.forwardRef((e,t)=>{let n=M0(P0,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=w0(P0,e.__scopeMenu),o=E0(P0,e.__scopeMenu);return(0,$.jsx)(g0.Provider,{scope:e.__scopeMenu,children:(0,$.jsx)(M,{present:r||a.open,children:(0,$.jsx)(g0.Slot,{scope:e.__scopeMenu,children:o.modal?(0,$.jsx)(R0,{...i,ref:t}):(0,$.jsx)(z0,{...i,ref:t})})})})}),R0=Z.forwardRef((e,t)=>{let n=w0(P0,e.__scopeMenu),r=Z.useRef(null),i=d(t,r);return Z.useEffect(()=>{let e=r.current;if(e)return F(e)},[]),(0,$.jsx)(V0,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:V(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),z0=Z.forwardRef((e,t)=>{let n=w0(P0,e.__scopeMenu);return(0,$.jsx)(V0,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),B0=P(`MenuContent.ScrollLock`),V0=Z.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=w0(P0,n),v=E0(P0,n),y=x0(n),b=S0(n),x=_0(n),[S,C]=Z.useState(null),w=Z.useRef(null),T=d(t,w,_.onContentChange),E=Z.useRef(0),O=Z.useRef(``),k=Z.useRef(0),A=Z.useRef(null),j=Z.useRef(`right`),M=Z.useRef(0),P=h?z:Z.Fragment,F=h?{as:B0,allowPinchZoom:!0}:void 0,I=e=>{let t=O.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Bse(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){O.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};Z.useEffect(()=>()=>window.clearTimeout(E.current),[]),N();let L=Z.useCallback(e=>j.current===A.current?.side&&Hse(e,A.current?.area),[]);return(0,$.jsx)(F0,{scope:n,searchRef:O,onItemEnter:Z.useCallback(e=>{L(e)&&e.preventDefault()},[L]),onItemLeave:Z.useCallback(e=>{L(e)||(w.current?.focus(),C(null))},[L]),onTriggerLeave:Z.useCallback(e=>{L(e)&&e.preventDefault()},[L]),pointerGraceTimerRef:k,onPointerGraceIntentChange:Z.useCallback(e=>{A.current=e},[]),children:(0,$.jsx)(P,{...F,children:(0,$.jsx)(D,{asChild:!0,trapped:i,onMountAutoFocus:V(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,$.jsx)(B,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:(0,$.jsx)(s0,{asChild:!0,...b,dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:V(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,$.jsx)(G,{role:`menu`,"aria-orientation":`vertical`,"data-state":b2(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...g,ref:T,style:{outline:`none`,...g.style},onKeyDown:V(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&I(e.key));let i=w.current;if(e.target!==i||!f0.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);d0.includes(e.key)&&a.reverse(),Rse(a)}),onBlur:V(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),O.current=``)}),onPointerMove:V(e.onPointerMove,C2(e=>{let t=e.target,n=M.current!==e.clientX;e.currentTarget.contains(t)&&n&&(j.current=e.clientX>M.current?`right`:`left`,M.current=e.clientX)}))})})})})})})});L0.displayName=P0;var H0=`MenuGroup`,U0=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,$.jsx)(k.div,{role:`group`,...r,ref:t})});U0.displayName=H0;var W0=`MenuLabel`,G0=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,$.jsx)(k.div,{...r,ref:t})});G0.displayName=W0;var K0=`MenuItem`,q0=`menu.itemSelect`,J0=Z.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=Z.useRef(null),o=E0(K0,e.__scopeMenu),s=I0(K0,e.__scopeMenu),c=d(t,a),l=Z.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(q0,{bubbles:!0,cancelable:!0});e.addEventListener(q0,e=>r?.(e),{once:!0}),L(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,$.jsx)(Y0,{...i,ref:c,disabled:n,onClick:V(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:V(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:V(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||l0.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});J0.displayName=K0;var Y0=Z.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=I0(K0,n),s=S0(n),c=Z.useRef(null),l=d(t,c),[u,f]=Z.useState(!1),[p,m]=Z.useState(``);return Z.useEffect(()=>{let e=c.current;e&&m((e.textContent??``).trim())},[a.children]),(0,$.jsx)(g0.ItemSlot,{scope:n,disabled:r,textValue:i??p,children:(0,$.jsx)(c0,{asChild:!0,...s,focusable:!r,children:(0,$.jsx)(k.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:V(e.onPointerMove,C2(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:V(e.onPointerLeave,C2(e=>o.onItemLeave(e))),onFocus:V(e.onFocus,()=>f(!0)),onBlur:V(e.onBlur,()=>f(!1))})})})}),X0=`MenuCheckboxItem`,Z0=Z.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,$.jsx)(a2,{scope:e.__scopeMenu,checked:n,children:(0,$.jsx)(J0,{role:`menuitemcheckbox`,"aria-checked":x2(n)?`mixed`:n,...i,ref:t,"data-state":S2(n),onSelect:V(i.onSelect,()=>r?.(x2(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Z0.displayName=X0;var Q0=`MenuRadioGroup`,[$0,e2]=y0(Q0,{value:void 0,onValueChange:()=>{}}),t2=Z.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=O(r);return(0,$.jsx)($0,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,$.jsx)(U0,{...i,ref:t})})});t2.displayName=Q0;var n2=`MenuRadioItem`,r2=Z.forwardRef((e,t)=>{let{value:n,...r}=e,i=e2(n2,e.__scopeMenu),a=n===i.value;return(0,$.jsx)(a2,{scope:e.__scopeMenu,checked:a,children:(0,$.jsx)(J0,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":S2(a),onSelect:V(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});r2.displayName=n2;var i2=`MenuItemIndicator`,[a2,o2]=y0(i2,{checked:!1}),s2=Z.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=o2(i2,n);return(0,$.jsx)(M,{present:r||x2(a.checked)||a.checked===!0,children:(0,$.jsx)(k.span,{...i,ref:t,"data-state":S2(a.checked)})})});s2.displayName=i2;var c2=`MenuSeparator`,l2=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,$.jsx)(k.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});l2.displayName=c2;var u2=`MenuArrow`,d2=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=x0(n);return(0,$.jsx)(W,{...i,...r,ref:t})});d2.displayName=u2;var f2=`MenuSub`,[p2,m2]=y0(f2),h2=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=w0(f2,t),o=x0(t),[s,c]=Z.useState(null),[l,u]=Z.useState(null),d=O(i);return Z.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,$.jsx)(U,{...o,children:(0,$.jsx)(C0,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,$.jsx)(p2,{scope:t,contentId:I(),triggerId:I(),trigger:s,onTriggerChange:c,children:n})})})};h2.displayName=f2;var g2=`MenuSubTrigger`,_2=Z.forwardRef((e,t)=>{let n=w0(g2,e.__scopeMenu),r=E0(g2,e.__scopeMenu),i=m2(g2,e.__scopeMenu),a=I0(g2,e.__scopeMenu),o=Z.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=Z.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return Z.useEffect(()=>u,[u]),Z.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,$.jsx)(k0,{asChild:!0,...l,children:(0,$.jsx)(Y0,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":b2(n.open),...e,ref:f(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:V(e.onPointerMove,C2(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:V(e.onPointerLeave,C2(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:V(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||p0[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});_2.displayName=g2;var v2=`MenuSubContent`,y2=Z.forwardRef((e,t)=>{let n=M0(P0,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=w0(P0,e.__scopeMenu),o=E0(P0,e.__scopeMenu),s=m2(v2,e.__scopeMenu),c=Z.useRef(null),l=d(t,c);return(0,$.jsx)(g0.Provider,{scope:e.__scopeMenu,children:(0,$.jsx)(M,{present:r||a.open,children:(0,$.jsx)(g0.Slot,{scope:e.__scopeMenu,children:(0,$.jsx)(V0,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:V(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:V(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:V(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=m0[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});y2.displayName=v2;function b2(e){return e?`open`:`closed`}function x2(e){return e===`indeterminate`}function S2(e){return x2(e)?`indeterminate`:e?`checked`:`unchecked`}function Rse(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function zse(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Bse(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=zse(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Vse(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Hse(e,t){return t?Vse({x:e.clientX,y:e.clientY},t):!1}function C2(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Use=D0,Wse=k0,Gse=N0,Kse=L0,qse=U0,Jse=G0,Yse=J0,Xse=Z0,Zse=t2,Qse=r2,$se=s2,ece=l2,tce=d2,nce=_2,rce=y2,w2=`DropdownMenu`,[ice,ace]=T(w2,[b0]),T2=b0(),[oce,E2]=ice(w2),D2=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=T2(t),l=Z.useRef(null),[u,d]=R({prop:i,defaultProp:a??!1,onChange:o,caller:w2});return(0,$.jsx)(oce,{scope:t,triggerId:I(),triggerRef:l,contentId:I(),open:u,onOpenChange:d,onOpenToggle:Z.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,$.jsx)(Use,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};D2.displayName=w2;var O2=`DropdownMenuTrigger`,k2=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=E2(O2,n),o=T2(n);return(0,$.jsx)(Wse,{asChild:!0,...o,children:(0,$.jsx)(k.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:f(t,a.triggerRef),onPointerDown:V(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:V(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});k2.displayName=O2;var sce=`DropdownMenuPortal`,A2=e=>{let{__scopeDropdownMenu:t,...n}=e,r=T2(t);return(0,$.jsx)(Gse,{...r,...n})};A2.displayName=sce;var j2=`DropdownMenuContent`,M2=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E2(j2,n),a=T2(n),o=Z.useRef(!1);return(0,$.jsx)(Kse,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:V(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:V(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});M2.displayName=j2;var cce=`DropdownMenuGroup`,lce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(qse,{...i,...r,ref:t})});lce.displayName=cce;var uce=`DropdownMenuLabel`,dce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(Jse,{...i,...r,ref:t})});dce.displayName=uce;var fce=`DropdownMenuItem`,N2=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(Yse,{...i,...r,ref:t})});N2.displayName=fce;var pce=`DropdownMenuCheckboxItem`,mce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(Xse,{...i,...r,ref:t})});mce.displayName=pce;var hce=`DropdownMenuRadioGroup`,gce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(Zse,{...i,...r,ref:t})});gce.displayName=hce;var _ce=`DropdownMenuRadioItem`,vce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(Qse,{...i,...r,ref:t})});vce.displayName=_ce;var yce=`DropdownMenuItemIndicator`,bce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)($se,{...i,...r,ref:t})});bce.displayName=yce;var xce=`DropdownMenuSeparator`,P2=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(ece,{...i,...r,ref:t})});P2.displayName=xce;var Sce=`DropdownMenuArrow`,Cce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(tce,{...i,...r,ref:t})});Cce.displayName=Sce;var wce=`DropdownMenuSubTrigger`,Tce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(nce,{...i,...r,ref:t})});Tce.displayName=wce;var Ece=`DropdownMenuSubContent`,Dce=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=T2(n);return(0,$.jsx)(rce,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Dce.displayName=Ece;var F2=D2,I2=k2,L2=A2,R2=M2,z2=N2,B2=P2;function V2(){return fM()&&window.electronAPI?.platform===`win32`}function Oce(e){return e?e.replace(/CmdOrCtrl/g,`Ctrl`).replace(/Command/g,`Ctrl`).replace(/\+/g,` + `):null}function kce(e){let t=(0,Q.c)(15),{item:n,onInvoke:r}=e;if(n.type===`separator`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(B2,{className:`my-1 h-px bg-edge-subtle`}),t[0]=e):e=t[0],e}let i;t[1]===n.accelerator?i=t[2]:(i=Oce(n.accelerator),t[1]=n.accelerator,t[2]=i);let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=u(`flex min-h-7 cursor-default select-none items-center gap-6 rounded-md px-2 py-1.5 text-xs text-fg outline-none`,`data-[highlighted]:bg-surface-hover data-[highlighted]:text-fg`),t[3]=o):o=t[3];let s;t[4]!==n.id||t[5]!==r?(s=()=>r(n.id),t[4]=n.id,t[5]=r,t[6]=s):s=t[6];let c;t[7]===n.label?c=t[8]:(c=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.label}),t[7]=n.label,t[8]=c);let l;t[9]===a?l=t[10]:(l=a?(0,$.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-mono text-[11px] text-fg-subtle`,children:a}):null,t[9]=a,t[10]=l);let d;return t[11]!==s||t[12]!==c||t[13]!==l?(d=(0,$.jsxs)(z2,{className:o,onSelect:s,children:[c,l]}),t[11]=s,t[12]=c,t[13]=l,t[14]=d):d=t[14],d}function Ace(e){let t=(0,Q.c)(6),{groups:n}=e,r=jce,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=u(`windows-titlebar-interactive flex min-w-0 items-center gap-1`,uM),t[0]=i):i=t[0];let a;if(t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>(0,$.jsxs)(F2,{modal:!1,children:[(0,$.jsx)(I2,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex h-8 shrink-0 items-center rounded-md px-3 text-sm font-normal text-fg-muted`,`outline-none transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent/60 data-[state=open]:bg-surface-hover data-[state=open]:text-fg`,uM),role:`menuitem`,children:e.label})}),(0,$.jsx)(L2,{children:(0,$.jsx)(R2,{align:`start`,sideOffset:4,className:u(`windows-titlebar-interactive z-[90] min-w-52 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover outline-none`,uM),children:e.items.map((t,n)=>(0,$.jsx)(kce,{item:t,onInvoke:r},t.type===`item`?t.id:`${e.id}-separator-${n}`))})})]},e.id),t[3]=e):e=t[3],a=n.map(e),t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,$.jsx)(`div`,{className:i,role:`menubar`,children:a}),t[4]=a,t[5]=o),o}function jce(e){window.electronAPI?.menu?.invoke(e)}var H2=(0,Z.memo)(function(){let e=(0,Q.c)(11),t=_(Mce),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0];let[r,i]=(0,Z.useState)(n),a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{if(!V2())return;let e=!1;return window.electronAPI?.menu?.getModel().then(t=>{e||i(t)}).catch(()=>{e||i([])}),()=>{e=!0}},e[1]=a):a=e[1];let o;if(e[2]===t?o=e[3]:(o=[t],e[2]=t,e[3]=o),(0,Z.useEffect)(a,o),!V2())return null;let s,c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=u(`windows-titlebar flex h-9 min-w-0 shrink-0 items-center gap-2 border-b border-edge-subtle`),c=(0,$.jsx)(`div`,{className:u(`windows-titlebar-interactive flex shrink-0 items-center gap-0.5`,uM),children:(0,$.jsx)(BM,{sidebarToggleVariant:`main`,showHistory:!0})}),e[4]=s,e[5]=c):(s=e[4],c=e[5]);let l;e[6]===r?l=e[7]:(l=(0,$.jsx)(Ace,{groups:r}),e[6]=r,e[7]=l);let d;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`div`,{className:u(`min-w-8 flex-1 self-stretch`,lM),"aria-hidden":!0}),e[8]=d):d=e[8];let f;return e[9]===l?f=e[10]:(f=(0,$.jsxs)(`header`,{className:s,children:[c,l,d]}),e[9]=l,e[10]=f),f});function Mce(e){return e.language}var U2=`xopc:shell-prefs-changed`,W2={notifyEnabled:!0,notifySoundEnabled:!0};function Nce(){return W2}function Pce(){typeof window>`u`||window.dispatchEvent(new CustomEvent(U2))}async function G2(){if(!fM()||!window.electronAPI?.system)return W2;try{let e=await window.electronAPI.system.getBehavior();W2={notifyEnabled:e.notifyEnabled,notifySoundEnabled:e.notifySoundEnabled}}catch{}return W2}function Fce(){try{let e=new AudioContext,t=e.createOscillator(),n=e.createGain();t.type=`sine`,t.frequency.value=880,n.gain.value=.07,t.connect(n),n.connect(e.destination),t.start(),t.stop(e.currentTime+.15),e.close()}catch{}}function K2(e){if(typeof Notification>`u`)return!1;let t=Nce();if(!t.notifyEnabled&&!e.force||Notification.permission!==`granted`)return!1;let n=e.title.trim();if(!n||!e.force&&!e.urgent&&!document.hidden)return!1;try{let r=new Notification(n,{body:e.body?.trim()||void 0,tag:e.tag,silent:!t.notifySoundEnabled});return r.onclick=()=>{window.focus(),r.close()},t.notifySoundEnabled&&Fce(),!0}catch{return!1}}async function Ice(e,t){if(typeof Notification>`u`)return`unsupported`;if(fM()&&window.electronAPI?.system?.requestNotifications){let n=await window.electronAPI.system.requestNotifications();if(n.status!==`granted`)return n.outcome===`opened-settings`||n.status===`denied`?`denied`:`default`;if(Notification.permission==="default"){let e=await Notification.requestPermission();if(e!==`granted`)return e===`denied`?`denied`:`default`}else if(Notification.permission===`denied`)return`denied`;return W2={...W2,notifyEnabled:!0},K2({title:e,body:t,tag:`xopc-notify-test`,force:!0}),`enabled`}let n=Notification.permission;return n==="default"&&(n=await Notification.requestPermission()),n===`denied`?`denied`:n===`granted`?(W2={...W2,notifyEnabled:!0},K2({title:e,body:t,tag:`xopc-notify-test`,force:!0}),`enabled`):`default`}function Lce(){let e=(0,Q.c)(4),t=_(Vce),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0],(0,Z.useEffect)(zce,n);let r,i;return e[1]===t?(r=e[2],i=e[3]):(r=()=>{if(!fM())return;let e=m(t).systemSettings.desktopNotify,n=Rce,r=t=>{let n=t.detail,r=n?.event;if(!r||r.type!==`error`)return;let i=typeof r.content==`string`?r.content.trim():``;K2({title:e.agentErrorTitle,body:i||e.agentErrorBody,tag:`xopc-agent-error-${n?.sessionKey??`unknown`}`,urgent:!0})};return window.addEventListener(ne,n),window.addEventListener(`agent-stream-event`,r),()=>{window.removeEventListener(ne,n),window.removeEventListener(`agent-stream-event`,r)}},i=[t],e[1]=t,e[2]=r,e[3]=i),(0,Z.useEffect)(r,i),null}function Rce(e){let t=e.detail,n=typeof t?.title==`string`?t.title.trim():``;if(!n)return;let r=typeof t?.message==`string`?t.message.trim():void 0,i=t?.type===`error`||t?.type===`warning`;K2({title:n,body:r,tag:`xopc-toast-${t?.type??`info`}`,urgent:i})}function zce(){if(!fM())return;G2();let e=Bce;return window.addEventListener(U2,e),()=>window.removeEventListener(U2,e)}function Bce(){G2()}function Vce(e){return e.language}function Hce(){let e=(0,Q.c)(16),t=_(Uce),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n.electron,[i,a]=(0,Z.useState)(null),o,s;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{if(!fM())return;let e=window.electronAPI?.gateway;if(e?.onExited)return e.onExited(e=>a(e))},s=[],e[2]=o,e[3]=s):(o=e[2],s=e[3]),(0,Z.useEffect)(o,s),!i)return null;let c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=u(`shrink-0 border-b border-danger/35 bg-danger/10 px-4 py-3 text-sm text-fg shadow-surface`),e[4]=c):c=e[4];let l;e[5]===r.gatewayExitTitle?l=e[6]:(l=(0,$.jsx)(`p`,{className:`font-semibold`,children:r.gatewayExitTitle}),e[5]=r.gatewayExitTitle,e[6]=l);let d;e[7]===r.gatewayExitBody?d=e[8]:(d=(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:r.gatewayExitBody}),e[7]=r.gatewayExitBody,e[8]=d);let f=i.code??`—`,p=i.signal??`—`,h;e[9]!==f||e[10]!==p?(h=(0,$.jsxs)(`p`,{className:`mt-2 font-mono text-xs text-fg-muted`,children:[`exit `,f,` · signal `,p]}),e[9]=f,e[10]=p,e[11]=h):h=e[11];let g;return e[12]!==l||e[13]!==d||e[14]!==h?(g=(0,$.jsxs)(`div`,{className:c,role:`alert`,children:[l,d,h]}),e[12]=l,e[13]=d,e[14]=h,e[15]=g):g=e[15],g}function Uce(e){return e.language}function q2(){let e=(0,Q.c)(3),t=br(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{if(!fM())return;let e=window.electronAPI;if(!e?.menu)return;let n=e.menu.onNavigate(e=>{t(e)}),r=e.menu.onTogglePalette(Kce),i=e.menu.onQuickCapture(Gce),a=e.menu.onToggleSidebar(Wce),o=e.menu.onHistoryNavigate(e=>{t(e)});return()=>{n(),r(),i(),a(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function Wce(){FM.getState().toggleCollapsed()}function Gce(){window.dispatchEvent(new CustomEvent(`open-quick-capture`))}function Kce(){window.dispatchEvent(new CustomEvent(`toggle-command-palette`))}var qce=1500,Jce=9e4;function Yce(){let e=(0,Q.c)(16),t=_(Qce),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n.updatePanel,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(0),l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=c.current+=1;a(!0),s(!1),(async()=>{await new Promise(Zce);let t=Date.now()+Jce;for(;e===c.current&&Date.now()<t;){try{if((await fetch(X(`/api/health`),{signal:AbortSignal.timeout(3e3)})).ok){window.location.reload();return}}catch{}await new Promise(Xce)}e===c.current&&s(!0)})()},e[2]=l):l=e[2];let d=l,f,p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=()=>d();return window.addEventListener(`gateway-restart-initiated`,e),()=>{c.current+=1,window.removeEventListener(`gateway-restart-initiated`,e)}},p=[d],e[3]=f,e[4]=p):(f=e[3],p=e[4]),(0,Z.useEffect)(f,p);let h;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{d()},e[5]=h):h=e[5];let g=h;if(!i)return null;let v=o?`border-red-500/20 bg-red-500/10 text-red-800 dark:text-red-200`:`border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-100`,y;e[6]===v?y=e[7]:(y=u(`flex min-h-10 w-full items-center justify-center gap-2 border-b px-4 py-2 text-sm`,v),e[6]=v,e[7]=y);let b;e[8]!==r.restartPollRetry||e[9]!==r.restartPollTimeout||e[10]!==r.restartPolling||e[11]!==o?(b=o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{children:r.restartPollTimeout}),(0,$.jsx)(`button`,{type:`button`,onClick:g,className:`ml-2 rounded bg-accent px-2 py-0.5 text-xs font-medium text-white hover:bg-accent/90`,children:r.restartPollRetry})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Fv,{className:`size-4 animate-spin`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.restartPolling})]}),e[8]=r.restartPollRetry,e[9]=r.restartPollTimeout,e[10]=r.restartPolling,e[11]=o,e[12]=b):b=e[12];let x;return e[13]!==y||e[14]!==b?(x=(0,$.jsx)(`div`,{className:y,children:b}),e[13]=y,e[14]=b,e[15]=x):x=e[15],x}function Xce(e){return setTimeout(e,qce)}function Zce(e){return setTimeout(e,2e3)}function Qce(e){return e.language}async function J2(){return J(X(`/api/tunnel/pair/context`))}async function $ce(){return J(X(`/api/tunnel/pair/enable-lan`),{method:`POST`,body:JSON.stringify({})})}async function ele(){return J(X(`/api/tunnel/status`))}async function tle(){await J(X(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function nle(){return J(X(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function rle(e){return J(X(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function ile(){return J(X(`/api/tunnel/qr`))}async function ale(){return J(X(`/api/tunnel/pair`),{method:`POST`,body:JSON.stringify({})})}async function ole(){let e=(await J(X(`/api/tunnel/reveal-registration-secret`),{method:`POST`,body:JSON.stringify({})})).payload;if(!e)throw Error(`Missing reveal payload`);return{registrationSecret:e.registrationSecret??null,source:e.source===`config`?`config`:`none`}}async function sle(e){await J(X(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}async function Y2(){if(fM()&&window.electronAPI?.gateway?.restart){let e=await window.electronAPI.gateway.restart();return e.ok&&e.token&&q.getState().setGatewayToken(e.token),e}let e=await J(X(`/api/gateway/restart`),{method:`POST`,body:JSON.stringify({})});return e.ok===!1?{ok:!1,message:e.message??e.error??`Gateway restart failed`}:{ok:!0}}async function cle(e,t={}){let n=t.timeoutMs??9e4,r=t.intervalMs??500,i=Date.now()+n,a=async()=>{if(Date.now()>=i)return!1;try{if((await fetch(X(`/api/tunnel/pair/context`),{headers:{Authorization:`Bearer ${e}`}})).ok)return!0}catch{}return await new Promise(e=>setTimeout(e,r)),a()};return a()}async function lle(e={}){let t=e.timeoutMs??9e4,n=e.intervalMs??500,r=Date.now()+t,i=async()=>{if(Date.now()>=r)return null;try{let e=await J2();if(e.pairingReady)return e}catch{}return await new Promise(e=>setTimeout(e,n)),i()};return i()}function ule({reminder:e,compact:t}){let n=_(e=>e.language),r=m(n).updatePanel,{show:i,dismiss:a,electronQuitAndInstall:o,runNpmUpdate:s,npmUpdateRunning:c}=e,[l,d]=(0,Z.useState)(!1),f=(0,Z.useCallback)(async()=>{let e=m(n).updatePanel;d(!0);try{let t=await Y2();if(t.ok){window.dispatchEvent(new Event(`gateway-restart-initiated`));return}re({type:`error`,title:e.updateErrorFailed,message:t.message??`Gateway restart failed`})}catch(t){re({type:`error`,title:e.updateErrorFailed,message:t instanceof Error?t.message:String(t)})}finally{d(!1)}},[n]),p=(0,Z.useCallback)(async()=>{let e=m(n).updatePanel,t=await s();if(t.ok){re({type:`success`,title:e.updateSuccess,message:e.updateSuccessDetail});return}re({type:`error`,title:t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed,message:t.message})},[s,n]);if(i.kind===`none`)return null;let h=`absolute right-2 top-1/2 z-[1] flex -translate-y-1/2 items-center gap-1 sm:right-3`;return i.kind===`electron-ready`?(0,$.jsxs)(`div`,{className:u(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 px-10 py-2 text-sm sm:px-12`,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-[min(100%,48rem)] items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(Bm,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0`,children:r.reminderElectronReady.replace(`{{version}}`,i.version)})]}),(0,$.jsxs)(`div`,{className:h,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:`rounded bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90`,children:[(0,$.jsx)(Lb,{className:`mr-1 inline size-3`}),r.restartToUpdate]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`rounded p-1 text-fg-muted hover:text-fg`,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(Sk,{className:`size-4`})})]})]}):i.kind===`electron-error`?(0,$.jsxs)(`div`,{className:u(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-red-500/20 bg-red-500/10 px-10 py-2 text-sm text-fg sm:px-12`,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-[min(100%,52rem)] items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(ld,{className:`size-4 shrink-0 text-red-500 dark:text-red-400`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:r.reminderElectronUpdateError.replace(`{{detail}}`,i.message)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:h,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(Sk,{className:`size-4`})})]}):i.kind===`electron-downloading`?(0,$.jsxs)(`div`,{className:u(`relative flex min-h-10 w-full min-w-0 flex-col items-center justify-center gap-2 border-b border-edge bg-surface-secondary px-10 py-2 text-sm text-fg-muted sm:flex-row sm:gap-4 sm:px-12`,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-full items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(Bm,{className:`size-4 shrink-0 animate-pulse`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.reminderDownloading.replace(`{{percent}}`,String(i.percent))})]}),(0,$.jsx)(`div`,{className:`h-1.5 w-full max-w-xs rounded-full bg-surface-tertiary sm:max-w-[12rem]`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${i.percent}%`}})}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:u(h,`sm:right-2`),"aria-label":r.dismissAria,children:(0,$.jsx)(Sk,{className:`size-4`})})]}):i.kind===`npm-restart-required`?(0,$.jsxs)(`div`,{className:u(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-amber-500/25 bg-amber-500/10 py-2 text-sm`,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`,children:[(0,$.jsx)(`span`,{children:r.restartRequired.replace(`{{version}}`,i.version)}),(0,$.jsxs)(`button`,{type:`button`,onClick:f,disabled:l,className:`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,children:[l?(0,$.jsx)(Fv,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Lb,{className:`size-3 shrink-0`,"aria-hidden":!0}),r.restartGateway]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:h,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(Sk,{className:`size-4`})})]}):i.kind===`npm`?(0,$.jsxs)(`div`,{className:u(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 py-2 text-sm`,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:u(`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`),children:[(0,$.jsxs)(`span`,{children:[r.reminderNpm.replace(`{{version}}`,i.version),i.channel&&i.channel!==`latest`?` (${i.channel})`:``]}),(0,$.jsxs)(`button`,{type:`button`,onClick:p,disabled:c,className:`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,children:[c?(0,$.jsx)(Fv,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Lb,{className:`size-3 shrink-0`,"aria-hidden":!0}),c?r.updateRunning:r.updateNow]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:h,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(Sk,{className:`size-4`})})]}):null}function dle(e,t,n){let r=m(e),i=r.commandPalette.actions,a=r.commandPalette.groups.actions;return[{kind:`action`,id:`action:automation:create`,title:`Create automation`,subtitle:`Open automations to create a trigger and action`,groupLabel:a,keywords:[`automation`,`schedule`,`trigger`,`action`,`timer`],run:()=>{n(),t(`/automations?action=create`)}},{kind:`action`,id:`action:automation:manage`,title:`Manage automations`,subtitle:`View automations and run history`,groupLabel:a,keywords:[`automation`,`schedule`,`tasks`,`runs`],run:()=>{n(),t(`/automations`)}},{kind:`action`,id:`action:skills:manage`,title:i.manageSkills,subtitle:i.manageSkillsSubtitle,groupLabel:a,keywords:[`skills`,`skill`,`catalog`],run:()=>{n(),t(`/skills`)}},{kind:`action`,id:`action:skills:reload`,title:i.reloadSkills,subtitle:i.reloadSkillsSubtitle,groupLabel:a,keywords:[`skills`,`reload`,`refresh`],run:()=>{n(),c(async()=>{let{reloadSkills:e}=await import(`./skill-reload-api-BBFUOxmf.js`).then(e=>e.n);return{reloadSkills:e}},__vite__mapDeps([22,1,11,3,2,4,12])).then(({reloadSkills:e})=>e())}}]}function X2(e){return m(e).commandPalette.groups}function fle(e){let t=X2(e);return{[t.navigate]:0,[t.projects]:1,[t.quickSettings]:2,[t.extensions]:3,[t.sessions]:4,[t.files]:5,[t.commands]:6,[t.skills]:7,[t.actions]:8}}function ple(e){let t=X2(e);return{[t.navigate]:12,[t.projects]:8,[t.quickSettings]:12,[t.actions]:8,[t.extensions]:8,[t.sessions]:8,[t.files]:10,[t.commands]:6,[t.skills]:6}}function Z2(e,t){return fle(e)[t]??10}function Q2(e){return e.trim().toLowerCase()}function mle(e,t){let n=Q2(e),r=Q2(t);if(!r)return 0;if(!n)return null;if(n===r)return 0;if(n.startsWith(r))return 1;let i=n.indexOf(r);return i>=0?2+Math.min(i,50)/100:null}function hle(e,t){let n=t.trim();if(!n)return 0;let r=[{text:e.title,weight:1},{text:e.subtitle??``,weight:1.75}];for(let t of e.keywords??[])r.push({text:t,weight:1.25});let i=null;for(let e of r){let t=mle(e.text,n);if(t===null)continue;let r=t*e.weight;i=i===null?r:Math.min(i,r)}if(i===null)return null;let a=e.kind===`route`?-.15:e.kind===`project`?-.12:e.kind===`file`?-.1:e.kind===`session`?-.05:e.kind===`setting`||e.kind===`action`?-.02:0;return Math.max(0,i+a)}function gle(e){return e.toSorted((e,t)=>e.rank===t.rank?e.groupLabel===t.groupLabel?e.title.localeCompare(t.title):e.groupLabel.localeCompare(t.groupLabel):e.rank-t.rank)}var _le=new Set([`settingsTunnel`,`settingsShares`,`settingsHeartbeat`,`settingsGoals`,`settingsDreams`,`logs`]),vle=[`/settings/remote-access`,`/settings/tunnel`,`/settings/shares`,`/settings/heartbeat`,`/settings/goals`,`/settings/dreams`,`/settings/logs`,`/settings/extensions/debug`,`/settings/ext/`];function $2(e,t){return t===`advanced`?!0:!_le.has(e)}function e4(e,t){return t===`advanced`?!0:!vle.some(t=>e===t||e.startsWith(t))}var t4=`/channels`;function n4(e){return`${t4}/${encodeURIComponent(e.trim().toLowerCase())}`}function yle(e){return e?.trim().toLowerCase()||null}var r4=h(b(e=>({mode:`simple`,setMode:t=>e({mode:t}),setShowAdvanced:t=>e({mode:t?`advanced`:`simple`})}),{name:`xopc-web-settings-mode`}));function ble(){return r4(xle)}function xle(e){return e.mode===`advanced`}var Sle=[`settingsUserProfile`,`settingsAgentBrowser`],Cle={settingsUserProfile:[`user`,`profile`,`preferences`,`timezone`],settingsAgentBrowser:[`browser`,`playwright`,`automation`]};function wle(e,t){let n=m(e).commandPalette.routes.agentsSubtitle;return Sle.filter(e=>$2(e,t)).map(t=>({id:`route:settings:agent:${t}`,title:p(e,t),subtitle:n,path:Zj(t),keywords:[`agent`,`manifest`,`preset`,`config`,...Cle[t]??[]]}))}function Tle(e,t){return e.filter(e=>e4(e.path.split(`?`)[0]??e.path,t))}function Ele(e){let t=m(e),n=t.commandPalette.routes,r=t.channelsSettings,i=r4.getState().mode;return Tle([{id:`route:chat`,title:t.nav.chat,subtitle:n.chatSubtitle,path:`/chat`,keywords:[`chat`,`new`,`compose`,`assistant`]},{id:`route:agents`,title:t.nav.agents,subtitle:n.agentsSubtitle,path:`/agents`,keywords:[`agent`,`persona`,`switch`]},{id:`route:extensions`,title:t.nav.extensions,subtitle:n.extensionsSubtitle,path:`/extensions`,keywords:[`extension`,`plugin`,`addon`]},{id:`route:sessions`,title:t.nav.sessions,subtitle:n.sessionsSubtitle,path:`/settings/sessions`,keywords:[`history`,`archive`,`pin`]},{id:`route:logs`,title:t.nav.logs,subtitle:n.logsSubtitle,path:`/settings/logs`,keywords:[`debug`,`errors`]},{id:`route:skills`,title:t.nav.skills,subtitle:n.skillsSubtitle,path:`/skills`,keywords:[`tools`,`catalog`]},{id:`route:connectors`,title:t.nav.connectors,subtitle:n.connectorsSubtitle,path:`/connectors`,keywords:[`connector`,`mcp`,`registry`,`integration`,`tools`]},{id:`route:channels`,title:t.nav.channels,subtitle:n.channelsSubtitle,path:`/channels`,keywords:[`telegram`,`weixin`,`feishu`,`channel`]},{id:`route:channels:telegram`,title:`Telegram`,subtitle:n.channelsSubtitle,path:n4(`telegram`),keywords:[`telegram`,`bot`,`channel`,`pairing`]},{id:`route:channels:weixin`,title:`Weixin`,subtitle:n.channelsSubtitle,path:n4(`weixin`),keywords:[`weixin`,`wechat`,`channel`,`qr`]},{id:`route:channels:feishu`,title:`Feishu/Lark`,subtitle:n.channelsSubtitle,path:n4(`feishu`),keywords:[`feishu`,`lark`,`channel`]},{id:`route:channels:telegram:pairing`,title:`Telegram — ${r.hubPairingButton}`,subtitle:n.channelsSubtitle,path:n4(`telegram`),keywords:[`telegram`,`pairing`,`approve`,`dm`]},{id:`route:automations`,title:`Automations`,subtitle:`Triggers, actions, and run history`,path:`/automations`,keywords:[`automation`,`automations`,`schedule`,`tasks`,`history`,`scheduler`]},{id:`route:settings:goals`,title:t.nav.settingsGoals,subtitle:n.goalsSettingsSubtitle,path:`/settings/goals`,keywords:[`goal`,`checklist`,`judge`,`/goal`,`automation`]},{id:`route:settings:dreams`,title:t.nav.settingsDreams,subtitle:n.dreamsSettingsSubtitle,path:`/settings/dreams`,keywords:[`dream`,`memory`,`consolidation`,`automation`]},{id:`route:settings`,title:t.nav.settings,subtitle:n.settingsSubtitle,path:`/settings/overview`,keywords:[`config`,`status`,`providers`,`models`,`agents`,`search`,`preferences`]},{id:`route:settings:credentials`,title:t.nav.settingsCredentials,subtitle:n.credentialsSubtitle,path:`/settings/credentials`,keywords:[`api`,`key`,`credentials`,`oauth`,`token`,`models`,`providers`]},{id:`route:settings:providers`,title:t.nav.settingsProviders,subtitle:n.providersSubtitle,path:`/settings/credentials?tab=services`,keywords:[`api`,`key`,`openai`,`anthropic`,`google`]},{id:`route:settings:models`,title:t.nav.settingsModels,subtitle:n.modelsSubtitle,path:`/settings/credentials?tab=services`,keywords:[`gpt`,`claude`,`gemini`,`llm`]},{id:`route:settings:image-models`,title:t.nav.settingsImageModels,subtitle:n.imageModelsSubtitle,path:`/settings/credentials?tab=image-models`,keywords:[`image`,`vision`,`generate`,`picture`]},{id:`route:settings:voice`,title:t.nav.settingsVoice,subtitle:n.voiceSubtitle,path:`/settings/credentials?tab=voice`,keywords:[`tts`,`stt`,`speech`,`microphone`]},{id:`route:settings:search`,title:t.nav.settingsSearch,subtitle:n.searchSubtitle,path:`/settings/credentials?tab=search`,keywords:[`search`,`web`,`tavily`,`serper`,`brave`]},{id:`route:settings:gateway`,title:t.nav.settingsGateway,subtitle:n.gatewaySubtitle,path:`/settings/gateway`,keywords:[`server`,`port`,`auth`,`token`]},...wle(e,i)],i)}async function Dle(e,t={}){let n=new URLSearchParams;return n.set(`q`,e.trim()),t.types?.length&&n.set(`types`,t.types.join(`,`)),t.limit&&n.set(`limit`,String(t.limit)),(await J(X(`/api/search?${n.toString()}`))).hits}function i4(e){x.getState().setPreference(e)}function a4(e){_.getState().setLanguage(e)}function Ole(e,t){let n=m(e),r=n.commandPalette.quickSettings,i=n.commandPalette.groups.quickSettings;return[{kind:`setting`,id:`setting:model`,title:r.switchModel,subtitle:r.switchModelSubtitle,groupLabel:i,keywords:[`model`,`default model`,`默认模型`,`gpt`,`claude`,`gemini`,`llm`,`模型`],run:()=>t.openModelPalette()},{kind:`setting`,id:`setting:agent`,title:r.switchAgent,subtitle:r.switchAgentSubtitle,groupLabel:i,keywords:[`agent`,`persona`,`bot`],run:()=>t.openAgentPalette()},{kind:`setting`,id:`setting:theme:light`,title:r.themeLight,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`light`,`appearance`],run:()=>{i4(`light`),t.closePalette()}},{kind:`setting`,id:`setting:theme:dark`,title:r.themeDark,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`dark`,`night`],run:()=>{i4(`dark`),t.closePalette()}},{kind:`setting`,id:`setting:theme:system`,title:r.themeSystem,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`system`,`auto`],run:()=>{i4(`system`),t.closePalette()}},{kind:`setting`,id:`setting:lang:en`,title:r.languageEn,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`english`,`language`,`locale`],run:()=>{a4(`en`),t.closePalette()}},{kind:`setting`,id:`setting:lang:zh`,title:r.languageZh,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`chinese`,`中文`,`language`],run:()=>{a4(`zh`),t.closePalette()}}]}function kle(e){let t=e===`zh`;return[{id:`field:gateway:port`,title:t?`网关端口`:`Gateway Port`,subtitle:t?`设置 HTTP 网关监听端口`:`HTTP gateway listen port`,path:`/settings/gateway`,keywords:[`port`,`listen`,`http`,`server`,`端口`]},{id:`field:gateway:host`,title:t?`网关绑定地址`:`Gateway Host`,subtitle:t?`设置绑定的网络接口`:`Network interface to bind`,path:`/settings/gateway`,keywords:[`host`,`bind`,`interface`,`localhost`,`地址`]},{id:`field:gateway:auth`,title:t?`网关认证令牌`:`Gateway Auth Token`,subtitle:t?`访问网关所需的 Bearer token`:`Bearer token for gateway access`,path:`/settings/gateway`,keywords:[`auth`,`token`,`bearer`,`password`,`security`,`认证`,`令牌`]},{id:`field:agent:model`,title:t?`Agent 模型配置`:`Agent model configuration`,subtitle:t?`配置智能体的模型角色与回退模型`:`Configure agent model roles and fallbacks`,path:`/agents`,keywords:[`agent model`,`model roles`,`llm`,`gpt`,`claude`,`gemini`,`智能体模型`,`模型角色`]},{id:`field:agent:temperature`,title:t?`温度 (Temperature)`:`Temperature`,subtitle:t?`控制回复的随机性`:`Controls response randomness`,path:`/agents`,keywords:[`temperature`,`sampling`,`randomness`,`creative`,`温度`,`随机`]},{id:`field:agent:maxTokens`,title:t?`最大输出 Tokens`:`Max Output Tokens`,subtitle:t?`单次回复的最大 token 数`:`Maximum tokens per response`,path:`/agents`,keywords:[`max`,`tokens`,`output`,`length`,`limit`,`最大`]},{id:`field:agent:workspace`,title:t?`工作目录`:`Workspace Directory`,subtitle:t?`代理的默认工作目录`:`Default working directory for the agent`,path:`/agents`,keywords:[`workspace`,`directory`,`folder`,`path`,`cwd`,`工作目录`]},{id:`field:agent:browser`,title:t?`浏览器自动化`:`Browser automation`,subtitle:t?`启用 browser_use 工具`:`Enable browser_use tools`,path:`/agents`,keywords:[`browser`,`browser_use`,`automation`,`浏览器`]},{id:`field:agent:browser-extension`,title:t?`Chrome 扩展连接`:`Chrome extension bridge`,subtitle:t?`安装扩展并启动 WebSocket 桥接`:`Install extension and start the bridge`,path:`/agents`,keywords:[`extension`,`chrome`,`bridge`,`websocket`,`扩展`,`桥接`]},{id:`field:agent:browser-playwright`,title:t?`安装 Playwright Chromium`:`Install Playwright Chromium`,subtitle:t?`本地 Playwright 后端就绪检查`:`Local Playwright backend setup`,path:`/agents`,keywords:[`playwright`,`chromium`,`install`,`local`,`安装`]},{id:`field:agent:browser-cloak`,title:t?`CloakBrowser 配置`:`CloakBrowser settings`,subtitle:t?`反指纹浏览器下载与高级选项`:`Stealth browser download and fingerprint options`,path:`/agents`,keywords:[`cloak`,`cloakbrowser`,`fingerprint`,`stealth`,`反指纹`]},{id:`field:agent:browser-headless`,title:t?`浏览器无头模式`:`Browser headless mode`,subtitle:t?`隐藏浏览器窗口`:`Run without a visible window`,path:`/agents`,keywords:[`headless`,`window`,`visible`,`无头`]},{id:`field:agent:browser-private-urls`,title:t?`允许内网 URL`:`Allow private URLs`,subtitle:t?`浏览器导航安全限制`:`Browser navigation security policy`,path:`/agents`,keywords:[`private`,`internal`,`localhost`,`security`,`内网`,`安全`]},{id:`field:agent:turnLimit`,title:t?`轮次限制`:`Turn Limit`,subtitle:t?`单次会话最大对话轮次`:`Maximum turns per session run`,path:`/agents`,keywords:[`turn`,`limit`,`iterations`,`max`,`轮次`,`限制`]},{id:`field:agent:timeout`,title:t?`超时时间`:`Timeout`,subtitle:t?`单次工具调用的超时`:`Tool execution timeout`,path:`/agents`,keywords:[`timeout`,`duration`,`seconds`,`超时`]},{id:`field:agent:compaction`,title:t?`上下文压缩`:`Context Compaction`,subtitle:t?`长对话自动压缩策略`:`Auto-compact strategy for long conversations`,path:`/agents`,keywords:[`compaction`,`context`,`pruning`,`tokens`,`window`,`压缩`,`上下文`]},{id:`field:agent:memory`,title:t?`记忆设置`:`Memory Settings`,subtitle:t?`会话记忆与回顾配置`:`Session memory and review configuration`,path:`/agents`,keywords:[`memory`,`review`,`session`,`recall`,`记忆`]},{id:`field:agent:systemPrompt`,title:t?`系统提示词`:`System Prompt`,subtitle:t?`自定义系统指令`:`Custom system instructions`,path:`/agents`,keywords:[`system`,`prompt`,`instructions`,`persona`,`系统提示词`,`指令`]},{id:`field:voice:sttProvider`,title:t?`STT 语音识别提供商`:`STT Provider`,subtitle:t?`语音转文字服务商`:`Speech-to-text service provider`,path:`/settings/credentials?tab=voice`,keywords:[`stt`,`speech`,`recognition`,`whisper`,`deepgram`,`语音识别`]},{id:`field:voice:ttsProvider`,title:t?`TTS 语音合成提供商`:`TTS Provider`,subtitle:t?`文字转语音服务商`:`Text-to-speech service provider`,path:`/settings/credentials?tab=voice`,keywords:[`tts`,`speech`,`synthesis`,`voice`,`elevenlabs`,`语音合成`]},{id:`field:search:engine`,title:t?`搜索引擎`:`Web Search Engine`,subtitle:t?`联网搜索使用的引擎`:`Engine for web search tool`,path:`/settings/credentials?tab=search`,keywords:[`search`,`engine`,`tavily`,`serper`,`brave`,`bing`,`搜索引擎`]},{id:`field:automations:enabled`,title:t?`自动化`:`Automations`,subtitle:t?`创建和管理自动化`:`Create and manage automations`,path:`/automations`,keywords:[`automation`,`automations`,`scheduler`,`timer`,`自动化`,`调度`]},{id:`field:automations:runs`,title:t?`自动化运行记录`:`Automation Runs`,subtitle:t?`查看自动化执行历史`:`Review automation run history`,path:`/automations`,keywords:[`automation`,`runs`,`history`,`自动化`,`历史`]},{id:`field:channels:telegram`,title:`Telegram Bot Token`,subtitle:t?`配置 Telegram 频道连接`:`Configure Telegram channel connection`,path:`/channels`,keywords:[`telegram`,`bot`,`token`,`channel`,`频道`]},{id:`field:channels:dmPolicy`,title:t?`私聊接入策略`:`DM Access Policy`,subtitle:t?`Telegram 私聊白名单/配对策略`:`Telegram DM allowlist/pairing policy`,path:`/channels`,keywords:[`dm`,`policy`,`pairing`,`allowlist`,`access`,`私聊`,`策略`]},{id:`field:mcp:servers`,title:t?`MCP 服务器配置`:`MCP Servers`,subtitle:t?`外部 MCP 工具服务器列表`:`External MCP tool server registry`,path:`/connectors`,keywords:[`mcp`,`server`,`tools`,`external`,`stdio`,`服务器`,`connector`]},{id:`field:heartbeat:interval`,title:t?`心跳间隔`:`Heartbeat Interval`,subtitle:t?`网关存活检测频率`:`Gateway keep-alive check frequency`,path:`/settings/heartbeat`,keywords:[`heartbeat`,`interval`,`keepalive`,`alive`,`心跳`]},{id:`field:tunnel:enabled`,title:t?`公网隧道`:`Public Tunnel`,subtitle:t?`FRP 远程访问隧道开关`:`FRP remote access tunnel toggle`,path:`/settings/remote-access`,keywords:[`tunnel`,`frp`,`remote`,`public`,`ngrok`,`隧道`,`远程`]}]}function Ale(e,t,n,r){return kle(e).map(e=>({kind:`setting`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:r,keywords:e.keywords,run:()=>{n(),t(e.path)}}))}async function o4(e){let t=await e.json().catch(()=>({}));if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;if(typeof e==`string`)return e}return`HTTP ${e.status}`}async function s4(){let e=await Y(X(`/api/skills`),{cache:`no-store`});if(!e.ok)throw Error(await o4(e));let t=await e.json();if(!t.payload)throw Error(`Invalid response`);return t.payload}var c4=`[a-zA-Z0-9](?:[a-zA-Z0-9._-]{0,62})`,jle=RegExp(`\\/skill:(${c4})`,`g`);function l4(){return new RegExp(jle.source,`g`)}var Mle=RegExp(`(\\/skill:${c4})$`),Nle=RegExp(`(\\/skill:${c4})([ \\t\\f\\v]*)$`),Ple=RegExp(`^${c4}$`);function Fle(e){return Ple.test(e.trim())}var Ile=RegExp(`^\\/skill:(${c4})`),u4=[],d4=new Map;function f4(e){let t=new Set;for(let n of e??[]){n?.name&&t.add(n.name);for(let e of n.aliases??[])typeof e==`string`&&e.length>0&&t.add(e)}u4=Array.from(t).toSorted((e,t)=>t.length-e.length).map(e=>({key:e})),d4.clear()}function Lle(e,t){if(t>=e.length)return!0;let n=e[t];return!/[a-zA-Z0-9_-]/.test(n)}function Rle(e,t){return!(e[t]!==`/`||t>0&&!/\s/.test(e[t-1]))}function p4(e,t){if(!Rle(e,t)||u4.length===0)return null;let n=e.slice(t);if(n.startsWith(`/skill:`))return null;for(let{key:e}of u4){let t=`/${e}`;if(n.startsWith(t)&&Lle(n,t.length))return{len:t.length,matchedKey:e}}return null}function m4(e){let t=[],n=0;for(;n<e.length;){if(e[n]!==`/`){n+=1;continue}let r=e.slice(n).match(Ile);if(r?.[0]){n+=r[0].length;continue}let i=p4(e,n);i?(t.push({start:n,end:n+i.len}),n+=i.len):n+=1}return t}function zle(e){for(let t=e.length-1;t>=0;--t){if(e[t]!==`/`||e.startsWith(`/skill:`,t))continue;let n=p4(e,t);if(n&&t+n.len===e.length)return!0}return!1}function Ble(e){if(!e.startsWith(`/`)||u4.length===0||e.startsWith(`/skill:`))return!1;let t=p4(e,0);return t?e.length===t.len||!/[a-zA-Z0-9_-]/.test(e[t.len]):!1}function Vle(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Hle(e){let t=d4.get(e);return t||(t=RegExp(`(${Vle(e)})([ \\t\\f\\v]*)$`),d4.set(e,t)),t}function Ule(e){for(let{key:t}of u4){let n=`/${t}`;if(!e.endsWith(n))continue;let r=e.length-n.length;if(p4(e,r))return{tokenStart:r}}return null}function Wle(e){for(let{key:t}of u4){let n=`/${t}`,r=e.match(Hle(n));if(!r)continue;let i=e.length-r[0].length;if(p4(e,i))return{tokenStart:i}}return null}async function h4(e){let t=await e.json().catch(()=>({}));if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;if(typeof e==`string`)return e}return`HTTP ${e.status}`}async function Gle(){let e=await Y(X(`/api/commands`));if(!e.ok)throw Error(await h4(e));return(await e.json()).payload?.commands??[]}var g4=6e4,_4=null,v4=0,y4=null,b4=null,x4=0,S4=null,C4=0,w4=new Map,T4=new Map,E4=0;async function D4(e=!1){return!e&&_4&&Date.now()<v4?(f4(_4),_4):y4||(y4=Gle().then(e=>(_4=e,v4=Date.now()+g4,f4(e),e)).catch(e=>{throw f4([]),e}).finally(()=>{y4=null}),y4)}async function O4(e,t=!1){let n=e?.trim()||`main`,r=Date.now(),i=w4.get(n);if(!t&&i&&r<i.expiry)return i.payload;let a=T4.get(n);if(a)return a;let o=E4,s=Y(X(`/api/chat/skills?agentId=${encodeURIComponent(n)}`)).then(async e=>{if(!e.ok)throw Error(await h4(e));let t=await e.json();if(!t.payload||!Array.isArray(t.payload.skills))throw Error(`Invalid /api/chat/skills response`);return o===E4&&w4.set(n,{payload:t.payload,expiry:Date.now()+g4}),t.payload}).finally(()=>{T4.delete(n)});return T4.set(n,s),s}async function Kle(e,t){let n=e?.trim()||`main`,r=await O4(n,!0),i=new Set(r.effectiveAllowlist??r.agentAllowlist??[]);i.add(t);let a=await Y(X(`/api/agents/${encodeURIComponent(n)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skills:[...i].sort((e,t)=>e.localeCompare(t))})});if(!a.ok)throw Error(await h4(a));k4(n)}function k4(e){if(E4+=1,e){w4.delete(e),T4.delete(e);return}w4.clear(),T4.clear()}function qle(e){k4(e),e||(C4+=1,b4=null,x4=0,S4=null)}async function Jle(e=!1){if(!e&&b4&&Date.now()<x4)return b4;if(S4)return S4;let t=C4;return S4=s4().then(e=>(t===C4&&(b4=e,x4=Date.now()+g4),e)).finally(()=>{S4=null}),S4}var A4=`fill-chat-composer`;function j4(e){window.dispatchEvent(new CustomEvent(A4,{detail:{text:e}}))}function M4(e){return e.acceptsArgs?`/${e.name} `:`/${e.name}`}var Yle=3e4,N4=null;function P4(e){return e.trim()}function Xle(e){return e.map(e=>({name:e.name,relativePath:e.path,isDirectory:e.isDirectory}))}async function F4(e,t){let n=t.sessionKey?.trim(),r=t.agentId?.trim(),i=t.limit??15,a=e.trim(),o=new URLSearchParams;if(o.set(`q`,a),o.set(`limit`,String(i)),n?o.set(`sessionKey`,n):r&&o.set(`agentId`,r),n&&a.length===0){let e=P4(n),t=Date.now();if(N4&&N4.key===e&&t-N4.at<Yle)return N4.items}let s=Xle((await J(X(`/api/workspace/editor/files/search?${o.toString()}`))).payload.entries??[]);return n&&a.length===0&&(N4={key:P4(n),at:Date.now(),items:s}),s}async function Zle(e,t){return Mq(e,{sessionKey:t.sessionKey,agentId:t.agentId})}function I4(e){let t=typeof e.profileDir==`string`?e.profileDir.trim():``,n=e.typedModels?.preset??[],r=e.typedModels?.entry,i=e.typedModels?.effective??n;return{...e,profileDir:t,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{},skills:e.skills?{...e.skills,preset:e.skills.preset??[]}:{preset:[]},tools:e.tools?{...e.tools,presetDenied:e.tools.presetDenied??[]}:{presetDenied:[],entryDisable:[],effectiveDisable:[]},typedModels:{defaultRole:e.typedModels.defaultRole,preset:n,...r===void 0?{}:{entry:r},effective:i},extends:Array.isArray(e.extends)?e.extends:[]}}async function L4(){let e=(await J(X(`/api/agents`))).payload;if(!e?.defaultId||!Array.isArray(e.agents))throw Error(`Invalid /api/agents response`);let t=Array.isArray(e.builtinToolIds)?e.builtinToolIds:[];return{defaultId:e.defaultId,agents:e.agents.map(I4),builtinToolIds:t}}async function Qle(e){let t=await J(X(`/api/agents/${encodeURIComponent(e)}/effective-manifest`));if(!t.payload?.manifest||typeof t.payload.sources!=`object`||t.payload.sources===null)throw Error(`Invalid /api/agents/:id/effective-manifest response`);return t.payload}async function $le(e){let t=await J(X(`/api/agents`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=typeof t.payload?.agentId==`string`?t.payload.agentId.trim():``,r=t.payload?.agents;if(!n||!r?.defaultId||!Array.isArray(r.agents))throw Error(`Invalid create agent response`);return{createdAgentId:n,defaultId:r.defaultId,agents:r.agents.map(I4),builtinToolIds:Array.isArray(r.builtinToolIds)?r.builtinToolIds:[]}}async function eue(e,t){let n=(await J(X(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).payload;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid update agent response`);return{defaultId:n.defaultId,agents:n.agents.map(I4),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}async function tue(e,t){let n=(await J(X(`/api/agents/${encodeURIComponent(e)}${t?`?purge=true`:``}`),{method:`DELETE`})).payload?.agents;if(!n?.defaultId||!Array.isArray(n.agents))throw Error(`Invalid delete agent response`);return{defaultId:n.defaultId,agents:n.agents.map(I4),builtinToolIds:Array.isArray(n.builtinToolIds)?n.builtinToolIds:[]}}async function nue(e){await J(X(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({tui:{defaultAgent:e}})}),hI()}function rue(e){if(!e||typeof e!=`object`||!(`bindings`in e))return[];let t=e.bindings;return Array.isArray(t)?t:[]}async function iue(e){await J(X(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({bindings:e})}),hI()}async function aue(){let e=(await J(X(`/api/skills`))).payload?.catalog;return Array.isArray(e)?e:[]}async function oue(e){let t=(await J(X(`/api/agents/${encodeURIComponent(e)}/files`))).payload,n=typeof t?.profileDir==`string`?t.profileDir.trim():``;if(!t?.files||!n)throw Error(`Invalid files list response`);return{agentId:t.agentId,profileDir:n,files:t.files}}async function sue(e,t){let n=(await J(X(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`))).payload?.content;if(typeof n!=`string`)throw Error(`Invalid file content response`);return n}async function cue(e,t,n){await J(X(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})}async function R4(){let e=(await J(X(`/api/user-profile`))).payload?.content;if(typeof e!=`string`)throw Error(`Invalid user profile response`);return e}async function z4(e){await J(X(`/api/user-profile`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:e})})}function lue(e){let t=e.type.toLowerCase();return t===`image/png`||t===`image/jpeg`||t===`image/jpg`||t===`image/webp`?t===`image/jpg`?`image/jpeg`:t:null}function uue(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=String(r.result??``),n=e.indexOf(`,`);t(n>=0?e.slice(n+1):``)},r.onerror=()=>n(r.error??Error(`read failed`)),r.readAsDataURL(e)})}async function due(e,t){let n=lue(t);if(!n)throw Error(`unsupported_image_type`);if(t.size===0||t.size>512*1024)throw Error(`avatar_too_large`);let r=await uue(t);if(!r)throw Error(`empty_file`);await J(X(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({base64:r,mimeType:n})})}async function fue(e){await J(X(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`DELETE`})}var B4=`main`;function V4(e,t){return e.name?.trim()||(e.id.trim().toLowerCase()===B4?t.defaultMainAgentName:e.id)}function H4(e,t){return e.description?.trim()||(e.id.trim().toLowerCase()===B4?t.defaultMainAgentDescription:``)}var pue=500,U4=null,W4;function G4(e){W4=e,U4!==null&&clearTimeout(U4),U4=setTimeout(()=>{U4=null;let e=W4;W4=void 0,window.dispatchEvent(new CustomEvent(`config-reload`,{detail:e}))},pue)}function mue(){let{pathname:e}=_r(),{sessionKey:t}=wr();if(!e.startsWith(`/chat`)||!t)return;let n=decodeURIComponent(t);return n&&n!==`new`?n:void 0}function K4(e){return{models:{defaultRole:`deep`,roles:{deep:{model:e}}}}}function q4(e,t,n,r){let i=e.trim().toLowerCase();if(i){try{globalThis.localStorage?.setItem(GL,i)}catch{}t.startsWith(`/chat`)?window.dispatchEvent(new CustomEvent(`xopc-set-chat-agent`,{detail:{agentId:i}})):n(`/chat/new`,{state:{agentId:i}}),r()}}function hue(e){switch(e.kind){case`extension`:return(0,$.jsx)($y,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`route`:return(0,$.jsx)(__,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`project`:return(0,$.jsx)(p_,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`session`:return(0,$.jsx)(__,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`file`:return(0,$.jsx)(Eg,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`command`:return(0,$.jsx)(sE,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`skill`:return(0,$.jsx)(SC,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});case`setting`:return(0,$.jsx)(uS,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`action`:return(0,$.jsx)(wk,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});default:return null}}function J4(e,t,n,r){if(r(),t.startsWith(`/chat`)){j4(e);return}let i=e.match(/^\/skill:(\S+)\s*$/),a=e.match(/^\/(\S+)\s*$/);i?n(`/chat/new?skill=${encodeURIComponent(i[1])}`):a?n(`/chat/new?slash=${encodeURIComponent(a[1])}`):(n(`/chat/new`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{j4(e)})}))}function gue(e){let t=[];for(let n of e.uiExtensions){let r=n.ui?.contributions?.commands;if(Array.isArray(r))for(let i of r)!i||typeof i.id!=`string`||typeof i.title!=`string`||t.push({kind:`extension`,id:`ext:${n.id}:${i.id}`,title:i.title,subtitle:n.name,groupLabel:e.extensionsGroupLabel,keywords:[n.id,n.name,i.id],run:()=>{e.close(),i.opensPanel!==void 0&&i.opensPanel!==``?e.navigate(`/extensions/${encodeURIComponent(n.id)}`):window.dispatchEvent(new CustomEvent(`extension-command`,{detail:{extensionId:n.id,commandId:i.id}}))}})}return t}function _ue(e,t){switch(t.type){case`setQuery`:return{...e,query:t.value};case`setSelectedIndex`:{let n=typeof t.value==`function`?t.value(e.selectedIndex):t.value;return{...e,selectedIndex:n}}case`setLayer`:return{...e,paletteLayer:t.layer,query:``,selectedIndex:0};case`resetMain`:return{query:``,selectedIndex:0,paletteLayer:`main`}}}var vue={query:``,selectedIndex:0,paletteLayer:`main`};async function yue(){let e=await J(X(`/api/registry`)),t=[];for(let n of e.payload?.providers??[])for(let e of n.models??[])e.available!==!1&&t.push({id:e.ref,title:e.name||e.ref,subtitle:e.ref});return t.sort((e,t)=>e.title.localeCompare(t.title)),t}async function bue(e){let t=await L4(),n=m(e).agentsSettings;return t.agents.map(e=>({id:e.id,title:V4(e,n),subtitle:e.id}))}function xue({onClose:e}){let t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),r=br(),{pathname:i}=_r(),a=_(e=>e.language),o=BF(),s=mue(),c=b1(e=>e.agentId),l=k1(e=>e.setPath),[u,d]=(0,Z.useReducer)(_ue,vue),[f,p]=(0,Z.useState)(0),{query:h,selectedIndex:g,paletteLayer:v}=u,y=(0,Z.useMemo)(()=>Ele(a),[a]),[b]=XQ(h,120);(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&t.section===`skills`&&p(e=>e+1)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[]);let x=(0,Z.useCallback)(()=>{d({type:`setLayer`,layer:`models`})},[]),S=(0,Z.useCallback)(()=>{d({type:`setLayer`,layer:`agents`})},[]),C=lP(async()=>v===`models`?yue():v===`agents`?bue(a):[],[v,a],{enabled:v===`models`||v===`agents`,initial:[],errorData:[]}),w=lP(async()=>{let t=b.trim(),n=e,u=m(a).commandPalette.groups,d=y.map(e=>({kind:`route`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:u.navigate,keywords:[...e.keywords??[],e.path],run:()=>{n(),r(e.path)}})),f=Ole(a,{closePalette:n,openModelPalette:x,openAgentPalette:S}),p=dle(a,r,n),h=gue({query:t,close:n,navigate:r,uiExtensions:o,extensionsGroupLabel:u.extensions}),[g,_,v,C,w]=await Promise.all([D4(),Jle(),t?Dle(t,{types:[`project`],limit:8}).catch(()=>[]):[],CK({search:t||void 0,limit:8,offset:0}).catch(()=>({items:[]})),(async()=>{let e=s?.trim(),n=c.trim();return!e&&!n?[]:await F4(t,{sessionKey:e||void 0,agentId:e?void 0:n||void 0,limit:10}).catch(()=>[])})()]),T=v.map(e=>({kind:`project`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:u.projects,keywords:[e.payload.project.slug,e.payload.project.workspaceRoot??``,e.payload.project.defaultAgentId??``,e.payload.project.brief??``],run:()=>{n(),r(e.href)}})),E=g.map(e=>({kind:`command`,id:`cmd:${e.id}`,title:`/${e.name}`,subtitle:e.description,groupLabel:u.commands,keywords:[e.id,...e.aliases??[],e.category??``],run:()=>{J4(M4(e),i,r,n)}})),D=_.catalog.flatMap(e=>!e.enabled||e.disableModelInvocation?[]:[{kind:`skill`,id:`skill:${e.name}`,title:`/skill:${e.name}`,subtitle:e.description,groupLabel:u.skills,keywords:[e.source??``,`skill`],run:()=>{J4(`/skill:${e.name} `,i,r,n)}}]),O=(C.items??[]).map(e=>({kind:`session`,id:`session:${e.key}`,title:e.name?.trim()||e.key,subtitle:e.key,groupLabel:u.sessions,keywords:[e.key,...e.tags??[],e.sourceChannel??``],run:()=>{n(),r(`/chat/${encodeURIComponent(e.key)}`)}})),k=w.flatMap(e=>e.isDirectory?[]:[{kind:`file`,id:`file:${e.relativePath}`,title:e.name,subtitle:e.relativePath,groupLabel:u.files,keywords:[e.relativePath],run:()=>{n();let t=e.relativePath.replace(/\\/g,`/`).replace(/^\/+/,``),a=()=>l(t);if(i.startsWith(`/chat`)){a();return}r(`/chat`),window.setTimeout(()=>a(),0)}}]),A=Ale(a,r,n,u.navigate),j=[...d,...f,...p,...h,...A,...T,...O,...k,...E,...D],M=[];for(let e of j){let n=hle(e,t);n!==null&&M.push({...e,rank:n})}let N=ple(a),P=gle(M),F=[],I={};for(let e of P){let t=(I[e.groupLabel]??0)+1;if(!(t>(N[e.groupLabel]??6))&&(I[e.groupLabel]=t,F.push(e),F.length>=36))break}return F.sort((e,t)=>Z2(a,e.groupLabel)-Z2(a,t.groupLabel)||e.rank-t.rank||e.title.localeCompare(t.title)),F},[b,y,o,r,s,c,i,l,a,x,S,e,f],{enabled:v===`main`,initial:[],errorData:[]}),T=w.data,E=w.loading,D=w.error,O=(0,Z.useMemo)(()=>{let e=h.trim().toLowerCase(),t=C.data;return e?t.filter(t=>t.title.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||(t.subtitle?.toLowerCase().includes(e)??!1)):t},[C.data,h]),k=`${v}|${h}|${String(O.length)}|${String(T.length)}`,A=(0,Z.useRef)(k);if(A.current!==k){A.current=k;let e=v===`main`?Math.max(0,T.length-1):Math.max(0,O.length);g>e&&d({type:`setSelectedIndex`,value:e})}(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>t.current?.focus(),50);return()=>window.clearTimeout(e)},[]);let j=(0,Z.useEffectEvent)(t=>{if(t.key===`Escape`){if(t.preventDefault(),v!==`main`){d({type:`resetMain`});return}e();return}let n=v===`main`?Math.max(0,T.length-1):Math.max(0,O.length);if(t.key===`ArrowDown`){t.preventDefault(),d({type:`setSelectedIndex`,value:e=>Math.min(e+1,n)});return}if(t.key===`ArrowUp`){t.preventDefault(),d({type:`setSelectedIndex`,value:e=>Math.max(0,e-1)});return}if(t.key===`Enter`){if(t.preventDefault(),v===`models`){if(g===0){d({type:`resetMain`});return}let t=O[g-1];if(!t)return;(async()=>{await J(X(`/api/global-defaults`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(K4(t.id))}),hI(),G4(),e(),d({type:`resetMain`})})();return}if(v===`agents`){if(g===0){d({type:`resetMain`});return}let t=O[g-1];if(!t)return;q4(t.id,i,r,e),d({type:`resetMain`});return}let n=T[g];n&&n.run()}});(0,Z.useEffect)(()=>{let e=e=>{j(e)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,Z.useLayoutEffect)(()=>{let e=n.current;e&&e.querySelector(`[data-global-palette-index="${String(g)}"]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[g,T,v,O.length]);let M=a===`zh`?`返回`:`Back`;if(v===`models`||v===`agents`){let o=O,s=C.loading;return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":a===`zh`?`选择模型或智能体`:`Model or agent picker`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,$.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,$.jsx)(`input`,{ref:t,type:`search`,value:h,onChange:e=>d({type:`setQuery`,value:e.target.value}),placeholder:v===`models`?a===`zh`?`搜索模型…`:`Search models…`:a===`zh`?`搜索智能体…`:`Search agents…`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,$.jsxs)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,children:[(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"data-global-palette-index":0,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-fg-muted`,g===0?`bg-surface-hover`:`hover:bg-surface-muted`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:0}),onClick:()=>d({type:`resetMain`}),children:[`← `,M]})}),s?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`加载中…`:`Loading…`}):o.length===0?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`无结果`:`No results`}):o.map((t,n)=>{let a=n+1;return(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,"data-global-palette-index":a,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,g===a?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-muted`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:a}),onClick:()=>{v===`models`?(async()=>{await J(X(`/api/global-defaults`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(K4(t.id))}),hI(),G4(),e(),d({type:`resetMain`})})():(q4(t.id,i,r,e),d({type:`resetMain`}))},children:(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:t.title}),t.subtitle?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:t.subtitle}):null]})})},t.id)})]})]})})}let N=``;return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Global search`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,$.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,$.jsx)(`input`,{ref:t,type:`search`,value:h,onChange:e=>d({type:`setQuery`,value:e.target.value}),placeholder:a===`zh`?`搜索…(会话 / 文件 / 设置 / 命令)`:`Search… (sessions, files, settings, commands)`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,$.jsx)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,"aria-activedescendant":T[g]?`global-hit-${T[g].id}`:void 0,children:T.length===0?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:E?a===`zh`?`搜索中…`:`Searching…`:D?D instanceof Error?D.message:String(D):a===`zh`?`无结果`:`No results`}):T.map((e,t)=>{let n=e.groupLabel===N?``:e.groupLabel;return N=e.groupLabel,(0,$.jsxs)(`li`,{children:[n?(0,$.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-fg-muted`,children:n}):null,(0,$.jsxs)(`button`,{id:`global-hit-${e.id}`,"data-global-palette-index":t,type:`button`,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,t===g?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-muted`].join(` `),onMouseEnter:()=>d({type:`setSelectedIndex`,value:t}),onClick:()=>e.run(),children:[(0,$.jsx)(`span`,{className:`mt-0.5`,children:hue(e)}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:e.title}),e.subtitle?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:e.subtitle}):null]})]})]},e.id)})})]})})}function Sue(){let e=(0,Q.c)(7),[t,n]=(0,Z.useState)(!1),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),n(wue))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i);let a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=()=>n(!0);return window.addEventListener(`open-command-palette`,e),()=>window.removeEventListener(`open-command-palette`,e)},o=[],e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,Z.useEffect)(a,o);let s,c;if(e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=()=>n(Cue);return window.addEventListener(`toggle-command-palette`,e),()=>window.removeEventListener(`toggle-command-palette`,e)},c=[],e[4]=s,e[5]=c):(s=e[4],c=e[5]),(0,Z.useEffect)(s,c),!t)return null;let l;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(xue,{onClose:()=>n(!1)}),e[6]=l):l=e[6],l}function Cue(e){return!e}function wue(e){return!e}var Tue=`meta+.`,Eue=h(b(e=>({shortcut:Tue,setShortcut:t=>e({shortcut:t})}),{name:`xopc-quick-capture-shortcut`})),Due={cmd:`meta`,command:`meta`,ctrl:`control`,ctl:`control`,opt:`alt`,option:`alt`};function Oue(e){let t=e.toLowerCase().trim();return Due[t]??t}function kue(e,t){let n=t.split(`+`).map(Oue),r=new Set(n.filter(e=>[`meta`,`control`,`alt`,`shift`].includes(e))),i=n.find(e=>!r.has(e));return!i||r.has(`meta`)!==e.metaKey||r.has(`control`)!==e.ctrlKey||r.has(`alt`)!==e.altKey||r.has(`shift`)!==e.shiftKey?!1:e.key.toLowerCase()===i||e.code.toLowerCase()===i}var Aue=`xopc-attachment`,jue=/^xopc-attachment:\/\/notes\/([^/]+)\/([^/?#]+)$/i,Mue=/^\/api\/notes\/([^/]+)\/media\/([^/?#]+)$/i;function Y4(e,t){return`${Aue}://notes/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function X4(e,t){let n=e.trim();if(!n)return null;let r=n.split(`?`)[0],i=r.match(jue),a=r.match(Mue),o=i??a;if(!o)return null;let s=decodeURIComponent(o[1]),c=decodeURIComponent(o[2]);return t&&s!==t?null:{noteId:s,attachmentId:c}}function Nue(e,t){return`/api/notes/${encodeURIComponent(e)}/media/${encodeURIComponent(t)}`}function Z4(e,t){return Y4(e,t)}function Pue(e){if(e<60)return`Voice · ${e}s`;let t=Math.floor(e/60),n=e%60;return`Voice · ${t}:${String(n).padStart(2,`0`)}`}async function Fue(e){let t=await e.json().catch(()=>({}));return typeof t.error==`string`?t.error:`HTTP ${e.status}`}async function Q4(e,t){let n=q.getState().token,r=new Headers;n&&r.set(`Authorization`,`Bearer ${n}`);let i=await fetch(e,{method:`POST`,headers:r,body:t});if(i.status===401&&q.getState().onUnauthorized(),!i.ok)throw Error(await Fue(i));return i.json()}var $4=new Map,e3=``;function t3(e,t,n){return`${n}:${e}:${t}`}function n3(){let e=q.getState().token??``;if(e!==e3){for(let e of $4.values())e.objectUrl&&URL.revokeObjectURL(e.objectUrl);$4.clear(),e3=e}}async function Iue(e,t){n3();let n=t3(e,t,q.getState().token??``),r=$4.get(n);return r||(r={blob:(async()=>{let n=await Y(X(Nue(e,t)));if(n.status===401&&q.getState().onUnauthorized(),!n.ok)throw Error(`HTTP ${n.status}`);return n.blob()})(),objectUrl:null,refCount:0},$4.set(n,r)),r.blob}async function r3(e,t){n3();let n=t3(e,t,q.getState().token??``),r=$4.get(n);if(r||(r={blob:Iue(e,t),objectUrl:null,refCount:0},$4.set(n,r)),!r.objectUrl){let e=await r.blob;r.objectUrl=URL.createObjectURL(e)}return r.refCount+=1,r.objectUrl}function i3(e,t){n3();let n=t3(e,t,q.getState().token??``),r=$4.get(n);r&&(r.refCount=Math.max(0,r.refCount-1),r.refCount===0&&r.objectUrl&&(URL.revokeObjectURL(r.objectUrl),r.objectUrl=null,$4.delete(n)))}function Lue(e){let t=(0,Q.c)(39),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({src:s,expectedNoteId:r,alt:c,className:n,onClick:i,onLoadFailed:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=c===void 0?``:c,d;t[8]!==r||t[9]!==s?(d=X4(s,r),t[8]=r,t[9]=s,t[10]=d):d=t[10];let f=d,[p,m]=(0,Z.useState)(f?null:s),[h,g]=(0,Z.useState)(!1),_,v;if(t[11]!==a||t[12]!==f||t[13]!==s?(_=()=>{if(g(!1),!f){m(s);return}let e=!1;return m(null),r3(f.noteId,f.attachmentId).then(t=>{e||m(t)}).catch(()=>{e||(g(!0),a?.())}),()=>{e=!0,i3(f.noteId,f.attachmentId)}},v=[s,f,a],t[11]=a,t[12]=f,t[13]=s,t[14]=_,t[15]=v):(_=t[14],v=t[15]),(0,Z.useEffect)(_,v),h){let e;t[16]===n?e=t[17]:(e=u(`flex items-center justify-center bg-surface-hover text-fg-muted`,n),t[16]=n,t[17]=e);let r=!l,i;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(hv,{className:`h-5 w-5`}),t[18]=i):i=t[18];let a;return t[19]!==e||t[20]!==r?(a=(0,$.jsx)(`div`,{className:e,"aria-hidden":r,children:i}),t[19]=e,t[20]=r,t[21]=a):a=t[21],a}if(!p){let e;t[22]===n?e=t[23]:(e=u(`animate-pulse bg-surface-hover`,n),t[22]=n,t[23]=e);let r=!l,i;return t[24]!==e||t[25]!==r?(i=(0,$.jsx)(`div`,{className:e,"aria-hidden":r}),t[24]=e,t[25]=r,t[26]=i):i=t[26],i}let y;t[27]!==p||t[28]!==i?(y=i?()=>i(p):void 0,t[27]=p,t[28]=i,t[29]=y):y=t[29];let b;t[30]===a?b=t[31]:(b=()=>{g(!0),a?.()},t[30]=a,t[31]=b);let x;return t[32]!==l||t[33]!==n||t[34]!==p||t[35]!==o||t[36]!==y||t[37]!==b?(x=(0,$.jsx)(`img`,{...o,src:p,alt:l,className:n,onClick:y,onError:b}),t[32]=l,t[33]=n,t[34]=p,t[35]=o,t[36]=y,t[37]=b,t[38]=x):x=t[38],x}function Rue(e){return e.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^)\s]+)/gi,`/api/notes/$1/media/$2`)}function zue(e,t){let n=[];return e.querySelectorAll(`.markdown-body img`).forEach(e=>{let r=X4(e.getAttribute(`src`)??``,t);if(!r)return;let i=!1;r3(r.noteId,r.attachmentId).then(t=>{i||(e.src=t)}).catch(()=>{e.classList.add(`note-media-load-failed`)}),n.push(()=>{i=!0,i3(r.noteId,r.attachmentId)})}),e.querySelectorAll(`.markdown-body a`).forEach(e=>{let r=X4(e.getAttribute(`href`)??``,t);if(!r)return;let i=document.createElement(`audio`);i.controls=!0,i.className=`note-media-audio mt-2 w-full max-w-md`,e.replaceWith(i);let a=!1;r3(r.noteId,r.attachmentId).then(e=>{a||(i.src=e)}).catch(()=>{i.remove()}),n.push(()=>{a=!0,i3(r.noteId,r.attachmentId)})}),()=>{for(let e of n)e()}}function Bue(e){let t=(0,Q.c)(17),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({content:n,noteId:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(0,Z.useRef)(null),o;t[4]===r?o=t[5]:(o=()=>{let e=a.current;if(e)return zue(e,r)},t[4]=r,t[5]=o);let s;t[6]!==n||t[7]!==r?(s=[n,r],t[6]=n,t[7]=r,t[8]=s):s=t[8],(0,Z.useLayoutEffect)(o,s);let c;t[9]===n?c=t[10]:(c=Rue(n),t[9]=n,t[10]=c);let l;t[11]===i.className?l=t[12]:(l=[`markdown-note`,i.className].filter(Boolean),t[11]=i.className,t[12]=l);let u=l.join(` `),d;return t[13]!==i||t[14]!==c||t[15]!==u?(d=(0,$.jsx)(`div`,{ref:a,children:(0,$.jsx)(gQ,{content:c,...i,className:u})}),t[13]=i,t[14]=c,t[15]=u,t[16]=d):d=t[16],d}async function Vue(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.kind&&t.set(`kind`,e.kind),e.tag&&t.set(`tag`,e.tag),e.pinned!==void 0&&t.set(`pinned`,String(e.pinned)),e.search&&t.set(`search`,e.search),e.limit&&t.set(`limit`,String(e.limit)),e.offset&&t.set(`offset`,String(e.offset)),e.sortBy&&t.set(`sortBy`,e.sortBy),e.sortOrder&&t.set(`sortOrder`,e.sortOrder);let n=t.toString();return J(X(`/api/notes${n?`?${n}`:``}`))}async function a3(e,t=`web`){return(await J(X(`/api/notes/quick-capture`),{method:`POST`,body:JSON.stringify({text:e,channel:t})})).note}async function Hue(e){return(await J(X(`/api/notes`),{method:`POST`,body:JSON.stringify({markdown:e.markdown,title:e.title,kind:e.kind,tags:e.tags,pinned:e.pinned,channel:e.channel??`web`})})).note}async function o3(e){let t=await Y(X(`/api/notes/${encodeURIComponent(e)}`));if(t.status===404)return null;let n=await t.json();if(!t.ok)throw Error(n.error||`HTTP ${t.status}`);return n.note??null}async function s3(e,t){return(await J(X(`/api/notes/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)})).note}async function Uue(e){await J(X(`/api/notes/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Wue(e){return J(X(`/api/notes/${encodeURIComponent(e)}/catalyze`),{method:`POST`})}async function Gue(e,t){return(await J(X(`/api/notes/${encodeURIComponent(e)}/catalysis-feedback`),{method:`POST`,body:JSON.stringify({feedback:t})})).note}async function Kue(e,t={}){return J(X(`/api/notes/${encodeURIComponent(e)}/chat`),{method:`POST`,body:JSON.stringify(t.forceNew?{forceNew:!0}:{})})}async function que(e){return(await J(X(`/api/notes/${encodeURIComponent(e)}/threads`))).items}async function Jue(e){return J(X(`/api/notes/${encodeURIComponent(e)}/context-status`))}async function Yue(e){return J(X(`/api/notes/${encodeURIComponent(e)}/context-rebuild`),{method:`POST`})}async function Xue(e,t,n){return(await J(X(`/api/notes/${encodeURIComponent(e)}/append`),{method:`POST`,body:JSON.stringify({content:t,heading:n})})).note}async function Zue(e,t={}){return(await J(X(`/api/notes/task`),{method:`POST`,body:JSON.stringify({title:e,channel:`web`,priority:t.priority,sourceSessionKey:t.sourceSessionKey||void 0,sourceNoteId:t.sourceNoteId||void 0})})).note}async function Que(e,t){let n=new FormData;return n.append(`file`,t),(await Q4(X(`/api/notes/${encodeURIComponent(e)}/media`),n)).attachment}async function c3(e,t){let n=new FormData;return n.append(`file`,e),t?.markdown&&n.append(`markdown`,t.markdown),n.append(`channel`,t?.channel??`web`),t?.kind&&n.append(`kind`,t.kind),t?.duration!==void 0&&n.append(`duration`,String(t.duration)),(await Q4(X(`/api/notes`),n)).note}async function $ue(e,t=`web`){let n=await c3(e,{channel:t}),r=n.attachments?.find(e=>e.type===`image`)??n.attachments?.[0];if(!r)return n;let i=`![${r.fileName}](${Z4(n.id,r.id)})`;return n.markdown!==i&&(n=await s3(n.id,{markdown:i})),n}async function ede(e,t,n=`web`){let r=await c3(e,{channel:n,kind:`voice`,duration:t}),i=r.attachments?.find(e=>e.type===`audio`)??r.attachments?.[0];if(!i)return r;let a=`[${Pue(t)}](${Z4(r.id,i.id)})`;return r.markdown!==a&&(r=await s3(r.id,{markdown:a,kind:`voice`})),r}async function tde(e){return(await J(X(`/api/notes/${encodeURIComponent(e)}/history`))).entries}async function nde(e,t){return(await J(X(`/api/notes/${encodeURIComponent(e)}/history/${t}`))).snapshot}async function rde(e,t){return(await J(X(`/api/notes/${encodeURIComponent(e)}/history/restore`),{method:`POST`,body:JSON.stringify({timestamp:t})})).note}function ide(e){let t=(0,Q.c)(50),{onClose:n}=e,r=br(),i=_(ade),a;t[0]===i?a=t[1]:(a=m(i),t[0]=i,t[1]=a);let o=a.notes,[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=window.setTimeout(()=>d.current?.focus(),50);return()=>window.clearTimeout(e)},p=[],t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Z.useEffect)(f,p);let h;t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==s?(h=async e=>{let t=s.trim();if(!(!t||l)){u(!0);try{let i=await a3(t,`web`);n(),e&&r(`/notes/${i.id}`)}catch{u(!1)}}},t[4]=r,t[5]=n,t[6]=l,t[7]=s,t[8]=h):h=t[8];let g=h,v;t[9]!==g||t[10]!==n?(v=e=>{if(e.key===`Escape`){e.preventDefault(),n();return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),g(!0);return}e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),g(!1))},t[9]=g,t[10]=n,t[11]=v):v=t[11];let y=v,b;t[12]===n?b=t[13]:(b=e=>{e.target===e.currentTarget&&n()},t[12]=n,t[13]=b);let x;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(hT,{className:`h-4 w-4 text-accent`}),t[14]=x):x=t[14];let S;t[15]===o.quickCapturePlaceholder?S=t[16]:(S=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge px-4 py-3`,children:[x,(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.quickCapturePlaceholder})]}),t[15]=o.quickCapturePlaceholder,t[16]=S);let C;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>c(e.target.value),t[17]=C):C=t[17];let w;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(w={fieldSizing:`content`,minHeight:`6rem`,maxHeight:`40vh`},t[18]=w):w=t[18];let T;t[19]!==y||t[20]!==o.quickCapturePlaceholder||t[21]!==l||t[22]!==s?(T=(0,$.jsx)(`textarea`,{ref:d,value:s,onChange:C,onKeyDown:y,placeholder:o.quickCapturePlaceholder,disabled:l,rows:4,className:`resize-none border-none bg-transparent px-4 py-3 text-sm leading-relaxed text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:w}),t[19]=y,t[20]=o.quickCapturePlaceholder,t[21]=l,t[22]=s,t[23]=T):T=t[23];let E;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Enter`}),t[24]=E):E=t[24];let D;t[25]===o.quickCaptureHintEnter?D=t[26]:(D=(0,$.jsxs)(`span`,{children:[E,` `,o.quickCaptureHintEnter]}),t[25]=o.quickCaptureHintEnter,t[26]=D);let O;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Shift+Enter`}),t[27]=O):O=t[27];let k;t[28]===o.quickCaptureHintShift?k=t[29]:(k=(0,$.jsxs)(`span`,{children:[O,` `,o.quickCaptureHintShift]}),t[28]=o.quickCaptureHintShift,t[29]=k);let A;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Esc`}),t[30]=A):A=t[30];let j;t[31]===o.quickCaptureHintEsc?j=t[32]:(j=(0,$.jsxs)(`span`,{children:[A,` `,o.quickCaptureHintEsc]}),t[31]=o.quickCaptureHintEsc,t[32]=j);let M;t[33]!==D||t[34]!==k||t[35]!==j?(M=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-[11px] text-fg-muted`,children:[D,k,j]}),t[33]=D,t[34]=k,t[35]=j,t[36]=M):M=t[36];let N;t[37]===l?N=t[38]:(N=l&&(0,$.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-accent border-t-transparent`}),t[37]=l,t[38]=N);let P;t[39]!==M||t[40]!==N?(P=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-4 py-2`,children:[M,N]}),t[39]=M,t[40]=N,t[41]=P):P=t[41];let F;t[42]!==T||t[43]!==P||t[44]!==S?(F=(0,$.jsxs)(`div`,{className:`flex w-full max-w-lg flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[S,T,P]}),t[42]=T,t[43]=P,t[44]=S,t[45]=F):F=t[45];let I;return t[46]!==o.quickCapturePlaceholder||t[47]!==F||t[48]!==b?(I=(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":o.quickCapturePlaceholder,onMouseDown:b,children:F}),t[46]=o.quickCapturePlaceholder,t[47]=F,t[48]=b,t[49]=I):I=t[49],I}function ade(e){return e.language}function ode(){let e=(0,Q.c)(8),[t,n]=(0,Z.useState)(!1),r=q(lde),i=Eue(cde),a,o;e[0]!==i||e[1]!==r?(a=()=>{let e=e=>{kue(e,i)&&(e.preventDefault(),r&&n(sde))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},o=[i,r],e[0]=i,e[1]=r,e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,Z.useEffect)(a,o);let s,c;if(e[4]===r?(s=e[5],c=e[6]):(s=()=>{let e=()=>{r&&n(!0)};return window.addEventListener(`open-quick-capture`,e),()=>window.removeEventListener(`open-quick-capture`,e)},c=[r],e[4]=r,e[5]=s,e[6]=c),(0,Z.useEffect)(s,c),!t)return null;let l;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(ide,{onClose:()=>n(!1)}),e[7]=l):l=e[7],l}function sde(e){return!e}function cde(e){return e.shortcut}function lde(e){return e.token}var ude=class{_config;_callbacks;_eventSource;_shouldReconnect=!0;_reconnectCount=0;constructor(e,t){this._config=e,this._callbacks=t}get maxReconnectAttempts(){return this._config.maxReconnectAttempts??10}get autoReconnect(){return this._config.autoReconnect??!0}connect(){if(this._eventSource)return;let e=new URL(X(`/api/events`));this._config.token&&e.searchParams.set(`token`,this._config.token),this._eventSource=new EventSource(e.toString()),this._eventSource.onopen=()=>{this._reconnectCount=0},this._eventSource.addEventListener(`connected`,()=>{this._callbacks.onConnected()});for(let e of[`agent.stream`,`config.reload`,`channels.status`,`message.sent`,`session.updated`,`session.transcript_updated`,`session.created`,`dreaming.phase.start`,`dreaming.phase.end`])this._eventSource.addEventListener(e,t=>{this._callbacks.onEvent(e,t.data)});this._eventSource.onerror=()=>{this._eventSource?.readyState===EventSource.CLOSED?this._handlePermanentDisconnect():this._callbacks.onReconnecting()}}_handlePermanentDisconnect(){this._callbacks.onDisconnected(),!(!this._shouldReconnect||!this.autoReconnect)&&(this._reconnectCount++,this._reconnectCount>this.maxReconnectAttempts&&this._callbacks.onError(`Connection failed after max retries`))}disconnect(){this._shouldReconnect=!1,this._eventSource?.close(),this._eventSource=void 0}reconnect(){this._shouldReconnect=!0,this._reconnectCount=0,this.disconnect(),this._shouldReconnect=!0,setTimeout(()=>this.connect(),100)}};function dde(e,t){if(e!==`goal.queue.updated`||!t||typeof t!=`object`)return;let n=t.item;if(!(!n||typeof n.status!=`string`)){if(n.status===`failed`){re({type:`error`,title:`Goal run failed`,message:n.error||n.goalId,duration:0});return}if(n.status===`retry_waiting`){re({type:`warning`,title:`Goal run retry scheduled`,message:n.error||n.goalId});return}if(n.status===`succeeded`){re({type:`success`,title:`Goal run finished`,message:n.goalId});return}n.status===`skipped`&&re({type:`info`,title:`Goal run skipped`,message:n.error||n.goalId})}}function fde(e,t){let n=t;try{n=JSON.parse(t)}catch{}if(e===`config.reload`){G4(n);return}dde(e,n);let r=e.replace(/[._]/g,`-`);window.dispatchEvent(new CustomEvent(r,{detail:n}));let i=e.replace(/\./g,`-`);if(i!==r&&window.dispatchEvent(new CustomEvent(i,{detail:n})),e===`agent.stream`&&n&&typeof n==`object`&&n){let e=n;typeof e.sessionKey==`string`&&e.sessionKey.length>0&&window.dispatchEvent(new CustomEvent(`agent-stream-event`,{detail:{sessionKey:e.sessionKey,event:e.event===void 0?e:e.event}}))}}var l3=null;function u3(e){l3=e}function pde(){l3?.reconnect()}var d3=h(()=>({connectionState:`idle`,error:null,reconnectAttempt:0}));function f3(e){d3.setState(e)}function mde(e){let t=new ude({token:e,autoReconnect:!0,maxReconnectAttempts:10},{onConnected:()=>{f3({connectionState:`connected`,error:null,reconnectAttempt:0})},onReconnecting:()=>{f3({connectionState:`reconnecting`})},onDisconnected:()=>{f3({connectionState:`disconnected`})},onError:e=>{f3({connectionState:`error`,error:e})},onEvent:(e,t)=>{fde(e,t)}});return u3(t),f3({connectionState:`connecting`,error:null}),t.connect(),()=>{t.disconnect(),u3(null),f3({connectionState:`disconnected`,error:null})}}function hde(){u3(null),f3({connectionState:`disconnected`,error:null,reconnectAttempt:0})}function gde(){let e=(0,Q.c)(3),t=q(_de),n,r;e[0]===t?(n=e[1],r=e[2]):(n=()=>{if(!t){hde();return}return mde(t)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r)}function _de(e){return e.token}function vde(){let e=(0,Q.c)(1);gde();let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(yde,t),null}function yde(){let e=bde;return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)}function bde(e){let t=le(e.detail);t===`skills`?qle():t===`agents`&&k4()}var p3=new Set([`light`,`deep`,`rem`]),xde=3e3,Sde=1200,Cde=800,wde=800;function m3(e,t){return`${t?.agentId?.trim()||`unknown`}:${e}`}function Tde(e){return e[0]?.phase??`deep`}function h3(e){if(typeof e!=`object`||!e)return{};let t=e;return{...typeof t.agentId==`string`&&t.agentId.trim()?{agentId:t.agentId.trim()}:{},...typeof t.agentName==`string`&&t.agentName.trim()?{agentName:t.agentName.trim()}:{},...typeof t.avatar==`string`&&t.avatar.trim()?{avatar:t.avatar.trim()}:{}}}function g3(e,t=`running`){let n=[...e.values()];return n.length===0?{status:`idle`}:{status:t,phase:Tde(n),agents:n}}function Ede(){let e=(0,Q.c)(15),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={status:`idle`},e[0]=t):t=e[0];let[n,r]=(0,Z.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=new Map,e[1]=i):i=e[1];let a=(0,Z.useRef)(i),o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=new Set,e[2]=o):o=e[2];let s=(0,Z.useRef)(o),c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{let n=setTimeout(()=>{s.current.delete(n),e()},t);return s.current.add(n),n},e[3]=c):c=e[3];let l=c,u;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{for(let e of s.current)clearTimeout(e);s.current.clear()},e[4]=u):u=e[4];let d=u,f;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(e,t)=>{let n=m3(e,t),i=a.current.get(n);a.current.set(n,{key:n,phase:e,status:`sleeping`,startedAt:i?.startedAt??Date.now(),...i,...t??{}}),r(g3(a.current))},e[5]=f):f=e[5];let p=f,m;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{if(a.current.size>0){r(g3(a.current));return}r(Ode),l(()=>r({status:`idle`}),Cde)},e[6]=m):m=e[6];let h=m,g;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=(e,t)=>{let n=m3(e,t),i=a.current.get(n);if(!i)return;let o={...i,...t??{},status:`waking`},s=Date.now()-o.startedAt;l(()=>{a.current.set(n,o),r(g3(a.current)),l(()=>{a.current.delete(n),h()},Sde)},Math.max(0,xde-s))},e[7]=g):g=e[7];let _=g,v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>{d(),a.current.clear(),r(Dde),l(()=>r({status:`idle`}),wde)},e[8]=v):v=e[8];let y=v,b,x;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{let e=e=>{let t=e.detail,n=typeof t==`object`&&t&&typeof t.phase==`string`?t.phase:typeof t==`string`?t:null;n&&p3.has(n)&&p(n,h3(t))},t=e=>{let t=e.detail,n=typeof t==`object`&&t&&typeof t.phase==`string`?t.phase:null;!n||!p3.has(n)||_(n,h3(t))};return window.addEventListener(`dreaming-phase-start`,e),window.addEventListener(`dreaming-phase-end`,t),()=>{window.removeEventListener(`dreaming-phase-start`,e),window.removeEventListener(`dreaming-phase-end`,t),d()}},b=[p,_,d],e[9]=b,e[10]=x):(b=e[9],x=e[10]),(0,Z.useEffect)(x,b);let S,C;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>d,C=[d],e[11]=S,e[12]=C):(S=e[11],C=e[12]),(0,Z.useEffect)(S,C);let w;return e[13]===n?w=e[14]:(w={state:n,triggerPhase:p,dismiss:y},e[13]=n,e[14]=w),w}function Dde(e){return e.status===`idle`?e:{...e,status:`fading-out`}}function Ode(e){return e.status===`idle`?e:{...e,status:`fading-out`}}var _3={light:`💤 Light Sleep — scanning memories…`,deep:`🌙 Deep Sleep — promoting memories…`,rem:`🌈 REM Sleep — discovering patterns…`};function kde(){return typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Ade(){let e=(0,Z.useRef)(null),t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),r=(0,Z.useRef)(null),{state:i,dismiss:a}=Ede(),o=(0,Z.useCallback)(async()=>{if(t.current)return t.current;if(n.current)return n.current;let i=e.current;return i?(n.current=c(async()=>{let{DreamingScene:e}=await import(`./dreaming-scene-BHMRVEUS.js`);return{DreamingScene:e}},[]).then(({DreamingScene:e})=>{if(!i.isConnected)return null;let n=new e(i);t.current=n;let a=r.current;return a&&n.resize(a.clientWidth,a.clientHeight),n}).finally(()=>{n.current=null}),n.current):null},[]);(0,Z.useEffect)(()=>()=>{t.current?.dispose(),t.current=null},[]),(0,Z.useEffect)(()=>{let e=()=>{let e=r.current;!e||!t.current||t.current.resize(e.clientWidth,e.clientHeight)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,Z.useEffect)(()=>{if(i.status===`running`){if(kde())return;let e=!1;return o().then(t=>{e||!t||t.startPhase(i.phase)}),()=>{e=!0}}else i.status===`fading-out`&&t.current?.fadeOut()},[o,i]),(0,Z.useEffect)(()=>{let e=r.current;!e||!t.current||t.current.resize(e.clientWidth,e.clientHeight)},[]);let s=i.status!==`idle`,l=i.status===`idle`?null:i.phase,d=i.status===`fading-out`,f=i.status===`idle`?[]:i.agents,p=(0,Z.useCallback)(()=>{a()},[a]);return!s&&!d?(0,$.jsx)(`div`,{ref:r,className:`pointer-events-none fixed inset-0 z-[90] opacity-0`,"aria-hidden":!0,children:(0,$.jsx)(`canvas`,{ref:e,className:`size-full`})}):(0,$.jsxs)(`div`,{ref:r,className:u(`fixed inset-0 z-[90] bg-[#1c1c1e]/70 transition-opacity`,d?`dreaming-overlay-exit pointer-events-none`:`dreaming-overlay-enter`),role:`status`,"aria-live":`polite`,"aria-label":l?_3[l]:void 0,children:[(0,$.jsx)(`canvas`,{ref:e,className:`pointer-events-none size-full`}),f.length>0?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-4 top-[15%] flex justify-center sm:inset-x-10`,children:(0,$.jsxs)(`div`,{className:`grid max-w-4xl grid-cols-2 gap-x-6 gap-y-6 sm:grid-cols-3 lg:grid-cols-4`,children:[f.slice(0,12).map((e,t)=>(0,$.jsxs)(`div`,{className:u(`dreaming-agent-sleeper flex flex-col items-center gap-2`,e.status===`waking`&&`dreaming-agent-wake`),style:{animationDelay:`${t*90}ms`},children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute inset-[-18px] rounded-full bg-white/10 blur-2xl`}),(0,$.jsx)(dz,{agentId:e.agentId||`dreaming-${t}`,avatar:e.avatar,size:78,className:`relative size-[78px] border border-white/20 shadow-float ring-4 ring-white/10`}),e.status===`sleeping`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`dreaming-agent-z dreaming-agent-z-a`,children:`Z`}),(0,$.jsx)(`span`,{className:`dreaming-agent-z dreaming-agent-z-b`,children:`Z`}),(0,$.jsx)(`span`,{className:`dreaming-agent-z dreaming-agent-z-c`,children:`Z`})]}):null]}),(0,$.jsx)(`div`,{className:`max-w-28 truncate rounded-full border border-white/10 bg-black/30 px-3 py-1 text-xs font-medium text-white/80 shadow-elevated backdrop-blur-md`,children:e.agentName||e.agentId})]},e.key)),f.length>12?(0,$.jsxs)(`div`,{className:`flex items-center justify-center rounded-full border border-white/10 bg-black/30 px-3 py-2 text-sm font-semibold text-white/75 backdrop-blur-md`,children:[`+`,f.length-12]}):null]})}):null,(0,$.jsxs)(`div`,{className:`pointer-events-auto absolute bottom-6 left-1/2 flex -translate-x-1/2 items-center gap-3`,children:[l?(0,$.jsxs)(`div`,{className:u(`flex items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium shadow-elevated backdrop-blur-sm`,`dreaming-pill-enter`,l===`light`&&`border-emerald-400/30 bg-emerald-950/60 text-emerald-300`,l===`deep`&&`border-indigo-400/30 bg-indigo-950/60 text-indigo-300`,l===`rem`&&`border-purple-400/30 bg-purple-950/60 text-purple-300`),children:[(0,$.jsx)(`span`,{className:`dreaming-pulse-dot`}),(0,$.jsx)(`span`,{children:_3[l]})]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:p,className:`rounded-full border border-edge-subtle bg-surface-panel/80 px-3 py-1.5 text-xs text-fg-muted shadow-elevated backdrop-blur-sm transition-colors hover:bg-surface-hover hover:text-fg`,"aria-label":`Dismiss dreaming animation`,children:`✕`})]})]})}function v3(e){let t=e;return e.fullscreenElement??t.webkitFullscreenElement??t.msFullscreenElement??null}async function jde(e){let t=e;try{if(typeof e.requestFullscreen==`function`){await e.requestFullscreen();return}}catch{}if(typeof t.webkitRequestFullscreen==`function`){await Promise.resolve(t.webkitRequestFullscreen());return}if(typeof t.msRequestFullscreen==`function`){await Promise.resolve(t.msRequestFullscreen());return}throw Error(`fullscreen_unavailable`)}async function Mde(e){let t=e;if(typeof e.exitFullscreen==`function`){await e.exitFullscreen();return}if(typeof t.webkitExitFullscreen==`function`){await Promise.resolve(t.webkitExitFullscreen());return}typeof t.msExitFullscreen==`function`&&await Promise.resolve(t.msExitFullscreen())}function Nde(){return typeof window<`u`&&typeof window.electronAPI?.fullscreen?.enter==`function`}function y3(){let e=(0,Q.c)(11),t=(0,Z.useRef)(null),[n,r]=(0,Z.useState)(!1),i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=Nde(),e[0]=i):i=e[0];let a=i,o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=t.current,n=v3(document);r(!!(e&&n===e))},e[1]=o):o=e[1];let s=o,c,l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{if(a)return;let e=()=>s();return document.addEventListener(`fullscreenchange`,e),document.addEventListener(`webkitfullscreenchange`,e),()=>{document.removeEventListener(`fullscreenchange`,e),document.removeEventListener(`webkitfullscreenchange`,e)}},l=[s,a],e[2]=c,e[3]=l):(c=e[2],l=e[3]),(0,Z.useEffect)(c,l);let u,d;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{if(!a)return;let e=window.electronAPI.fullscreen,t=e.onChange(e=>r(e));return e.isFullscreen().then(r),t},d=[a],e[4]=u,e[5]=d):(u=e[4],d=e[5]),(0,Z.useEffect)(u,d);let f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=async()=>{if(a){await window.electronAPI.fullscreen.enter();return}let e=t.current;if(e&&v3(document)!==e)try{await jde(e)}catch{}},e[6]=f):f=e[6];let p=f,m;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=async()=>{if(a){await window.electronAPI.fullscreen.exit();return}if(v3(document)===t.current)try{await Mde(document)}catch{}},e[7]=m):m=e[7];let h=m,g;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=async()=>{if(a){await window.electronAPI.fullscreen.toggle();return}v3(document)===t.current?await h():await p()},e[8]=g):g=e[8];let _=g,v;return e[9]===n?v=e[10]:(v={rootRef:t,active:n,enter:p,exit:h,toggle:_},e[9]=n,e[10]=v),v}var Pde=new Intl.DateTimeFormat(`zh-CN`,{dateStyle:`medium`,timeStyle:`short`}),Fde=new Intl.DateTimeFormat(`en`,{dateStyle:`medium`,timeStyle:`short`});function Ide(e,t){return(t===`zh`?Pde:Fde).format(new Date(e))}function b3(e){let t=(0,Q.c)(163),{filePath:n,onClose:r,targetLine:i,projectId:a,sessionKey:o,agentId:s}=e,c=_(Wde),l;t[0]===c?l=t[1]:(l=m(c),t[0]=c,t[1]=l);let d=l,f=x(Ude),p;t[2]!==s||t[3]!==n||t[4]!==a||t[5]!==o?(p={filePath:n,projectId:a,sessionKey:o,agentId:s},t[2]=s,t[3]=n,t[4]=a,t[5]=o,t[6]=p):p=t[6];let h=t$(p),g=RQ(h.descriptor),{rootRef:v,active:y,enter:b,exit:S}=y3(),{dialogOpen:C,loading:w,result:T,error:E,createShareLink:D,handleOpenChange:O}=h1(),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(!1),F;t[7]===n?F=t[8]:(F=n?Zq(n):``,t[7]=n,t[8]=F);let I=F,L;t[9]===n?L=t[10]:(L=n?Qq(n):``,t[9]=n,t[10]=L);let R=L,z=I===`.md`,B=I===`.html`||I===`.htm`,V;t[11]!==n||t[12]!==d.clipboard.copyFailed||t[13]!==d.workspace.pathCopied?(V=async()=>{if(n){if(await mA(n)){A(!0),window.setTimeout(()=>A(!1),2e3),FK(`success`,d.workspace.pathCopied,void 0,{duration:2e3});return}FK(`warning`,d.clipboard.copyFailed,void 0,{duration:4e3})}},t[11]=n,t[12]=d.clipboard.copyFailed,t[13]=d.workspace.pathCopied,t[14]=V):V=t[14];let H=V,U;t[15]!==s||t[16]!==D||t[17]!==n||t[18]!==a||t[19]!==o?(U=()=>{!n||a||D({path:n,...o==null?s?.trim()?{agentId:s.trim()}:{}:{sessionKey:o}})},t[15]=s,t[16]=D,t[17]=n,t[18]=a,t[19]=o,t[20]=U):U=t[20];let W=U,G=!!(n&&!h.loading&&!h.loadError),K;t[21]===h?K=t[22]:(K=()=>void h.onDownload(),t[21]=h,t[22]=K);let q;t[23]===h?q=t[24]:(q=()=>void h.onOpenWithSystemApp(),t[23]=h,t[24]=q);let ee;t[25]===h?ee=t[26]:(ee=()=>void h.onChooseOpenWithApp(),t[25]=h,t[26]=ee);let J;t[27]!==h.canChooseOpenWithApp||t[28]!==h.canDownload||t[29]!==h.canOpenWithSystemApp||t[30]!==K||t[31]!==q||t[32]!==ee?(J={onDownload:K,canDownload:h.canDownload,onOpenWithSystemApp:q,canOpenWithSystemApp:h.canOpenWithSystemApp,onChooseOpenWithApp:ee,canChooseOpenWithApp:h.canChooseOpenWithApp},t[27]=h.canChooseOpenWithApp,t[28]=h.canDownload,t[29]=h.canOpenWithSystemApp,t[30]=K,t[31]=q,t[32]=ee,t[33]=J):J=t[33];let te=J,Y;t[34]!==S||t[35]!==r?(Y=()=>{S(),r()},t[34]=S,t[35]=r,t[36]=Y):Y=t[36];let ne=Y;if(!n)return null;let re;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(re=u(`flex shrink-0 items-start gap-2 border-b border-edge px-4 py-2 dark:border-edge`,uM),t[37]=re):re=t[37];let X;t[38]===R?X=t[39]:(X=(0,$.jsx)(`h2`,{className:`truncate text-base font-semibold leading-tight tracking-tight text-fg`,title:R,children:R}),t[38]=R,t[39]=X);let ie;t[40]!==c||t[41]!==d.workspace.lastModified||t[42]!==h.loading||t[43]!==h.mtimeMs||t[44]!==i?(ie=!h.loading&&h.mtimeMs!=null?(0,$.jsxs)(`p`,{suppressHydrationWarning:!0,className:`mt-0.5 truncate text-xs leading-tight text-fg-muted`,title:new Date(h.mtimeMs).toISOString(),children:[d.workspace.lastModified,`: `,Ide(h.mtimeMs,c),i?` · Line ${i}`:``]}):null,t[40]=c,t[41]=d.workspace.lastModified,t[42]=h.loading,t[43]=h.mtimeMs,t[44]=i,t[45]=ie):ie=t[45];let ae;t[46]!==X||t[47]!==ie?(ae=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[X,ie]}),t[46]=X,t[47]=ie,t[48]=ae):ae=t[48];let oe;t[49]===h.loading?oe=t[50]:(oe=h.loading?(0,$.jsx)(Fv,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[49]=h.loading,t[50]=oe);let se;t[51]!==B||t[52]!==z||t[53]!==d.workspace.saved||t[54]!==d.workspace.saving||t[55]!==h.htmlCodeMode||t[56]!==h.saveStatus?(se=(z||B&&h.htmlCodeMode)&&h.saveStatus!==`idle`?(0,$.jsx)(`span`,{className:`shrink-0 text-xs leading-tight text-fg-muted`,children:h.saveStatus===`saving`?d.workspace.saving:d.workspace.saved}):null,t[51]=B,t[52]=z,t[53]=d.workspace.saved,t[54]=d.workspace.saving,t[55]=h.htmlCodeMode,t[56]=h.saveStatus,t[57]=se):se=t[57];let ce;t[58]!==te||t[59]!==g?(ce=(0,$.jsx)(HQ,{controller:g,actions:te}),t[58]=te,t[59]=g,t[60]=ce):ce=t[60];let le;t[61]!==B||t[62]!==z||t[63]!==d.workspace.edit||t[64]!==d.workspace.preview||t[65]!==d.workspace.viewing||t[66]!==h?(le=z?(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:h.markdownEditMode?d.workspace.viewing:d.workspace.edit,"aria-label":h.markdownEditMode?d.workspace.viewing:d.workspace.edit,onClick:()=>h.setMarkdownEditMode(Hde),children:h.markdownEditMode?(0,$.jsx)(bh,{className:`size-4`}):(0,$.jsx)(oy,{className:`size-4`})}):B?(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:h.htmlCodeMode?d.workspace.preview:d.workspace.edit,"aria-label":h.htmlCodeMode?d.workspace.preview:d.workspace.edit,onClick:()=>h.setHtmlCodeMode(Vde),children:h.htmlCodeMode?(0,$.jsx)(bh,{className:`size-4`}):(0,$.jsx)(oy,{className:`size-4`})}):null,t[61]=B,t[62]=z,t[63]=d.workspace.edit,t[64]=d.workspace.preview,t[65]=d.workspace.viewing,t[66]=h,t[67]=le):le=t[67];let ue;t[68]!==z||t[69]!==d.workspace.wordWrap||t[70]!==N||t[71]!==h.markdownEditMode?(ue=z&&h.markdownEditMode?(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,N&&`bg-surface-hover text-fg`,lA.focusRingPanel),title:`${d.workspace.wordWrap} (Option+Z)`,"aria-label":d.workspace.wordWrap,"aria-pressed":N,onClick:()=>P(Bde),children:(0,$.jsx)(bE,{className:`size-4`})}):null,t[68]=z,t[69]=d.workspace.wordWrap,t[70]=N,t[71]=h.markdownEditMode,t[72]=ue):ue=t[72];let de;t[73]!==y||t[74]!==G||t[75]!==b||t[76]!==S||t[77]!==d.chat?(de=G?(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,lA.focusRingPanel),title:y?d.chat.attachmentPreviewExitFullscreen:d.chat.attachmentPreviewFullscreen,"aria-label":y?d.chat.attachmentPreviewExitFullscreen:d.chat.attachmentPreviewFullscreen,onClick:()=>void(y?S():b()),children:y?(0,$.jsx)(Wv,{className:`size-4`,strokeWidth:1.75}):(0,$.jsx)(Rv,{className:`size-4`,strokeWidth:1.75})}):null,t[73]=y,t[74]=G,t[75]=b,t[76]=S,t[77]=d.chat,t[78]=de):de=t[78];let fe;t[79]!==d.workspace.openSystemApp||t[80]!==h?(fe=h.canOpenWithSystemApp?(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,lA.focusRingPanel),title:d.workspace.openSystemApp,"aria-label":d.workspace.openSystemApp,onClick:()=>void h.onOpenWithSystemApp(),children:(0,$.jsx)(gh,{className:`size-4`})}):null,t[79]=d.workspace.openSystemApp,t[80]=h,t[81]=fe):fe=t[81];let pe;t[82]!==d.workspace.chooseApp||t[83]!==d.workspace.openWith||t[84]!==d.workspace.recentApps||t[85]!==d.workspace.recommendedApps||t[86]!==j||t[87]!==h?(pe=h.canChooseOpenWithApp||h.recommendedOpenWithApps.length>0||h.recentOpenWithApps.length>0?(0,$.jsxs)(`div`,{className:`relative shrink-0`,children:[j?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 cursor-default bg-transparent`,"aria-hidden":!0,tabIndex:-1,onPointerDown:e=>{e.preventDefault(),M(!1)}}):null,(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,lA.focusRingPanel),title:d.workspace.openWith,"aria-label":d.workspace.openWith,"aria-haspopup":`menu`,"aria-expanded":j,onClick:()=>M(zde),children:(0,$.jsx)(sh,{className:`size-4`})}),j?(0,$.jsxs)(`div`,{role:`menu`,className:`absolute right-0 top-full z-50 mt-1 min-w-[13rem] rounded-md border border-edge bg-surface-panel py-1 shadow-popover`,children:[h.canChooseOpenWithApp?(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,className:`block w-full px-3 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>{M(!1),h.onChooseOpenWithApp()},children:d.workspace.chooseApp}):null,h.recommendedOpenWithApps.length>0?(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle py-1 dark:border-edge`,children:[(0,$.jsx)(`p`,{className:`px-3 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-normal text-fg-subtle`,children:d.workspace.recommendedApps}),h.recommendedOpenWithApps.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,className:`block w-full min-w-0 px-3 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,title:e.path,onClick:()=>{M(!1),h.onOpenWithRecentApp(e.path)},children:(0,$.jsx)(`span`,{className:`block truncate`,children:e.name})},e.path))]}):null,h.recentOpenWithApps.length>0?(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle py-1 dark:border-edge`,children:[(0,$.jsx)(`p`,{className:`px-3 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-normal text-fg-subtle`,children:d.workspace.recentApps}),h.recentOpenWithApps.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,className:`block w-full min-w-0 px-3 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,title:e.path,onClick:()=>{M(!1),h.onOpenWithRecentApp(e.path)},children:(0,$.jsx)(`span`,{className:`block truncate`,children:e.name})},e.path))]}):null]}):null]}):null,t[82]=d.workspace.chooseApp,t[83]=d.workspace.openWith,t[84]=d.workspace.recentApps,t[85]=d.workspace.recommendedApps,t[86]=j,t[87]=h,t[88]=pe):pe=t[88];let me;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(me=u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,lA.focusRingPanel),t[89]=me):me=t[89];let he;t[90]===H?he=t[91]:(he=()=>void H(),t[90]=H,t[91]=he);let ge;t[92]===k?ge=t[93]:(ge=k?(0,$.jsx)(Iu,{className:`size-4`}):(0,$.jsx)(Fp,{className:`size-4`}),t[92]=k,t[93]=ge);let _e;t[94]!==d.workspace.copyPath||t[95]!==he||t[96]!==ge?(_e=(0,$.jsx)(`button`,{type:`button`,className:me,title:d.workspace.copyPath,"aria-label":d.workspace.copyPath,onClick:he,children:ge}),t[94]=d.workspace.copyPath,t[95]=he,t[96]=ge,t[97]=_e):_e=t[97];let ve;t[98]!==d.workspace.revealInFolder||t[99]!==h?(ve=h.canRevealInFolder?(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,lA.focusRingPanel),title:d.workspace.revealInFolder,"aria-label":d.workspace.revealInFolder,onClick:()=>void h.onRevealInFolder(),children:(0,$.jsx)(__,{className:`size-4`})}):null,t[98]=d.workspace.revealInFolder,t[99]=h,t[100]=ve):ve=t[100];let ye;t[101]!==W||t[102]!==w||t[103]!==d.workspace.shareLink||t[104]!==a?(ye=a?null:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:d.workspace.shareLink,"aria-label":d.workspace.shareLink,onClick:W,disabled:w,children:w?(0,$.jsx)(Fv,{className:`size-4 animate-spin`}):(0,$.jsx)(Ov,{className:`size-4`})}),t[101]=W,t[102]=w,t[103]=d.workspace.shareLink,t[104]=a,t[105]=ye):ye=t[105];let be;t[106]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,$.jsx)(Sk,{className:`size-4`,strokeWidth:1.75}),t[106]=be):be=t[106];let xe;t[107]!==ne||t[108]!==d.workspace.close?(xe=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:d.workspace.close,"aria-label":d.workspace.close,onClick:ne,children:be}),t[107]=ne,t[108]=d.workspace.close,t[109]=xe):xe=t[109];let Se;t[110]!==oe||t[111]!==se||t[112]!==ce||t[113]!==le||t[114]!==ue||t[115]!==de||t[116]!==fe||t[117]!==pe||t[118]!==_e||t[119]!==ve||t[120]!==ye||t[121]!==xe?(Se=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[oe,se,ce,le,ue,de,fe,pe,_e,ve,ye,xe]}),t[110]=oe,t[111]=se,t[112]=ce,t[113]=le,t[114]=ue,t[115]=de,t[116]=fe,t[117]=pe,t[118]=_e,t[119]=ve,t[120]=ye,t[121]=xe,t[122]=Se):Se=t[122];let Ce;t[123]!==ae||t[124]!==Se?(Ce=(0,$.jsxs)(`div`,{className:re,children:[ae,Se]}),t[123]=ae,t[124]=Se,t[125]=Ce):Ce=t[125];let we;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(we=()=>P(Rde),t[126]=we):we=t[126];let Te=f===`dark`,Ee;t[127]!==N||t[128]!==h.htmlCodeMode||t[129]!==h.markdownEditMode||t[130]!==h.onHtmlChange||t[131]!==h.onSaveMarkdown||t[132]!==Te?(Ee={markdownEditMode:h.markdownEditMode,onSaveMarkdown:h.onSaveMarkdown,markdownWordWrap:N,onToggleMarkdownWordWrap:we,htmlCodeMode:h.htmlCodeMode,onHtmlChange:h.onHtmlChange,isDark:Te},t[127]=N,t[128]=h.htmlCodeMode,t[129]=h.markdownEditMode,t[130]=h.onHtmlChange,t[131]=h.onSaveMarkdown,t[132]=Te,t[133]=Ee):Ee=t[133];let De;t[134]!==c||t[135]!==te||t[136]!==g||t[137]!==f||t[138]!==h.binaryBuffer||t[139]!==h.descriptor||t[140]!==h.extractedText||t[141]!==h.extractedTextTruncated||t[142]!==h.hostAbsolutePath||t[143]!==h.loadError||t[144]!==h.loading||t[145]!==h.mtimeMs||t[146]!==h.textContent||t[147]!==Ee||t[148]!==i?(De=(0,$.jsx)(UQ,{language:c,resolvedTheme:f,descriptor:h.descriptor,loading:h.loading,loadError:h.loadError,textContent:h.textContent,binaryBuffer:h.binaryBuffer,hostAbsolutePath:h.hostAbsolutePath,mtimeMs:h.mtimeMs,targetLine:i,extractedText:h.extractedText,extractedTextTruncated:h.extractedTextTruncated,workspaceEditing:Ee,actions:te,controller:g,renderToolbar:Lde}),t[134]=c,t[135]=te,t[136]=g,t[137]=f,t[138]=h.binaryBuffer,t[139]=h.descriptor,t[140]=h.extractedText,t[141]=h.extractedTextTruncated,t[142]=h.hostAbsolutePath,t[143]=h.loadError,t[144]=h.loading,t[145]=h.mtimeMs,t[146]=h.textContent,t[147]=Ee,t[148]=i,t[149]=De):De=t[149];let Oe;t[150]!==v||t[151]!==Ce||t[152]!==De?(Oe=(0,$.jsxs)(`div`,{ref:v,className:`flex h-full min-h-0 flex-col bg-surface-panel`,children:[Ce,De]}),t[150]=v,t[151]=Ce,t[152]=De,t[153]=Oe):Oe=t[153];let ke;t[154]!==C||t[155]!==E||t[156]!==O||t[157]!==w||t[158]!==T?(ke=(0,$.jsx)(c1,{open:C,onOpenChange:O,loading:w,error:E,result:T}),t[154]=C,t[155]=E,t[156]=O,t[157]=w,t[158]=T,t[159]=ke):ke=t[159];let Ae;return t[160]!==Oe||t[161]!==ke?(Ae=(0,$.jsxs)($.Fragment,{children:[Oe,ke]}),t[160]=Oe,t[161]=ke,t[162]=Ae):Ae=t[162],Ae}function Lde(){return null}function Rde(e){return!e}function zde(e){return!e}function Bde(e){return!e}function Vde(e){return!e}function Hde(e){return!e}function Ude(e){return e.resolved}function Wde(e){return e.language}var Gde=(0,Z.memo)(function(){let e=(0,Q.c)(21),{pathname:t}=_r(),{sessionKey:n}=wr(),r;e[0]!==t||e[1]!==n?(r=t.startsWith(`/chat`)&&n?decodeURIComponent(n):void 0,e[0]=t,e[1]=n,e[2]=r):r=e[2];let i=r,a=k1(Kde),o=k1(qde),s=k1(Jde),c=b1(Yde),l,u;e[3]!==t||e[4]!==s?(l=()=>{t.startsWith(`/chat`)||s(null)},u=[t,s],e[3]=t,e[4]=s,e[5]=l,e[6]=u):(l=e[5],u=e[6]),(0,Z.useEffect)(l,u);let d,f;if(e[7]!==a||e[8]!==s?(d=()=>{if(!a)return;let e=e=>{e.key===`Escape`&&(s(null),e.stopPropagation())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},f=[a,s],e[7]=a,e[8]=s,e[9]=d,e[10]=f):(d=e[9],f=e[10]),(0,Z.useEffect)(d,f),!a)return null;let p;e[11]===c?p=e[12]:(p=c.trim()||void 0,e[11]=c,e[12]=p);let m;e[13]===s?m=e[14]:(m=()=>s(null),e[13]=s,e[14]=m);let h;return e[15]!==i||e[16]!==o||e[17]!==a||e[18]!==p||e[19]!==m?(h=(0,$.jsx)(`div`,{role:`region`,"aria-label":`File preview`,className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden border border-edge bg-surface-panel dark:border-edge`,children:(0,$.jsx)(b3,{filePath:a,targetLine:o,sessionKey:i,agentId:p,onClose:m})}),e[15]=i,e[16]=o,e[17]=a,e[18]=p,e[19]=m,e[20]=h):h=e[20],h});function Kde(e){return e.path}function qde(e){return e.line}function Jde(e){return e.setPath}function Yde(e){return e.agentId}async function x3(){let e=await ue(X(`/api/models`));if(!e.ok)throw Error(`Models: HTTP ${e.status}`);return(await e.json()).payload?.models??[]}var S3=null,C3=0,w3=null,T3=6e4,E3=`gateway-configured-models`;async function D3(){S3=null,C3=0;let{mutate:e}=await c(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([6,1,2]));await e(E3)}async function O3(e=!1){if(!e&&S3&&Date.now()<C3)return S3;if(e){let e=await x3();return S3=e,C3=Date.now()+T3,e}return w3||(w3=x3().then(e=>(S3=e,C3=Date.now()+T3,e)).finally(()=>{w3=null}),w3)}function Xde(e){let t=(0,Q.c)(9),{models:n,selectedId:r,onSelectedChange:i}=e;if(n.length===0)return null;let a;if(t[0]!==n||t[1]!==i||t[2]!==r){let e;t[4]!==i||t[5]!==r?(e=e=>{let t=r===e.id;return(0,$.jsxs)(`label`,{className:u(`flex cursor-pointer items-start gap-3 rounded-xl border border-edge px-3 py-2.5 transition-colors`,t?`border-accent bg-accent-soft`:`hover:bg-surface-hover`),children:[(0,$.jsx)(`input`,{type:`radio`,name:`onboarding-model`,className:`mt-1`,checked:t,onChange:()=>i(e.id),"aria-label":e.name||e.id}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e.name||e.id}),e.recommended?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-1.5 py-0.5 text-[10px] font-semibold text-accent-fg`,children:`Recommended`}):null]}),(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:e.id})]})]},e.id)},t[4]=i,t[5]=r,t[6]=e):e=t[6],a=n.slice().sort(Zde).map(e),t[0]=n,t[1]=i,t[2]=r,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,$.jsx)(`div`,{className:`flex max-h-[min(50vh,22rem)] flex-col gap-2 overflow-y-auto pr-1`,role:`radiogroup`,children:a}),t[7]=a,t[8]=o),o}function Zde(e,t){return e.recommended===t.recommended?(e.name||e.id).localeCompare(t.name||t.id,void 0,{sensitivity:`base`}):e.recommended?-1:1}function k3(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=u(`shrink-0`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,className:a,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function Qde(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`#5786FE`,d:`M23.748 4.651c-.254-.124-.364.113-.512.233-.051.04-.094.09-.137.137-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.155-.708-.311-.955-.65-.172-.24-.219-.509-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.094.172.187.129.323-.082.28-.18.553-.266.833-.055.179-.137.218-.328.14a5.5 5.5 0 0 1-1.737-1.179c-.857-.828-1.631-1.743-2.597-2.46a12 12 0 0 0-.689-.47c-.985-.957.13-1.743.387-1.836.27-.098.094-.433-.778-.428-.872.003-1.67.295-2.687.685a3 3 0 0 1-.465.136 9.6 9.6 0 0 0-2.883-.101c-1.885.21-3.39 1.1-4.497 2.622C.082 8.776-.231 10.854.152 13.02c.403 2.284 1.568 4.175 3.36 5.653 1.857 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.132-.284 4.994-1.86.47.234.962.328 1.78.398.629.058 1.235-.031 1.705-.129.735-.155.684-.836.418-.961-2.155-1.004-1.682-.595-2.112-.926 1.095-1.295 2.768-3.598 3.284-6.733.05-.346.115-.834.108-1.114-.004-.171.035-.238.23-.257a4.2 4.2 0 0 0 1.545-.475c1.397-.763 1.96-2.016 2.093-3.517.02-.23-.004-.467-.247-.588M11.58 18.168c-2.088-1.642-3.101-2.183-3.52-2.16-.39.024-.32.472-.234.763.09.288.207.487.371.74.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.168-1.361-.801-2.5-1.86-3.301-3.306-.775-1.393-1.225-2.888-1.299-4.482-.02-.385.094-.522.477-.592a4.7 4.7 0 0 1 1.53-.038c2.131.311 3.946 1.264 5.467 2.774.868.86 1.525 1.887 2.202 2.89.72 1.066 1.494 2.082 2.48 2.915.348.291.626.513.892.677-.802.09-2.14.109-3.055-.615zm1.001-6.44a.306.306 0 0 1 .415-.287.3.3 0 0 1 .113.074.3.3 0 0 1 .086.214c0 .17-.136.307-.308.307a.303.303 0 0 1-.306-.307m3.11 1.596c-.2.081-.4.151-.591.16a1.25 1.25 0 0 1-.798-.254c-.274-.23-.47-.358-.551-.758a1.7 1.7 0 0 1 .015-.588c.07-.327-.007-.537-.238-.727-.188-.156-.426-.199-.689-.199a.6.6 0 0 1-.254-.078.253.253 0 0 1-.114-.358 1 1 0 0 1 .192-.21c.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.392.451.462.576.685.915.176.264.336.536.446.848.066.194-.02.353-.25.45`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(k3,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function $de(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`#E73562`,d:`M11.43 3.92a.86.86 0 1 0-1.718 0v14.236a1.999 1.999 0 0 1-3.997 0V9.022a.86.86 0 1 0-1.718 0v3.87a1.999 1.999 0 0 1-3.997 0V11.49a.57.57 0 0 1 1.139 0v1.404a.86.86 0 0 0 1.719 0V9.022a1.999 1.999 0 0 1 3.997 0v9.134a.86.86 0 0 0 1.719 0V3.92a1.998 1.998 0 1 1 3.996 0v11.788a.57.57 0 1 1-1.139 0zm10.572 3.105a2 2 0 0 0-1.999 1.997v7.63a.86.86 0 0 1-1.718 0V3.923a1.999 1.999 0 0 0-3.997 0v16.16a.86.86 0 0 1-1.719 0V18.08a.57.57 0 1 0-1.138 0v2a1.998 1.998 0 0 0 3.996 0V3.92a.86.86 0 0 1 1.719 0v12.73a1.999 1.999 0 0 0 3.996 0V9.023a.86.86 0 1 1 1.72 0v6.686a.57.57 0 0 0 1.138 0V9.022a2 2 0 0 0-1.998-1.997`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(k3,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function A3(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`currentColor`,d:`m1.053 16.91 9.538 2.55a21 20.981 0 0 0 .06 2.031l5.956 1.592a12 11.99 0 0 1-15.554-6.172m-1.02-5.79 11.352 3.035a21 20.981 0 0 0-.469 2.01l10.817 2.89a12 11.99 0 0 1-1.845 2.004L.658 15.918a12 11.99 0 0 1-.625-4.796m1.593-5.146L13.573 9.17a21 20.981 0 0 0-1.01 1.874l11.297 3.02a21 20.981 0 0 1-.67 2.362l-11.55-3.087L.125 10.26a12 11.99 0 0 1 1.499-4.285ZM6.067 1.58l11.285 3.016a21 20.981 0 0 0-1.688 1.719l7.824 2.091a21 20.981 0 0 1 .513 2.664L2.107 5.218a12 11.99 0 0 1 3.96-3.638M21.68 4.866 7.222 1.003A12 11.99 0 0 1 21.68 4.866`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(k3,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function efe(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`currentColor`,d:`M22.28 9.82a5.98 5.98 0 0 0-.516-4.91 6.04 6.04 0 0 0-6.51-2.9A6.06 6.06 0 0 0 4.98 4.18a5.98 5.98 0 0 0-3.99 2.9 6.04 6.04 0 0 0 .743 7.09 5.98 5.98 0 0 0 .511 4.91 6.05 6.05 0 0 0 6.51 2.9A5.98 5.98 0 0 0 13.26 24a6.05 6.05 0 0 0 5.77-4.20 5.98 5.98 0 0 0 3.99-2.9 6.05 6.05 0 0 0-.748-7.07zm-9.02 12.60a4.47 4.47 0 0 1-2.87-1.04l.142-.08 4.77-2.75a.795.79 0 0 0 .393-.681v-6.73l2.02 1.16a.071.07 0 0 1 .038.05v5.58a4.50 4.50 0 0 1-4.49 4.49zm-9.66-4.12a4.47 4.47 0 0 1-.535-3.01l.142.08 4.78 2.75a.771.77 0 0 0 .781 0l5.84-3.36v2.33a.08.08 0 0 1-.033.06L9.74 19.95a4.49 4.49 0 0 1-6.14-1.64zM2.34 7.89a4.48 4.48 0 0 1 2.36-1.97V11.6a.766.76 0 0 0 .388.67l5.81 3.35-2.02 1.16a.076.07 0 0 1-.071 0l-4.83-2.78A4.50 4.50 0 0 1 2.34 7.87zm16.59 3.85L13.10 8.36 15.11 7.2a.076.07 0 0 1 .071 0l4.83 2.79a4.49 4.49 0 0 1-.677 8.10v-5.67a.79.79 0 0 0-.407-.667zm2.01-3.02-.142-.085-4.77-2.78a.776.77 0 0 0-.785 0L9.40 9.23V6.89a.066.06 0 0 1 .028-.062l4.83-2.78a4.49 4.49 0 0 1 6.68 4.66zM8.30 12.86l-2.02-1.16a.08.08 0 0 1-.038-.057V6.07a4.49 4.49 0 0 1 7.37-3.45l-.142.08L8.70 5.45a.795.79 0 0 0-.393.68zm1.09-2.36 2.60-1.5 2.60 1.5v2.99l-2.59 1.5-2.60-1.5Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(k3,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function tfe(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`#D4A27F`,d:`M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(k3,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function nfe(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i,a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`gemini-grad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`#4285F4`}),(0,$.jsx)(`stop`,{offset:`50%`,stopColor:`#9B72CB`}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`#D96570`})]})}),a=(0,$.jsx)(`path`,{fill:`url(#gemini-grad)`,d:`M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81`}),t[3]=i,t[4]=a):(i=t[3],a=t[4]);let o;return t[5]!==n||t[6]!==r?(o=(0,$.jsxs)(k3,{className:n,...r,children:[i,a]}),t[5]=n,t[6]=r,t[7]=o):o=t[7],o}function rfe(e){let t=(0,Q.c)(20),{providerId:n,className:r}=e,i;t[0]===r?i=t[1]:(i={className:r,"aria-hidden":!0},t[0]=r,t[1]=i);let a=i;switch(n){case`deepseek`:{let e;return t[2]===a?e=t[3]:(e=(0,$.jsx)(Qde,{...a}),t[2]=a,t[3]=e),e}case`minimax`:{let e;return t[4]===a?e=t[5]:(e=(0,$.jsx)($de,{...a}),t[4]=a,t[5]=e),e}case`kimi-coding`:{let e;return t[6]===a?e=t[7]:(e=(0,$.jsx)(A3,{...a}),t[6]=a,t[7]=e),e}case`moonshotai`:case`moonshotai-cn`:{let e;return t[8]===a?e=t[9]:(e=(0,$.jsx)(A3,{...a}),t[8]=a,t[9]=e),e}case`openai`:{let e;return t[10]===a?e=t[11]:(e=(0,$.jsx)(efe,{...a}),t[10]=a,t[11]=e),e}case`anthropic`:{let e;return t[12]===a?e=t[13]:(e=(0,$.jsx)(tfe,{...a}),t[12]=a,t[13]=e),e}case`google`:{let e;return t[14]===a?e=t[15]:(e=(0,$.jsx)(nfe,{...a}),t[14]=a,t[15]=e),e}default:{let e;t[16]===r?e=t[17]:(e=u(`flex items-center justify-center text-2xl`,r),t[16]=r,t[17]=e);let n;return t[18]===e?n=t[19]:(n=(0,$.jsx)(`span`,{className:e,children:`🤖`}),t[18]=e,t[19]=n),n}}}var j3=`models-json-config`;async function M3(){await Promise.all([hI(),oe(X(`/api/providers/meta`)),oe(j3),D3()])}function ife(e){return dA(e)}async function N3(){return(await J(X(`/api/providers/meta`))).payload?.providers??[]}function afe(e){if(!e||typeof e!=`object`||!(`providers`in e))return{};let t=e.providers;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`string`&&(n[e]=r);return n}function ofe(e,t,n){let r=new Set(n.map(e=>e.provider));return e.map(e=>({...e,configured:e.configured||r.has(e.id),apiKey:t[e.id]??(e.activeKeySource===`extension`?``:e.configured||r.has(e.id)?`••••••••••••`:``)}))}async function P3(e){await J(X(`/api/config`),{method:`PATCH`,body:JSON.stringify({providers:e})}),await M3()}async function sfe(e){await J(X(`/api/providers/${encodeURIComponent(e)}/key`),{method:`DELETE`}),await M3()}async function cfe(e){let t=await J(X(`/api/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}var F3=[{id:`openai`,name:`OpenAI`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`anthropic`,name:`Anthropic`,category:`common`,supportsOAuth:!0,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`xai`,name:`xAI`,category:`specialty`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`google`,name:`Google AI`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`openrouter`,name:`OpenRouter`,category:`specialty`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`deepseek`,name:`DeepSeek`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0}],I3=new Map(F3.map((e,t)=>[e.id,t]));function lfe(e){let t=e.recommendedModels?.map(e=>e.name||e.id).filter(Boolean).slice(0,2);return t?.length?t.join(`, `):e.hint}function ufe(e){let t=(0,Q.c)(14),{onSelect:n}=e,r=_(pfe),i;t[0]===r?i=t[1]:(i=m(r),t[0]=r,t[1]=i);let a=i.onboarding.providerRecommended,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[2]=o):o=t[2];let{data:s}=ie(`onboarding-provider-meta`,N3,o),c,l;if(t[3]!==s||t[4]!==n||t[5]!==a){let e=(s?.filter(ffe)??F3).slice().sort(dfe);c=`grid grid-cols-2 gap-2 sm:grid-cols-3`;let r;t[8]!==n||t[9]!==a?(r=(e,t)=>{let r=lfe(e),i=t===0;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:u(`relative flex min-h-32 flex-col items-center gap-1.5 rounded-xl border border-edge p-4 text-center transition-colors`,`hover:border-accent hover:bg-accent-soft`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,i&&`border-accent/50 bg-accent-soft/30`),children:[i&&(0,$.jsx)(`span`,{className:`absolute -top-2 right-2 rounded-full bg-accent px-2 py-0.5 text-[10px] font-semibold text-white`,children:a}),(0,$.jsx)(rfe,{providerId:e.id,className:`size-8`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name}),r?(0,$.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-muted`,children:r}):null]},e.id)},t[8]=n,t[9]=a,t[10]=r):r=t[10],l=e.map(r),t[3]=s,t[4]=n,t[5]=a,t[6]=c,t[7]=l}else c=t[6],l=t[7];let d;return t[11]!==c||t[12]!==l?(d=(0,$.jsx)(`div`,{className:c,children:l}),t[11]=c,t[12]=l,t[13]=d):d=t[13],d}function dfe(e,t){return(I3.get(e.id)??999)-(I3.get(t.id)??999)}function ffe(e){return e.onboardingFeatured}function pfe(e){return e.language}var mfe=[{value:`openai-completions`,label:`OpenAI Completions`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic-messages`,label:`Anthropic Messages`},{value:`google-generative-ai`,label:`Google Generative AI`},{value:`azure-openai-responses`,label:`Azure OpenAI`},{value:`bedrock-converse-stream`,label:`AWS Bedrock`},{value:`openai-codex-responses`,label:`OpenAI Codex`},{value:`google-gemini-cli`,label:`Google Gemini CLI`},{value:`google-vertex`,label:`Google Vertex AI`}];function L3(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;return typeof e==`string`?e:void 0}}function R3(e){if(!e||typeof e!=`object`)return{providers:{}};let t=e,n=t.providers;return n&&typeof n==`object`&&!Array.isArray(n)?e:{...t,providers:{}}}async function z3(){let e=await Y(X(`/api/models-json`)),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok||!t.payload)throw Error(L3(t)||`HTTP ${e.status}`);return{...t.payload,config:R3(t.payload.config)}}async function B3(e){let t=await Y(X(`/api/models-json`),{method:`PATCH`,body:JSON.stringify({config:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(L3(n)||`HTTP ${t.status}`);return await M3(),n.payload}async function hfe(e){let t=await Y(X(`/api/models-json/discover-models`),{method:`POST`,body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(L3(n)||`HTTP ${t.status}`);return n.payload.models}function gfe(e,t,n){return{id:e,name:t||e,input:[`text`],contextWindow:128e3,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},...n}}var V3={ollama:{label:`Ollama`,providerId:`ollama`,config:{baseUrl:`http://localhost:11434/v1`,api:`openai-completions`,apiKey:`ollama`}},lmstudio:{label:`LM Studio`,providerId:`lmstudio`,config:{baseUrl:`http://localhost:1234/v1`,api:`openai-completions`,apiKey:`lmstudio`}},openrouter:{label:`OpenRouter`,providerId:`openrouter`,config:{baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`,apiKey:``}},zhipuCn:{label:`Zhipu GLM China`,providerId:`zhipu-cn`,config:{baseUrl:`https://open.bigmodel.cn/api/paas/v4`,api:`openai-completions`,apiKey:`ZHIPU_API_KEY`,models:[{id:`glm-5.2`,name:`GLM 5.2`,contextWindow:1e6,maxTokens:65536,reasoning:!0,input:[`text`]}]}},zaiGeneral:{label:`Zhipu GLM International`,providerId:`zai`,config:{baseUrl:`https://api.z.ai/api/paas/v4`,api:`openai-completions`,apiKey:`ZAI_API_KEY`,models:[{id:`glm-5.2`,name:`GLM 5.2`,contextWindow:1e6,maxTokens:65536,reasoning:!0,input:[`text`]}]}},dashscopeCn:{label:`Alibaba Bailian / DashScope China`,providerId:`dashscope-cn`,description:`China OpenAI-compatible Qwen endpoint`,config:{baseUrl:`https://dashscope.aliyuncs.com/compatible-mode/v1`,api:`openai-completions`,apiKey:`DASHSCOPE_API_KEY`,models:[{id:`qwen3.7-max`,name:`Qwen3.7 Max`,contextWindow:1e6,input:[`text`,`image`]},{id:`qwen3.7-plus`,name:`Qwen3.7 Plus`,contextWindow:1e6,input:[`text`,`image`]},{id:`qwen3.6-flash`,name:`Qwen3.6 Flash`,contextWindow:1e6,input:[`text`]}]}},dashscopeIntl:{label:`Alibaba Bailian / DashScope International`,providerId:`dashscope-intl`,description:`International OpenAI-compatible Qwen endpoint`,config:{baseUrl:`https://dashscope-intl.aliyuncs.com/compatible-mode/v1`,api:`openai-completions`,apiKey:`DASHSCOPE_API_KEY`,models:[{id:`qwen3.7-max`,name:`Qwen3.7 Max`,contextWindow:1e6,input:[`text`,`image`]},{id:`qwen3.7-plus`,name:`Qwen3.7 Plus`,contextWindow:1e6,input:[`text`,`image`]},{id:`qwen3.6-flash`,name:`Qwen3.6 Flash`,contextWindow:1e6,input:[`text`]}]}},volcengineArk:{label:`Volcengine Ark`,providerId:`volcengine-ark`,description:`Use your Ark endpoint id as the model id`,config:{baseUrl:`https://ark.cn-beijing.volces.com/api/v3`,api:`openai-completions`,apiKey:`ARK_API_KEY`,models:[{id:`ep-your-endpoint-id`,name:`Ark endpoint ID`,contextWindow:128e3,input:[`text`]}]}},volcenginePlan:{label:`Volcengine Doubao Coding Plan`,providerId:`volcengine-plan`,description:`Doubao coding-plan endpoint on Volcengine Ark`,config:{baseUrl:`https://ark.cn-beijing.volces.com/api/coding/v3`,api:`openai-completions`,apiKey:`ARK_API_KEY`,models:[{id:`ark-code-latest`,name:`Ark Coding Plan`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-code`,name:`Doubao Seed 2.0 Code`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-pro`,name:`Doubao Seed 2.0 Pro`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-lite`,name:`Doubao Seed 2.0 Lite`,contextWindow:256e3,maxTokens:4096,input:[`text`]}]}},byteplusPlan:{label:`BytePlus Doubao Coding Plan`,providerId:`byteplus-plan`,description:`Doubao coding-plan endpoint on BytePlus`,config:{baseUrl:`https://ark.ap-southeast.bytepluses.com/api/coding/v3`,api:`openai-completions`,apiKey:`BYTEPLUS_API_KEY`,models:[{id:`ark-code-latest`,name:`Ark Coding Plan`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-code`,name:`Doubao Seed 2.0 Code`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-pro`,name:`Doubao Seed 2.0 Pro`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-lite`,name:`Doubao Seed 2.0 Lite`,contextWindow:256e3,maxTokens:4096,input:[`text`]}]}},deepseek:{label:`DeepSeek`,providerId:`deepseek`,config:{baseUrl:`https://api.deepseek.com`,api:`openai-completions`,apiKey:`DEEPSEEK_API_KEY`,models:[{id:`deepseek-v4-pro`,name:`DeepSeek V4 Pro`,contextWindow:1e6,maxTokens:393216,reasoning:!0,input:[`text`]},{id:`deepseek-v4-flash`,name:`DeepSeek V4 Flash`,contextWindow:1e6,maxTokens:393216,reasoning:!0,input:[`text`]}]}},moonshotCn:{label:`Kimi / Moonshot China`,providerId:`moonshotai-cn`,config:{baseUrl:`https://api.moonshot.cn/v1`,api:`openai-completions`,apiKey:`MOONSHOT_API_KEY`,models:[{id:`kimi-k2.7-code`,name:`Kimi K2.7 Code`,contextWindow:262144,maxTokens:32768,reasoning:!0,input:[`text`,`image`]},{id:`kimi-k2.6`,name:`Kimi K2.6`,contextWindow:128e3,input:[`text`]},{id:`kimi-k2.5`,name:`Kimi K2.5`,contextWindow:128e3,input:[`text`]}]}},moonshotIntl:{label:`Kimi / Moonshot International`,providerId:`moonshotai`,config:{baseUrl:`https://api.moonshot.ai/v1`,api:`openai-completions`,apiKey:`MOONSHOT_API_KEY`,models:[{id:`kimi-k2.7-code`,name:`Kimi K2.7 Code`,contextWindow:262144,maxTokens:32768,reasoning:!0,input:[`text`,`image`]},{id:`kimi-k2.6`,name:`Kimi K2.6`,contextWindow:128e3,input:[`text`]},{id:`kimi-k2.5`,name:`Kimi K2.5`,contextWindow:128e3,input:[`text`]}]}},kimiCoding:{label:`Kimi Coding`,providerId:`kimi-coding`,description:`Dedicated Kimi coding endpoint`,config:{baseUrl:`https://api.kimi.com/coding/`,api:`anthropic-messages`,apiKey:`KIMI_API_KEY`,headers:{"User-Agent":`claude-code/0.1.0`},models:[{id:`kimi-k2.7-code`,name:`Kimi K2.7 Code`,contextWindow:262144,maxTokens:32768,reasoning:!0,input:[`text`,`image`]},{id:`kimi-for-coding`,name:`Kimi Code`,contextWindow:262144,maxTokens:32768,reasoning:!0,input:[`text`,`image`]}]}},stepfunIntl:{label:`StepFun International`,providerId:`stepfun-intl`,config:{baseUrl:`https://api.stepfun.ai/v1`,api:`openai-completions`,apiKey:`STEPFUN_API_KEY`,models:[{id:`step-3.7-flash`,name:`Step 3.7 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash-2603`,name:`Step 3.5 Flash 2603`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash`,name:`Step 3.5 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`]}]}},stepfunCn:{label:`StepFun China`,providerId:`stepfun-cn`,config:{baseUrl:`https://api.stepfun.com/v1`,api:`openai-completions`,apiKey:`STEPFUN_API_KEY`,models:[{id:`step-3.7-flash`,name:`Step 3.7 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash-2603`,name:`Step 3.5 Flash 2603`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash`,name:`Step 3.5 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`]}]}},stepfunPlanIntl:{label:`StepFun Step Plan International`,providerId:`stepfun-plan-intl`,config:{baseUrl:`https://api.stepfun.ai/step_plan/v1`,api:`openai-completions`,apiKey:`STEPFUN_API_KEY`,models:[{id:`step-3.7-flash`,name:`Step 3.7 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash-2603`,name:`Step 3.5 Flash 2603`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash`,name:`Step 3.5 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`]}]}},stepfunPlanCn:{label:`StepFun Step Plan China`,providerId:`stepfun-plan-cn`,config:{baseUrl:`https://api.stepfun.com/step_plan/v1`,api:`openai-completions`,apiKey:`STEPFUN_API_KEY`,models:[{id:`step-3.7-flash`,name:`Step 3.7 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash-2603`,name:`Step 3.5 Flash 2603`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash`,name:`Step 3.5 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`]}]}},xiaomi:{label:`Xiaomi MiMo`,providerId:`xiaomi`,config:{baseUrl:`https://api.xiaomimimo.com/v1`,api:`openai-completions`,apiKey:`XIAOMI_API_KEY`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5-pro-ultraspeed`,name:`MiMo V2.5 Pro UltraSpeed`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5`,name:`MiMo V2.5`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]}]}},xiaomiTokenPlanCn:{label:`Xiaomi MiMo Token Plan China`,providerId:`xiaomi-token-plan-cn`,config:{baseUrl:`https://token-plan-cn.xiaomimimo.com/v1`,api:`openai-completions`,apiKey:`XIAOMI_TOKEN_PLAN_CN_API_KEY`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5-pro-ultraspeed`,name:`MiMo V2.5 Pro UltraSpeed`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5`,name:`MiMo V2.5`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]}]}},xiaomiTokenPlanAms:{label:`Xiaomi MiMo Token Plan Amsterdam`,providerId:`xiaomi-token-plan-ams`,config:{baseUrl:`https://token-plan-ams.xiaomimimo.com/v1`,api:`openai-completions`,apiKey:`XIAOMI_TOKEN_PLAN_AMS_API_KEY`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5-pro-ultraspeed`,name:`MiMo V2.5 Pro UltraSpeed`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5`,name:`MiMo V2.5`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]}]}},xiaomiTokenPlanSgp:{label:`Xiaomi MiMo Token Plan Singapore`,providerId:`xiaomi-token-plan-sgp`,config:{baseUrl:`https://token-plan-sgp.xiaomimimo.com/v1`,api:`openai-completions`,apiKey:`XIAOMI_TOKEN_PLAN_SGP_API_KEY`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5-pro-ultraspeed`,name:`MiMo V2.5 Pro UltraSpeed`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5`,name:`MiMo V2.5`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]}]}},minimax:{label:`MiniMax`,providerId:`minimax`,description:`Anthropic-compatible endpoint preferred for agent workflows`,config:{baseUrl:`https://api.minimax.io/anthropic`,api:`anthropic-messages`,apiKey:`MINIMAX_API_KEY`,authHeader:!0,models:[{id:`MiniMax-M3`,name:`MiniMax M3`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`MiniMax-M2.7-highspeed`,name:`MiniMax M2.7 Highspeed`,contextWindow:204800,input:[`text`]},{id:`MiniMax-M2.7`,name:`MiniMax M2.7`,contextWindow:204800,input:[`text`]}]}},zhipuCodingCn:{label:`Zhipu GLM Coding Plan China`,providerId:`zhipu-coding-cn`,config:{baseUrl:`https://open.bigmodel.cn/api/coding/paas/v4`,api:`openai-completions`,apiKey:`ZHIPU_API_KEY`,models:[{id:`glm-5.2`,name:`GLM 5.2`,contextWindow:1e6,maxTokens:65536,reasoning:!0,input:[`text`]}]}},zaiCodingGlobal:{label:`Zhipu GLM Coding Plan International`,providerId:`zai-coding-global`,config:{baseUrl:`https://api.z.ai/api/coding/paas/v4`,api:`openai-completions`,apiKey:`ZAI_API_KEY`,models:[{id:`glm-5.2`,name:`GLM 5.2`,contextWindow:1e6,maxTokens:65536,reasoning:!0,input:[`text`]}]}},minimaxCn:{label:`MiniMax China`,providerId:`minimax-cn`,config:{baseUrl:`https://api.minimaxi.com/anthropic`,api:`anthropic-messages`,apiKey:`MINIMAX_CN_API_KEY`,authHeader:!0,models:[{id:`MiniMax-M3`,name:`MiniMax M3`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`MiniMax-M2.7-highspeed`,name:`MiniMax M2.7 Highspeed`,contextWindow:204800,input:[`text`]},{id:`MiniMax-M2.7`,name:`MiniMax M2.7`,contextWindow:204800,input:[`text`]}]}}},H3=Object.entries(V3).map(([e,t])=>({key:e,...t}));function _fe(e){return V3[e]?.providerId??e}function vfe(e){return H3.find(t=>t.providerId===e)?.key}var yfe=new Set([`dashscope-cn`,`dashscope-intl`,`volcengine-ark`,`volcengine-plan`,`byteplus-plan`,`stepfun-cn`,`stepfun-intl`,`stepfun-plan-cn`,`stepfun-plan-intl`,`zhipu-cn`,`zai-coding-global`,`zhipu-coding-cn`]);function U3(e){if(yfe.has(e))return vfe(e)}function bfe(e,t){let n=U3(e);if(!n)return;let r=V3[n];if(r)return{providerId:r.providerId,config:{...r.config,apiKey:t?.trim()||r.config.apiKey,models:r.config.models?.map(e=>({...e}))}}}var xfe=[{value:`text`,labelKey:`inputTextOnly`},{value:`text,image`,labelKey:`inputTextVision`}];function Sfe(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,oA,`dark:border-edge`)}function Cfe(){return u(rA,nA)}function wfe(e){return(e.input||[`text`]).includes(`image`)?`text,image`:`text`}function Tfe(e){return e===`text,image`?[`text`,`image`]:[`text`]}function Efe(e,t){return e===`single`?t.getApiKey:e===`intl`?t.getApiKeyIntl:t.getApiKeyCn}var W3={openai:{apiKeyUrl:`https://platform.openai.com/api-keys`,pricingUrl:`https://openai.com/pricing`,docsUrl:`https://platform.openai.com/docs`,description:`The most widely used LLM provider. Powers ChatGPT.`,descriptionZh:`最广泛使用的 LLM 服务商,ChatGPT 背后的技术。`,bestFor:[`general`,`coding`,`vision`],freeTier:!1,freeTierNote:`Pay-as-you-go; new accounts may receive trial credits.`,aliases:[`chatgpt`,`gpt`,`gpt-4`,`gpt4`,`gpt-4o`,`gpt4o`],envVars:[`OPENAI_API_KEY`]},anthropic:{apiKeyUrl:`https://console.anthropic.com/settings/keys`,pricingUrl:`https://www.anthropic.com/pricing`,docsUrl:`https://docs.anthropic.com`,description:`Anthropic model access. Available models are loaded from the gateway catalog.`,descriptionZh:`Anthropic 模型服务。可用模型由网关目录动态加载。`,bestFor:[`long context`,`coding`,`reasoning`],freeTier:!1,aliases:[`claude`,`claude 3`,`claude sonnet`,`claude opus`,`claude haiku`],envVars:[`ANTHROPIC_OAUTH_TOKEN`,`ANTHROPIC_API_KEY`]},google:{apiKeyUrl:`https://aistudio.google.com/app/apikey`,pricingUrl:`https://ai.google.dev/pricing`,docsUrl:`https://ai.google.dev/docs`,description:`Google AI model access. Available models are loaded from the gateway catalog.`,descriptionZh:`Google AI 模型服务。可用模型由网关目录动态加载。`,bestFor:[`multimodal`,`long context`,`general`],freeTier:!0,freeTierNote:`Free tier available via Google AI Studio.`,aliases:[`gemini`,`google gemini`,`bard`,`google ai`],envVars:[`GEMINI_API_KEY`,`GOOGLE_API_KEY`]},"google-vertex":{apiKeyUrl:`https://console.cloud.google.com/apis/credentials`,pricingUrl:`https://cloud.google.com/vertex-ai/pricing`,docsUrl:`https://cloud.google.com/vertex-ai/docs`,description:`Google Vertex AI — enterprise-grade model hosting on GCP.`,descriptionZh:`Google Vertex AI,企业级 GCP 托管模型服务。`,bestFor:[`enterprise`,`multimodal`,`compliance`],freeTier:!1,aliases:[`vertex`,`vertex ai`,`gcp`,`google cloud`],envVars:[`GOOGLE_CLOUD_API_KEY`,`GOOGLE_CLOUD_PROJECT`,`GOOGLE_CLOUD_LOCATION`]},"google-gemini-cli":{apiKeyUrl:`https://aistudio.google.com/app/apikey`,pricingUrl:`https://ai.google.dev/pricing`,docsUrl:`https://ai.google.dev/docs`,description:`Gemini via CLI token — for users authenticated with the Gemini CLI tool.`,descriptionZh:`通过 Gemini CLI 令牌访问 Gemini,适合已安装 CLI 工具的用户。`,bestFor:[`general`,`multimodal`],freeTier:!0,freeTierNote:`Uses your existing Gemini CLI authentication.`,aliases:[`gemini cli`,`gemini-cli`],envVars:[`GEMINI_CLI_TOKEN`,`GOOGLE_TOKEN`]},"google-antigravity":{apiKeyUrl:`https://console.cloud.google.com/apis/credentials`,pricingUrl:`https://cloud.google.com/pricing`,docsUrl:`https://cloud.google.com/docs`,description:`Google Antigravity — internal/experimental Google AI endpoint.`,descriptionZh:`Google Antigravity,Google 内部/实验性 AI 端点。`,bestFor:[`experimental`],freeTier:!1,aliases:[`antigravity`,`google antigravity`],envVars:[`ANTIGRAVITY_API_KEY`]},groq:{apiKeyUrl:`https://console.groq.com/keys`,pricingUrl:`https://groq.com/pricing/`,docsUrl:`https://console.groq.com/docs`,description:`Extremely fast inference — ideal for latency-sensitive applications.`,descriptionZh:`推理速度极快,适合对延迟敏感的场景。`,bestFor:[`speed`,`cheap`],freeTier:!0,freeTierNote:`Generous free tier with rate limits.`,aliases:[`groq`,`llama on groq`,`mixtral on groq`],envVars:[`GROQ_API_KEY`]},deepseek:{apiKeyUrl:`https://platform.deepseek.com/api_keys`,pricingUrl:`https://api-docs.deepseek.com/quick_start/pricing/`,docsUrl:`https://platform.deepseek.com/api-docs/`,description:`DeepSeek model access through an OpenAI-compatible API.`,descriptionZh:`通过 OpenAI 兼容 API 访问 DeepSeek 模型。`,bestFor:[`reasoning`,`cheap`,`coding`],freeTier:!0,freeTierNote:`Free credits may be available for new accounts.`,aliases:[`deepseek`,`deep seek`,`deepseek v4`,`deepseek-v4`,`r1`],envVars:[`DEEPSEEK_API_KEY`]},"volcengine-ark":{apiKeyUrl:`https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey`,pricingUrl:`https://www.volcengine.com/docs/82379/1099320`,docsUrl:`https://www.volcengine.com/docs/82379/1302008`,description:`Volcengine Ark — OpenAI-compatible access to Doubao and custom Ark endpoints.`,descriptionZh:`火山方舟,通过 OpenAI 兼容接口访问豆包与自定义方舟 endpoint。`,bestFor:[`chinese`,`general`,`enterprise`],aliases:[`volcengine`,`ark`,`doubao`,`volces`,`火山方舟`,`豆包`],envVars:[`ARK_API_KEY`,`VOLCENGINE_API_KEY`]},"volcengine-plan":{apiKeyUrl:`https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey`,pricingUrl:`https://www.volcengine.com/docs/82379/1099320`,docsUrl:`https://www.volcengine.com/docs/82379/1302008`,description:`Volcengine Doubao Coding Plan — Ark coding endpoint.`,descriptionZh:`火山方舟豆包 Coding Plan,使用 Ark coding endpoint。`,bestFor:[`coding`,`chinese`],aliases:[`volcengine plan`,`ark coding`,`doubao coding`,`火山方舟 coding`],envVars:[`ARK_API_KEY`,`VOLCENGINE_API_KEY`]},"byteplus-plan":{apiKeyUrl:`https://console.byteplus.com/ark/region:ark+ap-southeast-1/apiKey`,pricingUrl:`https://docs.byteplus.com/en/docs/ModelArk`,docsUrl:`https://docs.byteplus.com/en/docs/ModelArk/OpenAI`,description:`BytePlus Doubao Coding Plan — international Ark coding endpoint.`,descriptionZh:`BytePlus 豆包 Coding Plan,国际区 Ark coding endpoint。`,bestFor:[`coding`,`chinese`],aliases:[`byteplus`,`byteplus plan`,`doubao coding international`],envVars:[`BYTEPLUS_API_KEY`,`ARK_API_KEY`]},xai:{apiKeyUrl:`https://console.x.ai/`,pricingUrl:`https://x.ai/api`,docsUrl:`https://docs.x.ai/`,description:`xAI model access. Available models are loaded from the gateway catalog.`,descriptionZh:`xAI 模型服务。可用模型由网关目录动态加载。`,bestFor:[`reasoning`,`real-time`],freeTier:!1,aliases:[`grok`,`xai`,`x.ai`],envVars:[`XAI_API_KEY`]},cerebras:{apiKeyUrl:`https://cloud.cerebras.ai/platform/`,pricingUrl:`https://cloud.cerebras.ai/platform/`,docsUrl:`https://inference-docs.cerebras.ai/`,description:`Ultra-fast inference on custom AI chips. Fastest Llama inference available.`,descriptionZh:`基于专用 AI 芯片的超快推理,Llama 推理速度业界最快。`,bestFor:[`speed`],freeTier:!0,freeTierNote:`Free tier available.`,aliases:[`cerebras`],envVars:[`CEREBRAS_API_KEY`]},mistral:{apiKeyUrl:`https://console.mistral.ai/api-keys/`,pricingUrl:`https://mistral.ai/technology/#pricing`,docsUrl:`https://docs.mistral.ai/`,description:`European open-weight models. Good balance of quality and cost.`,descriptionZh:`欧洲开源模型,质量与成本平衡好。`,bestFor:[`general`,`cheap`,`coding`],freeTier:!1,aliases:[`mistral`,`mixtral`,`codestral`],envVars:[`MISTRAL_API_KEY`]},openrouter:{apiKeyUrl:`https://openrouter.ai/keys`,pricingUrl:`https://openrouter.ai/models`,docsUrl:`https://openrouter.ai/docs`,description:`API gateway to 100+ models from many providers with a single key.`,descriptionZh:`统一 API 网关,一个 Key 访问 100+ 模型。`,bestFor:[`general`,`flexibility`],freeTier:!0,freeTierNote:`Some models are free; pay-per-use for others.`,aliases:[`openrouter`,`open router`],envVars:[`OPENROUTER_API_KEY`]},"azure-openai-responses":{apiKeyUrl:`https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI`,pricingUrl:`https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/`,docsUrl:`https://learn.microsoft.com/en-us/azure/ai-services/openai/`,description:`OpenAI models hosted on Azure. Enterprise SLA and data residency.`,descriptionZh:`Azure 托管的 OpenAI 模型,企业级 SLA 和数据合规。`,bestFor:[`enterprise`,`compliance`,`coding`],freeTier:!1,aliases:[`azure`,`azure openai`,`aoai`],envVars:[`AZURE_OPENAI_API_KEY`,`AZURE_OPENAI_BASE_URL`]},"amazon-bedrock":{apiKeyUrl:`https://console.aws.amazon.com/iam/home#/security_credentials`,pricingUrl:`https://aws.amazon.com/bedrock/pricing/`,docsUrl:`https://docs.aws.amazon.com/bedrock/`,description:`AWS Bedrock hosted model access with enterprise controls.`,descriptionZh:`AWS Bedrock 托管模型服务,提供企业级控制能力。`,bestFor:[`enterprise`,`compliance`],freeTier:!1,aliases:[`bedrock`,`aws`,`amazon`],envVars:[`AWS_ACCESS_KEY_ID`,`AWS_SECRET_ACCESS_KEY`,`AWS_REGION`]},minimax:{apiKeyUrl:`https://platform.minimax.io/user-center/basic-information/interface-key`,pricingUrl:`https://platform.minimax.io/docs/guides/models-intro`,docsUrl:`https://platform.minimax.io/docs/guides/quickstart-preparation`,description:`MiniMax — Chinese multimodal model with strong text and audio capabilities.`,descriptionZh:`MiniMax,国产多模态模型,文本和音频能力强。`,bestFor:[`multimodal`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`minimax`,`mini max`,`abab`],envVars:[`MINIMAX_API_KEY`]},"minimax-cn":{apiKeyUrl:`https://platform.minimaxi.com/user-center/basic-information/interface-key`,pricingUrl:`https://platform.minimaxi.com/document/Price`,docsUrl:`https://platform.minimaxi.com/document/Announcement`,description:`MiniMax (China endpoint) — domestic access for Chinese users.`,descriptionZh:`MiniMax 国内端点,国内用户直连访问。`,bestFor:[`multimodal`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`minimax cn`,`minimax china`,`abab`],envVars:[`MINIMAX_CN_API_KEY`,`MINIMAX_API_KEY`]},stepfun:{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun OpenAI-compatible endpoint.`,descriptionZh:`阶跃星辰 StepFun OpenAI 兼容端点。`,bestFor:[`chinese`,`reasoning`,`general`],aliases:[`stepfun`,`step`,`阶跃星辰`],envVars:[`STEPFUN_API_KEY`]},"stepfun-cn":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun China — OpenAI-compatible chat endpoint.`,descriptionZh:`阶跃星辰 StepFun 中国区 OpenAI 兼容对话端点。`,bestFor:[`chinese`,`reasoning`,`general`],aliases:[`stepfun cn`,`step cn`,`阶跃星辰`],envVars:[`STEPFUN_API_KEY`]},"stepfun-intl":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun International — OpenAI-compatible chat endpoint.`,descriptionZh:`阶跃星辰 StepFun 国际区 OpenAI 兼容对话端点。`,bestFor:[`chinese`,`reasoning`,`general`],aliases:[`stepfun intl`,`step international`],envVars:[`STEPFUN_API_KEY`]},"stepfun-plan":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun Step Plan coding/planning endpoint.`,descriptionZh:`阶跃星辰 Step Plan coding/planning 专用端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`stepfun plan`,`step plan`,`阶跃 plan`],envVars:[`STEPFUN_API_KEY`]},"stepfun-plan-cn":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun Step Plan China — coding/planning endpoint.`,descriptionZh:`阶跃星辰 Step Plan 中国区 coding/planning 专用端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`stepfun plan cn`,`step plan cn`,`阶跃 plan`],envVars:[`STEPFUN_API_KEY`]},"stepfun-plan-intl":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun Step Plan International — coding/planning endpoint.`,descriptionZh:`阶跃星辰 Step Plan 国际区 coding/planning 专用端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`stepfun plan intl`,`step plan international`],envVars:[`STEPFUN_API_KEY`]},"kimi-coding":{apiKeyUrl:`https://platform.kimi.com/console/api-keys`,pricingUrl:`https://platform.kimi.com/docs/pricing/chat`,docsUrl:`https://platform.kimi.com/docs`,description:`Kimi Coding — dedicated Anthropic-compatible coding endpoint.`,descriptionZh:`Kimi Coding,Anthropic 兼容的专用 coding 端点。`,bestFor:[`coding`,`chinese`,`vision`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`kimi coding`,`moonshot coding`,`kimi code`],envVars:[`KIMI_API_KEY`,`MOONSHOT_API_KEY`]},moonshotai:{apiKeyUrl:`https://platform.moonshot.ai/console/api-keys`,pricingUrl:`https://platform.moonshot.ai/docs/pricing`,docsUrl:`https://platform.moonshot.ai/docs`,description:`Moonshot Kimi — international API (api.moonshot.ai).`,descriptionZh:`月之暗面 Kimi 国际版 API(api.moonshot.ai)。`,bestFor:[`coding`,`chinese`,`long context`],freeTier:!0,aliases:[`moonshot`,`kimi`,`moonshot ai`],envVars:[`MOONSHOT_API_KEY`]},"moonshotai-cn":{apiKeyUrl:`https://platform.moonshot.cn/console/api-keys`,pricingUrl:`https://platform.moonshot.cn/docs/pricing/chat`,docsUrl:`https://platform.moonshot.cn/docs`,description:`Moonshot Kimi — China region endpoint.`,descriptionZh:`月之暗面 Kimi 中国区域端点。`,bestFor:[`coding`,`chinese`,`long context`],freeTier:!0,aliases:[`moonshot cn`,`kimi cn`],envVars:[`MOONSHOT_API_KEY`]},fal:{apiKeyUrl:`https://fal.ai/dashboard/keys`,pricingUrl:`https://fal.ai/pricing`,docsUrl:`https://fal.ai/docs`,description:`fal — serverless image and media generation APIs.`,descriptionZh:`fal:无服务器图像与媒体生成 API。`,bestFor:[`image`,`video`],freeTier:!0,aliases:[`fal ai`,`fal.ai`],envVars:[`FAL_KEY`,`FAL_API_KEY`]},fireworks:{apiKeyUrl:`https://fireworks.ai/account/api-keys`,pricingUrl:`https://fireworks.ai/pricing`,docsUrl:`https://docs.fireworks.ai`,description:`Fireworks AI — fast inference for open and proprietary models.`,descriptionZh:`Fireworks AI,多种开源与商业模型的高速推理服务。`,bestFor:[`speed`,`coding`,`open weights`],freeTier:!0,aliases:[`fireworks ai`,`fireworks`],envVars:[`FIREWORKS_API_KEY`]},together:{apiKeyUrl:`https://api.together.xyz/settings/api-keys`,pricingUrl:`https://www.together.ai/pricing`,docsUrl:`https://docs.together.ai`,description:`Together AI — hosted Llama, Qwen, DeepSeek, and more.`,descriptionZh:`Together AI,托管 Llama、Qwen、DeepSeek 等模型。`,bestFor:[`open source`,`flexibility`],freeTier:!0,aliases:[`together ai`,`together.xyz`],envVars:[`TOGETHER_API_KEY`]},"cloudflare-workers-ai":{apiKeyUrl:`https://dash.cloudflare.com/?to=/:account/ai/workers-ai`,pricingUrl:`https://developers.cloudflare.com/workers-ai/platform/pricing/`,docsUrl:`https://developers.cloudflare.com/workers-ai/`,description:`Cloudflare Workers AI — models at the edge via Cloudflare API.`,descriptionZh:`Cloudflare Workers AI,通过 Cloudflare API 在边缘运行模型。`,bestFor:[`edge`,`latency`],freeTier:!0,aliases:[`workers ai`,`cf workers ai`],envVars:[`CLOUDFLARE_API_KEY`]},"cloudflare-ai-gateway":{apiKeyUrl:`https://dash.cloudflare.com/?to=/:account/ai/ai-gateway`,pricingUrl:`https://developers.cloudflare.com/ai-gateway/pricing/`,docsUrl:`https://developers.cloudflare.com/ai-gateway/`,description:`Cloudflare AI Gateway — unified OpenAI/Anthropic-compatible routing.`,descriptionZh:`Cloudflare AI Gateway,统一 OpenAI/Anthropic 兼容路由。`,bestFor:[`routing`,`observability`,`enterprise`],freeTier:!0,aliases:[`cf ai gateway`,`cloudflare gateway`],envVars:[`CLOUDFLARE_API_KEY`]},xiaomi:{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo — API billing through the MiMo open platform; endpoint api.xiaomimimo.com.`,descriptionZh:`小米 MiMo 按量计费线路,在开放平台创建密钥;接口域名为 api.xiaomimimo.com。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi`,`mimo`,`小米`,`xiaomimimo`],envVars:[`XIAOMI_API_KEY`]},"xiaomi-token-plan-cn":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — China region (token-plan-cn.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 中国区(token-plan-cn.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token cn`,`mimo token cn`],envVars:[`XIAOMI_TOKEN_PLAN_CN_API_KEY`,`XIAOMI_TOKEN_PLAN_API_KEY`]},"xiaomi-token-plan-ams":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — Amsterdam region (token-plan-ams.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 阿姆斯特丹(token-plan-ams.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token ams`,`mimo token ams`],envVars:[`XIAOMI_TOKEN_PLAN_AMS_API_KEY`,`XIAOMI_TOKEN_PLAN_API_KEY`]},"xiaomi-token-plan-sgp":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — Singapore region (token-plan-sgp.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 新加坡(token-plan-sgp.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token sgp`,`mimo token sgp`],envVars:[`XIAOMI_TOKEN_PLAN_SGP_API_KEY`,`XIAOMI_TOKEN_PLAN_API_KEY`]},"ant-ling":{apiKeyUrl:`https://ling.tbox.cn/`,docsUrl:`https://ling.tbox.cn/`,description:`Ant Ling — domestic OpenAI-compatible access to Ling and Ring models.`,descriptionZh:`蚂蚁 Ling,国内 OpenAI 兼容服务,提供 Ling 与 Ring 系列模型。`,bestFor:[`chinese`,`reasoning`,`coding`],aliases:[`ant ling`,`ling`,`ring`,`蚂蚁 ling`,`蚂蚁灵`],envVars:[`ANT_LING_API_KEY`,`LING_API_KEY`]},"zai-coding-global":{apiKeyUrl:`https://z.ai/manage-apikey/apikey-list`,pricingUrl:`https://z.ai/manage-apikey/billing`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,description:`Zhipu GLM Coding Plan — international z.ai endpoint.`,descriptionZh:`智谱 GLM Coding Plan 国际区 z.ai 端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`zai coding`,`zhipu coding global`,`glm coding global`],envVars:[`ZAI_API_KEY`,`Z_AI_API_KEY`]},"zai-coding-cn":{apiKeyUrl:`https://bigmodel.cn/usercenter/proj-mgmt/apikeys`,pricingUrl:`https://bigmodel.cn/pricing`,docsUrl:`https://docs.bigmodel.cn/cn/guide/start/model-overview`,description:`Zhipu GLM Coding Plan — China endpoint from the pi-ai provider catalog.`,descriptionZh:`智谱 GLM Coding Plan 中国区,来自 pi-ai 内置 provider 目录。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`zai coding cn`,`zhipu coding cn`,`glm coding cn`,`智谱 coding`],envVars:[`ZHIPU_API_KEY`,`BIGMODEL_API_KEY`,`ZAI_API_KEY`]},"zhipu-coding-cn":{apiKeyUrl:`https://bigmodel.cn/usercenter/proj-mgmt/apikeys`,pricingUrl:`https://bigmodel.cn/pricing`,docsUrl:`https://docs.bigmodel.cn/cn/guide/start/model-overview`,description:`Zhipu GLM Coding Plan — China BigModel endpoint.`,descriptionZh:`智谱 GLM Coding Plan 中国区 BigModel 端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`zhipu coding`,`glm coding cn`,`智谱 coding`],envVars:[`ZHIPU_API_KEY`,`BIGMODEL_API_KEY`,`ZAI_API_KEY`]},"zhipu-cn":{apiKeyUrl:`https://bigmodel.cn/usercenter/proj-mgmt/apikeys`,pricingUrl:`https://bigmodel.cn/pricing`,docsUrl:`https://docs.bigmodel.cn/cn/guide/start/model-overview`,description:`Zhipu GLM China — BigModel OpenAI-compatible endpoint.`,descriptionZh:`智谱 GLM 中国区,通过 BigModel OpenAI 兼容接口访问。`,bestFor:[`chinese`,`reasoning`,`general`],freeTier:!0,aliases:[`zhipu`,`glm`,`bigmodel`,`智谱`,`z.ai cn`],envVars:[`ZHIPU_API_KEY`,`BIGMODEL_API_KEY`]},huggingface:{apiKeyUrl:`https://huggingface.co/settings/tokens`,pricingUrl:`https://huggingface.co/pricing`,docsUrl:`https://huggingface.co/docs/api-inference/`,description:`Access thousands of open-source models via Hugging Face Inference API.`,descriptionZh:`通过 Hugging Face 访问数千个开源模型。`,bestFor:[`open source`,`flexibility`],freeTier:!0,freeTierNote:`Free tier with rate limits.`,aliases:[`huggingface`,`hugging face`,`hf`],envVars:[`HF_TOKEN`,`HUGGINGFACE_TOKEN`]},opencode:{apiKeyUrl:`https://opencode.ai/auth`,pricingUrl:`https://opencode.ai/docs`,docsUrl:`https://opencode.ai/docs/providers/`,description:`OpenCode — AI coding assistant provider.`,descriptionZh:`OpenCode,AI 代码助手服务商。`,bestFor:[`coding`],freeTier:!1,aliases:[`opencode`,`open code`],envVars:[`OPENCODE_API_KEY`]},"opencode-go":{apiKeyUrl:`https://opencode.ai/auth`,pricingUrl:`https://opencode.ai/docs`,docsUrl:`https://opencode.ai/docs/providers/`,description:`OpenCode Go — AI coding assistant provider (Go variant).`,descriptionZh:`OpenCode Go,AI 代码助手服务商(Go 版本)。`,bestFor:[`coding`],freeTier:!1,aliases:[`opencode go`,`opencode-go`],envVars:[`OPENCODE_API_KEY`]},zai:{apiKeyUrl:`https://z.ai/manage-apikey/apikey-list`,pricingUrl:`https://z.ai/manage-apikey/billing`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,description:`Zhipu GLM International — z.ai OpenAI-compatible endpoint.`,descriptionZh:`智谱 GLM 国际区,通过 z.ai OpenAI 兼容接口访问。`,bestFor:[`general`,`reasoning`,`chinese`],freeTier:!1,aliases:[`zai`,`z.ai`,`zhipu global`,`glm global`,`智谱`],envVars:[`ZAI_API_KEY`,`Z_AI_API_KEY`]},dashscope:{apiKeyUrl:`https://dashscope.console.aliyun.com/apiKey`,pricingUrl:`https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-thousand-questions-metering-and-billing`,docsUrl:`https://help.aliyun.com/zh/model-studio/developer-reference/compatibility-of-openai-with-dashscope`,description:`Alibaba Bailian / DashScope service provider.`,descriptionZh:`阿里百炼 / DashScope 服务 provider。`,bestFor:[`chinese`,`coding`,`image`,`speech`],freeTier:!0,aliases:[`dash scope`,`alibaba dashscope`,`qwen`,`tongyi`,`阿里百炼`,`通义千问`],envVars:[`DASHSCOPE_API_KEY`,`QWEN_API_KEY`]},"dashscope-cn":{apiKeyUrl:`https://dashscope.console.aliyun.com/apiKey`,pricingUrl:`https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-thousand-questions-metering-and-billing`,docsUrl:`https://help.aliyun.com/zh/model-studio/developer-reference/compatibility-of-openai-with-dashscope`,description:`Alibaba Bailian / DashScope China — Qwen LLMs through the China endpoint.`,descriptionZh:`阿里百炼 / DashScope 中国区:通过国内端点访问通义千问 LLM。`,bestFor:[`chinese`,`coding`,`image`],freeTier:!0,aliases:[`dash scope cn`,`alibaba dashscope cn`,`qwen cn`,`tongyi cn`,`阿里百炼`,`通义千问`],envVars:[`DASHSCOPE_API_KEY`,`QWEN_API_KEY`]},"dashscope-intl":{apiKeyUrl:`https://modelstudio.console.alibabacloud.com/`,pricingUrl:`https://www.alibabacloud.com/help/en/model-studio/billing-for-tongyi-qianwen`,docsUrl:`https://www.alibabacloud.com/help/en/model-studio/compatibility-of-openai-with-dashscope`,description:`Alibaba Bailian / DashScope International — Qwen LLMs through the international endpoint.`,descriptionZh:`阿里百炼 / DashScope 国际区:通过国际端点访问通义千问 LLM。`,bestFor:[`chinese`,`coding`,`image`],freeTier:!0,aliases:[`dash scope intl`,`alibaba cloud dashscope`,`qwen intl`,`tongyi intl`],envVars:[`DASHSCOPE_API_KEY`,`QWEN_API_KEY`]},"vercel-ai-gateway":{apiKeyUrl:`https://vercel.com/account/tokens`,pricingUrl:`https://vercel.com/pricing`,docsUrl:`https://vercel.com/docs/ai/ai-gateway`,description:`Vercel AI Gateway — route requests to multiple LLM providers via Vercel.`,descriptionZh:`Vercel AI Gateway,通过 Vercel 路由请求到多个 LLM 服务商。`,bestFor:[`flexibility`,`enterprise`],freeTier:!1,aliases:[`vercel gateway`,`vercel ai gateway`],envVars:[`AI_GATEWAY_API_KEY`,`VERCEL_AI_GATEWAY_API_KEY`]},"github-copilot":{apiKeyUrl:`https://github.com/settings/tokens`,pricingUrl:`https://github.com/features/copilot#pricing`,docsUrl:`https://docs.github.com/en/copilot`,description:`GitHub Copilot — use your GitHub token to access Copilot models.`,descriptionZh:`使用 GitHub 令牌访问 Copilot 模型。`,bestFor:[`coding`],freeTier:!0,freeTierNote:`Free for verified students and open-source maintainers.`,aliases:[`github copilot`,`copilot`,`github`],envVars:[`COPILOT_GITHUB_TOKEN`,`GH_TOKEN`,`GITHUB_TOKEN`,`GITHUB_COPILOT_TOKEN`]}};function Dfe(e,t){let n=W3[e];return n&&n.apiKeyUrl?[{href:n.apiKeyUrl,kind:`single`}]:[]}async function G3(){let e=await J(X(`/api/global-defaults`));if(!e.payload||typeof e.payload.presetId!=`string`)throw Error(`Invalid global defaults response`);return e.payload}async function K3(e){let t=await J(X(`/api/global-defaults`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({models:e})});if(!t.payload||typeof t.payload.presetId!=`string`)throw Error(`Invalid global defaults response`);return t.payload}var Ofe={name:``,description:``,language:``,creature:``,emoji:``,avatar:``};function kfe(e){let t={...Ofe};if(!e.trim())return t;let n={name:`name`,description:`description`,language:`language`,creature:`creature`,emoji:`emoji`,avatar:`avatar`};for(let r of e.split(`
155
155
  `)){let e=r.match(/^[-*]\s+\*\*(\w+):\*\*\s*(.*)/i);if(!e)continue;let i=n[e[1].toLowerCase()];if(!i)continue;let a=e[2].trim();/^_\(.*\)_$/.test(a)&&(a=``),t[i]=a}return t}function Afe(e){return[`# IDENTITY.md - Who Am I?`,``,`- **Name:** ${e.name}`,`- **Description:** ${e.description}`,`- **Language:** ${e.language}`,`- **Creature:** ${e.creature}`,`- **Emoji:** ${e.emoji}`,`- **Avatar:** ${e.avatar}`,``].join(`
156
156
  `)}var jfe={callName:``,pronouns:``,timezone:``,notes:``};function q3(e){let t={...jfe};if(!e.trim())return t;let n={name:`callName`,"what to call them":`callName`,pronouns:`pronouns`,timezone:`timezone`,notes:`notes`},r=e.split(`
157
157
  `),i=-1;for(let e=0;e<r.length;e++){let a=r[e];if(/^##\s+Context/i.test(a)){i=e+1;continue}let o=a.match(/^[-*]\s+\*\*(.+?):\*\*\s*(.*)/i);if(!o)continue;let s=n[o[1].toLowerCase().trim()];if(!s)continue;let c=o[2].trim();/^_\(.*\)_$/.test(c)&&(c=``),t[s]=c}if(i>0){let e=r.slice(i).join(`
@@ -223,7 +223,7 @@ Warm, friendly, and a little playful. Like a helpful friend who happens to know
223
223
  Sharp, direct, slightly nerdy. The kind of engineer you'd want on your team — competent, opinionated, and occasionally funny.`},{id:`custom`,labelEn:`Custom`,labelZh:`自定义`,emoji:`✍️`,content:``}];function Mfe(e){let t=e.trimStart();if(!t.startsWith(`---`))return e;let n=t.indexOf(`---`,3);return n===-1?e:t.slice(n+3).trimStart()}function Nfe(e){let t=Mfe(e).trim();if(!t)return`professional`;for(let e of Y3)if(e.id!==`custom`&&(t===e.content.trim()||Ffe(t,e.id)>=2))return e.id;return`custom`}var Pfe={professional:/precise and efficient|Value the user's time|actionable answers/g,casual:/good friend|corporate drone|a little playful/g,geeky:/Precision over politeness|Go deep|slightly nerdy/g};function Ffe(e,t){let n=Pfe[t];if(!n)return 0;let r=new RegExp(n.source,`g`),i=new Set,a;for(;(a=r.exec(e))!==null;)if(i.add(a[0]),i.size>=2)return i.size;return i.size}var X3=[{value:``,labelEn:`Not set`,labelZh:`未设置`},{value:`Asia/Shanghai`,labelEn:`Asia/Shanghai (CST, UTC+8)`,labelZh:`亚洲/上海 (北京时间, UTC+8)`},{value:`Asia/Tokyo`,labelEn:`Asia/Tokyo (JST, UTC+9)`,labelZh:`亚洲/东京 (日本时间, UTC+9)`},{value:`Asia/Seoul`,labelEn:`Asia/Seoul (KST, UTC+9)`,labelZh:`亚洲/首尔 (韩国时间, UTC+9)`},{value:`Asia/Singapore`,labelEn:`Asia/Singapore (SGT, UTC+8)`,labelZh:`亚洲/新加坡 (UTC+8)`},{value:`Asia/Hong_Kong`,labelEn:`Asia/Hong Kong (HKT, UTC+8)`,labelZh:`亚洲/香港 (UTC+8)`},{value:`Asia/Taipei`,labelEn:`Asia/Taipei (CST, UTC+8)`,labelZh:`亚洲/台北 (UTC+8)`},{value:`Asia/Kolkata`,labelEn:`Asia/Kolkata (IST, UTC+5:30)`,labelZh:`亚洲/加尔各答 (印度时间, UTC+5:30)`},{value:`Asia/Dubai`,labelEn:`Asia/Dubai (GST, UTC+4)`,labelZh:`亚洲/迪拜 (UTC+4)`},{value:`Europe/London`,labelEn:`Europe/London (GMT/BST)`,labelZh:`欧洲/伦敦 (格林尼治时间)`},{value:`Europe/Paris`,labelEn:`Europe/Paris (CET, UTC+1)`,labelZh:`欧洲/巴黎 (中欧时间, UTC+1)`},{value:`Europe/Berlin`,labelEn:`Europe/Berlin (CET, UTC+1)`,labelZh:`欧洲/柏林 (中欧时间, UTC+1)`},{value:`Europe/Moscow`,labelEn:`Europe/Moscow (MSK, UTC+3)`,labelZh:`欧洲/莫斯科 (UTC+3)`},{value:`America/New_York`,labelEn:`America/New York (EST, UTC-5)`,labelZh:`美国/纽约 (东部时间, UTC-5)`},{value:`America/Chicago`,labelEn:`America/Chicago (CST, UTC-6)`,labelZh:`美国/芝加哥 (中部时间, UTC-6)`},{value:`America/Denver`,labelEn:`America/Denver (MST, UTC-7)`,labelZh:`美国/丹佛 (山地时间, UTC-7)`},{value:`America/Los_Angeles`,labelEn:`America/Los Angeles (PST, UTC-8)`,labelZh:`美国/洛杉矶 (太平洋时间, UTC-8)`},{value:`America/Sao_Paulo`,labelEn:`America/São Paulo (BRT, UTC-3)`,labelZh:`美洲/圣保罗 (巴西时间, UTC-3)`},{value:`Australia/Sydney`,labelEn:`Australia/Sydney (AEST, UTC+10)`,labelZh:`澳大利亚/悉尼 (UTC+10)`},{value:`Pacific/Auckland`,labelEn:`Pacific/Auckland (NZST, UTC+12)`,labelZh:`太平洋/奥克兰 (新西兰时间, UTC+12)`}];function Z3(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return``}}var Ife=[{value:`先生`,labelEn:`Mr.`,labelZh:`先生`},{value:`女士`,labelEn:`Ms.`,labelZh:`女士`},{value:`同学`,labelEn:`Colleague`,labelZh:`同学`},{value:`老师`,labelEn:`Teacher`,labelZh:`老师`},{value:`老板`,labelEn:`Boss`,labelZh:`老板`},{value:`朋友`,labelEn:`Friend`,labelZh:`朋友`}],Lfe=[{value:`AI assistant`,labelEn:`AI Assistant`,labelZh:`AI 助手`},{value:`robot`,labelEn:`Robot`,labelZh:`机器人`},{value:`familiar`,labelEn:`Familiar`,labelZh:`精灵`},{value:`ghost in the machine`,labelEn:`Ghost in the machine`,labelZh:`机器幽灵`},{value:`digital companion`,labelEn:`Digital Companion`,labelZh:`数字伙伴`}],Rfe={step:`provider`,selectedProvider:null,apiKey:``,busy:!1,error:null,models:[],selectedModelId:null,modelsLoading:!1,profile:{callName:``,pronouns:``,timezone:Z3(),notes:``}};function zfe(e,t){switch(t.type){case`patch`:return{...e,...t.patch};case`reset-models`:return{...e,models:[],selectedModelId:null}}}function Bfe({onComplete:e,onDismiss:t,canDismiss:n=!0}){let r=_(e=>e.language),i=m(r).onboarding,[a,o]=(0,Z.useReducer)(zfe,Rfe),{step:s,selectedProvider:c,apiKey:l,busy:u,error:d,models:f,selectedModelId:p,modelsLoading:h,profile:g}=a,v=(0,Z.useMemo)(()=>s===`profile`?i.optionalStep:i.stepOf.replace(`{{current}}`,String(s===`provider`?1:s===`apiKey`?2:3)).replace(`{{total}}`,`3`),[i.optionalStep,i.stepOf,s]),y=(0,Z.useCallback)(async e=>{o({type:`patch`,patch:{modelsLoading:!0,error:null}});try{let t=(await O3(!0)).filter(t=>t.provider===e).sort((e,t)=>e.recommended===t.recommended?(e.name||e.id).localeCompare(t.name||t.id,void 0,{sensitivity:`base`}):e.recommended?-1:1);o({type:`patch`,patch:{models:t,selectedModelId:t[0]?.id??null}})}catch(e){o({type:`patch`,patch:{error:e instanceof Error?e.message:String(e),models:[],selectedModelId:null}})}finally{o({type:`patch`,patch:{modelsLoading:!1}})}},[]);(0,Z.useEffect)(()=>{let e=!1;return(async()=>{try{let t=(await G3()).recommendations[0];if(!t||e)return;o({type:`patch`,patch:{selectedProvider:t.provider,step:`model`,error:null}}),await y(t.provider)}catch{}})(),()=>{e=!0}},[y]);let b=async()=>{if(!(!c||!l.trim())){o({type:`patch`,patch:{busy:!0,error:null}});try{let e=bfe(c,l.trim());if(e){let t=await z3(),n=t.config.providers[e.providerId]??{};await B3({...t.config,providers:{...t.config.providers,[e.providerId]:{...n,...e.config}}})}else await P3({[c]:l.trim()});await y(c),o({type:`patch`,patch:{step:`model`}})}catch(e){o({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{busy:!1}})}}},x=async()=>{try{let e=q3(await R4());o({type:`patch`,patch:{profile:{...e,timezone:e.timezone||Z3()}}})}catch{o({type:`patch`,patch:{profile:{...g,timezone:g.timezone||Z3()}}})}},S=async()=>{if(!c||!p)return;let e=f.find(e=>e.id===p)?.id??p;o({type:`patch`,patch:{busy:!0,error:null}});try{await K3({defaultRole:`deep`,roles:{deep:{model:e}}}),hI(),D3(),G4(),await x(),o({type:`patch`,patch:{step:`profile`}})}catch(e){o({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{busy:!1}})}},C=async t=>{o({type:`patch`,patch:{busy:!0,error:null}});try{t&&await z4(J3(g)),await e()}catch(e){o({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{busy:!1}})}},w=e=>{o({type:`patch`,patch:{profile:{...g,...e}}})};return(0,$.jsxs)(`div`,{className:`w-full max-w-xl rounded-2xl border border-edge bg-surface-panel p-6 shadow-elevated`,children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`div`,{className:`text-3xl`,"aria-hidden":!0,children:`🤖`}),(0,$.jsx)(`h2`,{className:`mt-3 text-lg font-semibold tracking-tight text-fg`,children:i.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.subtitle}),(0,$.jsx)(`p`,{className:`mt-2 text-xs font-medium uppercase tracking-wide text-fg-muted`,children:v})]}),(0,$.jsxs)(`div`,{className:`mt-6`,children:[s===`provider`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-base font-medium text-fg`,children:i.step1Title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.step1Subtitle})]}),(0,$.jsx)(ufe,{onSelect:e=>{o({type:`patch`,patch:{selectedProvider:e,step:`apiKey`,apiKey:``,error:null}})}}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 pt-2`,children:[(0,$.jsx)(Hi,{to:`/settings/credentials`,className:`text-xs font-medium text-accent-fg hover:underline`,children:r===`zh`?`高级设置…`:`More settings…`}),n?(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-fg-muted hover:text-fg hover:underline`,onClick:t,children:i.skipSetup}):null]})]}):null,s===`apiKey`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h3`,{className:`text-base font-medium text-fg`,children:[i.step2Title,c?` (${c})`:``]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.step2Subtitle})]}),c&&(()=>{let e=W3[c]?.apiKeyUrl;return e?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-xl border border-edge-subtle bg-surface-base px-3.5 py-2.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:r===`zh`?`获取 API Key:`:`Get your API Key:`}),(0,$.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,children:[r===`zh`?`前往获取`:`Get API Key`,(0,$.jsx)(gh,{className:`size-3`})]})]}):null})(),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:i.step2Placeholder}),(0,$.jsx)(xA,{className:`mt-1`,value:l,onChange:e=>o({type:`patch`,patch:{apiKey:e}}),placeholder:i.step2Placeholder,labels:CA(m(r).providersSettings),inputClassName:`rounded-xl py-2.5 ring-accent focus:border-accent focus:ring-2 focus:ring-accent/30`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.step2SecurityNote}),d?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2`,children:[(0,$.jsx)(tA,{type:`button`,variant:`secondary`,disabled:u,onClick:()=>o({type:`patch`,patch:{step:`provider`}}),children:i.back}),(0,$.jsx)(tA,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,disabled:u||!l.trim(),onClick:()=>void b(),children:i.continue})]})]}):null,s===`model`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-base font-medium text-fg`,children:i.step3Title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.step3Subtitle})]}),h?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r===`zh`?`加载模型…`:`Loading models…`}):d&&f.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}),(0,$.jsx)(`button`,{type:`button`,className:`text-left text-sm font-medium text-accent-fg hover:underline`,onClick:()=>c&&void y(c),children:r===`zh`?`重试`:`Retry`})]}):(0,$.jsx)(Xde,{models:f,selectedId:p,onSelectedChange:e=>o({type:`patch`,patch:{selectedModelId:e}})}),d&&f.length>0?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2`,children:[(0,$.jsx)(tA,{type:`button`,variant:`secondary`,disabled:u,onClick:()=>o({type:`patch`,patch:{step:`apiKey`}}),children:i.back}),(0,$.jsx)(tA,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,disabled:u||!p||h,onClick:()=>void S(),children:i.continue})]})]}):null,s===`profile`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-base font-medium text-fg`,children:i.profileTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.profileSubtitle})]}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.profileCallNameLabel,(0,$.jsx)(`input`,{value:g.callName,onChange:e=>w({callName:e.target.value}),placeholder:i.profileCallNamePlaceholder,className:`mt-1 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none transition focus:border-accent focus:ring-2 focus:ring-accent/30`})]}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.profileTimezoneLabel,(0,$.jsxs)(Aj,{value:g.timezone,onChange:e=>w({timezone:e.target.value}),className:`mt-1 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none transition focus:border-accent focus:ring-2 focus:ring-accent/30`,children:[(0,$.jsx)(Dj,{value:``,children:i.profileTimezonePlaceholder}),X3.map(e=>(0,$.jsx)(Dj,{value:e.value,children:r===`zh`?e.labelZh:e.labelEn},e.value))]})]}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.profileNotesLabel,(0,$.jsx)(`textarea`,{value:g.notes,onChange:e=>w({notes:e.target.value}),placeholder:i.profileNotesPlaceholder,rows:4,className:`mt-1 w-full resize-none rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none transition focus:border-accent focus:ring-2 focus:ring-accent/30`})]}),d?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2`,children:[(0,$.jsx)(tA,{type:`button`,variant:`secondary`,disabled:u,onClick:()=>void C(!1),children:i.skipProfile}),(0,$.jsx)(tA,{type:`button`,className:`bg-accent text-white hover:bg-accent/90`,disabled:u,onClick:()=>void C(!0),children:i.startChatting})]})]}):null]})]})}function Q3(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=t.roles;if(!n||typeof n!=`object`||Array.isArray(n))return;let r=typeof t.defaultRole==`string`&&t.defaultRole.trim()?t.defaultRole.trim():Object.keys(n)[0];if(!r)return;let i=n[r];if(!i||typeof i!=`object`||Array.isArray(i))return;let a=i.model;return typeof a==`string`&&a.trim()?a.trim():void 0}function Vfe(e){if(!e||typeof e!=`object`)return!0;let t=e.agents,n=``;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t,r=typeof e.defaultPreset==`string`&&e.defaultPreset.trim()?e.defaultPreset.trim():`default`,i=e.capabilityPresets,a=i&&typeof i==`object`&&!Array.isArray(i)?i:{},o=e=>{let t=a[e];if(!t||typeof t!=`object`||Array.isArray(t))return;let r=Q3(t.models);r&&(n=r)};o(r);let s=Array.isArray(e.list)?e.list:[],c=typeof e.default==`string`?e.default.trim():``,l=s.find(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.enabled!==!1&&t.default===!0}),u=s.find(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.enabled!==!1&&c&&t.id===c})??l??s.find(e=>!e||typeof e!=`object`||Array.isArray(e)?!1:e.enabled!==!1);if(u&&typeof u==`object`&&!Array.isArray(u)){let e=u,t=Array.isArray(e.extends)?e.extends:[];for(let e of t)typeof e==`string`&&e!==r&&o(e);let i=Q3(e.models);i&&(n=i)}}return!(n.trim().length>0)}function Hfe(e){let{enabled:t,ready:n,configError:r,modelsError:i,config:a,modelsData:o}=e;if(!t||!n||r||i)return!1;let s=Vfe(a),c=!Array.isArray(o)||o.length===0;return s||c}var Ufe=`xopc-onboarding-model-setup-dismissed`;function Wfe(e){let t=(0,Q.c)(21),[n,r]=(0,Z.useState)(Gfe),{data:i,error:a,isLoading:o,mutate:s}=mI(e),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={revalidateOnFocus:!1},t[0]=c):c=t[0];let{data:l,isLoading:u,error:d,mutate:f}=ie(e?E3:null,O3,c),p=!e||!o&&!u,m=i?.payload?.config,h;t[1]!==a||t[2]!==e||t[3]!==l||t[4]!==d||t[5]!==p||t[6]!==m?(h=Hfe({enabled:e,ready:p,configError:a,modelsError:d,config:m,modelsData:l}),t[1]=a,t[2]=e,t[3]=l,t[4]=d,t[5]=p,t[6]=m,t[7]=h):h=t[7];let g=h,_;t[8]!==s||t[9]!==f?(_=async()=>{await Promise.all([s(),f()])},t[8]=s,t[9]=f,t[10]=_):_=t[10];let v=_,y,b;t[11]!==e||t[12]!==f?(y=()=>{if(!e)return;let t=()=>{f()};return window.addEventListener(`config-reload`,t),()=>window.removeEventListener(`config-reload`,t)},b=[e,f],t[11]=e,t[12]=f,t[13]=y,t[14]=b):(y=t[13],b=t[14]),(0,Z.useEffect)(y,b);let x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{try{localStorage.setItem(Ufe,`1`)}catch{}r(!0)},t[15]=x):x=t[15];let S=x,C;return t[16]!==n||t[17]!==g||t[18]!==p||t[19]!==v?(C={needsSetup:g,ready:p,refresh:v,guideDismissed:n,dismissPermanently:S},t[16]=n,t[17]=g,t[18]=p,t[19]=v,t[20]=C):C=t[20],C}function Gfe(){return typeof localStorage<`u`&&localStorage.getItem(`xopc-onboarding-model-setup-dismissed`)===`1`}function Kfe(){let e=(0,Q.c)(21),t=q(Zfe),n=_(Xfe),r;e[0]===n?r=e[1]:(r=m(n),e[0]=n,e[1]=r);let i=r,a=br(),o=Wfe(!!t),s=!!t&&o.ready&&o.needsSetup,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(RN,{className:`fixed inset-0 z-[55] bg-scrim backdrop-blur-[2px]`}),e[2]=c):c=e[2];let l;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=u(`fixed left-1/2 top-1/2 z-[56] max-h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,36rem)] -translate-x-1/2 -translate-y-1/2 overflow-y-auto`,`rounded-xl p-2 outline-none sm:p-3`),e[3]=l):l=e[3];let d;e[4]===i.onboarding.title?d=e[5]:(d=(0,$.jsx)(BN,{className:`sr-only`,children:i.onboarding.title}),e[4]=i.onboarding.title,e[5]=d);let f;e[6]===i.onboarding.subtitle?f=e[7]:(f=(0,$.jsx)(VN,{className:`sr-only`,children:i.onboarding.subtitle}),e[6]=i.onboarding.subtitle,e[7]=f);let p;e[8]!==o||e[9]!==a?(p=async()=>{await o.refresh(),a(`/chat`)},e[8]=o,e[9]=a,e[10]=p):p=e[10];let h;e[11]!==o.dismissPermanently||e[12]!==p?(h=(0,$.jsx)(Bfe,{onComplete:p,onDismiss:o.dismissPermanently,canDismiss:!1}),e[11]=o.dismissPermanently,e[12]=p,e[13]=h):h=e[13];let g;e[14]!==d||e[15]!==f||e[16]!==h?(g=(0,$.jsxs)(LN,{children:[c,(0,$.jsxs)(zN,{className:l,onPointerDownOutside:Yfe,onEscapeKeyDown:Jfe,onOpenAutoFocus:qfe,children:[d,f,h]})]}),e[14]=d,e[15]=f,e[16]=h,e[17]=g):g=e[17];let v;return e[18]!==s||e[19]!==g?(v=(0,$.jsx)(FN,{open:s,children:g}),e[18]=s,e[19]=g,e[20]=v):v=e[20],v}function qfe(e){return e.preventDefault()}function Jfe(e){return e.preventDefault()}function Yfe(e){return e.preventDefault()}function Xfe(e){return e.language}function Zfe(e){return e.token}var $3=`--toast-top-inset`,Qfe=8;function $fe(e){let t=(0,Q.c)(4),{children:n}=e,r=(0,Z.useRef)(null),i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=r.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().height;t>0?document.documentElement.style.setProperty($3,`${Math.ceil(t+Qfe)}px`):document.documentElement.style.removeProperty($3)};t();let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect(),document.documentElement.style.removeProperty($3)}},a=[],t[0]=i,t[1]=a):(i=t[0],a=t[1]),(0,Z.useEffect)(i,a);let o;return t[2]===n?o=t[3]:(o=(0,$.jsx)(`div`,{ref:r,className:`shrink-0`,children:n}),t[2]=n,t[3]=o),o}function epe(){let e=(0,Q.c)(3),t=br(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=e=>{let n=e.detail;n?.sessionKey&&t(`/chat/${encodeURIComponent(n.sessionKey)}`)};return window.addEventListener(`navigate-to-chat`,e),()=>window.removeEventListener(`navigate-to-chat`,e)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function tpe(){let e=(0,Q.c)(3),t=br(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=e=>{let n=e.detail,r=typeof n?.path==`string`?n.path.trim():``;r&&t(r.startsWith(`/`)?r:`/${r}`)};return window.addEventListener(`extension-navigate`,e),()=>window.removeEventListener(`extension-navigate`,e)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function npe(){let e=(0,Q.c)(49),t=q(ape),{pathname:n}=_r(),r;e[0]===n?r=e[1]:(r=n.startsWith(`/settings`),e[0]=n,e[1]=r);let i=r,a=_(ipe),o=oP(),s=k1(rpe);if(!t){let t,n;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(H2,{}),n=(0,$.jsx)(q2,{}),e[2]=t,e[3]=n):(t=e[2],n=e[3]);let r;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[t,n,(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Qj,{})})]}),e[4]=r):r=e[4],r}let c;e[5]===n?c=e[6]:(c=n.split(`/`)[1]??`root`,e[5]=n,e[6]=c);let l=c,d=l===`chat`||l===`notes`,f=a===`zh`?`跳到主要内容`:`Skip to main content`,p;e[7]===f?p=e[8]:(p=(0,$.jsx)(`a`,{href:`#app-main-content`,className:`sr-only z-[80] rounded-lg bg-surface-panel px-3 py-2 text-sm text-fg shadow-elevated focus:not-sr-only focus:absolute focus:left-4 focus:top-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:f}),e[7]=f,e[8]=p);let m,h,g,v,y,b,x,S,C,w,T;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(vde,{}),x=(0,$.jsx)(Ade,{}),S=(0,$.jsx)(Lce,{}),C=(0,$.jsx)(q2,{}),w=(0,$.jsx)(epe,{}),T=(0,$.jsx)(tpe,{}),m=(0,$.jsx)(Sue,{}),h=(0,$.jsx)(ode,{}),g=(0,$.jsx)(oM,{}),v=(0,$.jsx)(j1,{}),y=(0,$.jsx)(Kfe,{}),e[9]=m,e[10]=h,e[11]=g,e[12]=v,e[13]=y,e[14]=b,e[15]=x,e[16]=S,e[17]=C,e[18]=w,e[19]=T):(m=e[9],h=e[10],g=e[11],v=e[12],y=e[13],b=e[14],x=e[15],S=e[16],C=e[17],w=e[18],T=e[19]);let E;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(H2,{}),e[20]=E):E=e[20];let D;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(Hce,{}),e[21]=D):D=e[21];let O;e[22]===o?O=e[23]:(O=(0,$.jsx)(ule,{reminder:o}),e[22]=o,e[23]=O);let k;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(Yce,{}),e[24]=k):k=e[24];let A;e[25]===O?A=e[26]:(A=(0,$.jsxs)($fe,{children:[D,O,k]}),e[25]=O,e[26]=A);let j;e[27]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(oq,{}),e[27]=j):j=e[27];let M;e[28]!==i||e[29]!==s?(M=!i&&!s?(0,$.jsx)(XM,{}):null,e[28]=i,e[29]=s,e[30]=M):M=e[30];let N;e[31]!==s||e[32]!==l||e[33]!==d?(N=(0,$.jsx)(`main`,{id:`app-main-content`,className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:s==null?(0,$.jsx)(`div`,{className:u(`page-enter flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,l===`settings`?`page-enter--gentle overflow-hidden`:d?`overflow-hidden`:`overflow-y-auto overscroll-contain [scrollbar-gutter:stable_both-edges]`),children:(0,$.jsx)(ai,{})},l):(0,$.jsx)(Gde,{})}),e[31]=s,e[32]=l,e[33]=d,e[34]=N):N=e[34];let P;e[35]!==M||e[36]!==N?(P=(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[M,N]}),e[35]=M,e[36]=N,e[37]=P):P=e[37];let F;e[38]===i?F=e[39]:(F=i?null:(0,$.jsx)(A1,{}),e[38]=i,e[39]=F);let I;e[40]!==P||e[41]!==F?(I=(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-row overflow-hidden`,children:[j,(0,$.jsx)(`div`,{className:`app-main-surface flex min-h-0 min-w-0 flex-1 min-w-0 flex-col overflow-hidden bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-row overflow-hidden`,children:[P,F]})})]}),e[40]=P,e[41]=F,e[42]=I):I=e[42];let L;e[43]!==A||e[44]!==I?(L=(0,$.jsxs)(`div`,{className:`app-chrome-shell flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[E,A,I]}),e[43]=A,e[44]=I,e[45]=L):L=e[45];let R;return e[46]!==L||e[47]!==p?(R=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[p,b,x,S,C,w,T,m,h,g,v,y,L]}),e[46]=L,e[47]=p,e[48]=R):R=e[48],R}function rpe(e){return e.path}function ipe(e){return e.language}function ape(e){return e.token}var ope=(0,Z.memo)(function(e){let t=(0,Q.c)(19),{className:n}=e,r=_(spe),i;t[0]===r?i=t[1]:(i=m(r),t[0]=r,t[1]=i);let a=i.settingsMode,o=r4(cpe),s=r4(lpe),c;t[2]===n?c=t[3]:(c=u(`shrink-0 border-t border-edge-subtle/80 px-4 py-3`,n),t[2]=n,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(aC,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=l):l=t[4];let d;t[5]===a.toggleLabel?d=t[6]:(d=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-sm font-medium text-fg`,children:a.toggleLabel}),t[5]=a.toggleLabel,t[6]=d);let f;t[7]===s?f=t[8]:(f=e=>s(e.target.checked),t[7]=s,t[8]=f);let p;t[9]!==a.toggleAria||t[10]!==o||t[11]!==f?(p=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5 shrink-0`,checked:o,onChange:f,"aria-label":a.toggleAria}),t[9]=a.toggleAria,t[10]=o,t[11]=f,t[12]=p):p=t[12];let h;t[13]!==d||t[14]!==p?(h=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-xl bg-surface-hover/35 px-3 py-2.5 transition-colors hover:bg-surface-hover/55 dark:bg-surface-hover/20 dark:hover:bg-surface-hover/35`,children:[l,d,p]}),t[13]=d,t[14]=p,t[15]=h):h=t[15];let g;return t[16]!==c||t[17]!==h?(g=(0,$.jsx)(`div`,{className:c,children:h}),t[16]=c,t[17]=h,t[18]=g):g=t[18],g});function spe(e){return e.language}function cpe(e){return e.mode===`advanced`}function lpe(e){return e.setShowAdvanced}var upe={chat:Hv,sessions:__,automations:wk,skills:Cv,connectors:Iy,goals:rE,channels:Iy,agents:dO,logs:_g,settingsOverview:Zi,settingsCredentials:xv,settingsAppearance:$v,settingsKeyboardShortcuts:Sv,settingsSystem:kS,settingsDesktopPet:iy,settingsDesktopApp:Qv,settingsAgentBrowser:ov,settingsUserProfile:Qd,settingsCapabilityPresets:Cv,settingsAgents:dO,settingsProviders:np,settingsModels:Gp,settingsImageModels:_v,settingsChannels:Iy,settingsVoice:Uv,settingsGateway:ov,settingsHeartbeat:fv,settingsTunnel:ub,settingsSearch:Qx,settingsShares:fS,settingsDreams:Jv,settingsGoals:rE};function dpe(e){let t=(0,Q.c)(3),{tab:n,className:r}=e,i=upe[n],a;return t[0]!==i||t[1]!==r?(a=(0,$.jsx)(i,{className:r,strokeWidth:1.75,"aria-hidden":!0}),t[0]=i,t[1]=r,t[2]=a):a=t[2],a}function fpe(e){let t=(0,Q.c)(34),{navLinkClassName:n,showAdvanced:r}=e,i=r===void 0?!0:r,a=_(ppe),o;t[0]===a?o=t[1]:(o=m(a),t[0]=a,t[1]=o);let s=o,c=BF(),l,u,d,f,p;if(t[2]!==s||t[3]!==n||t[4]!==i||t[5]!==c){p=Symbol.for(`react.early_return_sentinel`);bb0:{let e=mpe(c);if(!i){p=null;break bb0}t[11]===s.settingsNavGroups.extensions?f=t[12]:(f=(0,$.jsx)(`p`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wider text-fg-muted`,children:s.settingsNavGroups.extensions}),t[11]=s.settingsNavGroups.extensions,t[12]=f),l=`flex flex-col gap-0.5`;let r;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(ll,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=r):r=t[13];let a;t[14]===s.extensionDebug.nav?a=t[15]:(a=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:s.extensionDebug.nav}),t[14]=s.extensionDebug.nav,t[15]=a),t[16]!==n||t[17]!==a?(u=(0,$.jsxs)(Ui,{to:`/settings/extensions/debug`,className:n,children:[r,a]}),t[16]=n,t[17]=a,t[18]=u):u=t[18];let o;t[19]===n?o=t[20]:(o=e=>{let{extension:t,panel:r}=e;return(0,$.jsxs)(Ui,{to:`/settings/ext/${t.id}/${r.id}`,className:n,children:[(0,$.jsx)($y,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.title})]},`${t.id}:${r.id}`)},t[19]=n,t[20]=o),d=e.map(o)}t[2]=s,t[3]=n,t[4]=i,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p}else l=t[6],u=t[7],d=t[8],f=t[9],p=t[10];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let h;if(t[21]!==n||t[22]!==c){let e;t[24]===n?e=t[25]:(e=e=>(0,$.jsxs)(Ui,{to:`/settings/ext/${e.id}`,className:n,children:[(0,$.jsx)($y,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]},`${e.id}:config`),t[24]=n,t[25]=e),h=hpe(c).map(e),t[21]=n,t[22]=c,t[23]=h}else h=t[23];let g;t[26]!==l||t[27]!==u||t[28]!==d||t[29]!==h?(g=(0,$.jsxs)(`div`,{className:l,children:[u,d,h]}),t[26]=l,t[27]=u,t[28]=d,t[29]=h,t[30]=g):g=t[30];let v;return t[31]!==f||t[32]!==g?(v=(0,$.jsxs)(`div`,{children:[f,g]}),t[31]=f,t[32]=g,t[33]=v):v=t[33],v}function ppe(e){return e.language}function mpe(e){let t=[];for(let n of e){let e=n.ui?.contributions?.settingsPanels;if(e)for(let r of e)t.push({extension:n,panel:r})}return t.sort((e,t)=>{let n=e.panel.order??999,r=t.panel.order??999;return n===r?e.panel.title.localeCompare(t.panel.title):n-r}),t}function hpe(e){return e.filter(e=>(!!e.hasConfigSchema||NF(e))&&!(Array.isArray(e.ui?.contributions?.settingsPanels)&&e.ui.contributions.settingsPanels.length>0))}function gpe(e,t){let n=globalThis.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)}function _pe(e){return globalThis.matchMedia(e).matches}function e6(e,t){let n=(0,Q.c)(5),r=t===void 0?!1:t,i,a;n[0]===e?(i=n[1],a=n[2]):(i=t=>gpe(e,t),a=()=>_pe(e),n[0]=e,n[1]=i,n[2]=a);let o;return n[3]===r?o=n[4]:(o=()=>r,n[3]=r,n[4]=o),(0,Z.useSyncExternalStore)(i,a,o)}var t6=`settingsBackPath`;function n6(e){if(!e||typeof e!=`object`)return`/chat`;let t=e[t6];if(typeof t!=`string`)return`/chat`;let n=t.trim();return!n.startsWith(`/`)||n.startsWith(`//`)?`/chat`:n}var r6=`xopc-web-settings-rail-width-px`;function i6(e){return Math.min(360,Math.max(192,Math.round(e)))}function vpe(){try{let e=globalThis.localStorage?.getItem(r6);if(e==null)return i6(228);let t=Number.parseInt(e,10);return i6(Number.isFinite(t)?t:228)}catch{return i6(228)}}function ype(e){try{globalThis.localStorage?.setItem(r6,String(e))}catch{}}var a6=h((e,t)=>({widthPx:vpe(),setWidthPx:n=>{let r=i6(n);t().widthPx!==r&&(e({widthPx:r}),queueMicrotask(()=>ype(r)))}}));function o6({isActive:e}){return u(`flex w-full shrink-0 items-center gap-2.5 rounded-xl px-4 py-2 text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,e?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`)}var bpe=u(`inline-flex max-w-full items-center gap-2 rounded-xl px-3 py-2 text-sm font-medium transition-colors duration-200 ease-out`,`text-fg-muted hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`sm:px-4`),s6=u(`inline-flex size-10 shrink-0 items-center justify-center rounded-xl text-fg-muted transition-colors duration-200 ease-out`,`hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,uM);function c6(e,t){return e.tabs.filter(e=>$2(e,t)?!Uj.has(e)||fM():!1)}function xpe(e){let t=(0,Q.c)(26),{group:n,groupIndex:r,language:i,location:a,settingsMode:o}=e,s;t[0]===i?s=t[1]:(s=m(i),t[0]=i,t[1]=s);let c=s,l,d,f,h;if(t[2]!==n||t[3]!==r||t[4]!==i||t[5]!==a||t[6]!==c||t[7]!==o){h=Symbol.for(`react.early_return_sentinel`);bb0:{let e=c6(n,o);if(e.length===0){h=null;break bb0}let s=r===0&&`pt-0`,m;t[12]===s?m=t[13]:(m=u(`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wider text-fg-muted`,s),t[12]=s,t[13]=m);let g=c.settingsNavGroups[n.id];t[14]!==m||t[15]!==g?(f=(0,$.jsx)(`p`,{className:m,children:g}),t[14]=m,t[15]=g,t[16]=f):f=t[16],l=`flex flex-col gap-0.5`;let _;t[17]!==i||t[18]!==a?(_=e=>(0,$.jsxs)(Ui,{to:Zj(e),state:a.state,onMouseEnter:()=>xF(Zj(e)),onFocus:()=>xF(Zj(e)),className:Spe,children:[(0,$.jsx)(dpe,{tab:e,className:`size-5 shrink-0 opacity-90`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p(i,e)})]},e),t[17]=i,t[18]=a,t[19]=_):_=t[19],d=e.map(_)}t[2]=n,t[3]=r,t[4]=i,t[5]=a,t[6]=c,t[7]=o,t[8]=l,t[9]=d,t[10]=f,t[11]=h}else l=t[8],d=t[9],f=t[10],h=t[11];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let g;t[20]!==l||t[21]!==d?(g=(0,$.jsx)(`div`,{className:l,children:d}),t[20]=l,t[21]=d,t[22]=g):g=t[22];let _;return t[23]!==f||t[24]!==g?(_=(0,$.jsxs)(`div`,{children:[f,g]}),t[23]=f,t[24]=g,t[25]=_):_=t[25],_}function Spe(e){let{isActive:t}=e;return o6({isActive:t})}var Cpe=(0,Z.memo)(function(){let e=(0,Q.c)(86),t=_(wpe),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n,i=_r(),a=r4(Tpe),o=a6(Epe),s=a6(Dpe),[c,l]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),h=e6(pj),g=mM({runtime:pM(),sidebarCollapsed:!1,mobileNavOpen:d}),v=h?g.sidebarLeadingInsetClass:``,y;e[2]===s?y=e[3]:(y=e=>{e.preventDefault();let t=e.currentTarget,n=t.parentElement;t.setPointerCapture(e.pointerId),l(!0);let r=e.clientX,i=a6.getState().widthPx,a=e.pointerId,o=0,c=i,u=i,d=()=>{o=0,u=c,n?.style.setProperty(`--settings-rail-px`,`${u}px`)},f=e=>{c=i6(i+(e.clientX-r)),o===0&&(o=window.requestAnimationFrame(d))},p=()=>{o!==0&&(window.cancelAnimationFrame(o),d());try{t.releasePointerCapture(a)}catch{}l(!1),s(u),window.removeEventListener(`pointermove`,f),window.removeEventListener(`pointerup`,p),window.removeEventListener(`pointercancel`,p)};window.addEventListener(`pointermove`,f),window.addEventListener(`pointerup`,p),window.addEventListener(`pointercancel`,p)},e[2]=s,e[3]=y);let b=y,x;e[4]===i.state?x=e[5]:(x=n6(i.state),e[4]=i.state,e[5]=x);let S=x,C=r.sidebar.backToApp,w;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(w=u(bpe,uM),e[6]=w):w=e[6];let T;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(to,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),e[7]=T):T=e[7];let E;e[8]===C?E=e[9]:(E=(0,$.jsx)(`span`,{children:C}),e[8]=C,e[9]=E);let D;e[10]!==C||e[11]!==S||e[12]!==E?(D=(0,$.jsxs)(Hi,{to:S,replace:!1,className:w,title:C,children:[T,E]}),e[10]=C,e[11]=S,e[12]=E,e[13]=D):D=e[13];let O=D,k;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(k=[...Gj,...fM()?[Wj]:[]],e[14]=k):k=e[14];let A=k,j;e[15]!==i.pathname||e[16]!==a?(j=A.flatMap(e=>c6(e,a)).find(e=>i.pathname===Zj(e)),e[15]=i.pathname,e[16]=a,e[17]=j):j=e[17];let M=j,N;e[18]!==i.pathname||e[19]!==a?(N=e4(i.pathname,a),e[18]=i.pathname,e[19]=a,e[20]=N):N=e[20];let P=!N,F;e[21]!==M||e[22]!==t||e[23]!==r.nav.settings?(F=M?p(t,M):r.nav.settings,e[21]=M,e[22]=t,e[23]=r.nav.settings,e[24]=F):F=e[24];let I=F,L;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{f(!1)},e[25]=L):L=e[25];let R;e[26]!==i.pathname||e[27]!==i.search?(R=[i.pathname,i.search],e[26]=i.pathname,e[27]=i.search,e[28]=R):R=e[28],(0,Z.useEffect)(L,R);let z=r.nav.settings,B;e[29]!==t||e[30]!==i||e[31]!==a?(B=A.map((e,n)=>(0,$.jsx)(xpe,{group:e,groupIndex:n,language:t,location:i,settingsMode:a},e.id)),e[29]=t,e[30]=i,e[31]=a,e[32]=B):B=e[32];let V=a===`advanced`,H;e[33]===V?H=e[34]:(H=(0,$.jsx)(fpe,{navLinkClassName:o6,showAdvanced:V}),e[33]=V,e[34]=H);let U;e[35]!==B||e[36]!==H?(U=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[B,H]}),e[35]=B,e[36]=H,e[37]=U):U=e[37];let W;e[38]!==r.nav.settings||e[39]!==U?(W=(0,$.jsx)(`nav`,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 pb-4 pt-2`,"aria-label":z,children:U}),e[38]=r.nav.settings,e[39]=U,e[40]=W):W=e[40];let G;e[41]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(ope,{}),e[41]=G):G=e[41];let K;e[42]===W?K=e[43]:(K=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[W,G]}),e[42]=W,e[43]=K);let q=K,ee;e[44]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(to,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),e[44]=ee):ee=e[44];let J;e[45]!==C||e[46]!==S?(J=(0,$.jsx)(Hi,{to:S,className:s6,title:C,"aria-label":C,children:ee}),e[45]=C,e[46]=S,e[47]=J):J=e[47];let te;e[48]===r.nav.settings?te=e[49]:(te=(0,$.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wider text-fg-subtle`,children:r.nav.settings}),e[48]=r.nav.settings,e[49]=te);let Y;e[50]===I?Y=e[51]:(Y=(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:I}),e[50]=I,e[51]=Y);let ne;e[52]!==te||e[53]!==Y?(ne=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[te,Y]}),e[52]=te,e[53]=Y,e[54]=ne):ne=e[54];let re;e[55]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>f(!0),e[55]=re):re=e[55];let X;e[56]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,$.jsx)(zv,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),e[56]=X):X=e[56];let ie;e[57]!==r.nav.settings||e[58]!==d?(ie=(0,$.jsx)(`button`,{type:`button`,className:s6,onClick:re,"aria-label":r.nav.settings,"aria-expanded":d,children:X}),e[57]=r.nav.settings,e[58]=d,e[59]=ie):ie=e[59];let ae;e[60]!==O||e[61]!==r.nav.settings||e[62]!==d||e[63]!==q?(ae=d?(0,$.jsxs)(`div`,{className:`fixed inset-0 z-60 md:hidden`,role:`presentation`,children:[(0,$.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-scrim/45 backdrop-blur-[1px]`,onClick:()=>f(!1),"aria-label":r.nav.settings}),(0,$.jsxs)(`aside`,{className:`app-chrome-sidebar absolute inset-y-0 left-0 flex w-[min(20rem,calc(100vw-3rem))] flex-col bg-surface-rail shadow-float`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 px-4 pb-2 pt-4`,children:[O,(0,$.jsx)(`button`,{type:`button`,className:s6,onClick:()=>f(!1),"aria-label":r.nav.settings,children:(0,$.jsx)(Sk,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})})]}),q]})]}):null,e[60]=O,e[61]=r.nav.settings,e[62]=d,e[63]=q,e[64]=ae):ae=e[64];let oe=c&&`settings-page-rail-resizing`,se;e[65]===oe?se=e[66]:(se=u(`app-chrome-sidebar relative hidden shrink-0 flex-col bg-surface-rail md:flex`,`md:h-full md:min-h-0 md:shrink-0 md:overflow-hidden`,`settings-page-rail`,oe),e[65]=oe,e[66]=se);let ce=`${o}px`,le;e[67]===ce?le=e[68]:(le={"--settings-rail-px":ce},e[67]=ce,e[68]=le);let ue=le,de=u(`flex shrink-0 items-center justify-start pb-2 pt-4`,g.sidebarChromeDraggable&&`[-webkit-app-region:drag]`,v,h&&g.sidebarLeadingInsetClass?`pr-4`:`px-4`),fe;e[69]!==O||e[70]!==de?(fe=(0,$.jsx)(`div`,{className:de,children:O}),e[69]=O,e[70]=de,e[71]=fe):fe=e[71];let pe=r.sidebar.resizeHandleAria,me=c&&`bg-surface-hover/30 before:bg-edge/80! dark:before:bg-edge/85!`,he;e[72]===me?he=e[73]:(he=u(`pointer-events-auto absolute right-0 top-0 z-10 hidden h-full w-2 shrink-0 cursor-col-resize md:block`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:z-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:bg-surface-hover/20 hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,me,`transition-[background-color] duration-150`,`touch-none select-none`,uM),e[72]=me,e[73]=he);let ge;e[74]!==r.sidebar.resizeHandleAria||e[75]!==b||e[76]!==he?(ge=(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":pe,onPointerDown:b,className:he}),e[74]=r.sidebar.resizeHandleAria,e[75]=b,e[76]=he,e[77]=ge):ge=e[77];let _e;e[78]!==q||e[79]!==se||e[80]!==ue||e[81]!==fe||e[82]!==ge?(_e=(0,$.jsxs)(`div`,{className:se,style:ue,children:[fe,q,ge]}),e[78]=q,e[79]=se,e[80]=ue,e[81]=fe,e[82]=ge,e[83]=_e):_e=e[83];let ve;return e[84]===P?ve=e[85]:(ve=(0,$.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain bg-surface-panel scrollbar-gutter-both`,children:P?(0,$.jsx)(ii,{to:`/settings/overview`,replace:!0}):(0,$.jsx)(ai,{})}),e[84]=P,e[85]=ve),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:[(0,$.jsxs)(`div`,{className:u(`flex shrink-0 items-center gap-2 border-b border-edge-subtle bg-surface-panel px-3 py-2 md:hidden`,g.mainHeaderDraggable&&`[-webkit-app-region:drag]`),children:[J,ne,ie]}),ae,_e,ve]})});function wpe(e){return e.language}function Tpe(e){return e.mode}function Epe(e){return e.widthPx}function Dpe(e){return e.setWidthPx}var Ope=(0,Z.memo)(function(e){let t=(0,Q.c)(26),{children:n}=e,r=br(),i=_r(),a=_(kpe),o;t[0]===a?o=t[1]:(o=m(a),t[0]=a,t[1]=o);let s=o,c;t[2]===i.state?c=t[3]:(c=n6(i.state),t[2]=i.state,t[3]=c);let l=c,d=e6(pj),f,p;t[4]!==l||t[5]!==r?(f=()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),r(l))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},p=[r,l],t[4]=l,t[5]=r,t[6]=f,t[7]=p):(f=t[6],p=t[7]),(0,Z.useEffect)(f,p);let h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[8]=h):h=t[8],(0,Z.useEffect)(Ape,h);let g;t[9]!==l||t[10]!==r?(g=(0,$.jsx)(`div`,{role:`presentation`,className:`absolute inset-0 z-40 bg-scrim/55 backdrop-blur-[2px] dark:bg-black/50`,onClick:()=>r(l)}),t[9]=l,t[10]=r,t[11]=g):g=t[11];let v=g,y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=u(`relative z-50 flex min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,`max-md:shadow-elevated`,`md:m-3 md:max-h-[calc(100dvh-1.5rem)] md:rounded-2xl md:border md:border-edge md:shadow-elevated`,`settings-sheet-enter`),t[12]=y):y=t[12];let b;t[13]===n?b=t[14]:(b=(0,$.jsx)(xj,{layer:`page`,children:n}),t[13]=n,t[14]=b);let x;t[15]!==s.nav.settings||t[16]!==b?(x=(0,$.jsx)(`div`,{className:y,role:`dialog`,"aria-modal":`true`,"aria-label":s.nav.settings,children:b}),t[15]=s.nav.settings,t[16]=b,t[17]=x):x=t[17];let S=x,C;t[18]!==S||t[19]!==v?(C=(0,$.jsxs)($.Fragment,{children:[v,S]}),t[18]=S,t[19]=v,t[20]=C):C=t[20];let w=C;if(d){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=u(`fixed inset-0 flex min-h-0 flex-col bg-surface-base`,mj),t[21]=e):e=t[21];let n;return t[22]===w?n=t[23]:(n=(0,Xi.createPortal)((0,$.jsx)(`div`,{className:e,children:w}),document.body),t[22]=w,t[23]=n),n}let T;return t[24]===w?T=t[25]:(T=(0,$.jsx)(`div`,{className:`relative flex min-h-0 min-h-[100dvh] flex-1 flex-col md:min-h-0`,children:w}),t[24]=w,t[25]=T),T});function kpe(e){return e.language}function Ape(){let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}}var l6=`image/*,application/pdf,.docx,.pptx,.xlsx,.xls,.txt,.md,.json,.xml,.html,.css,.js,.ts,.jsx,.tsx,.yml,.yaml,.zip`,jpe=l6.split(`,`).flatMap(e=>{let t=e.trim();return t?[t]:[]});function Mpe(e){return`${e.name}\0${e.size}`}function Npe(e){let t=(e.type||``).toLowerCase(),n=e.name.toLowerCase();for(let e of jpe){let r=e.toLowerCase();if(r.endsWith(`/*`)){let e=r.slice(0,-1);if(t.startsWith(e))return!0}else if(e.startsWith(`.`)){if(n.endsWith(e.toLowerCase()))return!0}else if(t===r)return!0}return!1}function Ppe(e){if(!e)return[];let t=new Set,n=[],r=e=>{if(!e||e.size===0)return;let r=Mpe(e);t.has(r)||(t.add(r),n.push(e))},{files:i}=e;if(i?.length)for(let e=0;e<i.length;e++)r(i.item(e));for(let t of Array.from(e.items??[]))t.kind===`file`&&r(t.getAsFile());return n}var u6=String.raw`a-zA-Z0-9_./\-\p{L}\p{N}`,d6=`[${u6}]+`,f6=String.raw`(?:[^"\\]|\\.)*`,p6=String.raw`((?:[^"\\]|\\.)*)`,Fpe=RegExp(`^[${u6}]+$`,`u`);function Ipe(e){return e.replace(/\\(.)/g,(e,t)=>t)}var Lpe=RegExp(`@file:(?:"${p6}"|(${d6}))`,`gu`),Rpe=RegExp(`(@file:(?:"${f6}"|${d6}))$`,`u`),zpe=RegExp(`(@file:(?:"${f6}"|${d6}))([ \\t\\f\\v]*)$`,`u`),m6=`(?:"${f6}"|${d6})`;function Bpe(e){let t=e.lastIndexOf(`@file:`);return t===-1?!1:RegExp(`^@file:${m6}$`,`u`).test(e.slice(t))}function h6(e){let t=e[2];if(t!=null&&t!==``)return t;let n=e[1];return n==null?``:Ipe(n)}function g6(e){return Fpe.test(e)?e:`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function _6(){return new RegExp(Lpe.source,`gu`)}var v6=RegExp(`^@file:(?:"${p6}"|(${d6}))`,`u`),y6=`​`,b6=`⁠`,x6=RegExp(`^\\/skill:(${c4})`);function Vpe(e){return!!e.dataset.skill}function Hpe(e){return!!e.dataset.file}function Upe(e){return e.dataset.slashCommand!=null&&e.dataset.slashCommand!==``}function Wpe(e){let t=e.replace(/\/$/,``);return`@${t.split(`/`).pop()??t}`}function S6(e){let t=``;for(let n of e)if(n){if(t.length>0){let e=t[t.length-1],r=n[0];if(!/\s/.test(e)&&!/\s/.test(r)){let e=Bpe(t)||/\/skill:\S+$/.test(t)||zle(t),r=n.startsWith(`@file:`)||n.startsWith(`/skill:`)||Ble(n);(e||r)&&(t+=` `)}}t+=n}return t}function C6(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e.tagName;return t===`DIV`||t===`P`||t===`PRE`||t===`BLOCKQUOTE`}function Gpe(e,t){if(e.nodeType===Node.TEXT_NODE)t.push((e.textContent??``).replaceAll(y6,``));else if(e.nodeType===Node.ELEMENT_NODE){let n=e;if(Vpe(n)){let e=n.dataset.skill??``;e&&t.push(`/skill:${e}`)}else if(Hpe(n)){let e=n.dataset.file??``;e&&t.push(`@file:${g6(e)}`)}else if(Upe(n)){let e=n.dataset.slashCommand??``;e&&t.push(`/${e}`)}else n.tagName===`BR`?t.push(`
224
224
  `):w6(n,t)}}function w6(e,t){let n=Array.from(e.childNodes);for(let e=0;e<n.length;e++){let r=n[e],i=n[e+1];Gpe(r,t),i!=null&&(C6(r)||C6(i))&&t.push(`
225
225
  `)}}function T6(e,t){w6(e,t)}function E6(e){let t=[];return T6(e,t),S6(t).replaceAll(b6,``)}function Kpe(e){let t=window.getSelection();if(!t)return;let n=document.createRange(),r=e.firstChild;r&&r.nodeType===Node.TEXT_NODE?(n.setStart(r,0),n.collapse(!0)):(n.setStart(e,0),n.collapse(!0)),t.removeAllRanges(),t.addRange(n)}function D6(e){let t=E6(e);return t.length>0||e.childNodes.length===0?t:(k6(e,``),Kpe(e),``)}function qpe(e){let t=new Set,n=l4(),r;for(;(r=n.exec(e))!==null;){let e=r[1];e&&t.add(e)}return t}function O6(e){let t=window.getSelection();if(!t||t.rangeCount===0)return E6(e).length;let n=t.getRangeAt(0),r=document.createTextNode(b6);try{n.insertNode(r)}catch{return E6(e).length}let i=[];T6(e,i);let a=S6(i);r.parentNode?.removeChild(r);let o=a.indexOf(b6);return o>=0?o:a.replaceAll(b6,``).length}function Jpe(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.skill=t,n.className=`chat-skill-pill`,n.textContent=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(y6))}function Ype(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.file=t,n.className=`chat-file-pill`,n.textContent=Wpe(t),e.appendChild(n),e.appendChild(document.createTextNode(y6))}function Xpe(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.slashCommand=t,n.className=`chat-command-pill`,n.textContent=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(y6))}function Zpe(e){let t=[],n=n=>{let r,i=new RegExp(n.source,n.flags);for(;(r=i.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length})};n(l4()),n(_6());for(let n of m4(e))t.push(n);return t.sort((e,t)=>e.start-t.start),t}function Qpe(e,t){for(let{start:n,end:r}of Zpe(e))if(t>n&&t<=r)return{wire:e.slice(0,n)+e.slice(r),caret:n};return null}function $pe(e,t){if(t<=0)return null;let n=e.slice(0,t),r=r=>{let i=n.match(r);if(i?.[1]){let r=i[1],a=n.length-r.length;return{wire:e.slice(0,a)+e.slice(t),caret:a}}return null},i=[Mle,Rpe];for(let e of i){let t=r(e);if(t)return t}let a=Ule(n);if(a){let n=a.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}if(t===e.length){let r=[Nle,zpe];for(let i of r){let r=n.match(i);if(r?.[1]){let i=r[0],a=n.length-i.length;return{wire:e.slice(0,a)+e.slice(t),caret:a}}}let i=Wle(n);if(i){let n=i.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}}return null}function eme(e){let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;let n=t.getRangeAt(0),r=E6(e),i=O6(e);i===0&&r.length>0&&n.startContainer===e&&n.startOffset===e.childNodes.length&&(i=r.length);let a=Qpe(r,i);return a||=$pe(r,i),a?(k6(e,a.wire,a.caret),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0})),!0):!1}function tme(e,t){let n=e.slice(t);return x6.test(n)||v6.test(n)?!0:p4(e,t)!=null}function nme(e,t,n){let r=t.slice(n),i=[],a=r.match(x6);a?.[0]&&i.push({len:a[0].length,apply:()=>Jpe(e,a[1]??``)});let o=r.match(v6);o?.[0]&&i.push({len:o[0].length,apply:()=>Ype(e,h6(o))});let s=p4(t,n);if(s&&i.push({len:s.len,apply:()=>Xpe(e,s.matchedKey)}),i.length===0){let r=n+1;for(;r<t.length&&!tme(t,r);)r+=1;let i=t.slice(n,r);return i&&e.appendChild(document.createTextNode(i)),r}return i.sort((e,t)=>t.len-e.len),i[0].apply(),n+i[0].len}function k6(e,t,n){e.replaceChildren();let r=t;if(n!==void 0){let e=Math.max(0,Math.min(n,t.length));r=t.slice(0,e)+b6+t.slice(e)}let i=0;for(;i<r.length;)i=nme(e,r,i);if(n===void 0)return;let a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o;for(;o=a.nextNode();){let e=o.textContent??``,t=-1;for(let n=0;n<e.length;n++)if(e[n]===b6){t=n;break}if(t>=0){let n=o;n.textContent=e.slice(0,t)+e.slice(t+1);let r=window.getSelection(),i=document.createRange();i.setStart(n,t),i.collapse(!0),r?.removeAllRanges(),r?.addRange(i);return}}}function rme(e,t){for(let n of e)if(n.isActive()&&n.handleKey(t))return!0;return!1}function A6(e,t){e.classList.toggle(`composer-input-empty`,t.length===0)}function ime(e){let{disabled:t,autoFocusKey:n,welcomeDraftSeed:r,onExternalTextReplace:i,shouldSyncSelectionRef:a}=e,[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(0),[u,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(null),p=(0,Z.useRef)(o),m=(0,Z.useRef)(c),h=(0,Z.useRef)(0),g=(0,Z.useRef)(!0),_=(0,Z.useRef)(null);p.current=o,m.current=c;let v=(0,Z.useCallback)(()=>{let e=f.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,128)}px`)},[]),y=(0,Z.useCallback)(e=>{let t=e?.nextText??``,n=e?.caretOffset??t.length;s(t),p.current=t,l(n),requestAnimationFrame(()=>{let r=f.current;r&&(k6(r,t,n),A6(r,t),e?.focus&&r.focus({preventScroll:!0})),v()})},[v]);(0,Z.useEffect)(()=>{v()},[o,v]);let b=(0,Z.useRef)(r?.id??0);return r&&r.id!==b.current&&(b.current=r.id,h.current=r.id,i?.(),y({nextText:r.text,focus:!0})),(0,Z.useLayoutEffect)(()=>{if(t){g.current=!0;return}let e=n??null,r=g.current,i=e!=null&&e!==_.current;if(!r&&!i)return;g.current=!1,e!=null&&(_.current=e);let a=requestAnimationFrame(()=>{typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(hover: hover) and (pointer: fine)`).matches&&f.current?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(a)},[t,n]),(0,Z.useEffect)(()=>{let e=f.current;if(!e)return;let t=!1,n=null,r=!1,i=-1,o=()=>{if(n=null,r=!1,document.activeElement!==e)return;let t=O6(e);m.current=t,t!==i&&(i=t,a.current&&l(t))},s=()=>{t&&(r||(r=!0,n=requestAnimationFrame(o)))},c=()=>{t||(t=!0,document.addEventListener(`selectionchange`,s),s())},u=()=>{t&&(t=!1,document.removeEventListener(`selectionchange`,s),n!=null&&cancelAnimationFrame(n),n=null,r=!1)},d=()=>c(),p=()=>u();return e.addEventListener(`focus`,d),e.addEventListener(`blur`,p),document.activeElement===e&&c(),()=>{e.removeEventListener(`focus`,d),e.removeEventListener(`blur`,p),u()}},[a]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;typeof t?.text!=`string`||t.text.length===0||(i?.(),y({nextText:t.text,focus:!0}))};return window.addEventListener(A4,e),()=>window.removeEventListener(A4,e)},[i,y]),{value:o,cursor:c,isComposing:u,setIsComposing:d,editorRef:f,valueRef:p,setValue:s,setCursor:l,adjustHeight:v,resetEditor:y,onWireInput:(0,Z.useCallback)((e,t)=>{p.current=e,s(e),l(t)},[])}}var ame=(0,Z.memo)(function(e){let t=(0,Q.c)(26),{editorRef:n,disabled:r,placeholder:i,onWireInput:a,adjustHeight:o,processFiles:s,setIsComposing:c,kbdRef:l,chatMessages:d}=e,f=(0,Z.useRef)(!1),p=!r,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=u(`composer-input box-border m-0 max-h-32 min-h-10 w-full overflow-y-auto border-0 bg-transparent px-0 py-2 text-[0.9375rem] leading-6 text-fg focus:outline-none focus:ring-0 disabled:opacity-50`,`composer-input-empty`),t[0]=m):m=t[0];let h;t[1]!==o||t[2]!==a?(h=e=>{let t=e.currentTarget,n=f.current?E6(t):D6(t);A6(t,n),a(n,O6(t)),o()},t[1]=o,t[2]=a,t[3]=h):h=t[3];let g;t[4]===c?g=t[5]:(g=()=>{f.current=!0,c(!0)},t[4]=c,t[5]=g);let _;t[6]!==o||t[7]!==n||t[8]!==a||t[9]!==c?(_=()=>{f.current=!1,c(!1),queueMicrotask(()=>{let e=n.current;if(!e||f.current)return;let t=D6(e);A6(e,t),a(t,O6(e)),o()})},t[6]=o,t[7]=n,t[8]=a,t[9]=c,t[10]=_):_=t[10];let v;t[11]!==d||t[12]!==s?(v=async e=>{let t=e.clipboardData,n=Ppe(t??null),r=n.filter(Npe);if(r.length>0){e.preventDefault(),await s(r);return}if(n.length>0){e.preventDefault(),FK(`warning`,d.clipboardFileTypeUnsupported);return}let i=t?.getData(`text/plain`);i&&(e.preventDefault(),document.execCommand(`insertText`,!1,i))},t[11]=d,t[12]=s,t[13]=v):v=t[13];let y;t[14]!==n||t[15]!==l?(y=e=>{let t=l.current;if(e.key===`Backspace`&&!t.isComposing&&n.current&&eme(n.current)){e.preventDefault();return}if(rme(t.adapters,e))return;if(!t.isComposing&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){let n=e.key===`ArrowUp`?`up`:`down`;if(t.tryInputHistoryArrow?.(n)){e.preventDefault(),t.adjustHeight();return}}if(e.key===`Escape`&&!t.isComposing&&t.editingFollowUpId){e.preventDefault(),t.onCancelEditFollowUp?.();return}if(e.key===`Enter`&&e.shiftKey&&!t.isComposing){e.preventDefault(),document.execCommand(`insertText`,!1,`
226
- `);return}let r=typeof KeyboardEvent<`u`&&e.nativeEvent instanceof KeyboardEvent&&e.nativeEvent.isComposing;if(e.key===`Enter`&&!e.shiftKey&&!t.isComposing&&!r){e.preventDefault();let n=!!(t.valueRef.current.trim()||t.attachmentsLen>0);if(t.runBusy||t.pendingFollowUpsCount>0){if((e.metaKey||e.ctrlKey)&&n){t.interruptDraft?.();return}if(!e.metaKey&&!e.ctrlKey&&!e.altKey&&n){t.flushSteeringDraft?.();return}return}n&&t.send()}},t[14]=n,t[15]=l,t[16]=y):y=t[16];let b;return t[17]!==n||t[18]!==i||t[19]!==p||t[20]!==h||t[21]!==g||t[22]!==_||t[23]!==v||t[24]!==y?(b=(0,$.jsx)(`div`,{ref:n,role:`textbox`,"aria-multiline":`true`,"aria-label":i,contentEditable:p,suppressContentEditableWarning:!0,spellCheck:!0,className:m,"data-placeholder":i,onInput:h,onCompositionStart:g,onCompositionEnd:_,onPaste:v,onKeyDown:y}),t[17]=n,t[18]=i,t[19]=p,t[20]=h,t[21]=g,t[22]=_,t[23]=v,t[24]=y,t[25]=b):b=t[25],b}),ome=(0,Z.memo)(function(e){let t=(0,Q.c)(55),{items:n,disabled:r,editingFollowUpId:i,onEditInComposer:a,onRemove:o,onMove:s,onReorder:c,onSteer:l,steeringBusyId:d}=e,f=_(sme),p;t[0]===f?p=t[1]:(p=m(f),t[0]=f,t[1]=p);let h=p,g=cme,v;t[2]===c?v=t[3]:(v=e=>t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`);if(!n.startsWith(`xopc-followup:`))return;let r=Number.parseInt(n.slice(14),10);Number.isNaN(r)||r===e||c(r,e)},t[2]=c,t[3]=v);let y=v;if(n.length===0)return null;let b=h.chat.followUpQueueAria,x;t[4]===h.chat.followUpQueueHeading?x=t[5]:(x=(0,$.jsx)(`span`,{className:`text-[0.65rem] font-medium uppercase tracking-wide text-fg-muted`,children:h.chat.followUpQueueHeading}),t[4]=h.chat.followUpQueueHeading,t[5]=x);let S;t[6]===n.length?S=t[7]:(S=(0,$.jsxs)(`span`,{className:`tabular-nums text-[0.65rem] text-fg-muted`,children:[n.length,`/`,10]}),t[6]=n.length,t[7]=S);let C;t[8]!==x||t[9]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1 pb-0.5`,children:[x,S]}),t[8]=x,t[9]=S,t[10]=C):C=t[10];let w;if(t[11]!==r||t[12]!==i||t[13]!==n||t[14]!==h.chat.followUpQueueAttachmentOnly||t[15]!==h.chat.followUpQueueClickToEdit||t[16]!==h.chat.followUpQueueDrag||t[17]!==h.chat.followUpQueueEmptyPreview||t[18]!==h.chat.followUpQueueMoveDown||t[19]!==h.chat.followUpQueueMoveUp||t[20]!==h.chat.followUpQueueRemove||t[21]!==h.chat.followUpQueueSteerNow||t[22]!==y||t[23]!==a||t[24]!==s||t[25]!==o||t[26]!==l||t[27]!==d){let e;t[29]!==r||t[30]!==i||t[31]!==n.length||t[32]!==h.chat.followUpQueueAttachmentOnly||t[33]!==h.chat.followUpQueueClickToEdit||t[34]!==h.chat.followUpQueueDrag||t[35]!==h.chat.followUpQueueEmptyPreview||t[36]!==h.chat.followUpQueueMoveDown||t[37]!==h.chat.followUpQueueMoveUp||t[38]!==h.chat.followUpQueueRemove||t[39]!==h.chat.followUpQueueSteerNow||t[40]!==y||t[41]!==a||t[42]!==s||t[43]!==o||t[44]!==l||t[45]!==d?(e=(e,t)=>{let c=!e.attachments?.length&&e.text.trim().length>0,f=d===e.id,p=e.text.trim();return!p&&e.attachments?.length&&(p=e.attachments[0]?.name?.trim()||h.chat.followUpQueueAttachmentOnly),p||=h.chat.followUpQueueEmptyPreview,(0,$.jsxs)(`div`,{role:`listitem`,onDragOver:g,onDrop:r?void 0:y(t),className:u(`flex h-7 items-center gap-1 rounded border px-1`,i===e.id?`border-accent/50 bg-accent-soft/20 dark:border-accent/50 dark:bg-accent-soft/10`:`border-edge-subtle/80 bg-surface-hover/25 dark:border-edge-subtle/90 dark:bg-surface-hover/15`),children:[(0,$.jsx)(`div`,{draggable:!r,onDragStart:e=>{e.dataTransfer.setData(`text/plain`,`xopc-followup:${t}`),e.dataTransfer.effectAllowed=`move`},className:u(`flex shrink-0 cursor-grab items-center active:cursor-grabbing`,r&&`cursor-not-allowed opacity-40`),title:h.chat.followUpQueueDrag,children:(0,$.jsx)(sv,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,disabled:r,title:h.chat.followUpQueueClickToEdit,"aria-label":h.chat.followUpQueueClickToEdit,className:u(`h-6 min-w-0 flex-1 truncate rounded px-1.5 text-left text-[0.75rem] leading-none text-fg hover:bg-surface-panel/60 dark:hover:bg-surface-panel/40`,lA.press,lA.focusRingPanel,`disabled:pointer-events-none disabled:opacity-50`),onClick:()=>a(e.id),children:e.attachments?.length?(0,$.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,$.jsx)(Eg,{className:`size-3 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:p})]}):(0,$.jsx)(`span`,{className:`block truncate`,children:p})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-px`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:r||t===0,className:u(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,lA.press,lA.focusRingPanel,`disabled:pointer-events-none disabled:opacity-25`),title:h.chat.followUpQueueMoveUp,"aria-label":h.chat.followUpQueueMoveUp,onClick:t=>{t.stopPropagation(),s(e.id,`up`)},children:(0,$.jsx)(Xu,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,disabled:r||t>=n.length-1,className:u(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,lA.press,lA.focusRingPanel,`disabled:pointer-events-none disabled:opacity-25`),title:h.chat.followUpQueueMoveDown,"aria-label":h.chat.followUpQueueMoveDown,onClick:t=>{t.stopPropagation(),s(e.id,`down`)},children:(0,$.jsx)(Gu,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,disabled:r||!c||f,className:u(`inline-flex size-6 items-center justify-center rounded text-accent-fg hover:bg-accent-soft/80`,lA.press,lA.focusRingPanel,`disabled:pointer-events-none disabled:opacity-35`),title:h.chat.followUpQueueSteerNow,"aria-label":h.chat.followUpQueueSteerNow,onClick:t=>{t.stopPropagation(),l(e.id)},children:(0,$.jsx)(SC,{className:u(`size-3.5`,f&&`animate-pulse`),"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,disabled:r,className:u(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-red-500/15 hover:text-red-600 dark:hover:text-red-400`,lA.press,lA.focusRingPanel),title:h.chat.followUpQueueRemove,"aria-label":h.chat.followUpQueueRemove,onClick:t=>{t.stopPropagation(),o(e.id)},children:(0,$.jsx)(Sk,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id)},t[29]=r,t[30]=i,t[31]=n.length,t[32]=h.chat.followUpQueueAttachmentOnly,t[33]=h.chat.followUpQueueClickToEdit,t[34]=h.chat.followUpQueueDrag,t[35]=h.chat.followUpQueueEmptyPreview,t[36]=h.chat.followUpQueueMoveDown,t[37]=h.chat.followUpQueueMoveUp,t[38]=h.chat.followUpQueueRemove,t[39]=h.chat.followUpQueueSteerNow,t[40]=y,t[41]=a,t[42]=s,t[43]=o,t[44]=l,t[45]=d,t[46]=e):e=t[46],w=n.map(e),t[11]=r,t[12]=i,t[13]=n,t[14]=h.chat.followUpQueueAttachmentOnly,t[15]=h.chat.followUpQueueClickToEdit,t[16]=h.chat.followUpQueueDrag,t[17]=h.chat.followUpQueueEmptyPreview,t[18]=h.chat.followUpQueueMoveDown,t[19]=h.chat.followUpQueueMoveUp,t[20]=h.chat.followUpQueueRemove,t[21]=h.chat.followUpQueueSteerNow,t[22]=y,t[23]=a,t[24]=s,t[25]=o,t[26]=l,t[27]=d,t[28]=w}else w=t[28];let T;t[47]!==n||t[48]!==h.chat.followUpQueueAttachmentsNote?(T=n.some(lme)?(0,$.jsx)(`p`,{className:`px-1 pt-0.5 text-[0.65rem] leading-tight text-fg-muted`,children:h.chat.followUpQueueAttachmentsNote}):null,t[47]=n,t[48]=h.chat.followUpQueueAttachmentsNote,t[49]=T):T=t[49];let E;return t[50]!==h.chat.followUpQueueAria||t[51]!==C||t[52]!==w||t[53]!==T?(E=(0,$.jsxs)(`div`,{className:`space-y-0.5 px-2 py-1.5`,role:`list`,"aria-label":b,children:[C,w,T]}),t[50]=h.chat.followUpQueueAria,t[51]=C,t[52]=w,t[53]=T,t[54]=E):E=t[54],E});function sme(e){return e.language}function cme(e){e.preventDefault(),e.dataTransfer.dropEffect=`move`}function lme(e){return e.attachments?.length}function j6(e){let t=(0,Q.c)(10),{attachments:n,topPadded:r,onRemove:i}=e;if(n.length===0)return null;let a=r?`pt-2`:`pt-3`,o;t[0]===a?o=t[1]:(o=u(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,a),t[0]=a,t[1]=o);let s;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=(e,t)=>(0,$.jsxs)(`div`,{className:`flex max-w-[200px] items-center gap-1.5 rounded-lg bg-surface-hover px-2 py-1 text-xs dark:bg-surface-hover/80`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,$.jsx)(Uv,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,$.jsx)(Eg,{className:`size-3.5 shrink-0 text-fg-muted`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:HI(e.size)}),(0,$.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,onClick:()=>i(t),children:`×`})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`),t[5]=i,t[6]=e),s=n.map(e),t[2]=n,t[3]=i,t[4]=s}else s=t[4];let c;return t[7]!==o||t[8]!==s?(c=(0,$.jsx)(`div`,{className:o,children:s}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}var ume=4;function M6(e){return!Number.isFinite(e)||e<=0?0:Math.ceil(e/ume)}function dme(e){return e.inputTokens!=null||e.outputTokens!=null?(e.inputTokens??0)+(e.outputTokens??0):e.totalTokens==null?null:e.totalTokens}function N6(e){let t=0;for(let n of e.content)n.type===`text`||n.type===`thinking`?t+=n.text.length:n.type===`tool_use`&&(t+=JSON.stringify(n.input??``).length,n.result!=null&&(t+=typeof n.result==`string`?n.result.length:JSON.stringify(n.result).length));if(e.attachments?.length)for(let n of e.attachments)t+=(n.extractedText?.length??0)+(n.name?.length??0);return M6(t)}function fme(e,t=0){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.role!==`assistant`||!r.usage)continue;let i=dme(r.usage);if(i==null||i<=0)continue;let a=0;for(let t=n+1;t<e.length;t++)a+=N6(e[t]);return i+a+M6(t)}let n=0;for(let t of e)n+=N6(t);return n+M6(t)}function P6(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var F6=7,I6=2.25,L6=2*Math.PI*F6;function R6(e){if(!Number.isFinite(e)||e<0)return`0`;if(e>=1e6){let t=e/1e6;return`${t>=10?Math.round(t):t.toFixed(1)}M`.replace(/\.0M$/,`M`)}if(e>=1e4)return`${Math.round(e/1e3)}k`;if(e>=1e3){let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`.replace(/\.0k$/,`k`)}return String(Math.round(e))}function pme(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0)return`0`;let n=Math.min(100,Math.max(0,100*e/t));return n>=10||n===0?String(Math.round(n)):n.toFixed(1).replace(/\.0$/,``)}var mme=(0,Z.memo)(function(e){let t=(0,Q.c)(35),{sessionModel:n,messages:r,draftChars:i,chat:a,disabled:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[0]=s):s=t[0];let{data:c}=ie(E3,O3,s),l;t[1]===c?l=t[2]:(l=c===void 0?[]:c,t[1]=c,t[2]=l);let d=l,f;t[3]!==d||t[4]!==n?(f=d.find(e=>e.id===n)?.contextWindow,t[3]=d,t[4]=n,t[5]=f):f=t[5];let p=f,m=fme(r,i),h=(p!=null&&p>0?Math.min(1,Math.max(0,m/p)):0)*L6,g;bb0:{if(p!=null&&p>0){let e;t[6]!==a.contextWindowAriaSummary||t[7]!==p||t[8]!==m?(e=P6(a.contextWindowAriaSummary,{used:R6(m),limit:R6(p)}),t[6]=a.contextWindowAriaSummary,t[7]=p,t[8]=m,t[9]=e):e=t[9],g=e;break bb0}let e;t[10]!==a.contextWindowAriaSummaryNoLimit||t[11]!==m?(e=P6(a.contextWindowAriaSummaryNoLimit,{used:R6(m)}),t[10]=a.contextWindowAriaSummaryNoLimit,t[11]=m,t[12]=e):e=t[12],g=e}let _=g,v;bb1:{if(p!=null&&p>0){let e;t[13]!==a.contextWindowHoverShort||t[14]!==p||t[15]!==m?(e=P6(a.contextWindowHoverShort,{percent:pme(m,p)}),t[13]=a.contextWindowHoverShort,t[14]=p,t[15]=m,t[16]=e):e=t[16],v=e;break bb1}let e;t[17]!==a.contextWindowHoverNoLimit||t[18]!==m?(e=P6(a.contextWindowHoverNoLimit,{used:R6(m)}),t[17]=a.contextWindowHoverNoLimit,t[18]=m,t[19]=e):e=t[19],v=e}let y=v,b=o||void 0,x=o&&`cursor-default opacity-40`,S;t[20]===x?S=t[21]:(S=u(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle`,`hover:bg-surface-hover hover:text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,x),t[20]=x,t[21]=S);let C;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:F6,fill:`none`,stroke:`currentColor`,className:`text-fg-subtle opacity-[0.35]`,strokeWidth:I6}),t[22]=C):C=t[22];let w=`${h} ${L6}`,T;t[23]===w?T=t[24]:(T=(0,$.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 18 18`,className:`shrink-0`,"aria-hidden":!0,children:[C,(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:F6,fill:`none`,stroke:`currentColor`,className:`text-fg-muted`,strokeWidth:I6,strokeLinecap:`round`,strokeDasharray:w,transform:`rotate(-90 9 9)`})]}),t[23]=w,t[24]=T);let E;t[25]!==_||t[26]!==T||t[27]!==b||t[28]!==S?(E=(0,$.jsx)(V$,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-disabled":b,"aria-label":_,className:S,children:T})}),t[25]=_,t[26]=T,t[27]=b,t[28]=S,t[29]=E):E=t[29];let D;t[30]===y?D=t[31]:(D=(0,$.jsx)(H$,{children:(0,$.jsx)(U$,{side:`top`,sideOffset:6,collisionPadding:12,className:`!z-[10000] whitespace-nowrap rounded-lg border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg shadow-md`,children:y})}),t[30]=y,t[31]=D);let O;return t[32]!==E||t[33]!==D?(O=(0,$.jsx)(z$,{delayDuration:280,children:(0,$.jsxs)(B$,{children:[E,D]})}),t[32]=E,t[33]=D,t[34]=O):O=t[34],O});function hme(e){switch(e){case`modal`:return vj;case`page`:return _j;default:return`z-50`}}function gme(e){return`${e.id} ${e.name} ${e.provider}`.toLowerCase()}function _me(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=n.split(/\s+/).filter(Boolean);return e.filter(e=>{let t=gme(e);return r.every(e=>t.includes(e))})}function vme(e,t,n){if(t!==`vision`)return e;let r=e.filter(e=>e.vision===!0);if(!n||r.some(e=>e.id===n))return r;let i=e.find(e=>e.id===n);if(i)return[i,...r];let a=n.indexOf(`/`),o=a>=0?n.slice(0,a):``;return[{id:n,name:(a>=0?n.slice(a+1):n)||n,provider:o||`—`,vision:!1},...r]}function z6(e){let t=(0,Q.c)(85),{value:n,disabled:r,placeholder:i,searchPlaceholder:a,noMatches:o,capabilitiesFilter:s,outOfFilterNote:c,registryEmptyHint:l,compact:d,showProviderInTrigger:f,contentSide:p,contentAlign:h,className:g,popoverContentClassName:v,showProviderSettingsFooter:y,onChange:b}=e,x=f===void 0?!0:f,S=p===void 0?`bottom`:p,C=h===void 0?`end`:h,w=br(),T=_(bme),E;t[0]===T?E=t[1]:(E=m(T),t[0]=T,t[1]=E);let D=E.chat,[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(``),M=Sj(),N=Cj(),P=hme(M),F;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(F={revalidateOnFocus:!1},t[2]=F):F=t[2];let{data:I,isLoading:L,error:R}=ie(E3,O3,F),z;t[3]===I?z=t[4]:(z=I===void 0?[]:I,t[3]=I,t[4]=z);let B=z,V;t[5]===n?V=t[6]:(V=n.trim(),t[5]=n,t[6]=V);let H=V,U;t[7]!==s||t[8]!==B||t[9]!==H?(U=vme(B,s,H),t[7]=s,t[8]=B,t[9]=H,t[10]=U):U=t[10];let W=U,G;t[11]!==W||t[12]!==A?(G=_me(W,A),t[11]=W,t[12]=A,t[13]=G):G=t[13];let K=G,q;t[14]!==B||t[15]!==W||t[16]!==n?(q=B.find(e=>e.id===n)??W.find(e=>e.id===n),t[14]=B,t[15]=W,t[16]=n,t[17]=q):q=t[17];let ee=q,J=ee?x?`${ee.name} (${ee.provider})`:ee.name:n||i,te=!R&&s===`vision`&&W.length===0,Y=NA,ne=r||L,re=ee?`${ee.name} (${ee.provider})`:i,X=d&&`py-1.5 text-[13px]`,ae;t[18]!==g||t[19]!==X?(ae=u(cA,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-left text-sm font-normal text-fg`,lA.transition,`hover:border-edge hover:bg-surface-hover/45`,iA,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,X,g),t[18]=g,t[19]=X,t[20]=ae):ae=t[20];let oe=L?`…`:J,se;t[21]===oe?se=t[22]:(se=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:oe}),t[21]=oe,t[22]=se);let ce;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(id,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[23]=ce):ce=t[23];let le;t[24]!==ne||t[25]!==re||t[26]!==ae||t[27]!==se?(le=(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,disabled:ne,title:re,className:ae,children:[se,ce]})}),t[24]=ne,t[25]=re,t[26]=ae,t[27]=se,t[28]=le):le=t[28];let ue=NA,de=N??void 0,fe=NA,pe=u(P,`w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,v),me;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(me=u(`mb-1 w-full rounded-lg border border-edge-subtle bg-surface-base px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-disabled dark:bg-surface-hover/40`,aA),t[29]=me):me=t[29];let he;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(he=e=>j(e.target.value),t[30]=he):he=t[30];let ge;t[31]!==A||t[32]!==a?(ge=(0,$.jsx)(`input`,{type:`search`,className:me,placeholder:a,value:A,onChange:he}),t[31]=A,t[32]=a,t[33]=ge):ge=t[33];let _e;t[34]===R?_e=t[35]:(_e=R?(0,$.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:R instanceof Error?R.message:`Failed to load models`}):null,t[34]=R,t[35]=_e);let ve;t[36]!==R||t[37]!==o||t[38]!==l||t[39]!==te?(ve=!R&&te?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:l??o}):null,t[36]=R,t[37]=o,t[38]=l,t[39]=te,t[40]=ve):ve=t[40];let ye;t[41]!==R||t[42]!==K.length||t[43]!==o||t[44]!==te?(ye=!R&&!te&&K.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:o}):null,t[41]=R,t[42]=K.length,t[43]=o,t[44]=te,t[45]=ye):ye=t[45];let be;if(t[46]!==s||t[47]!==K||t[48]!==b||t[49]!==c||t[50]!==n||t[51]!==H){let e;t[53]!==s||t[54]!==b||t[55]!==c||t[56]!==n||t[57]!==H?(e=e=>{let t=!!c&&s===`vision`&&e.vision!==!0&&e.id===H;return(0,$.jsxs)(`button`,{type:`button`,className:u(`flex w-full flex-col gap-0.5 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,e.id===n&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{b(e.id),k(!1),j(``)},children:[(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-center gap-2`,children:[(0,$.jsx)(Iu,{className:u(`size-4 shrink-0`,e.id!==n&&`invisible`),"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),` `,(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[`(`,e.provider,`)`]})]})]}),t?(0,$.jsx)(`span`,{className:`pl-6 text-[11px] leading-snug text-amber-700 dark:text-amber-300`,children:c}):null]},e.id)},t[53]=s,t[54]=b,t[55]=c,t[56]=n,t[57]=H,t[58]=e):e=t[58],be=K.map(e),t[46]=s,t[47]=K,t[48]=b,t[49]=c,t[50]=n,t[51]=H,t[52]=be}else be=t[52];let xe;t[59]!==_e||t[60]!==ve||t[61]!==ye||t[62]!==be?(xe=(0,$.jsxs)(`div`,{className:`max-h-60 overflow-auto`,children:[_e,ve,ye,be]}),t[59]=_e,t[60]=ve,t[61]=ye,t[62]=be,t[63]=xe):xe=t[63];let Se;t[64]!==D||t[65]!==w||t[66]!==y?(Se=y?(0,$.jsx)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:(0,$.jsxs)(`button`,{type:`button`,className:u(`flex w-full items-center gap-2 rounded-md p-2 text-left text-sm font-medium text-accent`,lA.transition,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{w(`/settings/credentials`),k(!1),j(``)},children:[(0,$.jsx)(lS,{className:`size-4 shrink-0 opacity-90`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0`,children:D.modelProviderSettingsLink})]})}):null,t[64]=D,t[65]=w,t[66]=y,t[67]=Se):Se=t[67];let Ce;t[68]!==C||t[69]!==S||t[70]!==fe.Content||t[71]!==pe||t[72]!==ge||t[73]!==xe||t[74]!==Se?(Ce=(0,$.jsxs)(fe.Content,{className:pe,side:S,sideOffset:4,align:C,onOpenAutoFocus:yme,children:[ge,xe,Se]}),t[68]=C,t[69]=S,t[70]=fe.Content,t[71]=pe,t[72]=ge,t[73]=xe,t[74]=Se,t[75]=Ce):Ce=t[75];let we;t[76]!==ue.Portal||t[77]!==de||t[78]!==Ce?(we=(0,$.jsx)(ue.Portal,{container:de,children:Ce}),t[76]=ue.Portal,t[77]=de,t[78]=Ce,t[79]=we):we=t[79];let Te;return t[80]!==O||t[81]!==Y.Root||t[82]!==le||t[83]!==we?(Te=(0,$.jsxs)(Y.Root,{open:O,onOpenChange:k,children:[le,we]}),t[80]=O,t[81]=Y.Root,t[82]=le,t[83]=we,t[84]=Te):Te=t[84],Te}function yme(e){return e.preventDefault()}function bme(e){return e.language}async function B6(e){let t=String(e??``).trim();if(!t)return{active:!1};let n=await Y(X(_K(t)));if(!n.ok)return{active:!1};try{return pK(await n.json())}catch{return{active:!1}}}async function xme(e){let t=String(e??``).trim();if(!t)return null;try{let e=await B6(t);if(e.active&&e.runId)return LL(t,e.runId),e.runId}catch{}if(!IL(t))return null;try{let e=sessionStorage.getItem(FL(t));if(!e)return null;let n=JSON.parse(e);return(typeof n.runId==`string`?n.runId.trim():``)||null}catch{return null}}var Sme=3e4,V6=null;function Cme(e){V6={sessions:[...e],fetchedAt:Date.now()}}function wme(e){let t=e.key.trim();if(!t)return;let n=new Date().toISOString();V6={sessions:[{...e,key:t,messageCount:e.messageCount??0,updatedAt:e.updatedAt??n},...(V6?.sessions??[]).filter(e=>e.key.trim()!==t)],fetchedAt:Date.now()}}function Tme(){return V6?Date.now()-V6.fetchedAt>Sme?(V6=null,null):V6.sessions:null}var Eme=`webchat`,H6=new Map,U6=new Map,W6=50,Dme=500,G6=new Map;function Ome(e){let t=e.trim().split(`:`);if(t.length<6)return null;let[n,r,i,a,o,...s]=t,c=s.join(`:`).trim();return n!==`agent`||!r?.trim()||i!==`webchat`||a!=="default"||o!==`direct`||!c?null:{agentId:r.trim().toLowerCase(),channel:i,chatId:c}}async function K6(e){let t=await e.json().catch(()=>({}));return typeof t.error==`string`?t.error:t.error?.message??`HTTP ${e.status}`}var kme=class{async loadSessions(){let e=[],t=0;for(let n=0;n<100;n++){let n=await CK({channel:Eme,limit:100,offset:t});for(let t of n.items)e.push({key:t.key,sessionId:t.sessionId,name:t.name,updatedAt:t.updatedAt,messageCount:t.messageCount,sourceChannel:t.sourceChannel,sourceChatId:t.sourceChatId,projectId:t.projectId,customData:t.customData,routing:t.routing});if(!n.hasMore)break;t+=100}let n=e.sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime());return Cme(n),n}async loadSessionAgentConfig(e){let t=H6.get(e);if(t)return t;let n=(async()=>{let t=await Y(X(`/api/sessions/${encodeURIComponent(e)}/agent-config`));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();return{thinkingLevel:n.payload?.thinkingLevel??`medium`,model:typeof n.payload?.model==`string`?n.payload.model:``,reasoningLevel:n.payload?.reasoningLevel??`stream`,effectiveWorkspacePath:typeof n.payload?.effectiveWorkspacePath==`string`?n.payload.effectiveWorkspacePath:``,workingDirectoryLocked:!!n.payload?.workingDirectoryLocked}})().finally(()=>{H6.delete(e)});return H6.set(e,n),n}async patchSessionAgentConfig(e,t){let n=await Y(X(`/api/sessions/${encodeURIComponent(e)}/agent-config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}}fetchSessionActiveRun(e){return B6(e)}async loadSession(e,t=0,n){let r=`${e}\0${t}\0${n??``}`,i=U6.get(r);if(i)return i;let a=(async()=>{let r=async(t,n)=>{let r=await ue(X(gK(e,{limit:W6,before:n,offset:n?void 0:t})));if(!r.ok)throw Error(`HTTP ${r.status}: ${r.statusText}`);return await r.json()},i=await r(t,n),a=i.session?.messages||[],o=lL(a),s=i.pagination?.hasMore??a.length>=W6,c=i.pagination?.nextBeforeCursor,l=typeof i.session?.name==`string`&&i.session.name.trim()?i.session.name.trim():void 0;for(;t===0&&!n&&s&&c&&a.length<Dme&&o[0]?.role===`assistant`;){i=await r(0,c);let e=i.session?.messages||[];if(e.length===0)break;a=[...e,...a],o=lL(a),s=i.pagination?.hasMore??e.length>=W6,c=i.pagination?.nextBeforeCursor}return{messages:o,hasMore:s,name:l,nextBeforeCursor:c}})().finally(()=>{U6.delete(r)});return U6.set(r,a),a}async loadTimeline(e){let t=G6.get(e);if(t)return t;let n=(async()=>{let t=await ue(X(`/api/sessions/${encodeURIComponent(e)}/timeline`));if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.json();return Array.isArray(n.items)?n.items:[]})().finally(()=>{G6.delete(e)});return G6.set(e,n),n}async createSession(e){let t={channel:`webchat`},n=e?.agentId?.trim();n&&(t.agentId=n.toLowerCase());let r=e?.projectId?.trim();r&&(t.projectId=r);let i=await Y(X(`/api/sessions`),{method:`POST`,body:JSON.stringify(t)});if(!i.ok)throw Error(`HTTP ${i.status}`);return(await i.json()).session}async ensureSessionExists(e){let t=e.trim();if(!t)throw Error(`Session key is required`);let n=await Y(X(`/api/sessions/resolve`),{method:`POST`,body:JSON.stringify({sessionKey:t})});if(n.ok)return;if(n.status!==404)throw Error(await K6(n));let r=Ome(t);if(!r)throw Error(`Session not found`);let i=await Y(X(`/api/sessions`),{method:`POST`,body:JSON.stringify({channel:r.channel,agentId:r.agentId,chat_id:r.chatId})});if(!i.ok)throw Error(await K6(i))}async fetchSessionName(e){let t=await ue(X(`/api/sessions/${encodeURIComponent(e)}?offset=0&limit=1`));if(!t.ok)return;let n=(await t.json()).session?.name;return typeof n==`string`&&n.trim()?n.trim():void 0}updateUrl(e){let t=`#/chat/${encodeURIComponent(e)}`;if(location.hash!==t){let e=window.history.state,n=e&&typeof e==`object`&&!Array.isArray(e)?{...e}:e;history.replaceState(n,``,t)}}parseSessionFromHash(){let e=location.hash.slice(1),t=e.match(/^\/chat\/(.+)$/)||e.match(/^chat\/(.+)$/),n=t?decodeURIComponent(t[1]):null;return n&&n!==`new`?n:null}async deleteMessages(e,t){let n=await Y(X(`/api/sessions/${encodeURIComponent(e)}/messages`),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}}},q6=`xopc.recentWorkspaceDirs.v1`,Ame=10;function jme(){try{let e=localStorage.getItem(q6);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}catch{return[]}}function Mme(e){let t=e.trim();if(t)try{let e=[t,...jme().filter(e=>e!==t)].slice(0,Ame);localStorage.setItem(q6,JSON.stringify(e))}catch{}}function J6(e){let t=e.trim().replace(/[/\\]+$/,``);if(!t)return e;let n=t.split(/[/\\]/);return n[n.length-1]||t}function Y6(e){let t=(0,Q.c)(27),{value:n,onPick:r,disabled:i,placeholder:a,title:o,className:s,maxWidthClass:c,compact:l,"aria-label":d}=e,f=c===void 0?`max-w-[min(12rem,40vw)]`:c,p=l===void 0?!1:l,m,h;t[0]!==a||t[1]!==n?(h=n.trim(),m=h?J6(h):a??``,t[0]=a,t[1]=n,t[2]=m,t[3]=h):(m=t[2],h=t[3]);let g=m,_=o??(h||void 0),v=d??o??g,y=p?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,b=!p&&f,x=i&&`cursor-not-allowed opacity-60`,S;t[4]!==s||t[5]!==y||t[6]!==b||t[7]!==x?(S=u(y,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,lA.transition,lA.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,b,x,s),t[4]=s,t[5]=y,t[6]=b,t[7]=x,t[8]=S):S=t[8];let C;t[9]!==i||t[10]!==r?(C=e=>{e.stopPropagation(),i||r()},t[9]=i,t[10]=r,t[11]=C):C=t[11];let w=p?`size-4`:`size-3.5`,T;t[12]===w?T=t[13]:(T=u(`shrink-0 text-fg-muted`,w),t[12]=w,t[13]=T);let E;t[14]===T?E=t[15]:(E=(0,$.jsx)(u_,{className:T,"aria-hidden":!0}),t[14]=T,t[15]=E);let D;t[16]!==p||t[17]!==g?(D=p?null:(0,$.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:g}),t[16]=p,t[17]=g,t[18]=D):D=t[18];let O;return t[19]!==i||t[20]!==C||t[21]!==E||t[22]!==D||t[23]!==_||t[24]!==v||t[25]!==S?(O=(0,$.jsxs)(`button`,{type:`button`,disabled:i,title:_,"aria-label":v,className:S,onClick:C,children:[E,D]}),t[19]=i,t[20]=C,t[21]=E,t[22]=D,t[23]=_,t[24]=v,t[25]=S,t[26]=O):O=t[26],O}async function Nme(e){let t=typeof window<`u`?window.electronAPI?.file?.openDirectory:void 0;if(!t)return null;let n=e?.trim();return n?t({defaultPath:n}):t()}function X6(e={}){let{initialPath:t,onPicked:n,trackRecent:r=!0}=e,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=typeof window<`u`&&!!window.electronAPI?.file?.openDirectory,l=(0,Z.useCallback)(async e=>{let t=e.trim();t&&(r&&Mme(t),await n?.(t))},[n,r]);return{hasNativePicker:c,modalOpen:i,setModalOpen:a,pick:(0,Z.useCallback)(()=>{if(c){(async()=>{s(!0);try{let e=await Nme(t);e&&await l(e)}finally{s(!1)}})();return}a(!0)},[l,c,t]),confirmPick:l,picking:o}}function Pme(){return function(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e}}}function Z6(e,t){return{...e,...t.patch}}function Fme(e){let{enabled:t,parsed:n,dirty:r,trackedParsedRef:i,dispatch:a,onResetDirty:o}=e;if(!t){i.current!==null&&(i.current=null,a({type:`reset`}),o?.());return}n!==null&&!r&&i.current!==n&&(i.current=n,a({type:`sync`,value:n}))}async function Q6(e){let t=new URLSearchParams;e!=null&&e!==``&&t.set(`path`,e);let n=t.toString();return(await J(X(`/api/host/fs/list${n?`?${n}`:``}`))).payload}async function Ime(){return(await J(X(`/api/host/fs/meta`))).payload}function Lme(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-sm text-fg`,`placeholder:text-fg-subtle`,oA,`dark:border-edge`)}function $6(e){return/^[A-Za-z]:\\?$/.test(e.replace(/\\$/,`\\`))}function Rme(e){return!e||e.currentPath===``?!1:e.parentPath===null?e.currentPath===`/`?!1:!!$6(e.currentPath):!0}var zme={metaHostname:null,listState:null,listLoading:!1,listError:null,manualPath:``};function e8({open:e,onOpenChange:t,initialAbsolutePath:n,onConfirm:r,wd:i}){let a=(0,Z.useId)(),[o,s]=(0,Z.useReducer)(Z6,zme),{metaHostname:c,listState:l,listLoading:d,listError:f,manualPath:p}=o,m=(0,Z.useCallback)(async e=>{s({type:`patch`,patch:{listLoading:!0,listError:null}});try{s({type:`patch`,patch:{listState:await Q6(e)}})}catch(e){s({type:`patch`,patch:{listError:e instanceof Error?e.message:String(e),listState:null}})}finally{s({type:`patch`,patch:{listLoading:!1}})}},[]);(0,Z.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await Ime();t||s({type:`patch`,patch:{metaHostname:e.hostname}})}catch{t||s({type:`patch`,patch:{metaHostname:null}})}})(),()=>{t=!0}},[e]),(0,Z.useEffect)(()=>{if(!e)return;let t=n?.trim()??``;s({type:`patch`,patch:{manualPath:t}});let r=!1;return(async()=>{s({type:`patch`,patch:{listLoading:!0,listError:null}});try{if(t)try{let e=await Q6(t);r||s({type:`patch`,patch:{listState:e}})}catch{let e=await Q6();r||s({type:`patch`,patch:{listState:e}})}else{let e=await Q6();r||s({type:`patch`,patch:{listState:e}})}}catch(e){let t=e instanceof Error?e.message:String(e);r||s({type:`patch`,patch:{listError:t,listState:null}})}finally{r||s({type:`patch`,patch:{listLoading:!1}})}})(),()=>{r=!0}},[e,n]);let h=e=>{e.isDirectory&&m(e.absolutePath)},g=()=>{if(!l)return;let{parentPath:e,currentPath:t}=l;if(e!==null){m(e);return}t===`/`||t===``||$6(t)&&m(void 0)},_=l?.currentPath===``?i.pickerDrives:l?.currentPath??``,v=!!l&&l.currentPath!==``&&!d&&!f,y=async()=>{if(!(!l||l.currentPath===``))try{await r(l.currentPath),t(!1)}catch{}},b=async()=>{let e=p.trim();if(e)try{await r(e),t(!1)}catch{}},x=d&&l;return(0,$.jsx)(FN,{open:e,onOpenChange:t,children:(0,$.jsxs)(LN,{children:[(0,$.jsx)(RN,{className:`fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(zN,{className:u(`fixed left-1/2 top-1/2 z-[101] flex max-h-[min(90vh,32rem)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsx)(BN,{className:`text-base font-semibold text-fg`,children:i.pathModalTitle}),(0,$.jsx)(VN,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:i.pathModalDescription}),c?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:i.pickerHostHint.replace(`{{hostname}}`,c)}):null,(0,$.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(tA,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1 px-2 py-1.5 text-xs`,disabled:d||!Rme(l)||!!f,onClick:()=>g(),title:i.pickerUp,children:[(0,$.jsx)(Xu,{className:`size-4`,"aria-hidden":!0}),i.pickerUp]}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 truncate rounded-md border border-edge-subtle/80 bg-surface-hover/30 px-2 py-1.5 font-mono text-xs text-fg`,title:_,children:d&&!l?i.pickerLoading:_||`—`})]}),(0,$.jsxs)(`div`,{className:u(`relative min-h-[12rem] overflow-y-auto rounded-lg border border-edge-subtle/80 bg-surface-hover/20 p-1 dark:border-edge-subtle`,lA.focusRingPanel),role:`listbox`,"aria-label":i.pathModalTitle,children:[x?(0,$.jsx)(`div`,{className:`absolute inset-0 z-[1] flex items-center justify-center rounded-lg bg-surface-panel/60`,"aria-hidden":!0,children:(0,$.jsx)(Fv,{className:`size-6 animate-spin text-fg-muted`})}):null,d&&!l?(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-12 text-sm text-fg-muted`,children:[(0,$.jsx)(Fv,{className:`size-4 animate-spin`,"aria-hidden":!0}),i.pickerLoading]}):null,f?(0,$.jsx)(`p`,{className:`px-2 py-8 text-center text-sm text-fg-muted`,children:i.pickerListError}):null,!d&&l&&!f&&l.entries.length===0?(0,$.jsx)(`p`,{className:`px-2 py-8 text-center text-sm text-fg-muted`,children:i.pickerEmptyFolder}):null,l?.entries.map(e=>(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":!1,disabled:!e.isDirectory,className:u(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,e.isDirectory?`cursor-pointer text-fg hover:bg-surface-hover`:`cursor-default text-fg-muted opacity-60`),onClick:()=>h(e),children:[(0,$.jsx)(u_,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name})]},e.absolutePath))]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:a,className:`text-xs text-fg-muted`,children:i.pickerManualPath}),(0,$.jsx)(`input`,{id:a,type:`text`,value:p,onChange:e=>s({type:`patch`,patch:{manualPath:e.target.value}}),placeholder:i.pathInputPlaceholder,className:Lme(),autoComplete:`off`,spellCheck:!1,onKeyDown:e=>{e.key===`Enter`&&p.trim()&&(e.preventDefault(),b())}})]})]}),(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[(0,$.jsx)(tA,{type:`button`,variant:`ghost`,onClick:()=>t(!1),children:i.pathModalCancel}),(0,$.jsx)(tA,{type:`button`,variant:`secondary`,disabled:!p.trim(),onClick:()=>void b(),children:i.pickerApplyManual}),(0,$.jsx)(tA,{type:`button`,disabled:!v,onClick:()=>void y(),children:i.pickerUseThisFolder})]})]})]})})}var Bme=(0,Z.memo)(function({sessionKey:e,disabled:t,canSelectWorkingDirectory:n,sessionMgr:r}){let i=m(_(e=>e.language)).chat.workingDirectory,a=O1(e=>e.toggleOpen),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,h]=(0,Z.useState)(null),g=(0,Z.useCallback)(async()=>{if(!e){s(``);return}l(!0);try{s((await r.loadSessionAgentConfig(e)).effectiveWorkspacePath)}catch{s(``)}finally{l(!1)}},[e,r]);(0,Z.useEffect)(()=>{g()},[g]);let v=X6({initialPath:o,onPicked:(0,Z.useCallback)(async t=>{if(!(!e?.trim()||!t.trim()))try{await r.patchSessionAgentConfig(e,{workingDirectory:t.trim()}),await g()}catch(e){throw h(e instanceof Error?e.message:String(e)),f(!0),e}},[e,r,g])}),y=(0,Z.useCallback)(()=>{re({type:`info`,title:i.lockedTapTitle,message:i.lockedTapBody,duration:6500})},[i.lockedTapBody,i.lockedTapTitle]);if(!e)return null;let b=o.trim(),x=!!b,S=x?J6(b):i.notSet,C=u(`inline-flex min-h-8 max-w-[min(12rem,40vw)] min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,lA.transition,lA.focusRingPanel),w=e=>{let{hasPath:t,fullPath:n,canSelect:r}=e,a;return a=!r&&t?i.tooltipOpenProjectFiles:r?t?i.chooseFolder:i.selectWorkingDirectory:i.selectionOnlyAtNewChat,(0,$.jsxs)(`div`,{className:`max-w-[min(22rem,90vw)] space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`font-semibold text-fg`,children:i.tooltipAgentWorkspace}),t?(0,$.jsx)(`p`,{className:`break-words font-mono text-[11px] leading-snug text-fg-muted`,children:n}):(0,$.jsx)(`p`,{className:`text-[11px] text-fg-muted`,children:i.notSet}),(0,$.jsx)(`p`,{className:`text-[11px] leading-snug text-fg-subtle`,children:a})]})},T=(e,t)=>(0,$.jsxs)(B$,{delayDuration:350,children:[(0,$.jsx)(V$,{asChild:!0,children:t}),(0,$.jsx)(H$,{children:(0,$.jsx)(U$,{side:`top`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-w-[min(22rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-snug text-fg shadow-lg`,children:e})})]}),E=()=>T(w({hasPath:!1,fullPath:``,canSelect:!1}),(0,$.jsxs)(`button`,{type:`button`,className:u(C,`cursor-pointer text-left text-fg-muted hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`),"aria-label":`${i.notSet}. ${i.selectionOnlyAtNewChat}`,onClick:e=>{e.stopPropagation(),y()},children:[(0,$.jsx)(u_,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:S})]})),D=()=>T(w({hasPath:!0,fullPath:b,canSelect:!1}),(0,$.jsxs)(`button`,{type:`button`,disabled:t||c||!x,className:u(C,x&&`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,(t||c||!x)&&`cursor-not-allowed opacity-60`),"aria-label":`${i.tooltipAgentWorkspace}: ${b}`,onClick:e=>{e.stopPropagation(),x&&!t&&!c&&a()},children:[(0,$.jsx)(u_,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:S})]}));if(!n)return x?(0,$.jsx)(z$,{delayDuration:350,children:(0,$.jsx)(`div`,{className:`inline-flex items-center`,children:D()})}):(0,$.jsx)(z$,{delayDuration:350,children:(0,$.jsx)(`div`,{className:`inline-flex items-center`,children:E()})});let O=x&&!t&&!c?`${i.tooltipAgentWorkspace}: ${b}. ${i.chooseFolder}`:x?`${i.tooltipAgentWorkspace}: ${b}`:i.selectWorkingDirectory;return(0,$.jsx)(z$,{delayDuration:350,children:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`inline-flex items-center`,children:T(w({hasPath:x,fullPath:b,canSelect:!0}),(0,$.jsx)(Y6,{value:b,onPick:v.pick,disabled:t||c||v.picking,placeholder:i.notSet,"aria-label":O,className:u((t||c||v.picking)&&`cursor-not-allowed opacity-60`)}))}),v.hasNativePicker?null:(0,$.jsx)(e8,{open:v.modalOpen,onOpenChange:v.setModalOpen,initialAbsolutePath:b||void 0,onConfirm:v.confirmPick,wd:i}),(0,$.jsx)(FN,{open:d,onOpenChange:e=>{f(e),e||h(null)},children:(0,$.jsxs)(LN,{children:[(0,$.jsx)(RN,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(zN,{className:u(`fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsx)(BN,{className:`text-base font-semibold text-fg`,children:i.applyErrorTitle}),p?(0,$.jsx)(VN,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:p}):null,(0,$.jsx)(`div`,{className:`mt-4 flex items-center justify-end border-t border-edge-subtle/60 pt-3`,children:(0,$.jsx)(tA,{type:`button`,onClick:()=>f(!1),children:i.applyErrorClose})})]})]})})]})})});function t8(e,t){let n=e.finishedAt??e.startedAt??e.at,r=e.verdict;return{...e,at:n,turnsUsed:t?.turnsUsed??e.turnsUsed??0,maxTurns:t?.maxTurns??e.maxTurns??0,statusAfter:t?.status??e.statusAfter??`active`,willContinue:r===`continue`||r===`decompose`}}function n8(e){if(!e)return null;let t=e.latestRun?t8(e.latestRun,e):void 0;return{...e,checklist:e.checklist??[],latestRun:t,lastTurnAt:e.updatedAt??e.lastTurnAt??e.createdAt,lastVerdict:t?.verdict??e.lastVerdict,lastReason:t?.reason??e.lastReason??e.blockedReason}}async function r8(e,t){return{ok:!0,goal:n8((await J(X(`/api/goals/current?${new URLSearchParams({sessionKey:e}).toString()}`))).goal)}}async function Vme(e,t,n){return{ok:!0,goal:n8((await J(X(`/api/goals`),{method:`POST`,body:JSON.stringify({sessionKey:e,title:t,...n?.uiLocale?{uiLocale:n.uiLocale}:{}})})).goal)}}async function Hme(e){let t=new URLSearchParams;return t.set(`status`,e?.status??`active,paused,blocked,needs_input`),t.set(`limit`,String(e?.limit??50)),e?.sessionKey&&t.set(`sessionKey`,e.sessionKey),{ok:!0,goals:(await J(X(`/api/goals?${t.toString()}`))).goals.map(e=>n8(e)).filter(e=>e!=null)}}async function Ume(e,t,n){let r=(await r8(e,n)).goal;return r?{ok:!0,goal:n8((await J(X(t===`pause`?`/api/goals/${encodeURIComponent(r.id)}/pause`:t===`clear`?`/api/goals/${encodeURIComponent(r.id)}/archive`:t===`detach`?`/api/goals/${encodeURIComponent(r.id)}/detach`:`/api/goals/${encodeURIComponent(r.id)}/continue`),{method:`POST`,body:JSON.stringify({sessionKey:e,...n?.uiLocale?{uiLocale:n.uiLocale}:{}})})).goal)}:{ok:!0,goal:null}}async function Wme(e,t){return{ok:!0,goal:n8((await J(X(`/api/goals/${encodeURIComponent(t)}/attach`),{method:`POST`,body:JSON.stringify({sessionKey:e})})).goal)}}async function Gme(e){return{ok:!0,goal:n8((await J(X(`/api/goals/${encodeURIComponent(e)}/detach`),{method:`POST`,body:JSON.stringify({})})).goal)}}async function Kme(e,t,n){let r=(await r8(e,n)).goal;if(!r)return{ok:!0,goal:null};if(t.op===`reset`)return await Promise.all(r.checklist.map(e=>X(`/api/goals/${encodeURIComponent(r.id)}/checklist/${encodeURIComponent(e.id)}`)).map(e=>J(e,{method:`DELETE`}))),r8(e,n);if(t.op===`add`)return{ok:!0,goal:n8((await J(X(`/api/goals/${encodeURIComponent(r.id)}/checklist`),{method:`POST`,body:JSON.stringify({text:t.text})})).goal)};let i=r.checklist[t.index-1];return i?t.op===`remove`?{ok:!0,goal:n8((await J(X(`/api/goals/${encodeURIComponent(r.id)}/checklist/${encodeURIComponent(i.id)}`),{method:`DELETE`})).goal)}:{ok:!0,goal:n8((await J(X(`/api/goals/${encodeURIComponent(r.id)}/checklist/${encodeURIComponent(i.id)}`),{method:`PATCH`,body:JSON.stringify({status:t.status})})).goal)}:{ok:!0,goal:r}}async function i8(e,t){let n=(await r8(e)).goal;if(!n)return{ok:!0,runs:[]};let r=new URLSearchParams;t?.limit!=null&&Number.isFinite(t.limit)&&r.set(`limit`,String(Math.min(500,Math.max(1,Math.floor(t.limit)))));let i=r.toString()?`?${r.toString()}`:``;return{ok:!0,runs:(await J(X(`/api/goals/${encodeURIComponent(n.id)}/runs${i}`))).runs.map(e=>t8(e,n))}}async function a8(){return(await J(X(`/api/workflows/definitions`))).definitions??[]}async function qme(e,t){return J(X(`/api/workflows/definitions/validate`),{method:`POST`,body:JSON.stringify({name:e,script:t})})}async function Jme(e){return(await J(X(`/api/workflows/definitions/draft`),{method:`POST`,body:JSON.stringify(e)})).draft}async function Yme(e,t){return(await J(X(`/api/workflows/definitions`),{method:`POST`,body:JSON.stringify({name:e,script:t})})).definition}async function Xme(e){await J(X(`/api/workflows/definitions/${encodeURIComponent(e)}`),{method:`DELETE`})}function o8(e,t){let n=t?.ownerAgentId?.trim();n&&e.set(`agentId`,n)}async function Zme(e,t){let n=e?.trim(),r=new URLSearchParams;return n&&r.set(`definitionId`,n),o8(r,t),(await J(X(`/api/workflows/stats${r.size>0?`?${r.toString()}`:``}`))).stats}async function Qme(e=50,t){let n=new URLSearchParams({limit:String(e)});o8(n,t);let r=t?.goalId?.trim();r&&n.set(`goalId`,r);let i=t?.projectId?.trim();return i&&n.set(`projectId`,i),(await J(X(`/api/workflows/runs?${n.toString()}`))).runs??[]}async function $me(e,t){let n=new URLSearchParams;o8(n,t);let r=n.size>0?`?${n.toString()}`:``;return(await J(X(`/api/workflows/runs/${encodeURIComponent(e)}${r}`))).view}async function ehe(e,t){let n=new URLSearchParams;o8(n,t);let r=n.size>0?`?${n.toString()}`:``;return(await J(X(`/api/workflows/runs/${encodeURIComponent(e)}/comparison${r}`))).comparison}async function the(e,t,n){let r=new URLSearchParams;o8(r,n);let i=r.size>0?`?${r.toString()}`:``,a=await Y(X(`/api/workflows/runs/${encodeURIComponent(e)}/artifacts/${encodeURIComponent(t)}${i}`),{headers:{Accept:`*/*`}});if(!a.ok){let e=await a.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message;throw Error(te(a.status,a.statusText,t))}return a.blob()}async function nhe(e){return J(X(`/api/workflows/runs`),{method:`POST`,body:JSON.stringify(e)})}async function rhe(e,t=50){let n=new URLSearchParams({limit:String(t)});return(await J(X(`/api/goals/${encodeURIComponent(e)}/workflow-runs?${n.toString()}`))).runs??[]}async function s8(e){let t=await J(X(`/api/goals/${encodeURIComponent(e.goalId)}/workflows/run`),{method:`POST`,body:JSON.stringify({definitionId:e.definitionId,goal:e.goal,input:e.input,concurrency:e.concurrency,maxSubagents:e.maxSubagents})});return{runId:t.runId,sessionKey:t.sessionKey}}async function c8(e,t){let n=new URLSearchParams;o8(n,t);let r=n.size>0?`?${n.toString()}`:``;await J(X(`/api/workflows/runs/${encodeURIComponent(e)}/cancel${r}`),{method:`POST`})}async function ihe(e,t){let n=new URLSearchParams;o8(n,t);let r=n.size>0?`?${n.toString()}`:``,i=t?.projectId?.trim();return J(X(`/api/workflows/runs/${encodeURIComponent(e)}/retry${r}`),{method:`POST`,body:JSON.stringify(i?{projectId:i}:{})})}async function ahe(e,t,n){let r=new URLSearchParams;o8(r,n);let i=r.size>0?`?${r.toString()}`:``;return J(X(`/api/workflows/runs/${encodeURIComponent(e)}/replay${i}`),{method:`POST`,body:JSON.stringify({scope:t})})}var l8=`min-w-0 rounded-md border border-edge bg-surface-muted px-2.5 py-1.5 text-xs text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`;function u8(e){return`${e.status===`blocked`||e.status===`needs_input`?`${e.status}: `:``}${e.title}`}function ohe({sessionKey:e,disabled:t,onDone:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)([]),[l,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),b=(0,Z.useCallback)(async()=>{if(e){y(null);try{let[t,n]=await Promise.all([r8(e),Hme({limit:100})]);i(t.goal),o(n.goals),p(e=>e||n.goals.find(e=>e.id!==t.goal?.id)?.id||``)}catch(e){y(e instanceof Error?e.message:`Failed to load goals`)}}},[e]);(0,Z.useEffect)(()=>{let e=!1;return a8().then(t=>{e||(c(t),h(e=>e||t[0]?.id||``))}).catch(t=>{e||y(t instanceof Error?t.message:`Failed to load workflows`)}),()=>{e=!0}},[]),(0,Z.useEffect)(()=>{b()},[b]);let x=(0,Z.useMemo)(()=>a.filter(e=>e.id!==r?.id),[a,r?.id]),S=(0,Z.useCallback)(()=>{e&&window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:e}}))},[e]),C=async()=>{if(!e)return;let t=l.trim();if(t){_(`start`),y(null);try{i((await Vme(e,t)).goal),d(``),S(),re({type:`success`,title:`Goal started`,message:t}),n?.()}catch(e){y(e instanceof Error?e.message:`Failed to start goal`)}finally{_(null)}}},w=async()=>{if(!(!e||!f)){_(`attach`),y(null);try{let t=await Wme(e,f);i(t.goal),S(),re({type:`success`,title:`Goal attached`,message:t.goal?.title}),n?.()}catch(e){y(e instanceof Error?e.message:`Failed to attach goal`)}finally{_(null)}}},T=async()=>{if(r){_(`detach`),y(null);try{await Gme(r.id),i(null),S(),re({type:`info`,title:`Goal detached`}),n?.()}catch(e){y(e instanceof Error?e.message:`Failed to detach goal`)}finally{_(null)}}},E=async()=>{if(!(!r||!m)){_(`workflow`),y(null);try{let e=await s8({goalId:r.id,definitionId:m,goal:r.nextAction||r.title});S(),re({type:`success`,title:`Workflow started`,message:r.title}),window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e.sessionKey}})),n?.()}catch(e){y(e instanceof Error?e.message:`Failed to start workflow`)}finally{_(null)}}},D=t||!e||g!=null;return(0,$.jsxs)(`div`,{className:`grid w-72 gap-2 px-1 py-1 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1.5 text-fg`,children:[(0,$.jsx)(rE,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:`Goal`}),(0,$.jsx)(`div`,{className:`truncate text-fg-muted`,children:r?u8(r):`No goal attached`})]})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-edge/70 bg-surface-muted/30 p-2`,children:[(0,$.jsx)(`div`,{className:`font-medium text-fg-muted`,children:`Start goal`}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(`input`,{value:l,onChange:e=>d(e.target.value),className:u(l8,`flex-1`),placeholder:`Goal title`,disabled:D}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-accent text-white disabled:opacity-50`,disabled:D||!l.trim(),title:`Start goal`,"aria-label":`Start goal`,onClick:()=>void C(),children:(0,$.jsx)(Ly,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-edge/70 bg-surface-muted/30 p-2`,children:[(0,$.jsx)(`div`,{className:`font-medium text-fg-muted`,children:r?`Switch goal`:`Attach goal`}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsxs)(Aj,{value:f,onChange:e=>p(e.target.value),className:u(l8,`flex-1`),disabled:D||x.length===0,children:[x.length===0?(0,$.jsx)(Dj,{value:``,children:`No open goals`}):null,x.map(e=>(0,$.jsx)(Dj,{value:e.id,children:u8(e)},e.id))]}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md border border-edge text-fg hover:bg-surface-hover disabled:opacity-50`,disabled:D||!f,title:r?`Switch goal`:`Attach goal`,"aria-label":r?`Switch goal`:`Attach goal`,onClick:()=>void w(),children:(0,$.jsx)(Ov,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center gap-2 rounded-md px-2 text-left text-fg hover:bg-surface-hover disabled:opacity-50`,disabled:D||!r,onClick:()=>void T(),children:[(0,$.jsx)(BD,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),`Detach current goal`]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-edge/70 bg-surface-muted/30 p-2`,children:[(0,$.jsx)(`div`,{className:`font-medium text-fg-muted`,children:`Run workflow`}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsxs)(Aj,{value:m,onChange:e=>h(e.target.value),className:u(l8,`flex-1`),disabled:D||!r||s.length===0,children:[s.length===0?(0,$.jsx)(Dj,{value:``,children:`No workflows`}):null,s.map(e=>(0,$.jsx)(Dj,{value:e.id,children:e.title||e.name},e.id))]}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md border border-edge text-fg hover:bg-surface-hover disabled:opacity-50`,disabled:D||!r||!m,title:`Run workflow`,"aria-label":`Run workflow`,onClick:()=>void E(),children:(0,$.jsx)(rE,{className:`size-4`,"aria-hidden":!0})})]})]}),v?(0,$.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5 text-destructive`,children:v}):null]})}function she(e){return e===`off`?$o:SC}var che=(0,Z.memo)(function(e){let t=(0,Q.c)(104),{sessionKey:n,sessionManager:r,disabled:i,sending:a,streaming:o,canSelectWorkingDirectory:s,runBusy:c,chat:l,hasDraft:d,showSteeringInterrupt:f,attachmentCount:p,maxAttachments:m,onPickFiles:h,onOpenReviewLauncher:g,thinkingLevel:_,showThinkingSelector:v,onThinkingChange:y,voiceActive:b,onStartVoiceInput:x,onSend:S,onAbort:C,onInterrupt:w,sessionModel:T,showModelSelector:E,onModelChange:D,modelDisabled:O,contextUsageMessages:k,composerDraftChars:A}=e,[j,M]=(0,Z.useState)(!1),N=_,P;t[0]===N?P=t[1]:(P=she(N),t[0]=N,t[1]=P);let F=P,I=p>=m,L;t[2]!==p||t[3]!==I||t[4]!==l.attachFile||t[5]!==l.maxAttachmentsReached||t[6]!==m?(L=I?P6(l.maxAttachmentsReached,{max:m}):`${l.attachFile} (${p}/${m})`,t[2]=p,t[3]=I,t[4]=l.attachFile,t[5]=l.maxAttachmentsReached,t[6]=m,t[7]=L):L=t[7];let R=L,z;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(z=u(`flex flex-wrap items-center gap-2 border-t border-edge-subtle/90 px-4 py-2.5 dark:border-edge-subtle`),t[8]=z):z=t[8];let B=i||c,V;t[9]!==s||t[10]!==n||t[11]!==r||t[12]!==B?(V=(0,$.jsx)(Bme,{sessionKey:n,sessionMgr:r,canSelectWorkingDirectory:s,disabled:B}),t[9]=s,t[10]=n,t[11]=r,t[12]=B,t[13]=V):V=t[13];let H;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(H=u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-subtle hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/50`,lA.transition,lA.press,lA.focusRingPanel),t[14]=H):H=t[14];let U;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(Ly,{className:`size-4`}),t[15]=U):U=t[15];let W;t[16]!==l.moreActions||t[17]!==j?(W=(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:H,title:l.moreActions,"aria-label":l.moreActions,"aria-expanded":j,children:U})}),t[16]=l.moreActions,t[17]=j,t[18]=W):W=t[18];let G;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(G=u(`z-50 min-w-[12rem] rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover dark:border-edge`),t[19]=G):G=t[19];let K=i||c,q;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>M(!1),t[20]=q):q=t[20];let ee;t[21]!==n||t[22]!==K?(ee=(0,$.jsx)(ohe,{sessionKey:n,disabled:K,onDone:q}),t[21]=n,t[22]=K,t[23]=ee):ee=t[23];let J;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(J=u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:cursor-not-allowed disabled:opacity-50`),t[24]=J):J=t[24];let te=i||c||!n,Y;t[25]===g?Y=t[26]:(Y=()=>{g(),M(!1)},t[25]=g,t[26]=Y);let ne;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(kv,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[27]=ne):ne=t[27];let re;t[28]===l.reviewLauncher.actionLabel?re=t[29]:(re=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:l.reviewLauncher.actionLabel}),t[28]=l.reviewLauncher.actionLabel,t[29]=re);let X;t[30]!==te||t[31]!==Y||t[32]!==re?(X=(0,$.jsxs)(`button`,{type:`button`,className:J,disabled:te,onClick:Y,children:[ne,re]}),t[30]=te,t[31]=Y,t[32]=re,t[33]=X):X=t[33];let ie;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(`div`,{className:`my-1 h-px bg-edge-subtle`}),t[34]=ie):ie=t[34];let ae;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ae=u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:cursor-not-allowed disabled:opacity-50`),t[35]=ae):ae=t[35];let oe=I||i||c,se;t[36]===h?se=t[37]:(se=()=>{h(),M(!1)},t[36]=h,t[37]=se);let ce;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(Eg,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[38]=ce):ce=t[38];let le;t[39]===l.attachFile?le=t[40]:(le=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:l.attachFile}),t[39]=l.attachFile,t[40]=le);let ue;t[41]!==p||t[42]!==m?(ue=(0,$.jsxs)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:[p,`/`,m]}),t[41]=p,t[42]=m,t[43]=ue):ue=t[43];let de;t[44]!==R||t[45]!==oe||t[46]!==se||t[47]!==le||t[48]!==ue?(de=(0,$.jsxs)(`button`,{type:`button`,className:ae,disabled:oe,title:R,onClick:se,children:[ce,le,ue]}),t[44]=R,t[45]=oe,t[46]=se,t[47]=le,t[48]=ue,t[49]=de):de=t[49];let fe;t[50]!==F||t[51]!==i||t[52]!==l.thinkingLevelLabel||t[53]!==l.thinkingLevels||t[54]!==y||t[55]!==a||t[56]!==v||t[57]!==o||t[58]!==_?(fe=v?(0,$.jsxs)(`label`,{className:u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-sm text-fg`,`hover:bg-surface-hover`),title:`${l.thinkingLevelLabel}: ${l.thinkingLevels[_]??_}`,children:[(0,$.jsx)(F,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:l.thinkingLevelLabel}),(0,$.jsx)(Aj,{className:`min-w-0 flex-1 cursor-pointer appearance-none rounded-md bg-surface-hover/80 px-2 py-0.5 text-sm font-medium text-fg focus:outline-none focus-visible:ring-2 focus-visible:ring-accent`,value:_,disabled:i||a&&!o,onChange:e=>y(e.target.value),children:Object.keys(l.thinkingLevels).map(e=>(0,$.jsx)(Dj,{value:e,children:l.thinkingLevels[e]},e))})]}):null,t[50]=F,t[51]=i,t[52]=l.thinkingLevelLabel,t[53]=l.thinkingLevels,t[54]=y,t[55]=a,t[56]=v,t[57]=o,t[58]=_,t[59]=fe):fe=t[59];let pe;t[60]!==ee||t[61]!==X||t[62]!==de||t[63]!==fe?(pe=(0,$.jsx)(lj,{children:(0,$.jsx)(uj,{className:G,side:`top`,align:`start`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:lhe,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[ee,X,ie,de,fe]})})}),t[60]=ee,t[61]=X,t[62]=de,t[63]=fe,t[64]=pe):pe=t[64];let me;t[65]!==j||t[66]!==pe||t[67]!==W?(me=(0,$.jsxs)(oj,{open:j,onOpenChange:M,children:[W,pe]}),t[65]=j,t[66]=pe,t[67]=W,t[68]=me):me=t[68];let he;t[69]!==A||t[70]!==k||t[71]!==l||t[72]!==O||t[73]!==D||t[74]!==T||t[75]!==E?(he=E?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`min-w-0 w-fit max-w-[min(20rem,calc(100vw-10rem))] shrink-0`,children:(0,$.jsx)(z6,{value:T,disabled:O,placeholder:l.modelPlaceholder,searchPlaceholder:l.modelSearchPlaceholder,noMatches:l.modelNoMatches,compact:!0,showProviderInTrigger:!1,contentSide:`top`,contentAlign:`end`,showProviderSettingsFooter:!0,onChange:D})}),(0,$.jsx)(mme,{sessionModel:T,messages:k,draftChars:A,chat:l,disabled:O})]}):null,t[69]=A,t[70]=k,t[71]=l,t[72]=O,t[73]=D,t[74]=T,t[75]=E,t[76]=he):he=t[76];let ge;t[77]!==i||t[78]!==l.voiceInput||t[79]!==x||t[80]!==b?(ge=b?null:(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-fg-subtle hover:bg-surface-hover hover:text-fg`,lA.transition,lA.press,lA.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),disabled:i,title:l.voiceInput,"aria-label":l.voiceInput,onClick:()=>void x(),children:(0,$.jsx)(Uv,{className:`size-4 stroke-[1.75]`})}),t[77]=i,t[78]=l.voiceInput,t[79]=x,t[80]=b,t[81]=ge):ge=t[81];let _e;t[82]!==i||t[83]!==d||t[84]!==l.abort||t[85]!==l.sendMessage||t[86]!==l.steeringInterruptSend||t[87]!==C||t[88]!==w||t[89]!==S||t[90]!==c||t[91]!==f||t[92]!==b?(_e=c?(0,$.jsxs)($.Fragment,{children:[f&&w?(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-accent-fg hover:bg-accent-soft dark:hover:bg-accent-soft`,lA.transition,lA.press,lA.focusRingPanel),title:l.steeringInterruptSend,"aria-label":l.steeringInterruptSend,onClick:()=>void w(),children:(0,$.jsx)(rS,{className:`size-4 stroke-[1.75]`})}):null,(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/50`,lA.transition,lA.press,lA.focusRingPanel),title:l.abort,"aria-label":l.abort,onClick:C,children:(0,$.jsx)(Yw,{className:`size-4 stroke-[1.75]`})})]}):(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border transition-colors duration-150 ease-out`,lA.press,lA.focusRingPanel,d?`border-transparent text-accent-fg hover:bg-accent-soft dark:text-accent-fg dark:hover:bg-accent-soft`:`border-transparent text-fg-disabled`),disabled:i||b||!d,title:l.sendMessage,"aria-label":l.sendMessage,onClick:S,children:(0,$.jsx)(rS,{className:`size-4 stroke-[1.75]`})}),t[82]=i,t[83]=d,t[84]=l.abort,t[85]=l.sendMessage,t[86]=l.steeringInterruptSend,t[87]=C,t[88]=w,t[89]=S,t[90]=c,t[91]=f,t[92]=b,t[93]=_e):_e=t[93];let ve;t[94]!==ge||t[95]!==_e?(ve=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[ge,_e]}),t[94]=ge,t[95]=_e,t[96]=ve):ve=t[96];let ye;t[97]!==he||t[98]!==ve?(ye=(0,$.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-2`,children:[he,ve]}),t[97]=he,t[98]=ve,t[99]=ye):ye=t[99];let be;return t[100]!==me||t[101]!==ye||t[102]!==V?(be=(0,$.jsxs)(`div`,{className:z,children:[V,me,ye]}),t[100]=me,t[101]=ye,t[102]=V,t[103]=be):be=t[103],be});function lhe(e){return e.preventDefault()}function uhe(e){return e.map(e=>({type:e.type===`voice`?`voice`:(e.mimeType??``).startsWith(`image/`)?`image`:`document`,mimeType:e.mimeType??`application/octet-stream`,content:e.data??``,name:e.name??`file`,size:e.size??0,uri:e.uri,...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}}))}var dhe=100,fhe=400,d8=900;function phe(e,t){switch(t.type){case`reset`:return{box:null,hoverPreview:null};case`set-box`:return{...e,box:t.box};case`set-hover`:return{...e,hoverPreview:t.hoverPreview}}}function mhe(e,t){let n=t.trim().toLowerCase();if(!n)return[];let r=e.toLowerCase(),i=[],a=0;for(let e=0;e<r.length&&a<n.length;e++)r[e]===n[a]&&(i.push([e,e+1]),a++);return i}function hhe(e){let t=(0,Q.c)(8),{name:n,query:r}=e,i;t[0]!==n||t[1]!==r?(i=mhe(n,r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i;if(a.length===0){let e;return t[3]===n?e=t[4]:(e=(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:n}),t[3]=n,t[4]=e),e}let o;if(t[5]!==n||t[6]!==a){let e=[],r=0;a.forEach(t=>{let[i,a]=t;i>r&&e.push((0,$.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r,i)},`pre-${i}`)),e.push((0,$.jsx)(`span`,{className:`font-semibold text-accent-fg`,children:n.slice(i,a)},`hl-${i}-${a}`)),r=a}),r<n.length&&e.push((0,$.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r)},`tail`)),o=(0,$.jsx)($.Fragment,{children:e}),t[5]=n,t[6]=a,t[7]=o}else o=t[7];return o}var ghe=(0,Z.memo)(function(e){let t=(0,Q.c)(44),{open:n,anchorRef:r,items:i,selectedIndex:a,loading:o,query:s,noResults:c,sessionKey:l,recentLabel:d,ariaLabel:f,onSelectItem:p,shiftHint:m}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h={box:null,hoverPreview:null},t[0]=h):h=t[0];let[g,_]=(0,Z.useReducer)(phe,h),v=g.box,y=g.hoverPreview,b=(0,Z.useRef)(null),x=(0,Z.useRef)(0),S=(0,Z.useRef)(null),C;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{b.current&&=(clearTimeout(b.current),null)},t[1]=C):C=t[1];let w=C,T;t[2]===l?T=t[3]:(T=(e,t,n)=>{w(),x.current+=1;let r=x.current,i=e.relativePath;if(!l?.trim()||e.isDirectory||e.isBrowseUp||!i){_({type:`set-hover`,hoverPreview:null});return}b.current=setTimeout(()=>{b.current=null,r===x.current&&Pq(i,{sessionKey:l}).then(e=>{let{content:i}=e,a=i.length>d8?`${i.slice(0,d8)}…`:i;r===x.current&&_({type:`set-hover`,hoverPreview:{text:a,x:t,y:n}})}).catch(()=>{r===x.current&&_({type:`set-hover`,hoverPreview:null})})},420)},t[2]=l,t[3]=T);let E=T,D,O;t[4]!==r||t[5]!==n?(D=()=>{if(!n){_({type:`reset`}),w(),x.current+=1;return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();_({type:`set-box`,box:{left:t.left,top:t.top,width:t.width}})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},O=[n,r],t[4]=r,t[5]=n,t[6]=D,t[7]=O):(D=t[6],O=t[7]),(0,Z.useLayoutEffect)(D,O);let k,A;if(t[8]!==i.length||t[9]!==n||t[10]!==a?(k=()=>{!n||a<0||a>=i.length||(S.current?.querySelector(`#at-mention-${a}`))?.scrollIntoView({block:`nearest`})},A=[n,a,i.length],t[8]=i.length,t[9]=n,t[10]=a,t[11]=k,t[12]=A):(k=t[11],A=t[12]),(0,Z.useLayoutEffect)(k,A),!n||typeof document>`u`||v===null)return null;let j=i.length,M=Math.min(v.width,fhe),N;t[13]!==v.left||t[14]!==v.top||t[15]!==M?(N={position:`fixed`,left:v.left,top:v.top,width:M,transform:`translateY(calc(-100% - 8px))`,zIndex:dhe},t[13]=v.left,t[14]=v.top,t[15]=M,t[16]=N):N=t[16];let P=a>=0&&a<j?`at-mention-${a}`:void 0,F;t[17]!==o||t[18]!==j?(F=o&&j===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 text-sm text-fg-muted`,children:[(0,$.jsx)(Fv,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:`…`})]}):null,t[17]=o,t[18]=j,t[19]=F):F=t[19];let I;t[20]!==i||t[21]!==o||t[22]!==c||t[23]!==p||t[24]!==s||t[25]!==d||t[26]!==E||t[27]!==a||t[28]!==j?(I=!o&&j===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-fg-muted`,children:c}):(0,$.jsx)($.Fragment,{children:i.map((e,t)=>(0,$.jsxs)(`div`,{id:`at-mention-${t}`,role:`option`,"aria-selected":a===t,tabIndex:-1,className:u(`flex cursor-pointer items-start gap-2 px-3 py-2 text-left text-sm`,a===t?`bg-surface-hover text-fg`:`text-fg-subtle hover:bg-surface-hover/80`,e.isRecent&&`border-l-2 border-l-accent/60`),onPointerDown:t=>{t.pointerType===`mouse`&&t.button!==0||(t.preventDefault(),p(e,{shiftKey:t.shiftKey}))},onPointerEnter:t=>E(e,t.clientX,t.clientY),onPointerLeave:()=>{w(),x.current+=1,_({type:`set-hover`,hoverPreview:null})},children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.isBrowseUp?(0,$.jsx)(O_,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0}):e.isDirectory?(0,$.jsx)(O_,{className:`size-3.5 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}):(0,$.jsx)(_g,{className:u(`size-3.5`,_q(e.name)),"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:(0,$.jsx)(hhe,{name:e.name,query:s})}),e.isRecent?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-accent-soft px-1 py-0 text-[0.65rem] text-accent-fg`,children:d}):null]}),(0,$.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:e.relativePath||`—`})]})]},`${e.relativePath}-${e.name}`))}),t[20]=i,t[21]=o,t[22]=c,t[23]=p,t[24]=s,t[25]=d,t[26]=E,t[27]=a,t[28]=j,t[29]=I):I=t[29];let L;t[30]!==f||t[31]!==F||t[32]!==I||t[33]!==P?(L=(0,$.jsxs)(`div`,{ref:S,className:`max-h-[min(26rem,54vh)] overflow-y-auto`,role:`listbox`,"aria-label":f,"aria-activedescendant":P,children:[F,I]}),t[30]=f,t[31]=F,t[32]=I,t[33]=P,t[34]=L):L=t[34];let R;t[35]===m?R=t[36]:(R=m?(0,$.jsx)(`div`,{className:`border-t border-edge-subtle px-3 py-1.5 text-[0.65rem] text-fg-muted`,children:m}):null,t[35]=m,t[36]=R);let z;t[37]===y?z=t[38]:(z=y?(0,$.jsx)(`div`,{className:`pointer-events-none fixed z-[200] max-h-48 max-w-sm overflow-auto rounded-md border border-edge bg-surface-panel p-2 font-mono text-[0.7rem] text-fg shadow-lg`,style:{left:Math.min(y.x+12,window.innerWidth-320),top:Math.min(y.y+12,window.innerHeight-200)},children:y.text}):null,t[37]=y,t[38]=z);let B;return t[39]!==L||t[40]!==R||t[41]!==z||t[42]!==N?(B=(0,Xi.createPortal)((0,$.jsxs)(`div`,{className:`pointer-events-auto max-h-[min(28rem,60vh)] min-h-[2.5rem] overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-lg dark:bg-surface-panel/95`,style:N,role:`presentation`,children:[L,R,z]}),document.body),t[39]=L,t[40]=R,t[41]=z,t[42]=N,t[43]=B):B=t[43],B}),f8=new Set([`abort`,`stop`,`cancel`]);function _he(e){if(e.kind!==`command`)return!1;if(f8.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(f8.has(t.toLowerCase()))return!0;return!1}function p8(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}var vhe={skill:(e,t)=>{let n=t.slashRange;if(!n)return;if(e.availability?.status&&e.availability.status!==`available`){t.callbacks.onUnavailableSkill?.(e);return}let r=`/skill:${e.name} `,i=p8(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0})},command:(e,t)=>{let n=t.slashRange;if(!n||n.start!==0)return;if(e.name.toLowerCase()===`review`&&t.callbacks.onReviewLauncher&&!t.runBusy&&t.pendingFollowUpsCount===0){let e=t.editor.valueRef.current,r=e.slice(0,n.start)+e.slice(n.end);t.editor.resetEditor({nextText:r,caretOffset:n.start,focus:!0}),t.callbacks.onReviewLauncher();return}if(e.acceptsArgs===!0){let r=`/${e.name} `,i=p8(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0});return}let r=`/${e.name}`;if(t.runBusy||t.pendingFollowUpsCount>0){if(_he(e)){if(!t.callbacks.onAbort)return;t.callbacks.onAbort();let e=t.editor.valueRef.current,r=e.slice(0,n.start)+e.slice(n.end);t.editor.resetEditor({nextText:r,caretOffset:n.start});return}if(!t.callbacks.onAddPendingFollowUp||t.pendingFollowUpsCount>=t.maxPendingFollowUps)return;t.callbacks.onAddPendingFollowUp(r,void 0),t.callbacks.onUserTextCommitted?.(r),t.attachments.clearAttachments(),t.editor.resetEditor();return}t.callbacks.onSend(r,void 0,t.thinkingLevel),t.callbacks.onUserTextCommitted?.(r),t.attachments.clearAttachments(),t.editor.resetEditor()},agent:(e,t)=>{let n=t.slashRange;if(!n||n.start!==0||!t.callbacks.onChatAgentChange)return;let r=t.editor.valueRef.current,i=r.slice(0,n.start)+r.slice(n.end);t.editor.resetEditor({nextText:i,caretOffset:n.start}),t.attachments.clearAttachments(),t.callbacks.onChatAgentChange(e.name)}};function yhe(e,t){let n=vhe[e.kind];n&&n(e,t)}var m8={new:10,help:11,list:12,clear:13,switch:14,models:15,usage:16,skills:17,settings:18,start:19,think:20,reasoning:21,verbose:22,status:23,tts:24},bhe=new Set([`abort`,`archive`]);function h8(e){if(e.kind===`command`){let t=e.name.toLowerCase();if(m8[t]!==void 0)return 0;if(bhe.has(t))return 2}return 1}function g8(e,t){let n=h8(e),r=h8(t);if(n!==r)return n-r;if(n===0){let n=m8[e.name.toLowerCase()]??999,r=m8[t.name.toLowerCase()]??999;if(n!==r)return n-r}let i=e.name.localeCompare(t.name);return i===0?e.id.localeCompare(t.id):i}var xhe=RegExp(`^@file:${m6}`,`u`);function _8(e){if(e.kind!==`command`)return!1;if(f8.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(f8.has(t.toLowerCase()))return!0;return!1}function v8(e,t){return e.kind!==`command`||e.acceptsArgs===!0||_8(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount>=t.maxPendingFollowUps}function She(e,t){return e.kind!==`command`||e.acceptsArgs===!0||_8(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount<t.maxPendingFollowUps}function Che(e,t){let n=0;for(;n<e.length;){let r=e.indexOf(`@file:`,n);if(r===-1)return null;let i=e.slice(r).match(xhe);if(!i){n=r+1;continue}let a=r+i[0].length;if(t>=r&&t<a)return{start:r,end:a};n=a}return null}var whe=20,y8=3;function The(e){return e.includes(`/`)||/^[A-Za-z]:/u.test(e)?!0:/^(Users|home|var|tmp|etc|opt|private|Volumes|System|Applications|Library|usr|dev|bin|sbin|proc|sys)(\/|$)/iu.test(e)}function Ehe(e,t){if(t===0)return!1;let n=e[t-1];if(n===void 0||n===`.`||n===`:`||n===`/`)return!0;let r=e.slice(0,t);return/[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/u.test(r)}function Dhe(e,t){let n=e.length,r=Math.min(Math.max(t,0),n);if(r<1&&e===`/`&&(r=1),r<1)return null;let i=e.slice(0,r).match(/\/[^\s]*$/);if(!i||i.index===void 0||Che(e,i.index))return null;let a=i.index;if(Ehe(e,a))return null;let o=i[0],s=o.slice(1);return The(s)||o.startsWith(`/skill:`)?null:{start:i.index,end:r,query:s}}function Ohe(e,t){let n=t.trim().toLowerCase();if(!n)return 0;let r=e.name.toLowerCase();if(r===n)return 0;for(let t of e.aliases??[])if(t.toLowerCase()===n)return 1;if(r.startsWith(n))return 2;for(let t of e.aliases??[])if(t.toLowerCase().startsWith(n))return 3;if(r.includes(n))return 4;for(let t of e.aliases??[])if(t.toLowerCase().includes(n))return 5;return(e.description??``).toLowerCase().includes(n)?100:(e.category??``).toLowerCase().includes(n)?101:e.kind===`skill`&&(e.source??``).toLowerCase().includes(n)?102:null}function khe(e,t){return t===0?0:Math.min(e,t-1)}function Ahe(e,t,n){let r=(0,Q.c)(57),[i,a]=(0,Z.useState)(0),[o,s]=(0,Z.useState)(0),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m=_(Ghe);n?.isComposing;let h;r[0]!==t||r[1]!==n?.isComposing||r[2]!==e?(h=n?.isComposing?null:Dhe(e,t),r[0]=t,r[1]=n?.isComposing,r[2]=e,r[3]=h):h=r[3];let g=h,v=!!(g&&!n?.suppress),y,b;r[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&(t.section===`skills`||t.section===`agents`)&&s(Whe)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},b=[],r[4]=y,r[5]=b):(y=r[4],b=r[5]),(0,Z.useEffect)(y,b),!v&&(c||u||f)&&(l(!1),d(!1),p(!1));let x;r[6]===n?.currentAgentId?x=r[7]:(x=async()=>{let[e,t,r]=await Promise.all([D4(),O4(n?.currentAgentId),_I().catch(Uhe)]),i=e.map(Hhe),a=t.skills.map(Vhe),o=r&&r.items.length>1?r.items.map(Bhe):[];return[...a,...i,...o]},r[6]=n?.currentAgentId,r[7]=x);let S=n?.currentAgentId,C;r[8]!==m||r[9]!==o||r[10]!==S?(C=[m,S,o],r[8]=m,r[9]=o,r[10]=S,r[11]=C):C=r[11];let w;r[12]===Symbol.for(`react.memo_cache_sentinel`)?(w=[],r[12]=w):w=r[12];let T;r[13]===Symbol.for(`react.memo_cache_sentinel`)?(T=[],r[13]=T):T=r[13];let E;r[14]===v?E=r[15]:(E={enabled:v,initial:w,errorData:T},r[14]=v,r[15]=E);let D=lP(x,C,E),O=D.data,k=D.error==null?null:D.error instanceof Error?D.error.message:String(D.error),A=g?.query??``,j=g!==null&&g.start===0,M=j,N;r[16]===A?N=r[17]:(N=A.trim(),r[16]=A,r[17]=N);let P=N===``,F=v&&P&&c,I=v&&P&&u,L=v&&P&&f,R;r[18]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{l(!0)},r[18]=R):R=r[18];let z=R,B;r[19]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{d(!0)},r[19]=B):B=r[19];let V=B,H;r[20]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{p(!0)},r[20]=H):H=r[20];let U=H,W;if(r[21]!==M||r[22]!==O||r[23]!==j||r[24]!==L||r[25]!==I||r[26]!==F||r[27]!==P||r[28]!==A||r[29]!==e){bb0:{let t=qpe(e),n=[];for(let e of O){if(e.kind===`command`&&!j||e.kind===`agent`&&!M||e.kind===`skill`&&t.has(e.name)||e.kind===`skill`&&P&&e.availability?.status!==`available`)continue;let r=Ohe(e,A);r!==null&&n.push({item:e,rank:r})}if(P){let e=zhe,t=n.filter(Rhe).sort(e).map(Lhe),r=n.filter(Ihe).sort(e).map(Fhe),i=n.filter(Phe).sort(e).map(Nhe),a=F?t:t.slice(0,y8),o=I?r:r.slice(0,y8),s=L?i:i.slice(0,y8),c=F?0:Math.max(0,t.length-y8),l=I?0:Math.max(0,r.length-y8),u=L?0:Math.max(0,i.length-y8);W={items:[...a,...o,...s],skillRowCount:a.length,commandRowCount:o.length,groupedHasSkills:t.length>0,groupedHasCommands:r.length>0,groupedHasAgents:i.length>0,groupedSkillsMoreCount:c,groupedCommandsMoreCount:l,groupedAgentsMoreCount:u};break bb0}n.sort(Mhe);let i;r[31]===n?i=r[32]:(i={items:n.slice(0,whe).map(jhe),skillRowCount:0,commandRowCount:0,groupedHasSkills:!1,groupedHasCommands:!1,groupedHasAgents:!1,groupedSkillsMoreCount:0,groupedCommandsMoreCount:0,groupedAgentsMoreCount:0},r[31]=n,r[32]=i),W=i}r[21]=M,r[22]=O,r[23]=j,r[24]=L,r[25]=I,r[26]=F,r[27]=P,r[28]=A,r[29]=e,r[30]=W}else W=r[30];let{items:G,skillRowCount:K,commandRowCount:q,groupedHasSkills:ee,groupedHasCommands:J,groupedHasAgents:te,groupedSkillsMoreCount:Y,groupedCommandsMoreCount:ne,groupedAgentsMoreCount:re}=W,X=g?A:``,ie=(0,Z.useRef)(X);ie.current!==X&&(ie.current=X,i!==0&&a(0));let ae;r[33]!==G.length||r[34]!==i?(ae=khe(i,G.length),r[33]=G.length,r[34]=i,r[35]=ae):ae=r[35];let oe=ae,se;r[36]===G.length?se=r[37]:(se=e=>{G.length!==0&&a(t=>e===`down`?(t+1)%G.length:(t-1+G.length)%G.length)},r[36]=G.length,r[37]=se);let ce=se,le;return r[38]!==M||r[39]!==q||r[40]!==j||r[41]!==P||r[42]!==re||r[43]!==ne||r[44]!==te||r[45]!==J||r[46]!==ee||r[47]!==Y||r[48]!==G||r[49]!==k||r[50]!==ce||r[51]!==v||r[52]!==A||r[53]!==oe||r[54]!==K||r[55]!==g?(le={open:v,slashRange:g,commandsAllowed:j,agentsAllowed:M,grouped:P,skillRowCount:K,commandRowCount:q,groupedHasSkills:ee,groupedHasCommands:J,groupedHasAgents:te,groupedSkillsMoreCount:Y,groupedCommandsMoreCount:ne,groupedAgentsMoreCount:re,items:G,selectedIndex:oe,query:A,loadError:k,onNavigate:ce,setSelectedIndex:a,expandGroupedSkills:z,expandGroupedCommands:V,expandGroupedAgents:U},r[38]=M,r[39]=q,r[40]=j,r[41]=P,r[42]=re,r[43]=ne,r[44]=te,r[45]=J,r[46]=ee,r[47]=Y,r[48]=G,r[49]=k,r[50]=ce,r[51]=v,r[52]=A,r[53]=oe,r[54]=K,r[55]=g,r[56]=le):le=r[56],le}function jhe(e){return e.item}function Mhe(e,t){let n=e.item.kind===`skill`&&e.item.availability?.status!==`available`;if(n!==(t.item.kind===`skill`&&t.item.availability?.status!==`available`))return n?1:-1;if(e.rank!==t.rank)return e.rank-t.rank;let r=g8(e.item,t.item);return r===0?0:r}function Nhe(e){return e.item}function Phe(e){return e.item.kind===`agent`}function Fhe(e){return e.item}function Ihe(e){return e.item.kind===`command`}function Lhe(e){return e.item}function Rhe(e){return e.item.kind===`skill`}function zhe(e,t){let n=g8(e.item,t.item);return n===0?e.item.id.localeCompare(t.item.id):n}function Bhe(e){return{kind:`agent`,id:`agent:${e.id}`,name:e.id,description:e.description??``,category:`agent`,...e.avatar?{avatar:e.avatar}:{},...e.name?{aliases:[e.name]}:{}}}function Vhe(e){return{kind:`skill`,id:`skill:${e.name}`,name:e.name,description:e.description,category:`skill`,source:e.source,availability:{status:e.availableForCurrentAgent?`available`:e.unavailableReason??`agent-denied`,reason:e.unavailableReason??void 0}}}function Hhe(e){return{kind:`command`,id:`cmd:${e.id}`,name:e.name,description:e.description,category:e.category,aliases:e.aliases,acceptsArgs:e.acceptsArgs}}function Uhe(){return null}function Whe(e){return e+1}function Ghe(e){return e.language}var Khe=100,qhe=280;function b8(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);if(r>=0)return(0,$.jsxs)($.Fragment,{children:[e.slice(0,r),(0,$.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]});let i=[],a=0,o=0;for(let t of e){let e=n[a],r=`${String(o)}-${t}`;e!==void 0&&t.toLowerCase()===e?(i.push((0,$.jsx)(`span`,{className:`text-accent-fg`,children:t},r)),a+=1):i.push((0,$.jsx)(Z.Fragment,{children:t},r)),o+=1}return(0,$.jsx)($.Fragment,{children:i})}function Jhe(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);return r<0?e:(0,$.jsxs)($.Fragment,{children:[e.slice(0,r),(0,$.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}var Yhe=(0,Z.memo)(function(e){let t=(0,Q.c)(45),{open:n,anchorRef:r,items:i,selectedIndex:a,noResults:o,grouped:s,skillRowCount:c,commandRowCount:l,query:d,skillsLabel:f,commandsLabel:p,agentsLabel:m,groupedHasSkills:h,groupedHasCommands:g,groupedHasAgents:_,groupedSkillsShowMoreLabel:v,groupedCommandsShowMoreLabel:y,groupedAgentsShowMoreLabel:b,currentAgentId:x,currentBadgeLabel:S,runBusy:C,pendingFollowUpsCount:w,maxPendingFollowUps:T,queueBadgeLabel:E,queueFullBadgeLabel:D,queueFullTooltip:O,skillUnavailableLabel:k,skillAgentDeniedLabel:A,onExpandSkills:j,onExpandCommands:M,onExpandAgents:N,onSelectItem:P,panelRef:F}=e,[I,L]=(0,Z.useState)(null),R,z;if(t[0]!==r||t[1]!==n?(R=()=>{if(!n){L(null);return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();L({left:t.left,top:t.top,width:t.width})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},z=[n,r],t[0]=r,t[1]=n,t[2]=R,t[3]=z):(R=t[2],z=t[3]),(0,Z.useLayoutEffect)(R,z),!n||typeof document>`u`||I===null)return null;let B=i.length,V=Math.min(I.width,qhe),H;if(t[4]!==m||t[5]!==l||t[6]!==p||t[7]!==x||t[8]!==S||t[9]!==s||t[10]!==b||t[11]!==y||t[12]!==_||t[13]!==g||t[14]!==h||t[15]!==v||t[16]!==i||t[17]!==T||t[18]!==o||t[19]!==N||t[20]!==M||t[21]!==j||t[22]!==P||t[23]!==w||t[24]!==d||t[25]!==E||t[26]!==D||t[27]!==O||t[28]!==C||t[29]!==a||t[30]!==A||t[31]!==c||t[32]!==k||t[33]!==f||t[34]!==B){let e=d.trim(),n=!s&&e.length>0,r={runBusy:C,pendingFollowUpsCount:w,maxPendingFollowUps:T},F=(t,i)=>{let o=t.kind===`skill`,s=t.kind===`agent`,c=s?(0,$.jsx)(dz,{agentId:t.name,avatar:t.avatar,size:18,className:`size-[18px] shrink-0`}):o?(0,$.jsx)(SC,{className:`size-3 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,$.jsx)(wk,{className:`size-3 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),l=s?n?(0,$.jsx)($.Fragment,{children:b8(t.name,e)}):(0,$.jsx)(`span`,{className:`text-fg`,children:t.name}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-fg`,children:`/`}),b8(t.name,e)]}):(0,$.jsxs)(`span`,{className:`text-fg`,children:[`/`,t.name]}),u=s&&x!=null&&x.length>0&&t.name===x,d=o&&t.availability?.status!==`available`,f=She(t,r),p=v8(t,r),m=null;return u?m=(0,$.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-accent-soft px-1 py-px text-[0.6rem] font-medium leading-none text-accent-fg`,"aria-label":S,children:S}):d?m=(0,$.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":t.availability?.reason??`unavailable`,children:t.availability?.status===`agent-denied`?A:k}):p?m=(0,$.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-red-100 px-1 py-px text-[0.6rem] font-medium leading-none text-red-700 dark:bg-red-900/40 dark:text-red-300`,"aria-label":D,children:D}):f&&(m=(0,$.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":E,children:E})),(0,$.jsx)(Xhe,{item:t,icon:c,selected:a===i,id:`palette-${i}`,nameLine:l,descriptionLine:t.description?n?Jhe(t.description,e):t.description:null,dimCategoryBadge:n,trailingBadge:m,disabled:p,disabledTooltip:p?O:void 0,onSelect:()=>P(t)})};H=B===0?(0,$.jsx)(`div`,{className:`p-2.5 text-xs leading-normal text-fg-muted`,children:o}):s?(0,$.jsxs)($.Fragment,{children:[h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mb-1.5 px-2.5 pt-2.5 text-[0.6rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,"aria-hidden":!0,children:f}),i.slice(0,c).map((e,t)=>(0,$.jsx)(Z.Fragment,{children:F(e,t)},e.id)),v?(0,$.jsx)(`button`,{type:`button`,className:`w-full px-2.5 py-1 text-left text-[11px] leading-tight text-fg-muted transition hover:bg-surface-hover/80 hover:text-fg`,onClick:e=>{e.preventDefault(),j()},children:v}):null]}):null,g?(0,$.jsxs)(`div`,{className:u(h&&`mt-1 border-t border-edge-subtle`),children:[(0,$.jsx)(`div`,{className:`mb-1.5 px-2.5 pt-2.5 text-[0.6rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,"aria-hidden":!0,children:p}),i.slice(c,c+l).map((e,t)=>(0,$.jsx)(Z.Fragment,{children:F(e,c+t)},e.id)),y?(0,$.jsx)(`button`,{type:`button`,className:`w-full px-2.5 py-1 text-left text-[11px] leading-tight text-fg-muted transition hover:bg-surface-hover/80 hover:text-fg`,onClick:e=>{e.preventDefault(),M()},children:y}):null]}):null,_?(0,$.jsxs)(`div`,{className:u((h||g)&&`mt-1 border-t border-edge-subtle`),children:[(0,$.jsx)(`div`,{className:`mb-1.5 px-2.5 pt-2.5 text-[0.6rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,"aria-hidden":!0,children:m}),i.slice(c+l).map((e,t)=>(0,$.jsx)(Z.Fragment,{children:F(e,c+l+t)},e.id)),b?(0,$.jsx)(`button`,{type:`button`,className:`w-full px-2.5 py-1 text-left text-[11px] leading-tight text-fg-muted transition hover:bg-surface-hover/80 hover:text-fg`,onClick:e=>{e.preventDefault(),N()},children:b}):null]}):null]}):i.map((e,t)=>(0,$.jsx)(Z.Fragment,{children:F(e,t)},e.id)),t[4]=m,t[5]=l,t[6]=p,t[7]=x,t[8]=S,t[9]=s,t[10]=b,t[11]=y,t[12]=_,t[13]=g,t[14]=h,t[15]=v,t[16]=i,t[17]=T,t[18]=o,t[19]=N,t[20]=M,t[21]=j,t[22]=P,t[23]=w,t[24]=d,t[25]=E,t[26]=D,t[27]=O,t[28]=C,t[29]=a,t[30]=A,t[31]=c,t[32]=k,t[33]=f,t[34]=B,t[35]=H}else H=t[35];let U=H,W;t[36]!==I.left||t[37]!==I.top||t[38]!==V?(W={position:`fixed`,left:I.left,top:I.top,width:V,transform:`translateY(calc(-100% - 8px))`,zIndex:Khe},t[36]=I.left,t[37]=I.top,t[38]=V,t[39]=W):W=t[39];let G=a>=0&&a<B?`palette-${a}`:void 0,K;return t[40]!==U||t[41]!==F||t[42]!==W||t[43]!==G?(K=(0,Xi.createPortal)((0,$.jsx)(z$,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!1,children:(0,$.jsx)(`div`,{ref:F,className:`pointer-events-auto max-h-[min(24rem,55vh)] min-h-8 overflow-y-auto rounded-md border border-edge bg-surface-panel text-xs leading-4 shadow-lg dark:bg-surface-panel/95`,style:W,role:`listbox`,"aria-label":`Commands`,"aria-activedescendant":G,children:U})}),document.body),t[40]=U,t[41]=F,t[42]=W,t[43]=G,t[44]=K):K=t[44],K}),Xhe=(0,Z.memo)(function(e){let t=(0,Q.c)(39),{item:n,icon:r,selected:i,id:a,nameLine:o,descriptionLine:s,dimCategoryBadge:c,trailingBadge:l,disabled:d,disabledTooltip:f,onSelect:p}=e,m=n.description??``,h;t[0]===m?h=t[1]:(h=m.trim(),t[0]=m,t[1]=h);let g=h,_=g.length>0&&s!=null,v=g.length>0,y=n.description??``,b=n.category&&n.kind!==`skill`&&!c&&!(n.kind===`agent`&&l),x;t[2]===o?x=t[3]:(x=(0,$.jsx)(`span`,{className:`min-w-0 max-w-[min(12rem,46%)] shrink-0 truncate font-semibold text-fg`,children:o}),t[2]=o,t[3]=x);let S;t[4]!==n.category||t[5]!==b?(S=b?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-normal leading-none text-fg-muted`,children:n.category}):null,t[4]=n.category,t[5]=b,t[6]=S):S=t[6];let C;t[7]!==s||t[8]!==_?(C=_?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-normal leading-tight text-fg-muted`,children:s}):null,t[7]=s,t[8]=_,t[9]=C):C=t[9];let w;t[10]!==x||t[11]!==S||t[12]!==C?(w=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1`,children:[x,S,C]}),t[10]=x,t[11]=S,t[12]=C,t[13]=w):w=t[13];let T=w,E=d?`cursor-not-allowed opacity-50 text-fg-muted`:i?`cursor-pointer bg-surface-hover text-fg`:`cursor-pointer text-fg-subtle hover:bg-surface-hover/80`,D;t[14]===E?D=t[15]:(D=u(`flex w-full min-w-0 items-center gap-1.5 px-2.5 py-1 text-left text-xs leading-4`,E),t[14]=E,t[15]=D);let O=D,k;t[16]!==d||t[17]!==p?(k=e=>{d||e.pointerType===`mouse`&&e.button!==0||(e.preventDefault(),p())},t[16]=d,t[17]=p,t[18]=k):k=t[18];let A=k,j;t[19]===r?j=t[20]:(j=(0,$.jsx)(`span`,{className:`shrink-0 [&_svg]:align-middle`,children:r}),t[19]=r,t[20]=j);let M;t[21]!==j||t[22]!==T||t[23]!==l?(M=(0,$.jsxs)($.Fragment,{children:[j,T,l]}),t[21]=j,t[22]=T,t[23]=l,t[24]=M):M=t[24];let N=M,P=d&&f?f:v?y:null,F=d||void 0,I;t[25]!==a||t[26]!==A||t[27]!==O||t[28]!==N||t[29]!==i||t[30]!==F?(I=(0,$.jsx)(`div`,{id:a,role:`option`,"aria-selected":i,"aria-disabled":F,tabIndex:-1,className:O,onPointerDown:A,children:N}),t[25]=a,t[26]=A,t[27]=O,t[28]=N,t[29]=i,t[30]=F,t[31]=I):I=t[31];let L=I;if(P!==null){let e;t[32]===L?e=t[33]:(e=(0,$.jsx)(V$,{asChild:!0,children:L}),t[32]=L,t[33]=e);let n;t[34]===P?n=t[35]:(n=(0,$.jsx)(H$,{children:(0,$.jsx)(U$,{side:`right`,align:`start`,sideOffset:8,collisionPadding:12,className:`!z-[10000] max-h-[min(12rem,40vh)] max-w-sm overflow-y-auto rounded-md border border-edge bg-surface-panel px-2 py-1.5 text-left text-[11px] leading-snug text-fg shadow-lg select-text [max-width:min(20rem,90vw)]`,"data-slash-palette-tooltip":``,children:(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:P})})}),t[34]=P,t[35]=n);let r;return t[36]!==e||t[37]!==n?(r=(0,$.jsxs)(B$,{delayDuration:0,children:[e,n]}),t[36]=e,t[37]=n,t[38]=r):r=t[38],r}return L}),x8=20,Zhe=200,S8=`xopc.composer.inputHistory.v2`,Qhe=`xopc.composer.inputHistory:`;function C8(){try{return globalThis.localStorage===void 0?null:globalThis.localStorage}catch{return null}}function w8(){return{version:2,sessions:{}}}function T8(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).slice(0,x8):[]}function $he(e){if(!e)return w8();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return w8();let n=t.sessions;if(!n||typeof n!=`object`||Array.isArray(n))return w8();let r={};for(let[e,t]of Object.entries(n)){let n=e.trim();if(!n||!t||typeof t!=`object`||Array.isArray(t))continue;let i=T8(t.items);if(i.length===0)continue;let a=t.updatedAt;r[n]={updatedAt:typeof a==`number`&&Number.isFinite(a)?a:0,items:i}}return{version:2,sessions:r}}catch{return w8()}}function E8(e){let t=$he(e.getItem(S8)),n=[];for(let r=0;r<e.length;r++){let i=e.key(r);if(!i?.startsWith(Qhe))continue;let a=i.slice(27).trim();if(a){n.push(i);try{let n=T8(JSON.parse(e.getItem(i)??`null`));if(n.length===0||t.sessions[a])continue;t.sessions[a]={updatedAt:0,items:n}}catch{}}}return{store:t,legacyKeys:n}}function ege(e){let t=[];for(let[n,r]of Object.entries(e.sessions)){let e=T8(r.items);e.length!==0&&t.push([n,{updatedAt:Number.isFinite(r.updatedAt)?r.updatedAt:0,items:e}])}return{version:2,sessions:Object.fromEntries(t.sort((e,t)=>t[1].updatedAt-e[1].updatedAt).slice(0,Zhe))}}function tge(e){let t=Math.max(0,...Object.values(e.sessions).map(e=>e.updatedAt));return Math.max(Date.now(),t+1)}function D8(e,t,n=[]){e.setItem(S8,JSON.stringify(ege(t)));for(let t of n)e.removeItem(t)}function nge(e){let t=e?.trim(),n=C8();if(!t||!n)return[];try{let{store:e,legacyKeys:r}=E8(n);return r.length>0&&D8(n,e,r),e.sessions[t]?.items.slice(0,x8)??[]}catch{return[]}}function rge(e,t){let n=e?.trim(),r=t.trim(),i=C8();if(!(!n||!r||!i))try{let{store:e,legacyKeys:t}=E8(i),a=e.sessions[n]?.items??[],o=tge(e),s=[r,...a].slice(0,x8);e.sessions[n]={updatedAt:o,items:a[0]===r?a:s},D8(i,e,t)}catch{}}function ige(e){let t=(0,Q.c)(17),{sessionKey:n,editorRef:r,valueRef:i,resetEditor:a,onWireInput:o}=e,s=(0,Z.useRef)(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{s.current=null},t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{l()},t[1]=u):u=t[1];let d;t[2]===n?d=t[3]:(d=[n,l],t[2]=n,t[3]=d),(0,Z.useEffect)(u,d);let f;t[4]===n?f=t[5]:(f=e=>{rge(n,e),l()},t[4]=n,t[5]=f);let p=f,m;t[6]===o?m=t[7]:(m=(e,t)=>{s.current=null,o(e,t)},t[6]=o,t[7]=m);let h=m,g;t[8]!==r||t[9]!==a||t[10]!==n||t[11]!==i?(g=e=>{let t=n?.trim();if(!t)return!1;let o=nge(t);if(o.length===0)return!1;let c=s.current,l=r.current,u=l?O6(l):0,d=i.current;if(e===`up`){if(c==null){if(u!==0)return!1;s.current={index:0,stash:d};let e=o[0];return e?(a({nextText:e,caretOffset:e.length,focus:!0}),!0):!1}if(c.index>=o.length-1)return!0;c.index+=1;let e=o[c.index];return e?(a({nextText:e,caretOffset:e.length,focus:!0}),!0):!1}if(c==null)return!1;if(--c.index,c.index<0){let e=c.stash;return s.current=null,a({nextText:e,caretOffset:e.length,focus:!0}),!0}let f=o[c.index];return f?(a({nextText:f,caretOffset:f.length,focus:!0}),!0):!1},t[8]=r,t[9]=a,t[10]=n,t[11]=i,t[12]=g):g=t[12];let _=g,v;return t[13]!==p||t[14]!==h||t[15]!==_?(v={onUserTextCommitted:p,onWireInputClearWalk:h,tryInputHistoryArrow:_},t[13]=p,t[14]=h,t[15]=_,t[16]=v):v=t[16],v}function O8(e){if(e.voiceActive)return e.cancelVoiceInput(),null;let t=e.getTextValue();return!t.trim()&&e.getAttachmentCount()===0?null:{text:t,attachments:e.wireAttachmentsPayload()}}function age(e){let{chat:t,runBusy:n,voiceActive:r,cancelVoiceInput:i,editingFollowUpId:a,getTextValue:o,getAttachmentCount:s,wireAttachmentsPayload:c,getThinkingLevel:l,onSend:u,onAddPendingFollowUp:d,onSteeringInterrupt:f,onCommitEditFollowUp:p,onPendingFollowUpRemove:m,pendingFollowUpsCount:h,resetEditor:g,clearAttachments:_,clearEditFollowUpRef:v,onUserTextCommitted:y}=e,b={getTextValue:o,getAttachmentCount:s,wireAttachmentsPayload:c};return{send:(0,Z.useCallback)(()=>{if(n)return;let e=O8({voiceActive:r,cancelVoiceInput:i,...b});e&&(u(e.text,e.attachments.length>0?e.attachments:void 0,l()),y?.(e.text),g(),_())},[n,r,i,u,l,y,g,_,o,s,c]),flushSteeringDraft:(0,Z.useCallback)(async()=>{if(!n&&h===0)return;let e=O8({voiceActive:r,cancelVoiceInput:i,...b});if(e){if(a){p(a,e.text,e.attachments.length>0?e.attachments:void 0,l()),y?.(e.text),v(),g(),_();return}if(d){if(h>=10){FK(`warning`,t.followUpQueueMaxReached,{max:10});return}await d(e.text,e.attachments.length>0?e.attachments:void 0),y?.(e.text),g(),_()}}},[n,r,i,a,h,d,p,l,t.followUpQueueMaxReached,v,y,g,_,o,s,c]),interruptDraft:(0,Z.useCallback)(()=>{if(!n||!f)return;let e=O8({voiceActive:r,cancelVoiceInput:i,...b});e&&(f(e.text,e.attachments.length>0?e.attachments:void 0),y?.(e.text),a&&(v(),m(a)),g(),_())},[n,r,i,a,m,f,y,v,g,_,o,s,c])}}function k8(e){let{chat:t}=e,[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(null),s=(0,Z.useRef)(n);s.current=n;let l=(0,Z.useCallback)(()=>{r([])},[]),u=(0,Z.useCallback)(e=>{r(t=>t.filter((t,n)=>n!==e))},[]),d=(0,Z.useCallback)(()=>s.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]);return{attachments:n,setAttachments:r,attachmentsRef:s,isDragging:i,setIsDragging:a,fileInputRef:o,processFiles:(0,Z.useCallback)(async e=>{if(e.length===0)return;let n=10-s.current.length;if(n<=0){FK(`warning`,t.maxAttachmentsReached,{max:10});return}let i=e.slice(0,n);e.length>i.length&&FK(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-i.length});let{loadAttachment:a}=await c(async()=>{let{loadAttachment:e}=await import(`./attachment-load-N3csiRso.js`);return{loadAttachment:e}},__vite__mapDeps([93,20])),o=(await Promise.all(i.map(async e=>{if(e.size>33554432)return FK(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:HI(PL)}),null;try{return await a(e,e.name)}catch{return FK(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null);r(e=>[...e,...o])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]),removeAttachment:u,clearAttachments:l,wireAttachmentsPayload:d}}function oge(e){let t=(0,Q.c)(6),{active:n,anchors:r,ignoreSelector:i,onDismiss:a}=e,o,s;t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a?(o=()=>{if(!n)return;let e=e=>{let t=e.target;if(t instanceof Node){for(let e of r){let n=e.current;if(n&&n.contains(t))return}i&&t instanceof Element&&t.closest(i)||a()}};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},s=[n,r,i,a],t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s):(o=t[4],s=t[5]),(0,Z.useEffect)(o,s)}var A8=20,sge=`xopc.atMention.recent:`;function j8(e){return`${sge}${e.trim()}`}function M8(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(j8(t));if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0).slice(0,A8):[]}catch{return[]}}function cge(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=[r,...M8(n).filter(e=>e!==r)].slice(0,A8);localStorage.setItem(j8(n),JSON.stringify(e))}catch{}}var lge=150,uge=15;function N8(e,t){let n=e.length,r=Math.min(Math.max(t,0),n);if(r<1)return null;let i=e.slice(0,r),a=i.match(/@([^\s]*)$/);if(!a||a.index===void 0)return null;let o=a.index;if(o>0&&/[a-zA-Z0-9_]/.test(e[o-1]))return null;let s=i.slice(o);return/^@(file|doc|url|symbol):/.test(s)?null:{start:o,end:r,query:a[1]??``}}function dge(e){let t=e.trim();return t.length>0&&t.endsWith(`/`)&&!/^https?:\/\//i.test(t)}function P8(e){return e.replace(/\/+$/,``).trim()}function fge(e){let t=e.replace(/\/+$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n<=0?``:t.slice(0,n)}function pge(e,t){return t===0?0:Math.min(e,t-1)}function mge(e,t,n){let[r,i]=(0,Z.useState)(0),a=(0,Z.useMemo)(()=>n.precomputedAtRange===void 0?n.isComposing||n.slashPaletteOpen?null:N8(e,t):n.isComposing||n.slashPaletteOpen?null:n.precomputedAtRange,[e,t,n.slashPaletteOpen,n.isComposing,n.precomputedAtRange]),o=a!==null,[s]=XQ(o?a?.query??``:``,lge),c=o?s:``,l=n.sessionKey?.trim()??``,u=lP(async()=>{if(!l)return[];if(dge(c)){let e=P8(c),t=(await Zle(e,{sessionKey:l})).map(e=>({name:e.name,relativePath:e.path,isDirectory:e.isDirectory}));return e?[{name:`..`,relativePath:``,isDirectory:!0,isBrowseUp:!0},...t]:t}let e=await F4(c,{sessionKey:l,limit:uge}),t=M8(l),n=[],r=new Set(e.map(e=>e.relativePath));for(let e of t){if(r.has(e))continue;r.add(e);let t=e.replace(/\/$/,``).split(`/`).pop()??e;if(n.push({name:t,relativePath:e,isDirectory:e.endsWith(`/`),isRecent:!0}),n.length>=5)break}return[...n,...e]},[c,l],{enabled:o&&!!l,initial:[],errorData:[]}),d=o?u.data:[],f=o?u.loading:!1,p=o&&u.error!=null?u.error instanceof Error?u.error.message:String(u.error):null,m=a?.start,h=a?.end,g=`${m??``}:${h??``}:${c}`,_=(0,Z.useRef)(g);_.current!==g&&(_.current=g,r!==0&&i(0));let v=pge(r,d.length),y=(0,Z.useCallback)(e=>{d.length!==0&&i(t=>e===`down`?(t+1)%d.length:(t-1+d.length)%d.length)},[d.length]);return{open:o,atRange:a,items:d,selectedIndex:v,query:a?.query??``,loading:f,error:p,onNavigate:y,setSelectedIndex:i}}function hge(e){let{sessionKey:t,editorValue:n,editorCursor:r,isComposing:i,runBusy:a,thinkingLevel:o,editorRef:s,valueRef:c,resetEditor:l,clearAttachments:u,onSend:d,onUserTextCommitted:f,onChatAgentChange:p,currentAgentId:m,onUnavailableSkill:h,onReviewLauncher:g,onAddPendingFollowUp:_,onAbort:v,pendingFollowUpsCount:y,maxPendingFollowUps:b,commandPalettePanelRef:x}=e,S=(0,Z.useMemo)(()=>N8(n,r),[n,r]),C=Ahe(n,r,{suppress:S!=null,isComposing:i,currentAgentId:m}),w=mge(n,r,{sessionKey:t,slashPaletteOpen:C.open,isComposing:i,precomputedAtRange:S}),T=C.open||w.open||S!=null,E=(0,Z.useCallback)(()=>({slashRange:C.slashRange,runBusy:a,pendingFollowUpsCount:y,maxPendingFollowUps:b,thinkingLevel:o,editor:{valueRef:c,resetEditor:l},attachments:{clearAttachments:u},callbacks:{onSend:d,onUserTextCommitted:f,onChatAgentChange:p,onAddPendingFollowUp:_,onAbort:v,onUnavailableSkill:h,onReviewLauncher:g}}),[C.slashRange,a,y,b,o,c,l,u,d,f,p,_,v,h,g]),D=(0,Z.useCallback)(e=>{yhe(e,E())},[E]),O=(0,Z.useCallback)((e,n)=>{let r=w.atRange;if(!r)return;if(e.isBrowseUp){let e=fge(P8(r.query)),t=`@${e?`${e}/`:``}`;l({nextText:p8(c.current,r.start,r.end,t),caretOffset:r.start+t.length,focus:!0});return}let i=e.isDirectory&&!e.relativePath.endsWith(`/`)?`${e.relativePath}/`:e.relativePath,a=`@file:${g6(i)}`;t&&!e.isDirectory&&cge(t,i.replace(/\/$/,``));let o=a+(n?.stayOpen?` @`:` `);l({nextText:p8(c.current,r.start,r.end,o),caretOffset:r.start+o.length,focus:!0})},[w.atRange,t,c,l]),k=(0,Z.useRef)(C.slashRange);k.current=C.slashRange;let A=c,j=(0,Z.useCallback)(()=>{let e=k.current;if(!e)return;let t=A.current;l({nextText:t.slice(0,e.start)+t.slice(e.end),caretOffset:e.start})},[l,A]),M=(0,Z.useMemo)(()=>[s,x],[s,x]);oge({active:C.open,anchors:M,ignoreSelector:`[data-slash-palette-tooltip]`,onDismiss:j});let N=(0,Z.useRef)(w);N.current=w;let P=(0,Z.useRef)(C);P.current=C;let F=(0,Z.useRef)(i);F.current=i;let I=(0,Z.useRef)(D);I.current=D;let L=(0,Z.useRef)(O);L.current=O;let R=(0,Z.useRef)({runBusy:a,pendingFollowUpsCount:y,maxPendingFollowUps:b});R.current={runBusy:a,pendingFollowUpsCount:y,maxPendingFollowUps:b};let z=(0,Z.useMemo)(()=>({name:`at-mention`,isActive:()=>{let e=N.current;return e.open&&e.atRange!=null&&!F.current},handleKey:e=>{let t=N.current;if(!t.atRange)return!1;if(e.key===`Escape`){e.preventDefault();let n=t.atRange,r=A.current;return l({nextText:p8(r,n.start,n.end,``),caretOffset:n.start,focus:!0}),!0}if(t.items.length===0)return!1;if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let n=t.items[t.selectedIndex];return n&&L.current(n,{stayOpen:e.shiftKey}),!0}return!1}}),[l,A]),B=(0,Z.useMemo)(()=>({name:`slash-palette`,isActive:()=>P.current.open&&!F.current,handleKey:e=>{let t=P.current;if(t.items.length>0){if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){e.preventDefault();let n=t.items[t.selectedIndex];return!n||v8(n,R.current)||I.current(n),!0}}if(e.key===`Escape`){e.preventDefault();let n=t.slashRange;if(n){let e=A.current;l({nextText:p8(e,n.start,n.end,``),caretOffset:n.start,focus:!0})}return!0}return!1}}),[l,A]);return{palette:C,atPicker:w,shouldSyncSelection:T,adapters:(0,Z.useMemo)(()=>[z,B],[z,B]),applyPalette:D,applyAtMention:O}}function gge(e,t){let n=t.trim();if(!n)return e;let r=e.trim();return r?`${r} ${n}`:n}var F8=u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,lA.transition,lA.press,lA.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),_ge=(0,Z.memo)(function(e){let t=(0,Q.c)(30),{phase:n,elapsedLabel:r,disabled:i,chat:a,onCancel:o,onConfirm:s}=e,c=n===`transcribing`,l=a.voiceInput,d=!c&&`animate-pulse`,f;t[0]===d?f=t[1]:(f=u(`size-2 shrink-0 rounded-full bg-red-500`,d),t[0]=d,t[1]=f);let p;t[2]===f?p=t[3]:(p=(0,$.jsx)(`span`,{className:f,"aria-hidden":!0}),t[2]=f,t[3]=p);let m=c?a.voiceTranscribing:a.voiceRecordingStatus,h;t[4]===m?h=t[5]:(h=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg-muted`,children:m}),t[4]=m,t[5]=h);let g=c?``:r,_;t[6]===g?_=t[7]:(_=(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums text-sm text-fg-subtle`,"aria-live":`polite`,children:g}),t[6]=g,t[7]=_);let v=i||c,y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Sk,{className:`size-4`}),t[8]=y):y=t[8];let b;t[9]!==a.voiceInputCancel||t[10]!==o||t[11]!==v?(b=(0,$.jsx)(`button`,{type:`button`,className:F8,disabled:v,title:a.voiceInputCancel,"aria-label":a.voiceInputCancel,onClick:o,children:y}),t[9]=a.voiceInputCancel,t[10]=o,t[11]=v,t[12]=b):b=t[12];let x;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(x=u(F8,`text-fg`),t[13]=x):x=t[13];let S=i||c,C;t[14]===c?C=t[15]:(C=c?(0,$.jsx)(Fv,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Iu,{className:`size-4`}),t[14]=c,t[15]=C);let w;t[16]!==a.voiceInputConfirm||t[17]!==s||t[18]!==S||t[19]!==C?(w=(0,$.jsx)(`button`,{type:`button`,className:x,disabled:S,title:a.voiceInputConfirm,"aria-label":a.voiceInputConfirm,onClick:s,children:C}),t[16]=a.voiceInputConfirm,t[17]=s,t[18]=S,t[19]=C,t[20]=w):w=t[20];let T;t[21]!==b||t[22]!==w?(T=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[b,w]}),t[21]=b,t[22]=w,t[23]=T):T=t[23];let E;return t[24]!==a.voiceInput||t[25]!==T||t[26]!==p||t[27]!==h||t[28]!==_?(E=(0,$.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-2 py-2`,role:`region`,"aria-label":l,children:[p,h,_,T]}),t[24]=a.voiceInput,t[25]=T,t[26]=p,t[27]=h,t[28]=_,t[29]=E):E=t[29],E});async function vge(e){return BI(await e.arrayBuffer())}async function yge(e,t){let n=await vge(e),r=await J(X(`/api/voice/transcribe`),{method:`POST`,body:JSON.stringify({audio:n,mimeType:t})});if(!r.payload)throw Error(`Missing transcription payload`);return r.payload}var I8=null;async function bge(){if(I8!==null)return I8;try{I8=(await J(X(`/api/status`))).voice?.sttAvailable===!0}catch{I8=!1}return I8}function xge(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function Sge(e){let{disabled:t,chat:n,onTranscript:r}=e,[i,a]=(0,Z.useState)(`idle`),[o,s]=(0,Z.useState)(0),c=(0,Z.useRef)(null),l=(0,Z.useRef)([]),u=(0,Z.useRef)(null),d=(0,Z.useRef)(``),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!1),m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(r);g.current=r;let _=(0,Z.useCallback)(()=>{h.current!=null&&(clearInterval(h.current),h.current=null)},[]),v=(0,Z.useCallback)(()=>{u.current?.getTracks().forEach(e=>e.stop()),u.current=null},[]),y=(0,Z.useCallback)(()=>{_(),v(),c.current=null,l.current=[],m.current=null,p.current=!1,f.current=!1,s(0),a(`idle`)},[_,v]),b=(0,Z.useCallback)(()=>{let e=c.current;e&&e.state!==`inactive`?e.stop():y(),c.current=null},[y]),x=(0,Z.useCallback)(()=>{f.current=!0,p.current=!1,b()},[b]),S=(0,Z.useCallback)(async(e,t)=>{a(`transcribing`);let r=new Blob(e,{type:t||`audio/webm`});if(r.size<32){FK(`warning`,n.voiceTranscribeEmpty),y();return}try{let e=await yge(r,r.type||t||`audio/webm`),i=(e.refined??e.raw).trim();if(!i){FK(`warning`,n.voiceTranscribeEmpty),y();return}g.current(i),y()}catch(e){let t=e instanceof Error?e.message:String(e);t.includes(`STT is not configured`)||t.includes(`503`)?FK(`error`,n.voiceSttNotConfigured):FK(`error`,n.voiceTranscribeFailed),y()}},[y,n.voiceSttNotConfigured,n.voiceTranscribeEmpty,n.voiceTranscribeFailed]),C=(0,Z.useCallback)(()=>{_(),h.current=setInterval(()=>{let e=m.current;typeof e==`number`&&s(Math.max(0,(performance.now()-e)/1e3))},200)},[_]),w=(0,Z.useCallback)(async()=>{if(!(t||i!==`idle`)){if(!await bge()){FK(`error`,n.voiceSttNotConfigured);return}f.current=!1,p.current=!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});u.current=e;let t=MediaRecorder.isTypeSupported(`audio/webm;codecs=opus`)?`audio/webm;codecs=opus`:MediaRecorder.isTypeSupported(`audio/webm`)?`audio/webm`:``;d.current=t;let n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);l.current=[],n.ondataavailable=e=>{e.data.size>0&&l.current.push(e.data)},n.onstop=()=>{(async()=>{try{let e=l.current;l.current=[];let t=d.current||n.mimeType;if(f.current){y();return}if(p.current){p.current=!1,await S(e,t);return}y()}finally{v()}})()},c.current=n,m.current=performance.now(),s(0),n.start(250),a(`recording`),C()}catch{y(),FK(`error`,n.voiceMicDenied)}}},[t,y,n.voiceMicDenied,n.voiceSttNotConfigured,i,S,C,v]),T=(0,Z.useCallback)(()=>{i===`recording`&&(p.current=!0,f.current=!1,a(`transcribing`),_(),b())},[i,b,_]);return(0,Z.useEffect)(()=>()=>{f.current=!0,p.current=!1,b()},[b]),{phase:i,voiceActive:i!==`idle`,elapsedLabel:xge(o),startVoiceInput:w,cancelVoiceInput:x,confirmVoiceInput:T}}function L8(e){return/^[A-Za-z0-9._/@:-]+$/.test(e)?e:JSON.stringify(e)}function R8(e,t){let n=t?.trim();return n?`${e} --instructions ${L8(n)}`:e}function Cge(e){if(e.preset===`base`){if(!e.baseBranch?.trim())throw Error(`Missing base branch.`);return R8(`/review --base ${L8(e.baseBranch.trim())}`,e.instructions)}if(e.preset===`commit`){if(!e.commitSha?.trim())throw Error(`Missing commit SHA.`);return R8(`/review --commit ${L8(e.commitSha.trim())}`,e.instructions)}return e.preset,R8(`/review --uncommitted`,e.instructions)}async function wge(e){let t=await Y(X(`/api/review/context?${new URLSearchParams({sessionKey:e}).toString()}`)),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(te(t.status,t.statusText,n.error?.message));return n.payload}function Tge(e,t){let n=e?.status;if(!n)return``;if(n.isClean)return t.statusClean;let r=[];return n.changedFiles>0&&r.push(t.statusChanged.replace(`{{count}}`,String(n.changedFiles))),n.untrackedFiles>0&&r.push(t.statusUntracked.replace(`{{count}}`,String(n.untrackedFiles))),r.join(`, `)}function Ege(e,t){let n=t.trim().toLowerCase(),r=[...(e?.branches??[]).filter(e=>!e.current)].sort((t,n)=>t.name===e?.defaultBaseBranch&&n.name!==e.defaultBaseBranch?-1:n.name===e?.defaultBaseBranch&&t.name!==e.defaultBaseBranch?1:t.name.localeCompare(n.name));return n?r.filter(e=>e.name.toLowerCase().includes(n)):r}function Dge(e,t){let n=t.trim().toLowerCase(),r=e?.commits??[];return n?r.filter(e=>`${e.sha} ${e.shortSha} ${e.subject}`.toLowerCase().includes(n)):r}function z8(e){let t=(0,Q.c)(15),{icon:n,title:r,description:i,disabled:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=u(`flex min-h-16 w-full items-center gap-3 rounded-lg border border-edge bg-surface-panel px-3 py-2.5 text-left`,`hover:border-accent/45 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:cursor-not-allowed disabled:opacity-50`,lA.transition),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(`span`,{className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:n}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:r}),t[3]=r,t[4]=l);let d;t[5]===i?d=t[6]:(d=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:i}),t[5]=i,t[6]=d);let f;t[7]!==l||t[8]!==d?(f=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,d]}),t[7]=l,t[8]=d,t[9]=f):f=t[9];let p;return t[10]!==a||t[11]!==o||t[12]!==c||t[13]!==f?(p=(0,$.jsxs)(`button`,{type:`button`,disabled:a,className:s,onClick:o,children:[c,f]}),t[10]=a,t[11]=o,t[12]=c,t[13]=f,t[14]=p):p=t[14],p}function Oge(e){let t=(0,Q.c)(89),{open:n,sessionKey:r,disabled:i,chat:a,onClose:o,onSendCommand:s}=e,c=a.reviewLauncher,[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(`presets`),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),x;t[0]!==c.noSession||t[1]!==r?(x=()=>{if(!r){u(null),m(c.noSession);return}f(!0),m(null),wge(r).then(e=>u(e)).catch(e=>{u(null),m(e instanceof Error?e.message:String(e))}).finally(()=>f(!1))},t[0]=c.noSession,t[1]=r,t[2]=x):x=t[2];let S=x,C,w;t[3]!==S||t[4]!==n?(C=()=>{n&&(g(`presets`),v(``),b(``),S())},w=[S,n],t[3]=S,t[4]=n,t[5]=C,t[6]=w):(C=t[5],w=t[6]),(0,Z.useEffect)(C,w);let T;t[7]!==l||t[8]!==_?(T=Ege(l,_),t[7]=l,t[8]=_,t[9]=T):T=t[9];let E=T,D;t[10]!==l||t[11]!==_?(D=Dge(l,_),t[10]=l,t[11]=_,t[12]=D):D=t[12];let O=D,k;t[13]!==l||t[14]!==c?(k=Tge(l,c),t[13]=l,t[14]=c,t[15]=k):k=t[15];let A=k,j;t[16]!==y||t[17]!==o||t[18]!==s?(j=(e,t)=>{s(Cge({preset:e,baseBranch:t?.branch,commitSha:t?.commit,instructions:y})),o()},t[16]=y,t[17]=o,t[18]=s,t[19]=j):j=t[19];let M=j,N=h===`base`?c.baseTitle:h===`commit`?c.commitTitle:h===`custom`?c.customTitle:c.title,P;t[20]===o?P=t[21]:(P=e=>!e&&o(),t[20]=o,t[21]=P);let F;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(RN,{className:`xopc-dialog-overlay fixed inset-0 z-[120] bg-scrim backdrop-blur-[1px]`}),t[22]=F):F=t[22];let I;t[23]!==c.back||t[24]!==h?(I=h===`presets`?null:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":c.back,onClick:()=>{g(`presets`),v(``)},children:(0,$.jsx)(to,{className:`size-4`})}),t[23]=c.back,t[24]=h,t[25]=I):I=t[25];let L;t[26]===N?L=t[27]:(L=(0,$.jsx)(BN,{className:`truncate text-sm font-semibold text-fg`,children:N}),t[26]=N,t[27]=L);let R=l?.cwd??c.description,z;t[28]===R?z=t[29]:(z=(0,$.jsx)(VN,{className:`truncate text-xs text-fg-muted`,children:R}),t[28]=R,t[29]=z);let B;t[30]!==L||t[31]!==z?(B=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[L,z]}),t[30]=L,t[31]=z,t[32]=B):B=t[32];let V;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(Sk,{className:`size-4`}),t[33]=V):V=t[33];let H;t[34]!==c.close||t[35]!==o?(H=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":c.close,onClick:o,children:V}),t[34]=c.close,t[35]=o,t[36]=H):H=t[36];let U;t[37]!==I||t[38]!==B||t[39]!==H?(U=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-3`,children:[I,B,H]}),t[37]=I,t[38]=B,t[39]=H,t[40]=U):U=t[40];let W;t[41]!==E||t[42]!==O||t[43]!==l||t[44]!==i||t[45]!==p||t[46]!==y||t[47]!==S||t[48]!==d||t[49]!==c.customDescription||t[50]!==c.customPlaceholder||t[51]!==c.defaultBadge||t[52]!==c.errorTitle||t[53]!==c.loading||t[54]!==c.localBadge||t[55]!==c.noBranches||t[56]!==c.noCommits||t[57]!==c.presetBase||t[58]!==c.presetBaseDescription||t[59]!==c.presetBaseDescriptionNoDefault||t[60]!==c.presetCommit||t[61]!==c.presetCommitDescription||t[62]!==c.presetCustom||t[63]!==c.presetCustomDescription||t[64]!==c.presetUncommitted||t[65]!==c.remoteBadge||t[66]!==c.retry||t[67]!==c.searchBranches||t[68]!==c.searchCommits||t[69]!==_||t[70]!==M||t[71]!==A||t[72]!==h?(W=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:d?(0,$.jsxs)(`div`,{className:`flex h-full min-h-56 items-center justify-center text-sm text-fg-muted`,children:[(0,$.jsx)(Lb,{className:`mr-2 size-4 animate-spin`}),c.loading]}):p?(0,$.jsxs)(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.errorTitle}),(0,$.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:p}),(0,$.jsxs)(tA,{type:`button`,className:`mt-4 h-9 rounded-lg`,variant:`secondary`,onClick:S,children:[(0,$.jsx)(Lb,{className:`size-4`}),c.retry]})]}):h===`presets`?(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(z8,{icon:(0,$.jsx)(iv,{className:`size-4`}),title:c.presetBase,description:l?.defaultBaseBranch?c.presetBaseDescription.replace(`{{branch}}`,l.defaultBaseBranch):c.presetBaseDescriptionNoDefault,disabled:i,onClick:()=>g(`base`)}),(0,$.jsx)(z8,{icon:(0,$.jsx)(kv,{className:`size-4`}),title:c.presetUncommitted,description:A,disabled:i,onClick:()=>M(`uncommitted`)}),(0,$.jsx)(z8,{icon:(0,$.jsx)(av,{className:`size-4`}),title:c.presetCommit,description:c.presetCommitDescription.replace(`{{count}}`,String(l?.commits.length??0)),disabled:i,onClick:()=>g(`commit`)}),(0,$.jsx)(z8,{icon:(0,$.jsx)(kv,{className:`size-4`}),title:c.presetCustom,description:c.presetCustomDescription,disabled:i,onClick:()=>g(`custom`)})]}):h===`base`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(B8,{value:_,placeholder:c.searchBranches,onChange:v}),(0,$.jsx)(`div`,{className:`grid gap-1`,children:E.length===0?(0,$.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noBranches}):E.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center justify-between gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:i,onClick:()=>M(`base`,{branch:e.name}),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.name===l?.defaultBaseBranch?c.defaultBadge:e.remote?c.remoteBadge:c.localBadge})]},e.name))})]}):h===`commit`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(B8,{value:_,placeholder:c.searchCommits,onChange:v}),(0,$.jsx)(`div`,{className:`grid gap-1`,children:O.length===0?(0,$.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noCommits}):O.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:i,onClick:()=>M(`commit`,{commit:e.sha}),children:[(0,$.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:e.shortSha}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.subject}),e.date?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.date.slice(0,10)}):null]},e.sha))})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`textarea`,{className:`h-40 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-disabled focus:border-accent focus:ring-2 focus:ring-accent/25`,value:y,placeholder:c.customPlaceholder,onChange:e=>b(e.target.value)}),(0,$.jsx)(`div`,{className:`text-xs text-fg-muted`,children:c.customDescription})]})}),t[41]=E,t[42]=O,t[43]=l,t[44]=i,t[45]=p,t[46]=y,t[47]=S,t[48]=d,t[49]=c.customDescription,t[50]=c.customPlaceholder,t[51]=c.defaultBadge,t[52]=c.errorTitle,t[53]=c.loading,t[54]=c.localBadge,t[55]=c.noBranches,t[56]=c.noCommits,t[57]=c.presetBase,t[58]=c.presetBaseDescription,t[59]=c.presetBaseDescriptionNoDefault,t[60]=c.presetCommit,t[61]=c.presetCommitDescription,t[62]=c.presetCustom,t[63]=c.presetCustomDescription,t[64]=c.presetUncommitted,t[65]=c.remoteBadge,t[66]=c.retry,t[67]=c.searchBranches,t[68]=c.searchCommits,t[69]=_,t[70]=M,t[71]=A,t[72]=h,t[73]=W):W=t[73];let G;t[74]!==i||t[75]!==c.cancel||t[76]!==c.runReview||t[77]!==o||t[78]!==M||t[79]!==h?(G=h===`custom`?(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[(0,$.jsx)(tA,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:o,children:c.cancel}),(0,$.jsx)(tA,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,disabled:i,onClick:()=>M(`custom`),children:c.runReview})]}):null,t[74]=i,t[75]=c.cancel,t[76]=c.runReview,t[77]=o,t[78]=M,t[79]=h,t[80]=G):G=t[80];let K;t[81]!==U||t[82]!==W||t[83]!==G?(K=(0,$.jsxs)(LN,{children:[F,(0,$.jsxs)(zN,{className:`fixed left-1/2 top-1/2 z-[121] flex h-[min(86vh,34rem)] w-[min(100vw-2rem,40rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[U,W,G]})]}),t[81]=U,t[82]=W,t[83]=G,t[84]=K):K=t[84];let q;return t[85]!==n||t[86]!==K||t[87]!==P?(q=(0,$.jsx)(FN,{open:n,onOpenChange:P,children:K}),t[85]=n,t[86]=K,t[87]=P,t[88]=q):q=t[88],q}function B8(e){let t=(0,Q.c)(7),{value:n,placeholder:r,onChange:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Qx,{className:`size-4 shrink-0 text-fg-muted`}),t[0]=a):a=t[0];let o;t[1]===i?o=t[2]:(o=e=>i(e.target.value),t[1]=i,t[2]=o);let s;return t[3]!==r||t[4]!==o||t[5]!==n?(s=(0,$.jsxs)(`label`,{className:`flex h-9 items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/25`,children:[a,(0,$.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent outline-none placeholder:text-fg-disabled`,value:n,placeholder:r,onChange:o})]}),t[3]=r,t[4]=o,t[5]=n,t[6]=s):s=t[6],s}var kge=(0,Z.memo)(function({disabled:e,sending:t,streaming:n,sessionKey:r,sessionManager:i,canSelectWorkingDirectory:a,thinkingLevel:o,showThinkingSelector:s,onThinkingChange:c,onSend:l,onAbort:d,onAddPendingFollowUp:f,onSteeringInterrupt:p,pendingFollowUps:h,editingFollowUpId:g,onBeginEditFollowUp:v,onCancelEditFollowUp:y,onCommitEditFollowUp:b,onPendingFollowUpRemove:x,onPendingFollowUpMove:S,onPendingFollowUpReorder:C,onPendingFollowUpSteer:w,steeringFollowUpId:T,welcomeDraftSeed:E,sessionModel:D,showModelSelector:O,onModelChange:k,modelDisabled:A,contextUsageMessages:j,onChatAgentChange:M,currentAgentId:N}){let P=m(_(e=>e.language));(0,Z.useEffect)(()=>{D4()},[]);let F=(0,Z.useRef)(!1),I=(0,Z.useRef)(null),L=(0,Z.useRef)(null),R=(0,Z.useRef)(null),z=(0,Z.useRef)(!1),[B,V]=(0,Z.useState)(!1),H=(0,Z.useRef)(l),U=(0,Z.useRef)(o);H.current=l,U.current=o;let W=k8({chat:P.chat}),G=(0,Z.useCallback)(()=>{W.clearAttachments()},[W.clearAttachments]),K=(0,Z.useCallback)(e=>{let t=e.availability?.status===`agent-denied`?P.chat.commandPalette.skillAgentDeniedReason:P.chat.commandPalette.skillDisabledReason,n=P6(P.chat.commandPalette.skillUnavailableMessage,{name:e.name,agent:N||`main`,reason:t});if(e.availability?.status===`agent-denied`&&window.confirm(`${n}\n\n${P.chat.commandPalette.skillAddToAllowlistConfirm}`)){Kle(N,e.name).catch(e=>{window.alert(e instanceof Error?e.message:String(e))});return}window.alert(n)},[N,P.chat.commandPalette]),q=ime({disabled:e,autoFocusKey:r,welcomeDraftSeed:E,onExternalTextReplace:G,shouldSyncSelectionRef:F}),{onUserTextCommitted:ee,onWireInputClearWalk:J,tryInputHistoryArrow:te}=ige({sessionKey:r,editorRef:q.editorRef,valueRef:q.valueRef,resetEditor:q.resetEditor,onWireInput:q.onWireInput}),Y=t||n;z.current=Y;let ne=(0,Z.useCallback)(()=>{z.current||V(!0)},[]),re=(0,Z.useCallback)(e=>{H.current(e,void 0,U.current),ee?.(e)},[ee]),X=hge({sessionKey:r,editorValue:q.value,editorCursor:q.cursor,isComposing:q.isComposing,runBusy:Y,thinkingLevel:o,editorRef:q.editorRef,valueRef:q.valueRef,resetEditor:q.resetEditor,clearAttachments:W.clearAttachments,onSend:l,onUserTextCommitted:ee,onChatAgentChange:M,currentAgentId:N,onUnavailableSkill:K,onReviewLauncher:ne,onAddPendingFollowUp:f,onAbort:d,pendingFollowUpsCount:h.length,maxPendingFollowUps:10,commandPalettePanelRef:I});F.current=X.shouldSyncSelection;let ie=(0,Z.useMemo)(()=>q.value.length,[q.value]),ae=Sge({disabled:e,chat:P.chat,onTranscript:e=>{let t=q.valueRef.current,n=gge(t,e);q.resetEditor({nextText:n,caretOffset:n.length,focus:!0})}}),oe=(0,Z.useCallback)(()=>{R.current=null},[]),se=age({chat:P.chat,runBusy:Y,voiceActive:ae.voiceActive,cancelVoiceInput:ae.cancelVoiceInput,editingFollowUpId:g,getTextValue:()=>q.valueRef.current,getAttachmentCount:()=>W.attachmentsRef.current.length,wireAttachmentsPayload:W.wireAttachmentsPayload,getThinkingLevel:()=>U.current,onSend:l,onAddPendingFollowUp:f,onSteeringInterrupt:p,onCommitEditFollowUp:b,onPendingFollowUpRemove:x,pendingFollowUpsCount:h.length,resetEditor:()=>{q.resetEditor()},clearAttachments:W.clearAttachments,clearEditFollowUpRef:oe,onUserTextCommitted:ee});(0,Z.useLayoutEffect)(()=>{if(!g){R.current&&=(W.clearAttachments(),q.resetEditor(),null);return}if(g===R.current)return;let e=h.find(e=>e.id===g);if(!e){y();return}R.current=g,e.thinkingLevel!=null&&s&&c(e.thinkingLevel),W.setAttachments(uhe(e.attachments??[])),q.resetEditor({nextText:e.text,focus:!0})},[W.clearAttachments,W.setAttachments,q.resetEditor,g,y,c,h,s]);let ce=(0,Z.useCallback)(e=>{v(e)},[v]),le=(0,Z.useRef)({});le.current={adapters:X.adapters,send:se.send,runBusy:Y,pendingFollowUpsCount:h.length,flushSteeringDraft:se.flushSteeringDraft,interruptDraft:se.interruptDraft,editingFollowUpId:g,onCancelEditFollowUp:y,attachmentsLen:W.attachments.length,isComposing:q.isComposing,valueRef:q.valueRef,adjustHeight:q.adjustHeight,editorRef:q.editorRef,tryInputHistoryArrow:te};let ue=Y,de=!!q.value.trim()||W.attachments.length>0,fe=de&&!!p;return(0,$.jsxs)(`div`,{className:u(`relative flex min-h-0 w-full flex-col overflow-hidden rounded-xl bg-surface-panel shadow-surface ring-1 ring-inset ring-edge dark:bg-surface-panel/60 dark:shadow-none`,W.isDragging&&`ring-2 ring-accent ring-inset`),onDragOver:e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),W.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&W.setIsDragging(!1)},onDrop:async e=>{e.preventDefault(),W.setIsDragging(!1);let t=e.dataTransfer?.files;t?.length&&await W.processFiles(Array.from(t))},children:[W.isDragging?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-accent-soft/80 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,children:P.chat.dropFiles}):null,h.length>0?(0,$.jsx)(`div`,{className:`max-h-[min(30vh,11rem)] shrink-0 overflow-y-auto overflow-x-hidden border-b border-edge-subtle/80 [scrollbar-gutter:stable] dark:border-edge-subtle/70`,children:(0,$.jsx)(ome,{items:h,disabled:e,editingFollowUpId:g,onEditInComposer:ce,onRemove:x,onMove:S,onReorder:C,onSteer:w,steeringBusyId:T})}):null,(0,$.jsx)(j6,{attachments:W.attachments,topPadded:h.length>0,onRemove:W.removeAttachment}),(0,$.jsxs)(`div`,{className:`flex min-h-0 shrink-0 flex-col`,children:[(0,$.jsx)(`input`,{ref:L,type:`file`,multiple:!0,accept:l6,className:`hidden`,onChange:async e=>{let t=e.target.files;t&&await W.processFiles(Array.from(t)),e.target.value=``}}),(0,$.jsxs)(`div`,{className:u(`relative px-4 pb-0 pt-1`,W.attachments.length>0&&`pt-2`),children:[(0,$.jsx)(ghe,{open:X.atPicker.open,anchorRef:q.editorRef,items:X.atPicker.items,selectedIndex:X.atPicker.selectedIndex,loading:X.atPicker.loading,query:X.atPicker.query,noResults:X.atPicker.error??P.chat.atMention.noResults,sessionKey:r,recentLabel:P.chat.atMention.recentBadge,ariaLabel:P.chat.atMention.placeholder,shiftHint:P.chat.atMention.shiftHint,onSelectItem:(e,t)=>X.applyAtMention(e,{stayOpen:t?.shiftKey===!0})}),(0,$.jsx)(Yhe,{open:X.palette.open,anchorRef:q.editorRef,panelRef:I,items:X.palette.loadError?[]:X.palette.items,selectedIndex:X.palette.selectedIndex,noResults:X.palette.loadError??P.chat.commandPalette.noResults,grouped:X.palette.loadError?!1:X.palette.grouped,skillRowCount:X.palette.loadError?0:X.palette.skillRowCount,commandRowCount:X.palette.loadError?0:X.palette.commandRowCount,query:X.palette.query,skillsLabel:P.chat.commandPalette.skillsSection,commandsLabel:P.chat.commandPalette.commandsSection,agentsLabel:P.chat.commandPalette.agentsSection,groupedHasSkills:X.palette.loadError?!1:X.palette.groupedHasSkills,groupedHasCommands:X.palette.loadError?!1:X.palette.groupedHasCommands,groupedHasAgents:X.palette.loadError?!1:X.palette.groupedHasAgents,groupedSkillsShowMoreLabel:X.palette.loadError||!X.palette.grouped?null:X.palette.groupedSkillsMoreCount>0?P6(P.chat.commandPalette.showGroupedMore,{count:X.palette.groupedSkillsMoreCount}):null,groupedCommandsShowMoreLabel:X.palette.loadError||!X.palette.grouped?null:X.palette.groupedCommandsMoreCount>0?P6(P.chat.commandPalette.showGroupedMore,{count:X.palette.groupedCommandsMoreCount}):null,groupedAgentsShowMoreLabel:X.palette.loadError||!X.palette.grouped?null:X.palette.groupedAgentsMoreCount>0?P6(P.chat.commandPalette.showGroupedMore,{count:X.palette.groupedAgentsMoreCount}):null,onExpandSkills:X.palette.expandGroupedSkills,onExpandCommands:X.palette.expandGroupedCommands,onExpandAgents:X.palette.expandGroupedAgents,currentAgentId:N,currentBadgeLabel:P.chat.commandPalette.currentBadge,runBusy:Y,pendingFollowUpsCount:h.length,maxPendingFollowUps:10,queueBadgeLabel:P.chat.commandPalette.queueBadge,queueFullBadgeLabel:P.chat.commandPalette.queueFullBadge,queueFullTooltip:P.chat.commandPalette.queueFullTooltip,skillUnavailableLabel:P.chat.commandPalette.skillUnavailableBadge,skillAgentDeniedLabel:P.chat.commandPalette.skillAgentDeniedBadge,onSelectItem:X.applyPalette}),ae.voiceActive?(0,$.jsx)(_ge,{phase:ae.phase,elapsedLabel:ae.elapsedLabel,disabled:e,chat:P.chat,onCancel:ae.cancelVoiceInput,onConfirm:ae.confirmVoiceInput}):(0,$.jsx)(ame,{editorRef:q.editorRef,disabled:e,placeholder:ue?g?P.chat.inputPlaceholderSteeringEdit:P.chat.inputPlaceholderSteering:P.chat.inputPlaceholder,onWireInput:J,adjustHeight:q.adjustHeight,processFiles:W.processFiles,setIsComposing:q.setIsComposing,kbdRef:le,chatMessages:P.chat})]}),(0,$.jsx)(che,{sessionKey:r,sessionManager:i,disabled:e,sending:t,streaming:n,canSelectWorkingDirectory:a,runBusy:ue,chat:P.chat,hasDraft:de,showSteeringInterrupt:fe,attachmentCount:W.attachments.length,maxAttachments:10,onPickFiles:()=>L.current?.click(),onOpenReviewLauncher:ne,thinkingLevel:o,showThinkingSelector:s,onThinkingChange:c,voiceActive:ae.voiceActive,onStartVoiceInput:ae.startVoiceInput,onSend:se.send,onAbort:d,onInterrupt:se.interruptDraft,sessionModel:D,showModelSelector:O,onModelChange:k,modelDisabled:A,contextUsageMessages:j,composerDraftChars:ie})]}),(0,$.jsx)(Oge,{open:B,sessionKey:r,disabled:e||ue,chat:P.chat,onClose:()=>V(!1),onSendCommand:re})]})});function Age(e,t){let n=e.createdAt;if(!Number.isFinite(n)||n<=0)return 0;let r=typeof e.lastTurnAt==`number`&&Number.isFinite(e.lastTurnAt)?e.lastTurnAt:0,i=e.status===`done`&&r>=n?r:t;return Math.max(0,i-n)}function jge(e,t){let n=Math.max(0,Math.floor(e/1e3));if(n<60)return t===`zh`?`${n}秒`:`${n}s`;let r=Math.floor(n/60),i=n%60;if(r<60)return t===`zh`?`${r}分${String(i).padStart(2,`0`)}秒`:`${r}m ${i}s`;let a=Math.floor(r/60),o=r%60;return t===`zh`?`${a}小时${o}分`:`${a}h ${o}m`}function Mge(e){let t=(0,Q.c)(52),{goal:n,canEditChecklist:r,mutationBusy:i,t:a,onAction:o,onChecklist:s}=e,c=i||n.status!==`active`,l;t[0]===o?l=t[1]:(l=()=>void o(`pause`),t[0]=o,t[1]=l);let d;t[2]!==a.pause||t[3]!==c||t[4]!==l?(d=(0,$.jsx)(tA,{type:`button`,variant:`primary`,className:`h-8 px-3 text-xs`,disabled:c,onClick:l,children:a.pause}),t[2]=a.pause,t[3]=c,t[4]=l,t[5]=d):d=t[5];let f=i||n.status!==`paused`&&n.status!==`done`,p;t[6]===o?p=t[7]:(p=()=>void o(`resume`),t[6]=o,t[7]=p);let m;t[8]!==a.resume||t[9]!==f||t[10]!==p?(m=(0,$.jsx)(tA,{type:`button`,variant:`secondary`,className:`h-8 px-3 text-xs`,disabled:f,onClick:p,children:a.resume}),t[8]=a.resume,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(h=u(`flex h-8 cursor-pointer list-none items-center rounded-md border border-edge bg-surface-panel px-2.5 text-xs text-fg-muted`,`marker:hidden [&::-webkit-details-marker]:hidden`,`hover:bg-surface-hover hover:text-fg`),t[12]=h):h=t[12];let g;t[13]!==a.moreActions||t[14]!==a.moreHint?(g=(0,$.jsx)(`summary`,{className:h,title:a.moreHint,children:a.moreActions}),t[13]=a.moreActions,t[14]=a.moreHint,t[15]=g):g=t[15];let _;t[16]===o?_=t[17]:(_=()=>void o(`restart`),t[16]=o,t[17]=_);let v;t[18]!==i||t[19]!==a.restart||t[20]!==_?(v=(0,$.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-fg hover:bg-surface-hover`,disabled:i,onClick:_,children:a.restart}),t[18]=i,t[19]=a.restart,t[20]=_,t[21]=v):v=t[21];let y=i||!r,b;t[22]===s?b=t[23]:(b=()=>void s({op:`reset`}),t[22]=s,t[23]=b);let x;t[24]!==a.resetChecklist||t[25]!==y||t[26]!==b?(x=(0,$.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-fg hover:bg-surface-hover`,disabled:y,onClick:b,children:a.resetChecklist}),t[24]=a.resetChecklist,t[25]=y,t[26]=b,t[27]=x):x=t[27];let S;t[28]===o?S=t[29]:(S=()=>void o(`clear`),t[28]=o,t[29]=S);let C;t[30]!==i||t[31]!==a.clear||t[32]!==S?(C=(0,$.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-destructive hover:bg-surface-hover`,disabled:i,onClick:S,children:a.clear}),t[30]=i,t[31]=a.clear,t[32]=S,t[33]=C):C=t[33];let w;t[34]===o?w=t[35]:(w=()=>void o(`detach`),t[34]=o,t[35]=w);let T;t[36]!==i||t[37]!==a.detach||t[38]!==w?(T=(0,$.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-fg hover:bg-surface-hover`,disabled:i,onClick:w,children:a.detach}),t[36]=i,t[37]=a.detach,t[38]=w,t[39]=T):T=t[39];let E;t[40]!==v||t[41]!==x||t[42]!==C||t[43]!==T?(E=(0,$.jsxs)(`div`,{className:`absolute right-0 z-30 mt-1 min-w-[11rem] rounded-md border border-edge bg-surface-panel py-1 shadow-surface`,children:[v,x,C,T]}),t[40]=v,t[41]=x,t[42]=C,t[43]=T,t[44]=E):E=t[44];let D;t[45]!==E||t[46]!==g?(D=(0,$.jsxs)(`details`,{className:`group relative`,children:[g,E]}),t[45]=E,t[46]=g,t[47]=D):D=t[47];let O;return t[48]!==D||t[49]!==d||t[50]!==m?(O=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[d,m,D]}),t[48]=D,t[49]=d,t[50]=m,t[51]=O):O=t[51],O}function Nge(e){return e!==null&&e.status!==`archived`}function V8(e){let t=e.checklist??[];return{total:t.length,done:t.filter(e=>e.status===`completed`||e.status===`impossible`).length}}function Pge(e){let t=Math.max(0,e.maxTurns),n=Math.max(0,e.turnsUsed);return{used:n,total:t,percent:t>0?Math.min(100,100*n/t):0}}function Fge(e){let{done:t,total:n}=V8(e);return{done:t,total:n,percent:n>0?Math.min(100,100*t/n):0}}function Ige(e,t){return t?`agent_running`:e.status===`paused`||e.status===`blocked`||e.status===`needs_input`?`paused`:e.status===`done`?`done`:e.lastVerdict?`judge_recently_completed`:`idle`}function H8(e,t){return e===`agent_running`?t.phaseAgentRunning:e===`paused`?t.phasePaused:e===`done`?t.phaseDone:e===`judge_recently_completed`?t.phaseJudged:t.missionHeading}function U8(e,t){return e.status===`active`?t.statusActive:e.status===`paused`||e.status===`blocked`||e.status===`needs_input`?t.statusPaused:e.status===`done`?t.statusDone:e.status}function W8(e,t){return e===`done`?t.verdictDone:e===`continue`?t.verdictContinue:e===`decompose`?t.verdictDecompose:e===`blocked`||e===`needs_input`?t.statusPaused:e??``}function G8(e,t){return e?W8(e,t):``}function K8(e,t){return e===`active`?t.statusActive:e===`paused`?t.statusPaused:e===`done`?t.statusDone:e}function q8(e){return`xopc:goalBannerCollapsed:${e}`}function Lge(e){return e.status===`completed`?`✓`:e.status===`impossible`?`!`:`○`}function Rge(e){let t={pending:[],completed:[],impossible:[]};return e.forEach((e,n)=>{t[e.status].push({...e,index1Based:n+1})}),t}function zge(e){let t=(0,Q.c)(42),{goal:n,canEdit:r,mutationBusy:i,t:a,onMutate:o}=e,[s,c]=(0,Z.useState)(``),l,d,f;if(t[0]!==r||t[1]!==n.checklist||t[2]!==i||t[3]!==o||t[4]!==a.checklistEmpty||t[5]!==a.checklistHeading||t[6]!==a.completedGroup||t[7]!==a.evidenceLabel||t[8]!==a.impossibleGroup||t[9]!==a.judgeGenerated||t[10]!==a.markBlocked||t[11]!==a.markDone||t[12]!==a.pendingGroup||t[13]!==a.removeItem||t[14]!==a.userAdded){let e=n.checklist??[],s=Rge(e),c;t[18]!==r||t[19]!==i||t[20]!==o||t[21]!==a.evidenceLabel||t[22]!==a.judgeGenerated||t[23]!==a.markBlocked||t[24]!==a.markDone||t[25]!==a.removeItem||t[26]!==a.userAdded?(c=(e,t)=>t.length===0?null:(0,$.jsxs)(`section`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(`span`,{children:t.length})]}),(0,$.jsx)(`ul`,{className:`space-y-1.5`,children:t.map(e=>(0,$.jsx)(`li`,{className:`rounded-md border border-transparent px-1.5 py-1 hover:border-edge/60 hover:bg-surface-panel/70`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 w-4 shrink-0 text-center text-fg-muted`,title:e.status,children:Lge(e)}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5 text-[10px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`rounded-full bg-surface-panel px-1.5 py-0.5`,children:e.addedBy===`user`?a.userAdded:a.judgeGenerated}),e.evidenceSummary?(0,$.jsxs)(`span`,{className:`min-w-0 break-words`,children:[a.evidenceLabel,`: `,e.evidenceSummary]}):null]})]}),r&&e.status===`pending`?(0,$.jsxs)(`span`,{className:`flex shrink-0 flex-wrap justify-end gap-0.5`,children:[(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`h-7 px-1.5 text-[11px] text-accent`,disabled:i,onClick:()=>void o({op:`mark`,index:e.index1Based,status:`completed`}),children:a.markDone}),(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`h-7 px-1.5 text-[11px] text-fg-muted`,disabled:i,onClick:()=>void o({op:`mark`,index:e.index1Based,status:`impossible`}),children:a.markBlocked}),(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`h-7 px-1.5 text-[11px] text-destructive`,disabled:i,onClick:()=>void o({op:`remove`,index:e.index1Based}),children:a.removeItem})]}):null]})},`${e.index1Based}-${e.text.slice(0,24)}`))})]}),t[18]=r,t[19]=i,t[20]=o,t[21]=a.evidenceLabel,t[22]=a.judgeGenerated,t[23]=a.markBlocked,t[24]=a.markDone,t[25]=a.removeItem,t[26]=a.userAdded,t[27]=c):c=t[27];let u=c;l=`rounded-xl bg-surface-muted/70 px-2.5 py-2 dark:bg-surface-muted/40`,t[28]===a.checklistHeading?d=t[29]:(d=(0,$.jsx)(`p`,{className:`mb-1.5 text-[11px] font-medium uppercase tracking-wide text-fg-muted`,children:a.checklistHeading}),t[28]=a.checklistHeading,t[29]=d),f=e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.checklistEmpty}):(0,$.jsxs)(`div`,{className:`max-h-48 space-y-2 overflow-y-auto pr-0.5 text-xs`,children:[u(a.pendingGroup,s.pending),u(a.completedGroup,s.completed),u(a.impossibleGroup,s.impossible)]}),t[0]=r,t[1]=n.checklist,t[2]=i,t[3]=o,t[4]=a.checklistEmpty,t[5]=a.checklistHeading,t[6]=a.completedGroup,t[7]=a.evidenceLabel,t[8]=a.impossibleGroup,t[9]=a.judgeGenerated,t[10]=a.markBlocked,t[11]=a.markDone,t[12]=a.pendingGroup,t[13]=a.removeItem,t[14]=a.userAdded,t[15]=l,t[16]=d,t[17]=f}else l=t[15],d=t[16],f=t[17];let p;t[30]!==r||t[31]!==i||t[32]!==s||t[33]!==o||t[34]!==a.addCriterion||t[35]!==a.addCriterionPlaceholder?(p=r?(0,$.jsxs)(`div`,{className:`mt-2 flex gap-1.5`,children:[(0,$.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:a.addCriterionPlaceholder,className:u(`min-w-0 flex-1 rounded-md border border-edge bg-surface-muted px-2 py-1.5 text-xs text-fg`,`placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`),onKeyDown:e=>{e.key===`Enter`&&s.trim()&&(e.preventDefault(),Promise.resolve(o({op:`add`,text:s.trim()})).then(()=>c(``)))}}),(0,$.jsx)(tA,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:i||!s.trim(),onClick:()=>void Promise.resolve(o({op:`add`,text:s.trim()})).then(()=>c(``)),children:a.addCriterion})]}):null,t[30]=r,t[31]=i,t[32]=s,t[33]=o,t[34]=a.addCriterion,t[35]=a.addCriterionPlaceholder,t[36]=p):p=t[36];let m;return t[37]!==l||t[38]!==d||t[39]!==f||t[40]!==p?(m=(0,$.jsxs)(`div`,{className:l,children:[d,f,p]}),t[37]=l,t[38]=d,t[39]=f,t[40]=p,t[41]=m):m=t[41],m}function Bge(e){let t=(0,Q.c)(23),{goal:n,agentBusy:r,pillTitle:i,phase:a,statusShort:o,turnsShort:s,clLine:c,t:l,onExpand:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=u(`pointer-events-none absolute z-30`,`right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(0.5rem,env(safe-area-inset-top,0px))]`,`sm:right-[max(1.25rem,env(safe-area-inset-right,0px))] xl:right-[max(1.5rem,env(safe-area-inset-right,0px))]`),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=u(`pointer-events-auto flex h-11 min-w-11 max-w-[min(calc(100vw-1.5rem),16rem)] items-center gap-1.5 rounded-full border border-edge/60 bg-surface-panel/95 px-2.5 py-1 text-left shadow-elevated backdrop-blur-sm`,`transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[1]=p):p=t[1];let m=`${i}${c?` · ${c}`:``}${n.lastVerdict?`\n${l.lastVerdict}: ${n.lastVerdict}`:``}${n.lastReason?`\n${l.lastReason}: ${n.lastReason}`:``}\n${n.title}`,h=l.expandAria,g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(rE,{className:`size-4 text-accent`,"aria-hidden":!0}),t[2]=g):g=t[2];let _;t[3]!==r||t[4]!==n.status?(_=(0,$.jsxs)(`span`,{className:`relative flex size-8 shrink-0 items-center justify-center rounded-full bg-surface-muted`,children:[g,r?(0,$.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 flex size-2.5 rounded-full border-2 border-surface-panel bg-accent motion-safe:animate-pulse`}):(0,$.jsx)(`span`,{className:u(`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-surface-panel`,n.status===`active`&&`bg-accent`,n.status===`paused`&&`bg-fg-muted`,n.status===`done`&&`bg-fg-muted`)})]}),t[3]=r,t[4]=n.status,t[5]=_):_=t[5];let v;t[6]!==a||t[7]!==l?(v=H8(a,l),t[6]=a,t[7]=l,t[8]=v):v=t[8];let y;t[9]!==o||t[10]!==v?(y=(0,$.jsxs)(`span`,{className:`block truncate text-[10px] font-medium leading-tight text-fg`,children:[v,` · `,o]}),t[9]=o,t[10]=v,t[11]=y):y=t[11];let b=c?`${s} · ${c}`:s,x;t[12]===b?x=t[13]:(x=(0,$.jsx)(`span`,{className:`block truncate text-[10px] leading-tight text-fg-muted`,children:b}),t[12]=b,t[13]=x);let S;t[14]!==x||t[15]!==y?(S=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 pr-0.5`,children:[y,x]}),t[14]=x,t[15]=y,t[16]=S):S=t[16];let C;return t[17]!==d||t[18]!==l.expandAria||t[19]!==S||t[20]!==m||t[21]!==_?(C=(0,$.jsx)(`div`,{className:`relative h-0 shrink-0 overflow-visible`,children:(0,$.jsx)(`div`,{className:f,children:(0,$.jsxs)(`button`,{type:`button`,className:p,title:m,"aria-label":h,onClick:d,children:[_,S]})})}),t[17]=d,t[18]=l.expandAria,t[19]=S,t[20]=m,t[21]=_,t[22]=C):C=t[22],C}function Vge(e){let t=(0,Q.c)(36),{goal:n,t:r}=e,[i,a]=(0,Z.useState)(!1);if(!(n.lastVerdict||n.lastReason||n.blockedReason))return null;let o;t[0]!==n.lastVerdict||t[1]!==r?(o=n.lastVerdict?W8(n.lastVerdict,r):``,t[0]=n.lastVerdict,t[1]=r,t[2]=o):o=t[2];let s=o,c=n.blockedReason||n.lastReason,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>a(Hge),t[3]=l):l=t[3];let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-panel text-accent`,children:(0,$.jsx)(Dx,{className:`size-3.5`,"aria-hidden":!0})}),t[4]=u):u=t[4];let d;t[5]===r.lastJudgementTitle?d=t[6]:(d=(0,$.jsx)(`span`,{className:`font-medium`,children:r.lastJudgementTitle}),t[5]=r.lastJudgementTitle,t[6]=d);let f;t[7]===s?f=t[8]:(f=s?(0,$.jsx)(`span`,{className:`rounded-full border border-edge px-1.5 py-0.5 text-[10px] text-fg-muted`,children:s}):null,t[7]=s,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-fg`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===c?m=t[13]:(m=c?(0,$.jsx)(`span`,{className:`mt-0.5 line-clamp-2 block text-fg-muted`,children:c}):null,t[12]=c,t[13]=m);let h;t[14]!==p||t[15]!==m?(h=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16];let g=i?r.hideDetails:r.showDetails,_;t[17]===g?_=t[18]:(_=(0,$.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-muted`,children:g}),t[17]=g,t[18]=_);let v;t[19]!==_||t[20]!==h?(v=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full min-w-0 items-start gap-2 text-left`,onClick:l,children:[u,h,_]}),t[19]=_,t[20]=h,t[21]=v):v=t[21];let y;t[22]!==n.blockedReason||t[23]!==n.judgeModelRef||t[24]!==n.lastReason||t[25]!==n.lastVerdict||t[26]!==i||t[27]!==r.judgeModel||t[28]!==r.lastReason||t[29]!==r.lastVerdict||t[30]!==r.pausedReason||t[31]!==s?(y=i?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1.5 rounded-lg border border-edge/70 bg-surface-panel px-2 py-1.5 text-fg-muted`,children:[n.lastVerdict?(0,$.jsxs)(`p`,{children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.lastVerdict,`:`]}),` `,s]}):null,n.lastReason?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap break-words`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.lastReason,`:`]}),` `,n.lastReason]}):null,n.blockedReason?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap break-words`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.pausedReason,`:`]}),` `,n.blockedReason]}):null,n.judgeModelRef?(0,$.jsxs)(`p`,{className:`break-words`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.judgeModel,`:`]}),` `,n.judgeModelRef]}):null]}):null,t[22]=n.blockedReason,t[23]=n.judgeModelRef,t[24]=n.lastReason,t[25]=n.lastVerdict,t[26]=i,t[27]=r.judgeModel,t[28]=r.lastReason,t[29]=r.lastVerdict,t[30]=r.pausedReason,t[31]=s,t[32]=y):y=t[32];let b;return t[33]!==v||t[34]!==y?(b=(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge/70 bg-surface-muted/45 px-2.5 py-2 text-xs dark:bg-surface-muted/25`,children:[v,y]}),t[33]=v,t[34]=y,t[35]=b):b=t[35],b}function Hge(e){return!e}function Uge(e){let t=(0,Q.c)(3),{goal:n,t:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Vge,{goal:n,t:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var Wge=new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),Gge=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});function Kge(e,t){let n=typeof e==`string`?new Date(e):e;return(t===`zh`?Wge:Gge).format(n)}function J8(e){let t=(0,Q.c)(23),{sessionKey:n,goal:r,language:i,t:a}=e,o;t[0]===n?o=t[1]:(o=async()=>(await i8(n,{limit:1})).runs,t[0]=n,t[1]=o);let s;t[2]!==r.lastTurnAt||t[3]!==r.lastVerdict||t[4]!==r.turnsUsed||t[5]!==n?(s=[n,r.turnsUsed,r.lastTurnAt,r.lastVerdict],t[2]=r.lastTurnAt,t[3]=r.lastVerdict,t[4]=r.turnsUsed,t[5]=n,t[6]=s):s=t[6];let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[7]=c):c=t[7];let l;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(l={initial:c,errorData:[]},t[8]=l):l=t[8];let{data:u,loading:d}=lP(o,s,l),f=u[0];if(!f&&!d)return null;let p;t[9]===a.latestRunTitle?p=t[10]:(p=(0,$.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:a.latestRunTitle}),t[9]=a.latestRunTitle,t[10]=p);let m;t[11]!==i||t[12]!==f?(m=f?(0,$.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(f.at).toISOString(),children:Kge(f.at,i)}):null,t[11]=i,t[12]=f,t[13]=m):m=t[13];let h;t[14]!==p||t[15]!==m?(h=(0,$.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center justify-between gap-2 text-[10px] text-fg-muted`,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]!==f||t[18]!==a?(g=f?(0,$.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[auto_1fr_auto] sm:items-start`,children:[(0,$.jsx)(`div`,{className:`rounded-full border border-edge bg-surface-muted px-2 py-0.5 text-[10px] text-fg-muted`,children:a.runHistoryTurns.replace(`{{used}}`,String(f.turnsUsed)).replace(`{{max}}`,String(f.maxTurns))}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-fg`,children:[(0,$.jsx)(`span`,{children:G8(f.verdict,a)}),(0,$.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,$.jsx)(`span`,{children:K8(f.statusAfter,a)}),f.checklistProgress?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,$.jsx)(`span`,{children:a.checklistProgress.replace(`{{done}}`,String(f.checklistProgress.done)).replace(`{{total}}`,String(f.checklistProgress.total))})]}):null]}),f.reason?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-fg-muted`,children:f.reason}):null]}),(0,$.jsx)(`div`,{className:`text-[10px] text-accent sm:text-right`,children:f.willContinue?a.nextStepContinue:a.nextStepStop})]}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:a.runHistoryLoading}),t[17]=f,t[18]=a,t[19]=g):g=t[19];let _;return t[20]!==h||t[21]!==g?(_=(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge/70 bg-surface-panel px-2.5 py-2 text-xs`,children:[h,g]}),t[20]=h,t[21]=g,t[22]=_):_=t[22],_}function qge(e){let t=(0,Q.c)(20),{goal:n,t:r}=e,i;t[0]===n?i=t[1]:(i=Pge(n),t[0]=n,t[1]=i);let a=i,o;t[2]===n?o=t[3]:(o=Fge(n),t[2]=n,t[3]=o);let s=o,c=r.heading,l=n.status===`done`?`bg-accent`:`bg-accent/75`,d;t[4]===l?d=t[5]:(d=u(`h-full rounded-full transition-[width] duration-300`,l),t[4]=l,t[5]=d);let f=`${a.percent}%`,p;t[6]===f?p=t[7]:(p={width:f},t[6]=f,t[7]=p);let m;t[8]!==d||t[9]!==p?(m=(0,$.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-elevated`,children:(0,$.jsx)(`div`,{className:d,style:p})}),t[8]=d,t[9]=p,t[10]=m):m=t[10];let h;t[11]!==s.done||t[12]!==s.percent||t[13]!==s.total||t[14]!==r.checklistProgress?(h=s.total>0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:r.checklistProgress.replace(`{{done}}`,String(s.done)).replace(`{{total}}`,String(s.total))}),(0,$.jsx)(`div`,{className:`h-1 min-w-10 flex-1 overflow-hidden rounded-full bg-surface-muted`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-fg-muted/55 transition-[width] duration-300`,style:{width:`${s.percent}%`}})})]}):null,t[11]=s.done,t[12]=s.percent,t[13]=s.total,t[14]=r.checklistProgress,t[15]=h):h=t[15];let g;return t[16]!==r.heading||t[17]!==m||t[18]!==h?(g=(0,$.jsxs)(`div`,{className:`space-y-1.5`,"aria-label":c,children:[m,h]}),t[16]=r.heading,t[17]=m,t[18]=h,t[19]=g):g=t[19],g}var Jge=new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),Yge=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});function Xge(e,t){let n=typeof e==`string`?new Date(e):e;return(t===`zh`?Jge:Yge).format(n)}function Zge(e){let t=(0,Q.c)(25),{sessionKey:n,goal:r,language:i,t:a}=e,[o,s]=(0,Z.useState)(!1),c;t[0]===n?c=t[1]:(c=async()=>(await i8(n,{limit:40})).runs,t[0]=n,t[1]=c);let l;t[2]!==r.lastTurnAt||t[3]!==r.lastVerdict||t[4]!==r.turnsUsed||t[5]!==o||t[6]!==n?(l=[o,n,r.turnsUsed,r.lastTurnAt,r.lastVerdict],t[2]=r.lastTurnAt,t[3]=r.lastVerdict,t[4]=r.turnsUsed,t[5]=o,t[6]=n,t[7]=l):l=t[7];let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=[],t[9]=d):d=t[9];let f;t[10]===o?f=t[11]:(f={enabled:o,initial:u,errorData:d},t[10]=o,t[11]=f);let{data:p,loading:m,error:h}=lP(c,l,f),g=h==null?null:h instanceof Error?h.message:a.runHistoryLoadFailed,_;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>s(Qge),t[12]=_):_=t[12];let v;t[13]===a.runHistory?v=t[14]:(v=(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted underline-offset-2 hover:underline`,onClick:_,children:a.runHistory}),t[13]=a.runHistory,t[14]=v);let y;t[15]!==i||t[16]!==p||t[17]!==g||t[18]!==m||t[19]!==o||t[20]!==a?(y=o?(0,$.jsxs)(`div`,{className:`mt-1 max-h-52 space-y-2 overflow-y-auto rounded-md border border-edge bg-surface-panel p-2 text-xs text-fg-muted`,children:[m?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:a.runHistoryLoading}):null,g?(0,$.jsx)(`p`,{className:`text-destructive`,children:g}):null,!m&&!g&&p.length===0?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:a.runHistoryEmpty}):null,!m&&p.length>0?(0,$.jsx)(`ul`,{className:`space-y-2`,children:p.map(e=>(0,$.jsxs)(`li`,{className:`rounded-md border border-edge/80 bg-surface-muted/40 px-2 py-1.5 dark:bg-surface-muted/25`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-2 gap-y-0.5 text-[10px] text-fg-muted`,children:[(0,$.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(e.at).toISOString(),children:Xge(e.at,i)}),(0,$.jsx)(`span`,{children:a.runHistoryTurns.replace(`{{used}}`,String(e.turnsUsed)).replace(`{{max}}`,String(e.maxTurns))})]}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-fg`,children:[(0,$.jsx)(`span`,{children:G8(e.verdict,a)}),(0,$.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,$.jsx)(`span`,{children:K8(e.statusAfter,a)}),(0,$.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,$.jsx)(`span`,{children:e.willContinue?a.runHistoryContinue:a.runHistoryStop}),e.checklistProgress?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,$.jsx)(`span`,{children:a.checklistProgress.replace(`{{done}}`,String(e.checklistProgress.done)).replace(`{{total}}`,String(e.checklistProgress.total))})]}):null]}),e.reason?(0,$.jsxs)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-fg-muted`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[a.lastReason,`:`]}),` `,e.reason]}):null,e.assistantPreview?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-[10px] leading-snug text-fg-muted`,children:e.assistantPreview}):null]},e.id))}):null]}):null,t[15]=i,t[16]=p,t[17]=g,t[18]=m,t[19]=o,t[20]=a,t[21]=y):y=t[21];let b;return t[22]!==v||t[23]!==y?(b=(0,$.jsxs)(`div`,{children:[v,y]}),t[22]=v,t[23]=y,t[24]=b):b=t[24],b}function Qge(e){return!e}function $ge(e,t){switch(t.type){case`start`:return{busy:!0,error:null};case`error`:return{busy:!1,error:t.error};case`done`:return{busy:!1,error:null}}}function e_e(e){try{return sessionStorage.getItem(q8(e))===`1`}catch{return!1}}function Y8(e){let t=(0,Q.c)(3),{onTick:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{let e=window.setInterval(n,1e3);return()=>clearInterval(e)},i=[n],t[0]=n,t[1]=r,t[2]=i),(0,Z.useEffect)(r,i),null}function t_e(e){let t=(0,Q.c)(61),{goal:n,agentBusy:r,phase:i,statusShort:a,turnsShort:o,clLine:s,elapsedStr:c,mutationBusy:l,t:d,onAction:f,onOpenDetails:p,onMinimize:m}=e,h=n.status===`active`,g=n.status===`paused`||n.status===`done`||n.status===`blocked`||n.status===`needs_input`,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(rE,{className:`size-4 text-accent`,"aria-hidden":!0}),t[0]=_):_=t[0];let v=r&&`bg-accent motion-safe:animate-pulse`,y=!r&&n.status===`active`&&`bg-accent`,b=!r&&n.status!==`active`&&`bg-fg-muted`,x;t[1]!==v||t[2]!==y||t[3]!==b?(x=u(`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-surface-panel`,v,y,b),t[1]=v,t[2]=y,t[3]=b,t[4]=x):x=t[4];let S;t[5]===x?S=t[6]:(S=(0,$.jsxs)(`span`,{className:`relative flex size-8 shrink-0 items-center justify-center rounded-full bg-surface-muted`,children:[_,(0,$.jsx)(`span`,{className:x})]}),t[5]=x,t[6]=S);let C;t[7]!==i||t[8]!==d?(C=H8(i,d),t[7]=i,t[8]=d,t[9]=C):C=t[9];let w;t[10]===C?w=t[11]:(w=(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:C}),t[10]=C,t[11]=w);let T;t[12]===a?T=t[13]:(T=(0,$.jsx)(`span`,{className:`rounded-full border border-edge px-1.5 py-0.5`,children:a}),t[12]=a,t[13]=T);let E;t[14]===o?E=t[15]:(E=(0,$.jsx)(`span`,{children:o}),t[14]=o,t[15]=E);let D;t[16]===s?D=t[17]:(D=s?(0,$.jsx)(`span`,{children:s}):null,t[16]=s,t[17]=D);let O;t[18]!==c||t[19]!==n.status||t[20]!==d.elapsedLabel?(O=n.status!==`done`&&n.status!==`archived`?(0,$.jsxs)(`span`,{children:[d.elapsedLabel,`: `,(0,$.jsx)(`span`,{className:`text-fg`,children:c})]}):null,t[18]=c,t[19]=n.status,t[20]=d.elapsedLabel,t[21]=O):O=t[21];let k;t[22]!==E||t[23]!==D||t[24]!==O||t[25]!==w||t[26]!==T?(k=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-fg-muted`,children:[w,T,E,D,O]}),t[22]=E,t[23]=D,t[24]=O,t[25]=w,t[26]=T,t[27]=k):k=t[27];let A;t[28]===n.title?A=t[29]:(A=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-medium leading-tight text-fg`,children:n.title}),t[28]=n.title,t[29]=A);let j;t[30]!==k||t[31]!==A?(j=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 py-0.5`,children:[k,A]}),t[30]=k,t[31]=A,t[32]=j):j=t[32];let M;t[33]!==p||t[34]!==j||t[35]!==S?(M=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 rounded-lg text-left outline-none hover:bg-surface-hover/70 focus-visible:ring-2 focus-visible:ring-accent`,onClick:p,children:[S,j]}),t[33]=p,t[34]=j,t[35]=S,t[36]=M):M=t[36];let N=l||!h&&!g,P;t[37]!==h||t[38]!==f?(P=()=>void f(h?`pause`:`resume`),t[37]=h,t[38]=f,t[39]=P):P=t[39];let F;t[40]===h?F=t[41]:(F=h?(0,$.jsx)(ry,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(Py,{className:`size-3.5`,"aria-hidden":!0}),t[40]=h,t[41]=F);let I=h?d.pause:d.resume,L;t[42]!==N||t[43]!==P||t[44]!==F||t[45]!==I?(L=(0,$.jsxs)(tA,{type:`button`,variant:`ghost`,className:`hidden h-8 px-2 text-xs sm:inline-flex`,disabled:N,onClick:P,children:[F,I]}),t[42]=N,t[43]=P,t[44]=F,t[45]=I,t[46]=L):L=t[46];let R;t[47]!==p||t[48]!==d.details?(R=(0,$.jsx)(tA,{type:`button`,variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:p,children:d.details}),t[47]=p,t[48]=d.details,t[49]=R):R=t[49];let z;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(Gv,{className:`size-4`,"aria-hidden":!0}),t[50]=z):z=t[50];let B;t[51]!==m||t[52]!==d.collapseAria?(B=(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0 text-fg-muted hover:text-fg`,"aria-label":d.collapseAria,onClick:m,children:z}),t[51]=m,t[52]=d.collapseAria,t[53]=B):B=t[53];let V;t[54]!==L||t[55]!==R||t[56]!==B?(V=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[L,R,B]}),t[54]=L,t[55]=R,t[56]=B,t[57]=V):V=t[57];let H;return t[58]!==M||t[59]!==V?(H=(0,$.jsx)(`div`,{className:`shrink-0 w-full px-3 pt-1.5 sm:px-5 sm:pt-2 xl:px-6`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex min-h-12 w-full max-w-[var(--max-width-chat)] items-center gap-2 rounded-xl border border-edge bg-surface-panel px-2.5 py-2 shadow-surface sm:px-3`,children:[M,V]})}),t[58]=M,t[59]=V,t[60]=H):H=t[60],H}function X8(e){let t=(0,Q.c)(99),{open:n,sessionKey:r,goal:i,language:a,activeTab:o,canEditChecklist:s,mutationBusy:c,error:l,t:d,onOpenChange:f,onTabChange:p,onAction:m,onChecklist:h}=e,g;t[0]===d.tabOverview?g=t[1]:(g={id:`overview`,label:d.tabOverview},t[0]=d.tabOverview,t[1]=g);let _;t[2]===d.tabCriteria?_=t[3]:(_={id:`criteria`,label:d.tabCriteria},t[2]=d.tabCriteria,t[3]=_);let v;t[4]===d.tabRuns?v=t[5]:(v={id:`runs`,label:d.tabRuns},t[4]=d.tabRuns,t[5]=v);let y;t[6]!==g||t[7]!==_||t[8]!==v?(y=[g,_,v],t[6]=g,t[7]=_,t[8]=v,t[9]=y):y=t[9];let b=y,x=i.blockedReason||i.nextAction||d.noNextAction||``,S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(RN,{className:`xopc-dialog-overlay fixed inset-0 z-[120] bg-scrim backdrop-blur-[1px]`}),t[10]=S):S=t[10];let C;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(rE,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=C):C=t[11];let w;t[12]===d.detailsTitle?w=t[13]:(w=(0,$.jsx)(BN,{className:`truncate text-sm font-semibold text-fg`,children:d.detailsTitle}),t[12]=d.detailsTitle,t[13]=w);let T;t[14]!==i||t[15]!==d?(T=U8(i,d),t[14]=i,t[15]=d,t[16]=T):T=t[16];let E;t[17]===T?E=t[18]:(E=(0,$.jsx)(`span`,{className:`rounded-full border border-edge px-1.5 py-0.5 text-[10px] text-fg-muted`,children:T}),t[17]=T,t[18]=E);let D;t[19]!==w||t[20]!==E?(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[C,w,E]}),t[19]=w,t[20]=E,t[21]=D):D=t[21];let O;t[22]===i.title?O=t[23]:(O=(0,$.jsx)(VN,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:i.title}),t[22]=i.title,t[23]=O);let k;t[24]!==D||t[25]!==O?(k=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[24]=D,t[25]=O,t[26]=k):k=t[26];let A=`/goals/${encodeURIComponent(i.id)}`,j;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(gh,{className:`size-3.5`,"aria-hidden":!0}),t[27]=j):j=t[27];let M;t[28]!==d.openFullGoal||t[29]!==A?(M=(0,$.jsx)(tA,{asChild:!0,type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,children:(0,$.jsxs)(Hi,{to:A,children:[j,d.openFullGoal]})}),t[28]=d.openFullGoal,t[29]=A,t[30]=M):M=t[30];let N;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(Sk,{className:`size-4`,"aria-hidden":!0}),t[31]=N):N=t[31];let P;t[32]===d.closeDetails?P=t[33]:(P=(0,$.jsx)(HN,{asChild:!0,children:(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`size-8 p-0`,"aria-label":d.closeDetails,children:N})}),t[32]=d.closeDetails,t[33]=P);let F;t[34]!==M||t[35]!==P?(F=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[M,P]}),t[34]=M,t[35]=P,t[36]=F):F=t[36];let I;t[37]!==k||t[38]!==F?(I=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[k,F]}),t[37]=k,t[38]=F,t[39]=I):I=t[39];let L=d.detailsTitle,R;t[40]!==o||t[41]!==p||t[42]!==b?(R=b.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":o===e.id,className:u(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,o===e.id?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>p(e.id),children:e.label},e.id)),t[40]=o,t[41]=p,t[42]=b,t[43]=R):R=t[43];let z;t[44]!==d.detailsTitle||t[45]!==R?(z=(0,$.jsx)(`div`,{className:`flex shrink-0 gap-1 border-b border-edge px-4 py-2`,role:`tablist`,"aria-label":L,children:R}),t[44]=d.detailsTitle,t[45]=R,t[46]=z):z=t[46];let B;t[47]!==o||t[48]!==i||t[49]!==a||t[50]!==r||t[51]!==x||t[52]!==d?(B=o===`overview`?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(kv,{className:`size-4 text-accent`,"aria-hidden":!0}),d.currentState]}),(0,$.jsx)(`p`,{className:u(`break-words text-sm`,i.blockedReason?`text-warning`:`text-fg`),children:x})]}),(0,$.jsx)(qge,{goal:i,t:d}),(0,$.jsx)(Uge,{goal:i,t:d}),(0,$.jsx)(J8,{sessionKey:r,goal:i,language:a,t:d})]}):null,t[47]=o,t[48]=i,t[49]=a,t[50]=r,t[51]=x,t[52]=d,t[53]=B):B=t[53];let V;t[54]!==o||t[55]!==s||t[56]!==i||t[57]!==c||t[58]!==h||t[59]!==d?(V=o===`criteria`?(0,$.jsx)(zge,{goal:i,canEdit:s,mutationBusy:c,t:d,onMutate:h}):null,t[54]=o,t[55]=s,t[56]=i,t[57]=c,t[58]=h,t[59]=d,t[60]=V):V=t[60];let H;t[61]!==o||t[62]!==i||t[63]!==a||t[64]!==r||t[65]!==d?(H=o===`runs`?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(J8,{sessionKey:r,goal:i,language:a,t:d}),(0,$.jsx)(Zge,{sessionKey:r,goal:i,language:a,t:d})]}):null,t[61]=o,t[62]=i,t[63]=a,t[64]=r,t[65]=d,t[66]=H):H=t[66];let U;t[67]===l?U=t[68]:(U=l?(0,$.jsx)(`p`,{className:`mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:l}):null,t[67]=l,t[68]=U);let W;t[69]!==B||t[70]!==V||t[71]!==H||t[72]!==U?(W=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:[B,V,H,U]}),t[69]=B,t[70]=V,t[71]=H,t[72]=U,t[73]=W):W=t[73];let G;t[74]!==i.maxTurns||t[75]!==i.turnsUsed||t[76]!==d.turns?(G=d.turns.replace(`{{used}}`,String(i.turnsUsed)).replace(`{{max}}`,String(i.maxTurns)),t[74]=i.maxTurns,t[75]=i.turnsUsed,t[76]=d.turns,t[77]=G):G=t[77];let K;t[78]===G?K=t[79]:(K=(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:G}),t[78]=G,t[79]=K);let q;t[80]!==s||t[81]!==i||t[82]!==c||t[83]!==m||t[84]!==h||t[85]!==d?(q=(0,$.jsx)(Mge,{goal:i,canEditChecklist:s,mutationBusy:c,t:d,onAction:m,onChecklist:h}),t[80]=s,t[81]=i,t[82]=c,t[83]=m,t[84]=h,t[85]=d,t[86]=q):q=t[86];let ee;t[87]!==K||t[88]!==q?(ee=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-edge px-4 py-3`,children:[K,q]}),t[87]=K,t[88]=q,t[89]=ee):ee=t[89];let J;t[90]!==I||t[91]!==z||t[92]!==W||t[93]!==ee?(J=(0,$.jsxs)(LN,{children:[S,(0,$.jsxs)(zN,{className:`fixed left-1/2 top-1/2 z-[121] flex h-[min(82vh,42rem)] w-[min(100vw-2rem,48rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[I,z,W,ee]})]}),t[90]=I,t[91]=z,t[92]=W,t[93]=ee,t[94]=J):J=t[94];let te;return t[95]!==f||t[96]!==n||t[97]!==J?(te=(0,$.jsx)(FN,{open:n,onOpenChange:f,children:J}),t[95]=f,t[96]=n,t[97]=J,t[98]=te):te=t[98],te}function n_e({sessionKey:e,streaming:t,sending:n}){let r=_(e=>e.language),i=m(r).chat.goal,[a,o]=(0,Z.useState)(()=>e_e(e)),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`overview`),[d,f]=(0,Z.useReducer)($ge,{busy:!1,error:null}),[p,h]=(0,Z.useState)(()=>Date.now()),g=(0,Z.useRef)(t||n),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!1),b=t||n;g.current&&!b&&(y.current=!0),g.current=b;let x=(0,Z.useCallback)(t=>{o(t);try{t?sessionStorage.setItem(q8(e),`1`):sessionStorage.removeItem(q8(e))}catch{}},[e]),{data:S,loading:C,error:w,setData:T}=lP(async()=>(await r8(e,{uiLocale:r})).goal,[e,r],{initial:null,errorData:null}),E=(0,Z.useCallback)(async()=>{try{T((await r8(e,{uiLocale:r})).goal)}catch(e){f({type:`error`,error:e instanceof Error?e.message:i.loadFailed})}},[e,r,T,i.loadFailed]),D=(0,Z.useEffectEvent)(()=>{E()});(0,Z.useEffect)(()=>{if(!S){v.current=null;return}let e=v.current;if(v.current={goalId:S.id,status:S.status},!(!e||e.goalId!==S.id||e.status===S.status)){if(S.status===`done`){re({type:`success`,title:`Goal completed`,message:S.title,duration:0});return}if(S.status===`blocked`){re({type:`warning`,title:`Goal blocked`,message:S.blockedReason||S.title,duration:0});return}S.status===`needs_input`&&re({type:`warning`,title:`Goal needs input`,message:S.blockedReason||S.title,duration:0})}},[S?.id,S?.status,S?.updatedAt,S?.title,S?.blockedReason]),(0,Z.useEffect)(()=>{let t=t=>{t.detail?.key===e&&D()};return window.addEventListener(`session-updated`,t),()=>window.removeEventListener(`session-updated`,t)},[e]),(0,Z.useLayoutEffect)(()=>{y.current&&(y.current=!1,D())});let O=(0,Z.useCallback)(()=>{h(Date.now())},[]),k=async t=>{f({type:`start`});try{await Ume(e,t,{uiLocale:r}),await E(),f({type:`done`})}catch(e){f({type:`error`,error:e instanceof Error?e.message:i.loadFailed})}},A=async t=>{f({type:`start`});try{await Kme(e,t,{uiLocale:r}),await E(),f({type:`done`})}catch(e){f({type:`error`,error:e instanceof Error?e.message:i.loadFailed})}},j=!C||w!=null||S!=null,M=d.error??(w==null?null:w instanceof Error?w.message:i.loadFailed);if(!j||!Nge(S))return null;let N=S,P=t||n,F=`${N.turnsUsed}/${N.maxTurns}`,I=U8(N,i),{total:L,done:R}=V8(N),z=L>0?i.checklistProgress.replace(`{{done}}`,String(R)).replace(`{{total}}`,String(L)):``,B=jge(Age(N,p),r),V=Ige(N,P),H=i.pillTitle.replace(`{{status}}`,I).replace(`{{turns}}`,F),U=N.status!==`done`&&N.status!==`archived`;if(a)return(0,$.jsxs)($.Fragment,{children:[U?(0,$.jsx)(Y8,{onTick:O}):null,(0,$.jsx)(Bge,{goal:N,agentBusy:P,pillTitle:H,phase:V,statusShort:I,turnsShort:F,clLine:z,t:i,onExpand:()=>c(!0)}),(0,$.jsx)(X8,{open:s,sessionKey:e,goal:N,language:r,activeTab:l,canEditChecklist:N.status===`active`||N.status===`paused`,mutationBusy:d.busy,error:M,t:i,onOpenChange:c,onTabChange:u,onAction:k,onChecklist:A})]});let W=N.status===`active`||N.status===`paused`;return(0,$.jsxs)($.Fragment,{children:[U?(0,$.jsx)(Y8,{onTick:O}):null,(0,$.jsx)(t_e,{goal:N,agentBusy:P,phase:V,statusShort:I,turnsShort:F,clLine:z,elapsedStr:B,mutationBusy:d.busy,t:i,onAction:k,onOpenDetails:()=>c(!0),onMinimize:()=>x(!0)}),(0,$.jsx)(X8,{open:s,sessionKey:e,goal:N,language:r,activeTab:l,canEditChecklist:W,mutationBusy:d.busy,error:M,t:i,onOpenChange:c,onTabChange:u,onAction:k,onChecklist:A})]})}function r_e(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(n_e,{...e},e.sessionKey),t[0]=e,t[1]=n),n}function i_e(e,t){let n=V4(e,t),r=H4(e,t);return`${e.id} ${n} ${r}`.toLowerCase()}function a_e(e,t,n){let r=t.trim().toLowerCase();if(!r)return e;let i=r.split(/\s+/).filter(Boolean);return e.filter(e=>{let t=i_e(e,n);return i.every(e=>t.includes(e))})}function o_e(e){let t=(0,Q.c)(56),{items:n,value:r,disabled:i,placeholder:a,searchPlaceholder:o,noMatches:s,compact:c,contentSide:l,contentAlign:d,className:f,onChange:p}=e,h=l===void 0?`bottom`:l,g=d===void 0?`end`:d,v=_(c_e),y;t[0]===v?y=t[1]:(y=m(v),t[0]=v,t[1]=y);let b=y.agentsSettings,[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(``),T;t[2]!==b||t[3]!==n||t[4]!==C?(T=a_e(n,C,b),t[2]=b,t[3]=n,t[4]=C,t[5]=T):T=t[5];let E=T,D,O,k;if(t[6]!==b||t[7]!==n||t[8]!==a||t[9]!==r){let e;t[13]===r?e=t[14]:(e=e=>e.id===r,t[13]=r,t[14]=e),O=n.find(e),D=O?V4(O,b):r||a,k=O?[V4(O,b),H4(O,b)].filter(Boolean).join(` — `):void 0,t[6]=b,t[7]=n,t[8]=a,t[9]=r,t[10]=D,t[11]=O,t[12]=k}else D=t[10],O=t[11],k=t[12];let A=k??a,j=c&&`min-w-0 max-w-[min(calc(15ch+3rem),calc(100vw-8rem))] py-1.5 text-[13px]`,M;t[15]!==f||t[16]!==j?(M=u(cA,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-2 text-left text-sm font-normal text-fg`,lA.transition,`hover:border-edge hover:bg-surface-hover/45`,aA,iA,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,j,f),t[15]=f,t[16]=j,t[17]=M):M=t[17];let N;t[18]!==O?.avatar||t[19]!==r?(N=r?(0,$.jsx)(dz,{agentId:r,avatar:O?.avatar,size:28,className:`shrink-0`}):null,t[18]=O?.avatar,t[19]=r,t[20]=N):N=t[20];let P=c?`max-w-[15ch] shrink`:`flex-1`,F;t[21]===P?F=t[22]:(F=u(`min-w-0 truncate text-left`,P),t[21]=P,t[22]=F);let I;t[23]!==D||t[24]!==F?(I=(0,$.jsx)(`span`,{className:F,children:D}),t[23]=D,t[24]=F,t[25]=I):I=t[25];let L;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(id,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[26]=L):L=t[26];let R;t[27]!==i||t[28]!==I||t[29]!==A||t[30]!==M||t[31]!==N?(R=(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,disabled:i,title:A,className:M,children:[N,I,L]})}),t[27]=i,t[28]=I,t[29]=A,t[30]=M,t[31]=N,t[32]=R):R=t[32];let z;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(z=u(`z-50 w-[var(--radix-popover-trigger-width)] min-w-[12rem] max-h-[min(20rem,calc(100vh-6rem))] overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-md`,lA),t[33]=z):z=t[33];let B;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>w(e.target.value),t[34]=B):B=t[34];let V;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(V=u(`w-full rounded-md border border-edge bg-surface-elevated px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-muted`,aA),t[35]=V):V=t[35];let H;t[36]!==C||t[37]!==o?(H=(0,$.jsx)(`div`,{className:`border-b border-edge p-2`,children:(0,$.jsx)(`input`,{type:`search`,value:C,onChange:B,placeholder:o,className:V,"aria-label":o})}),t[36]=C,t[37]=o,t[38]=H):H=t[38];let U;t[39]!==b||t[40]!==E||t[41]!==s||t[42]!==p||t[43]!==r?(U=E.length===0?(0,$.jsx)(`li`,{className:`p-2 text-sm text-fg-muted`,children:s}):E.map(e=>{let t=e.id===r,n=V4(e,b),i=H4(e,b),a=i.length>0?i:void 0;return(0,$.jsx)(`li`,{role:`option`,"aria-selected":t,children:(0,$.jsxs)(`button`,{type:`button`,className:u(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg`,t?`bg-surface-hover`:`hover:bg-surface-hover`),onClick:()=>{p(e.id),S(!1),w(``)},children:[(0,$.jsx)(Iu,{className:u(`size-4 shrink-0`,t?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,$.jsx)(dz,{agentId:e.id,avatar:e.avatar,size:32,className:`shrink-0`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate font-medium leading-tight`,title:n,children:n}),i?(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs leading-tight text-fg-muted`,title:a,children:i}):null]})]})},e.id)}),t[39]=b,t[40]=E,t[41]=s,t[42]=p,t[43]=r,t[44]=U):U=t[44];let W;t[45]===U?W=t[46]:(W=(0,$.jsx)(`ul`,{className:`max-h-[min(16rem,calc(100vh-10rem))] overflow-y-auto p-1`,role:`listbox`,children:U}),t[45]=U,t[46]=W);let G;t[47]!==g||t[48]!==h||t[49]!==H||t[50]!==W?(G=(0,$.jsx)(lj,{children:(0,$.jsxs)(uj,{side:h,align:g,sideOffset:4,collisionPadding:8,className:z,onOpenAutoFocus:s_e,children:[H,W]})}),t[47]=g,t[48]=h,t[49]=H,t[50]=W,t[51]=G):G=t[51];let K;return t[52]!==x||t[53]!==R||t[54]!==G?(K=(0,$.jsxs)(oj,{open:x,onOpenChange:S,children:[R,G]}),t[52]=x,t[53]=R,t[54]=G,t[55]=K):K=t[55],K}function s_e(e){return e.preventDefault()}function c_e(e){return e.language}var l_e=`(max-width: 767px)`,u_e=(0,Z.memo)(function(e){let t=(0,Q.c)(23),{chatHeadline:n,chatAgents:r,showChatAgentSelector:i,chatAgentId:a,onChatAgentChange:o,chatAgentDisabled:s}=e,c=_(d_e),l;t[0]===c?l=t[1]:(l=m(c),t[0]=c,t[1]=l);let d=l,f=FM(f_e),p=O1(p_e),h=O1(m_e),g=UM(h_e),v=YM(g_e),y=YM(__e),b=e6(l_e),x;t[2]!==g||t[3]!==f?(x=mM({runtime:pM(),sidebarCollapsed:f,mobileNavOpen:g}),t[2]=g,t[3]=f,t[4]=x):x=t[4];let S=b?!g:x.collapsedNewChatVisible,C,w;return t[5]!==s||t[6]!==a||t[7]!==r||t[8]!==n||t[9]!==y||t[10]!==d.chat.agentNoMatches||t[11]!==d.chat.agentPlaceholder||t[12]!==d.chat.agentSearchPlaceholder||t[13]!==d.sidebar.newTask||t[14]!==d.workspace.openFiles||t[15]!==o||t[16]!==v||t[17]!==i||t[18]!==S||t[19]!==h||t[20]!==p?(C=()=>(v({className:`bg-surface-panel`,startExtra:S?(0,$.jsx)(Hi,{to:`/chat/new`,className:u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-panel text-sm font-medium leading-none text-fg transition-colors hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,uM),title:d.sidebar.newTask,children:(0,$.jsx)(Ly,{className:`size-4 shrink-0 text-accent-fg`,strokeWidth:2,"aria-hidden":!0})}):null,main:(0,$.jsx)(`div`,{className:`w-full min-w-0 max-w-(--max-width-chat) px-3 sm:px-5 xl:px-6`,children:(0,$.jsx)(`h1`,{className:u(`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,S?`text-left md:text-center`:`text-left`),title:n,children:n})}),end:(0,$.jsxs)(`div`,{className:u(`flex min-w-0 max-w-[min(32rem,calc(100vw-8rem))] shrink-0 items-center justify-end gap-2`,uM),children:[i?(0,$.jsx)(`div`,{className:`min-w-0 w-fit shrink-0`,children:(0,$.jsx)(o_e,{items:r,value:a,disabled:s,placeholder:d.chat.agentPlaceholder,searchPlaceholder:d.chat.agentSearchPlaceholder,noMatches:d.chat.agentNoMatches,compact:!0,contentSide:`bottom`,contentAlign:`end`,onChange:o})}):null,(0,$.jsx)(`button`,{type:`button`,className:u(`rounded-md p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p&&`bg-surface-hover text-fg`),title:d.workspace.openFiles,"aria-label":d.workspace.openFiles,"aria-pressed":p,onClick:h,children:(0,$.jsx)(__,{className:`size-4`})})]})}),()=>y()),w=[n,r,i,a,o,s,S,d.chat.agentPlaceholder,d.chat.agentSearchPlaceholder,d.chat.agentNoMatches,d.sidebar.newTask,d.workspace.openFiles,p,h,v,y],t[5]=s,t[6]=a,t[7]=r,t[8]=n,t[9]=y,t[10]=d.chat.agentNoMatches,t[11]=d.chat.agentPlaceholder,t[12]=d.chat.agentSearchPlaceholder,t[13]=d.sidebar.newTask,t[14]=d.workspace.openFiles,t[15]=o,t[16]=v,t[17]=i,t[18]=S,t[19]=h,t[20]=p,t[21]=C,t[22]=w):(C=t[21],w=t[22]),(0,Z.useLayoutEffect)(C,w),null});function d_e(e){return e.language}function f_e(e){return e.collapsed}function p_e(e){return e.open}function m_e(e){return e.toggleOpen}function h_e(e){return e.mobileNavOpen}function g_e(e){return e.setPageHeader}function __e(e){return e.clearPageHeader}var v_e=(0,Z.memo)(function(){let e=(0,Q.c)(13),t=_(y_e),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n,i=d3(b_e),a=d3(x_e);if(i===`idle`)return null;if(i===`error`&&a){let t;e[2]===a?t=e[3]:(t=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}),e[2]=a,e[3]=t);let n;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=u(`shrink-0 rounded-xl border border-red-200 bg-white px-2.5 py-1 text-xs font-medium text-red-700`,`hover:bg-red-50 dark:border-red-800 dark:bg-red-950/40 dark:text-red-300 dark:hover:bg-red-950/70`,lA.transition,lA.press,lA.focusRingPanel),e[4]=n):n=e[4];let i;e[5]===r.connection.reconnect?i=e[6]:(i=(0,$.jsx)(`button`,{type:`button`,className:n,onClick:S_e,children:r.connection.reconnect}),e[5]=r.connection.reconnect,e[6]=i);let o;return e[7]!==t||e[8]!==i?(o=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-red-100 bg-red-50 px-4 py-2 text-sm text-red-600 dark:border-red-900/40 dark:bg-red-950/50 dark:text-red-400`,children:[t,i]}),e[7]=t,e[8]=i,e[9]=o):o=e[9],o}if(i===`connecting`||i===`reconnecting`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`span`,{className:`inline-block size-3 animate-spin rounded-full border-2 border-amber-500 border-t-transparent`,"aria-hidden":!0}),e[10]=t):t=e[10];let n=i===`reconnecting`?r.connection.reconnecting:r.connection.connecting,a;return e[11]===n?a=e[12]:(a=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-4 py-2 text-sm text-amber-800 dark:border-amber-900/40 dark:bg-amber-950/50 dark:text-amber-200`,children:[t,(0,$.jsx)(`span`,{children:n})]}),e[11]=n,e[12]=a),a}return null});function y_e(e){return e.language}function b_e(e){return e.connectionState}function x_e(e){return e.error}function S_e(){return pde()}var C_e={folder:__,content:hT,documents:Mh,globe:ov};function w_e(e){let t=(0,Q.c)(2),{name:n}=e,r=C_e[n]??__,i;return t[0]===r?i=t[1]:(i=(0,$.jsx)(r,{className:`size-[1.125rem] text-accent-fg sm:size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=r,t[1]=i),i}var T_e=(0,Z.memo)(function(e){let t=(0,Q.c)(28),{chat:n,onPickPrompt:r}=e,i=n.welcomeSpotlight,a=(0,Z.useId)(),[o,s]=(0,Z.useState)(null),c;t[0]!==i?.categories||t[1]!==o?(c=i?.categories.find(e=>e.id===o),t[0]=i?.categories,t[1]=o,t[2]=c):c=t[2];let l=c;if(!i)return null;let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(Hk,{className:`size-12 shrink-0 sm:size-14`,"aria-hidden":!0}),t[3]=d):d=t[3];let f;t[4]===i.headline?f=t[5]:(f=(0,$.jsx)(`h1`,{className:`text-balance text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:i.headline}),t[4]=i.headline,t[5]=f);let p;t[6]===i.tagline?p=t[7]:(p=(0,$.jsx)(`p`,{className:`max-w-md text-pretty text-sm leading-snug text-fg-muted sm:text-[0.9375rem]`,children:i.tagline}),t[6]=i.tagline,t[7]=p);let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 px-1 pt-8 text-center sm:gap-2 sm:pt-10`,children:[d,f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;if(t[11]!==a||t[12]!==i.categories||t[13]!==o){let e;t[15]!==a||t[16]!==o?(e=e=>{let t=o===e.id;return(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":t?a:void 0,onClick:()=>s(t=>t===e.id?null:e.id),className:u(`flex flex-row items-start gap-2.5 rounded-xl border bg-surface-panel p-2.5 text-left shadow-surface sm:flex-col sm:gap-2`,lA.transition,lA.press,lA.focusRingPanel,t?`border-accent ring-1 ring-accent/25`:`border-edge hover:border-edge-strong hover:bg-surface-hover/40 dark:hover:bg-surface-hover/30`),children:[(0,$.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-accent-soft sm:size-10`,children:(0,$.jsx)(w_e,{name:e.icon})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium leading-snug text-fg sm:text-[0.9375rem]`,children:e.title}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs leading-snug text-fg-muted sm:text-sm`,children:e.description})]})]},e.id)},t[15]=a,t[16]=o,t[17]=e):e=t[17],h=i.categories.map(e),t[11]=a,t[12]=i.categories,t[13]=o,t[14]=h}else h=t[14];let g;t[18]===h?g=t[19]:(g=(0,$.jsx)(`div`,{className:`mt-10 grid w-full grid-cols-1 gap-2 sm:mt-12 sm:grid-cols-2 sm:gap-2.5 lg:grid-cols-4`,children:h}),t[18]=h,t[19]=g);let _;t[20]!==r||t[21]!==a||t[22]!==l?(_=l&&l.scenarios.length>0?(0,$.jsx)(`div`,{id:a,role:`region`,"aria-label":l.title,className:`flex flex-col gap-1.5 rounded-xl border border-edge bg-surface-base/80 p-2.5 dark:bg-surface-hover/20`,children:(0,$.jsx)(`ul`,{className:`flex flex-col gap-1`,children:l.scenarios.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(e.prompt),className:u(`flex w-full gap-2 rounded-lg border border-transparent px-2 py-1.5 text-left text-sm leading-snug text-fg`,lA.transition,lA.press,lA.focusRingPanel,`hover:border-edge hover:bg-surface-panel dark:hover:bg-surface-panel/40`),children:[(0,$.jsx)(Bv,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-pretty`,children:e.prompt})]})},e.prompt))})}):null,t[20]=r,t[21]=a,t[22]=l,t[23]=_):_=t[23];let v;return t[24]!==m||t[25]!==g||t[26]!==_?(v=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3.5 pb-2 sm:gap-4 sm:pb-3`,children:[m,g,_]}),t[24]=m,t[25]=g,t[26]=_,t[27]=v):v=t[27],v});function E_e(e){let t=[];for(let n of e.content??[])(n.type===`thinking`||n.type===`tool_use`)&&t.push(n);return t.length>0?t:[]}function D_e(e,t){switch(e){case`pdf`:return t.attachmentPreviewPdf;case`docx`:return t.attachmentPreviewDocument;case`pptx`:return t.attachmentPreviewPresentation;case`spreadsheet`:return t.attachmentPreviewSpreadsheet;default:return``}}function Z8({open:e,attachment:t,authToken:n,sessionKey:r,layerClassName:i=`z-[81]`,onClose:a}){let o=_(e=>e.language),s=m(o).chat,c=qQ({open:e,attachment:t,authToken:n,sessionKey:r,language:o}),l=RQ(c.descriptor),{rootRef:d,active:f,enter:p,exit:h}=y3(),{preview:g,fileType:v,hasExtractedText:y,showExtractedText:b}=c,x=v!==`image`&&v!==`text`&&v!==`pptx`&&y,S=!!(g&&!c.loading&&!c.loadError),C=()=>{h(),a()},w=()=>{if(!g)return;let e=g.mimeType||`application/octet-stream`,t=null;if(c.binaryBuffer)t=new Blob([c.binaryBuffer],{type:e});else{let n=FI(g);if(!n)return;try{let r=atob(n.replace(/\s/g,``)),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);t=new Blob([i],{type:e})}catch{return}}let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=g.name??`download`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},T=!!(c.binaryBuffer||FI(g??{})),E={onDownload:w,canDownload:T},D=u(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,lA.focusRingBase);return(0,$.jsx)(FN,{open:e,onOpenChange:e=>!e&&C(),children:(0,$.jsx)(LN,{children:(0,$.jsxs)(zN,{className:u(`xopc-dialog-content-fullscreen fixed inset-0 flex h-[100dvh] w-full flex-row overflow-hidden`,i,`border-0 bg-transparent p-0 shadow-none outline-none`),children:[(0,$.jsx)(`button`,{type:`button`,className:D,onClick:C,"aria-label":s.attachmentPreviewClose}),(0,$.jsxs)(`div`,{ref:d,className:u(`flex h-full min-h-0 w-[min(100%,var(--max-width-app-main))] shrink-0 flex-col overflow-hidden`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),children:[(0,$.jsxs)(`div`,{className:u(`flex shrink-0 items-start gap-2 border-b border-edge px-4 py-2 dark:border-edge`,uM),children:[(0,$.jsx)(BN,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,children:g?.name??``}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[x?(0,$.jsxs)(`div`,{className:`mr-2 flex rounded-lg border border-edge p-0.5 dark:border-edge`,role:`group`,"aria-label":s.attachmentPreviewText,children:[(0,$.jsx)(`button`,{type:`button`,className:`rounded-md px-2.5 py-1 text-xs font-medium ${b?`text-fg-muted hover:text-fg`:`bg-surface-hover text-fg`}`,onClick:()=>{c.setShowExtractedText(!1),c.clearLoadError()},children:D_e(v,s)}),(0,$.jsx)(`button`,{type:`button`,className:`rounded-md px-2.5 py-1 text-xs font-medium ${b?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`}`,onClick:()=>{c.setShowExtractedText(!0),c.clearLoadError()},children:s.attachmentPreviewText})]}):null,g?(0,$.jsx)(HQ,{controller:l,actions:E}):null,S?(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,title:f?s.attachmentPreviewExitFullscreen:s.attachmentPreviewFullscreen,"aria-label":f?s.attachmentPreviewExitFullscreen:s.attachmentPreviewFullscreen,onClick:()=>void(f?h():p()),children:f?(0,$.jsx)(Wv,{className:`size-4`}):(0,$.jsx)(Rv,{className:`size-4`})}):null,(0,$.jsx)(HN,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,title:s.attachmentPreviewClose,"aria-label":s.attachmentPreviewClose,children:(0,$.jsx)(Sk,{className:`size-4`})})})]})]}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4 pt-2 sm:px-8`,children:g?(0,$.jsx)(UQ,{language:o,descriptor:c.descriptor,loading:c.loading,loadError:c.loadError,textContent:c.textContent,binaryBuffer:c.binaryBuffer,showExtractedText:c.showExtractedText,extractedText:c.extractedText,extractedTextTruncated:c.extractedTextTruncated,actions:{onDownload:w,canDownload:T},controller:l,renderToolbar:()=>null}):null})]}),(0,$.jsx)(`button`,{type:`button`,className:D,onClick:C,"aria-label":s.attachmentPreviewClose})]})})})}function O_e(e,t){let n=t?.split(`;`)[0]?.trim();return!n?.startsWith(`image/`)||e.type===n?e:new Blob([e],{type:n})}function k_e(e,t){let n=(0,Q.c)(22),r;n[0]!==e.mimeType||n[1]!==e.type?(r=e.type===`image`||e.mimeType?.startsWith(`image/`)===!0,n[0]=e.mimeType,n[1]=e.type,n[2]=r):r=n[2];let i=r,a;n[3]!==e||n[4]!==i?(a=i?FI(e):void 0,n[3]=e,n[4]=i,n[5]=a):a=n[5];let o=a,s;bb0:{if(!o){s=void 0;break bb0}let t=e.mimeType?.startsWith(`image/`)?e.mimeType:`image/png`,r;n[6]!==o||n[7]!==t?(r=zI(t,o),n[6]=o,n[7]=t,n[8]=r):r=n[8],s=r}let c=s,[l,u]=(0,Z.useState)(),d;n[9]!==e.mimeType||n[10]!==e.uri||n[11]!==c||n[12]!==i||n[13]!==t.authToken||n[14]!==t.sessionKey?(d=()=>{if(c||!e.uri||!i){u(void 0);return}if(!String(t.authToken??``).trim()){u(void 0);return}let n,r=!1;return(async()=>{let i=await nJ({uri:e.uri,sessionKey:t.sessionKey});if(!i.ok||r)return;let a=URL.createObjectURL(O_e(i.blob,e.mimeType));n=a,u(a)})(),()=>{r=!0,n&&URL.revokeObjectURL(n)}},n[9]=e.mimeType,n[10]=e.uri,n[11]=c,n[12]=i,n[13]=t.authToken,n[14]=t.sessionKey,n[15]=d):d=n[15];let f;return n[16]!==e.uri||n[17]!==c||n[18]!==i||n[19]!==t.authToken||n[20]!==t.sessionKey?(f=[c,e.uri,i,t.authToken,t.sessionKey],n[16]=e.uri,n[17]=c,n[18]=i,n[19]=t.authToken,n[20]=t.sessionKey,n[21]=f):f=n[21],(0,Z.useEffect)(d,f),c??l??``}function Q8(e){let t=(0,Q.c)(43),{attachment:n,authToken:r,sessionKey:i,showDelete:a,onDelete:o,imageSize:s,compact:c,gridCellFill:l,className:d,overflowLabel:f,onOpen:p}=e,h=a===void 0?!1:a,g=s===void 0?`thumbnail`:s,v=c===void 0?!1:c,y=_(A_e),b;t[0]===y?b=t[1]:(b=m(y),t[0]=y,t[1]=b);let x=b,S=(0,Z.useId)(),C;t[2]!==n.mimeType||t[3]!==n.type?(C=n.mimeType?.startsWith(`image/`)||n.type===`image`,t[2]=n.mimeType,t[3]=n.type,t[4]=C):C=t[4];let w=C,T;t[5]!==r||t[6]!==i?(T={authToken:r,sessionKey:i},t[5]=r,t[6]=i,t[7]=T):T=t[7];let E=k_e(n,T),D=w&&!!E,O;t[8]===n?O=t[9]:(O=!!n.uri&&!FI(n),t[8]=n,t[9]=O);let k=O,A;t[10]!==r||t[11]!==k?(A=k&&!String(r??``).trim(),t[10]=r,t[11]=k,t[12]=A):A=t[12];let j=A,M=n.mimeType===`application/pdf`,N;t[13]!==n.mimeType||t[14]!==n.name?(N=n.mimeType?.includes(`spreadsheetml`)||n.name?.toLowerCase().endsWith(`.xlsx`)||n.name?.toLowerCase().endsWith(`.xls`),t[13]=n.mimeType,t[14]=n.name,t[15]=N):N=t[15];let P=N,F=n.name??`file`,I=j?`${F} — ${x.chat.attachmentPreviewMissingAuth}`:F,L=x.chat.attachmentPreviewMissingAuth,R=g===`single`?v?`max-h-28 w-full max-w-[9rem] object-contain`:`max-h-36 w-full max-w-44 object-contain`:g===`grid-cell`?`size-full object-cover`:`max-h-16 w-full object-cover`,z=g===`single`?v?`max-w-[9rem]`:`max-w-44`:g===`grid-cell`?`min-h-0 w-full`:`max-w-[10rem]`,B=g===`grid-cell`?`relative block aspect-square w-full min-w-0 overflow-hidden rounded-md border border-edge dark:border-edge`:`block w-full overflow-hidden rounded-md border border-edge dark:border-edge`,V=g===`grid-cell`?`w-full min-h-0`:`inline-block`,H;t[16]!==d||t[17]!==V?(H=u(`group relative min-w-0`,V,d),t[16]=d,t[17]=V,t[18]=H):H=t[18];let U;t[19]!==n||t[20]!==F||t[21]!==B||t[22]!==R||t[23]!==z||t[24]!==P||t[25]!==M||t[26]!==I||t[27]!==S||t[28]!==L||t[29]!==p||t[30]!==f||t[31]!==D||t[32]!==j||t[33]!==E?(U=D?(0,$.jsxs)(`div`,{className:z,children:[(0,$.jsxs)(`div`,{className:`relative size-full min-h-0`,children:[(0,$.jsxs)(`button`,{type:`button`,className:u(B,lA.transition,lA.press,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:()=>p(n),title:I,"aria-label":I,"aria-describedby":j?S:void 0,children:[(0,$.jsx)(`img`,{src:E,alt:F,className:R}),f?(0,$.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/55 text-lg font-semibold text-white`,children:f}):null]}),M?(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-1 right-1 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-semibold text-white`,"aria-hidden":!0,children:`PDF`}):null]}),j?(0,$.jsx)(`p`,{id:S,className:`mt-1 line-clamp-2 text-[10px] leading-snug text-amber-600 dark:text-amber-500`,children:L}):null]}):(0,$.jsx)(`div`,{className:`max-w-[14rem]`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>p(n),title:I,"aria-label":I,"aria-describedby":j?S:void 0,className:u(`flex w-full min-w-0 gap-2 rounded-md border border-edge bg-surface-hover px-2 py-1.5 text-left text-xs text-fg-muted hover:bg-surface-active dark:border-edge`,j?`items-start`:`items-center`,lA.transition,lA.press,lA.focusRingPanel),children:[P?(0,$.jsx)(pg,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}):(0,$.jsx)(_g,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-fg`,children:F}),j?(0,$.jsx)(`span`,{id:S,className:`mt-0.5 line-clamp-2 block text-[10px] font-normal leading-snug text-amber-600 dark:text-amber-500`,children:L}):null]})]})}),t[19]=n,t[20]=F,t[21]=B,t[22]=R,t[23]=z,t[24]=P,t[25]=M,t[26]=I,t[27]=S,t[28]=L,t[29]=p,t[30]=f,t[31]=D,t[32]=j,t[33]=E,t[34]=U):U=t[34];let W;t[35]!==x.chat.attachmentPreviewRemove||t[36]!==o||t[37]!==h?(W=h?(0,$.jsx)(`button`,{type:`button`,className:u(`absolute -right-1 -top-1 flex size-5 items-center justify-center rounded-full border border-edge bg-surface-panel text-fg-muted shadow-surface hover:text-fg dark:border-edge`,lA.transition,lA.press,lA.focusRingPanel),onClick:e=>{e.stopPropagation(),o?.()},title:x.chat.attachmentPreviewRemove,"aria-label":x.chat.attachmentPreviewRemove,children:(0,$.jsx)(Sk,{className:`size-3`})}):null,t[35]=x.chat.attachmentPreviewRemove,t[36]=o,t[37]=h,t[38]=W):W=t[38];let G;return t[39]!==H||t[40]!==U||t[41]!==W?(G=(0,$.jsxs)(`div`,{className:H,children:[U,W]}),t[39]=H,t[40]=U,t[41]=W,t[42]=G):G=t[42],G}function A_e(e){return e.language}function j_e(e){return typeof e==`number`&&Number.isFinite(e)&&e>0&&e!==1/0}function $8(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function M_e(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}function N_e({att:e,align:t=`start`,variant:n=`default`,sessionKey:r}){let i=m(_(e=>e.language)),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(),[c,l]=(0,Z.useState)(!1),d=(0,Z.useMemo)(()=>{let t=e.durationSeconds;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:0},[e.durationSeconds]),[f,p]=(0,Z.useState)(d),h=(0,Z.useRef)(d);h.current!==d&&(h.current=d,p(d));let[g,v]=(0,Z.useState)(0),y=(0,Z.useCallback)(()=>{let e=a.current;if(!e)return;let t=e.duration;j_e(t)&&p(t)},[]),b=`${e.uri??``}:${e.content?.length??0}:${e.mimeType??``}`,x=(0,Z.useRef)(b);x.current!==b&&(x.current=b,v(0),l(!1)),(0,Z.useEffect)(()=>{let t,n=!1;return(async()=>{let i=e.content??e.data;if(i){s(`data:${e.mimeType?.includes(`/`)?e.mimeType:`audio/mpeg`};base64,${i.replace(/\s/g,``)}`);return}if(e.uri)try{let i=await Y(X(PI(e.uri,r)));if(!i.ok||n)return;let a=await i.blob(),o=URL.createObjectURL(a);t=o,s(o)}catch{}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e,r]);let S=(0,Z.useCallback)(()=>{let e=a.current;!e||!o||(c?e.pause():e.play().catch(()=>{}))},[c,o]);if(!M_e(e))return null;let C=f>0?Math.min(100,Number.isFinite(f)?g/f*100:0):0,w=typeof f==`number`&&f>0&&Number.isFinite(f),T=!!(o&&!w),E=o?(0,$.jsxs)(`span`,{className:`tabular-nums tracking-tight text-fg-muted`,"aria-live":`polite`,children:[(0,$.jsx)(`span`,{children:$8(g)}),(0,$.jsx)(`span`,{className:`mx-0.5 text-fg-subtle`,children:`/`}),w?(0,$.jsx)(`span`,{children:$8(f)}):(0,$.jsx)(`span`,{className:`text-fg-subtle`,title:i.chat.voiceAwaitingMeta,children:`—`})]}):(0,$.jsx)(`span`,{className:`tabular-nums tracking-tight text-fg-subtle`,children:`— / —`}),D=o?(0,$.jsx)(`audio`,{ref:a,src:o,preload:`metadata`,className:`hidden`,onLoadedMetadata:y,onLoadedData:y,onDurationChange:y,onTimeUpdate:e=>v(e.currentTarget.currentTime),onPlay:()=>l(!0),onPause:()=>l(!1),onEnded:()=>{l(!1),v(0)}}):(0,$.jsx)(`span`,{className:`sr-only`,children:i.chat.voiceLoading}),O=(0,$.jsx)(`button`,{type:`button`,onClick:S,disabled:!o,className:u(`flex size-8 shrink-0 items-center justify-center rounded-full border text-accent-fg`,`border-edge-subtle bg-surface-panel transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`motion-safe:active:scale-[0.97]`,`dark:bg-surface-panel/90 dark:border-edge`,n===`compact`&&u(`border-white/55 bg-white/92 shadow-[inset_0_1px_0_rgb(255_255_255/0.65)]`,`dark:border-white/14 dark:bg-surface-hover/98 dark:shadow-none`),!o&&`opacity-50`),"aria-label":c?i.chat.voicePause:i.chat.voicePlay,title:c?i.chat.voicePause:i.chat.voicePlay,children:c?(0,$.jsx)(ry,{className:`size-[14px]`,strokeWidth:2}):(0,$.jsx)(Py,{className:`size-[14px] ml-px`,strokeWidth:2})}),k=u(`relative h-0.5 min-h-[2px] w-full overflow-hidden rounded-full bg-edge-subtle dark:bg-edge/65`,n===`compact`&&`bg-white/45 dark:bg-white/14`),A=u(`inline-flex min-w-0 items-center rounded-full border`,n===`compact`?`max-w-[min(220px,88vw)] gap-2 px-2 py-1.5 backdrop-blur-[2px]`:`min-w-[min(160px,80vw)] max-w-[17rem] gap-2 px-2 py-1.5`,n===`compact`?`border-white/58 bg-white/86 shadow-none dark:border-white/13 dark:bg-black/[0.22] dark:backdrop-blur-sm`:`border-edge-subtle bg-surface-panel/[0.96] shadow-surface dark:border-edge dark:bg-surface-panel/92`),j=`${i.chat.voiceAriaRegion}${e.name?` · ${e.name}`:``}`;return(0,$.jsx)(`div`,{className:u(`flex min-w-0`,t===`end`&&`justify-end`,t===`center`&&`justify-center`),children:(0,$.jsxs)(`div`,{role:`group`,"aria-label":j,className:A,children:[O,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-1 py-px`,children:[n==="default"?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] leading-snug tracking-tight text-fg-muted`,children:[(0,$.jsx)(Uv,{className:`size-3 shrink-0 opacity-90 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate font-normal`,children:i.chat.voiceMessage})]}):(0,$.jsx)(`span`,{className:`sr-only`,children:i.chat.voiceMessage}),(0,$.jsx)(`div`,{className:k,"aria-hidden":!0,children:o?T?(0,$.jsx)(`span`,{className:u(`absolute inset-y-0 left-[18%] w-[42%] max-w-[4.5rem] rounded-full bg-accent/45 motion-safe:animate-pulse`)}):(0,$.jsx)(`div`,{className:u(`h-full rounded-full bg-accent motion-safe:transition-[width] motion-safe:duration-150 motion-safe:ease-linear`),style:{width:`${C}%`}}):null}),(0,$.jsx)(`div`,{className:u(`flex justify-end text-[10px] leading-snug tracking-tight text-fg-muted`),children:E})]}),D]})})}function e5(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}var t5=9;function P_e(e,t){let n=t?`max-w-[11rem]`:`max-w-52`,r=`gap-1`;return e===1?{container:`grid grid-cols-1 ${n} ${r}`,tileSize:`single`}:e===2?{container:`grid grid-cols-2 ${n} ${r}`,tileSize:`grid-cell`}:e===3?{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`}:e===4?{container:`grid grid-cols-2 ${n} ${r}`,tileSize:`grid-cell`}:e<=t5?{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`}:{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`,overflowCount:e-(t5-1)}}function n5(e){let t=(0,Q.c)(23),{attachments:n,authToken:r,sessionKey:i,layout:a,centerUserVoiceRow:o}=e,s=a===void 0?`assistant`:a,c=o===void 0?!1:o,[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null);if(!n?.length)return null;let m,h,g,_;if(t[0]!==n||t[1]!==r||t[2]!==c||t[3]!==s||t[4]!==i){let e=n.filter(I_e),a=n.filter(e5),o=n.filter(F_e);m=`flex flex-col gap-2`,h=e.length>0?(()=>{let t=P_e(e.length,s===`user`),n=t.overflowCount==null?e:e.slice(0,t5-1);return(0,$.jsxs)(`div`,{className:u(`w-full min-w-0`,t.container),children:[n.map((e,n)=>(0,$.jsx)(Q8,{attachment:e,authToken:r,sessionKey:i,imageSize:t.tileSize,compact:s===`user`,onOpen:e=>{p(e),d(!0)}},e.id??`${e.name}-${n}`)),t.overflowCount==null?null:(0,$.jsx)(Q8,{attachment:e[t5-1],authToken:r,sessionKey:i,imageSize:`grid-cell`,compact:s===`user`,gridCellFill:`square`,overflowLabel:`+${t.overflowCount}`,onOpen:e=>{p(e),d(!0)}},e[t5-1]?.id??`overflow-${t5-1}`)]})})():null,g=a.length>0?(0,$.jsx)(`div`,{className:u(`flex flex-col gap-2`,s===`user`&&(c?`items-center`:`items-end`)),children:a.map((e,t)=>(0,$.jsx)(N_e,{att:e,sessionKey:i,align:s===`user`?c?`center`:`end`:`start`,variant:s===`user`?`compact`:`default`},e.id??`${e.name}-${t}`))}):null,_=o.length>0?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.map((e,t)=>(0,$.jsx)(Q8,{attachment:e,authToken:r,sessionKey:i,onOpen:e=>{p(e),d(!0)}},e.id??`${e.name}-${t}`))}):null,t[0]=n,t[1]=r,t[2]=c,t[3]=s,t[4]=i,t[5]=m,t[6]=h,t[7]=g,t[8]=_}else m=t[5],h=t[6],g=t[7],_=t[8];let v;t[9]!==m||t[10]!==h||t[11]!==g||t[12]!==_?(v=(0,$.jsxs)(`div`,{className:m,children:[h,g,_]}),t[9]=m,t[10]=h,t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{d(!1),p(null)},t[14]=y):y=t[14];let b;t[15]!==f||t[16]!==r||t[17]!==l||t[18]!==i?(b=(0,$.jsx)(Z8,{open:l,attachment:f,authToken:r,sessionKey:i,onClose:y}),t[15]=f,t[16]=r,t[17]=l,t[18]=i,t[19]=b):b=t[19];let x;return t[20]!==v||t[21]!==b?(x=(0,$.jsxs)($.Fragment,{children:[v,b]}),t[20]=v,t[21]=b,t[22]=x):x=t[22],x}function F_e(e){return e.type!==`image`&&!e.mimeType?.startsWith(`image/`)&&!e5(e)}function I_e(e){return e.type===`image`||e.mimeType?.startsWith(`image/`)}function L_e(e){let t=[];for(let n of e)if(!(!n.name.toLowerCase().includes(`search`)||n.result==null))try{let e=typeof n.result==`string`?JSON.parse(n.result):n.result,r=Array.isArray(e)?e:e?.results??[];for(let e of r)e.url&&t.push({url:e.url,title:e.title??e.url,snippet:e.snippet})}catch{}return t}function R_e(e){let t=(0,Q.c)(16),{blocks:n}=e,r=_(V_e),i,a,o,s,c;if(t[0]!==n||t[1]!==r){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=m(r),l=L_e(n.filter(B_e));if(l.length===0){c=null;break bb0}o=`mt-6`;let u=e.chat.searchSourcesHeading.replace(`{{count}}`,String(l.length));t[7]===u?s=t[8]:(s=(0,$.jsx)(`p`,{className:`mb-3 text-xs font-medium text-fg-muted`,children:u}),t[7]=u,t[8]=s),i=`space-y-3`,a=l.map(z_e)}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[9]!==i||t[10]!==a?(l=(0,$.jsx)(`ol`,{className:i,children:a}),t[9]=i,t[10]=a,t[11]=l):l=t[11];let u;return t[12]!==o||t[13]!==s||t[14]!==l?(u=(0,$.jsxs)(`div`,{className:o,children:[s,l]}),t[12]=o,t[13]=s,t[14]=l,t[15]=u):u=t[15],u}function z_e(e,t){let n=(()=>{try{return new URL(e.url).hostname}catch{return``}})(),r=n?`https://www.google.com/s2/favicons?domain=${n}&sz=16`:void 0;return(0,$.jsxs)(`li`,{className:`flex min-w-0 gap-2.5`,children:[(0,$.jsxs)(`span`,{className:`mt-0.5 shrink-0 text-xs text-fg-disabled`,children:[t+1,`.`]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-1.5`,children:[r?(0,$.jsx)(`img`,{src:r,alt:``,className:`mt-0.5 size-3.5 shrink-0 rounded-sm`,"aria-hidden":!0}):null,(0,$.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 break-words text-xs font-medium text-accent-fg [overflow-wrap:anywhere] hover:underline`,children:e.title})]}),e.snippet?(0,$.jsx)(`p`,{className:`mt-0.5 line-clamp-4 text-xs break-words text-fg-muted [overflow-wrap:anywhere]`,children:e.snippet}):null]})]},e.url)}function B_e(e){return e.type===`tool_use`}function V_e(e){return e.language}var H_e=String.raw`png|jpe?g|gif|webp|bmp|svg|pdf|docx?|xlsx?|pptx?|txt|md|json|html?|css|mjs?|cjs|js|ts|mp3|wav|ogg|m4a|mp4|mov|webm`;function r5(){return`(?:${H_e})`}var U_e=RegExp(`(/[^\\s"'"<>|*?\\n]+?\\.(?:${r5()}))`,`gi`),W_e=RegExp(`([A-Za-z]:[\\\\/][^"'\`<>*?\\n|=]+?\\.(?:${r5()}))`,`gi`),G_e={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`,svg:`image/svg+xml`,pdf:`application/pdf`,doc:`application/msword`,docx:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,xls:`application/vnd.ms-excel`,xlsx:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,ppt:`application/vnd.ms-powerpoint`,pptx:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,txt:`text/plain`,md:`text/markdown`,json:`application/json`,html:`text/html`,htm:`text/html`,css:`text/css`,mjs:`text/javascript`,cjs:`text/javascript`,js:`text/javascript`,ts:`text/typescript`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,m4a:`audio/mp4`,mp4:`video/mp4`,mov:`video/quicktime`,webm:`video/webm`};function i5(e){let t=e.lastIndexOf(`.`);return t<0?`application/octet-stream`:G_e[e.slice(t+1).toLowerCase()]??`application/octet-stream`}function a5(e){return e.startsWith(`image/`)}function o5(e){let t=e.trim();if(t.length<4||t.startsWith(`//`)&&!t.startsWith(`//Users`)||t.startsWith(`http:`)||t.startsWith(`https:`)||t.startsWith(`data:`)||t.startsWith(`file://`))return!1;if(t.startsWith(`/`))return/^\/(?:Users|usr|var|opt|tmp|home|root|System|private|dev|media|mnt|Volumes|data)(?:\/|[\s]|$)/i.test(t);if(/^[A-Za-z]:[\\/]/.test(t)){let e=t.replace(/\\/g,`/`);return!/^[A-Za-z]:\/{2,}/.test(e)}return!!t.startsWith(`\\\\`)}function s5(e){let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);return t[t.length-1]||e}function c5(e){let t=e.trim();return t.includes(`
226
+ `);return}let r=typeof KeyboardEvent<`u`&&e.nativeEvent instanceof KeyboardEvent&&e.nativeEvent.isComposing;if(e.key===`Enter`&&!e.shiftKey&&!t.isComposing&&!r){e.preventDefault();let n=!!(t.valueRef.current.trim()||t.attachmentsLen>0);if(t.runBusy||t.pendingFollowUpsCount>0){if((e.metaKey||e.ctrlKey)&&n){t.interruptDraft?.();return}if(!e.metaKey&&!e.ctrlKey&&!e.altKey&&n){t.flushSteeringDraft?.();return}return}n&&t.send()}},t[14]=n,t[15]=l,t[16]=y):y=t[16];let b;return t[17]!==n||t[18]!==i||t[19]!==p||t[20]!==h||t[21]!==g||t[22]!==_||t[23]!==v||t[24]!==y?(b=(0,$.jsx)(`div`,{ref:n,role:`textbox`,"aria-multiline":`true`,"aria-label":i,contentEditable:p,suppressContentEditableWarning:!0,spellCheck:!0,className:m,"data-placeholder":i,onInput:h,onCompositionStart:g,onCompositionEnd:_,onPaste:v,onKeyDown:y}),t[17]=n,t[18]=i,t[19]=p,t[20]=h,t[21]=g,t[22]=_,t[23]=v,t[24]=y,t[25]=b):b=t[25],b}),ome=(0,Z.memo)(function(e){let t=(0,Q.c)(55),{items:n,disabled:r,editingFollowUpId:i,onEditInComposer:a,onRemove:o,onMove:s,onReorder:c,onSteer:l,steeringBusyId:d}=e,f=_(sme),p;t[0]===f?p=t[1]:(p=m(f),t[0]=f,t[1]=p);let h=p,g=cme,v;t[2]===c?v=t[3]:(v=e=>t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`);if(!n.startsWith(`xopc-followup:`))return;let r=Number.parseInt(n.slice(14),10);Number.isNaN(r)||r===e||c(r,e)},t[2]=c,t[3]=v);let y=v;if(n.length===0)return null;let b=h.chat.followUpQueueAria,x;t[4]===h.chat.followUpQueueHeading?x=t[5]:(x=(0,$.jsx)(`span`,{className:`text-[0.65rem] font-medium uppercase tracking-wide text-fg-muted`,children:h.chat.followUpQueueHeading}),t[4]=h.chat.followUpQueueHeading,t[5]=x);let S;t[6]===n.length?S=t[7]:(S=(0,$.jsxs)(`span`,{className:`tabular-nums text-[0.65rem] text-fg-muted`,children:[n.length,`/`,10]}),t[6]=n.length,t[7]=S);let C;t[8]!==x||t[9]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1 pb-0.5`,children:[x,S]}),t[8]=x,t[9]=S,t[10]=C):C=t[10];let w;if(t[11]!==r||t[12]!==i||t[13]!==n||t[14]!==h.chat.followUpQueueAttachmentOnly||t[15]!==h.chat.followUpQueueClickToEdit||t[16]!==h.chat.followUpQueueDrag||t[17]!==h.chat.followUpQueueEmptyPreview||t[18]!==h.chat.followUpQueueMoveDown||t[19]!==h.chat.followUpQueueMoveUp||t[20]!==h.chat.followUpQueueRemove||t[21]!==h.chat.followUpQueueSteerNow||t[22]!==y||t[23]!==a||t[24]!==s||t[25]!==o||t[26]!==l||t[27]!==d){let e;t[29]!==r||t[30]!==i||t[31]!==n.length||t[32]!==h.chat.followUpQueueAttachmentOnly||t[33]!==h.chat.followUpQueueClickToEdit||t[34]!==h.chat.followUpQueueDrag||t[35]!==h.chat.followUpQueueEmptyPreview||t[36]!==h.chat.followUpQueueMoveDown||t[37]!==h.chat.followUpQueueMoveUp||t[38]!==h.chat.followUpQueueRemove||t[39]!==h.chat.followUpQueueSteerNow||t[40]!==y||t[41]!==a||t[42]!==s||t[43]!==o||t[44]!==l||t[45]!==d?(e=(e,t)=>{let c=!e.attachments?.length&&e.text.trim().length>0,f=d===e.id,p=e.text.trim();return!p&&e.attachments?.length&&(p=e.attachments[0]?.name?.trim()||h.chat.followUpQueueAttachmentOnly),p||=h.chat.followUpQueueEmptyPreview,(0,$.jsxs)(`div`,{role:`listitem`,onDragOver:g,onDrop:r?void 0:y(t),className:u(`flex h-7 items-center gap-1 rounded border px-1`,i===e.id?`border-accent/50 bg-accent-soft/20 dark:border-accent/50 dark:bg-accent-soft/10`:`border-edge-subtle/80 bg-surface-hover/25 dark:border-edge-subtle/90 dark:bg-surface-hover/15`),children:[(0,$.jsx)(`div`,{draggable:!r,onDragStart:e=>{e.dataTransfer.setData(`text/plain`,`xopc-followup:${t}`),e.dataTransfer.effectAllowed=`move`},className:u(`flex shrink-0 cursor-grab items-center active:cursor-grabbing`,r&&`cursor-not-allowed opacity-40`),title:h.chat.followUpQueueDrag,children:(0,$.jsx)(sv,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,disabled:r,title:h.chat.followUpQueueClickToEdit,"aria-label":h.chat.followUpQueueClickToEdit,className:u(`h-6 min-w-0 flex-1 truncate rounded px-1.5 text-left text-[0.75rem] leading-none text-fg hover:bg-surface-panel/60 dark:hover:bg-surface-panel/40`,lA.press,lA.focusRingPanel,`disabled:pointer-events-none disabled:opacity-50`),onClick:()=>a(e.id),children:e.attachments?.length?(0,$.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,$.jsx)(Eg,{className:`size-3 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:p})]}):(0,$.jsx)(`span`,{className:`block truncate`,children:p})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-px`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:r||t===0,className:u(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,lA.press,lA.focusRingPanel,`disabled:pointer-events-none disabled:opacity-25`),title:h.chat.followUpQueueMoveUp,"aria-label":h.chat.followUpQueueMoveUp,onClick:t=>{t.stopPropagation(),s(e.id,`up`)},children:(0,$.jsx)(Xu,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,disabled:r||t>=n.length-1,className:u(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,lA.press,lA.focusRingPanel,`disabled:pointer-events-none disabled:opacity-25`),title:h.chat.followUpQueueMoveDown,"aria-label":h.chat.followUpQueueMoveDown,onClick:t=>{t.stopPropagation(),s(e.id,`down`)},children:(0,$.jsx)(Gu,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,disabled:r||!c||f,className:u(`inline-flex size-6 items-center justify-center rounded text-accent-fg hover:bg-accent-soft/80`,lA.press,lA.focusRingPanel,`disabled:pointer-events-none disabled:opacity-35`),title:h.chat.followUpQueueSteerNow,"aria-label":h.chat.followUpQueueSteerNow,onClick:t=>{t.stopPropagation(),l(e.id)},children:(0,$.jsx)(SC,{className:u(`size-3.5`,f&&`animate-pulse`),"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,disabled:r,className:u(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-red-500/15 hover:text-red-600 dark:hover:text-red-400`,lA.press,lA.focusRingPanel),title:h.chat.followUpQueueRemove,"aria-label":h.chat.followUpQueueRemove,onClick:t=>{t.stopPropagation(),o(e.id)},children:(0,$.jsx)(Sk,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id)},t[29]=r,t[30]=i,t[31]=n.length,t[32]=h.chat.followUpQueueAttachmentOnly,t[33]=h.chat.followUpQueueClickToEdit,t[34]=h.chat.followUpQueueDrag,t[35]=h.chat.followUpQueueEmptyPreview,t[36]=h.chat.followUpQueueMoveDown,t[37]=h.chat.followUpQueueMoveUp,t[38]=h.chat.followUpQueueRemove,t[39]=h.chat.followUpQueueSteerNow,t[40]=y,t[41]=a,t[42]=s,t[43]=o,t[44]=l,t[45]=d,t[46]=e):e=t[46],w=n.map(e),t[11]=r,t[12]=i,t[13]=n,t[14]=h.chat.followUpQueueAttachmentOnly,t[15]=h.chat.followUpQueueClickToEdit,t[16]=h.chat.followUpQueueDrag,t[17]=h.chat.followUpQueueEmptyPreview,t[18]=h.chat.followUpQueueMoveDown,t[19]=h.chat.followUpQueueMoveUp,t[20]=h.chat.followUpQueueRemove,t[21]=h.chat.followUpQueueSteerNow,t[22]=y,t[23]=a,t[24]=s,t[25]=o,t[26]=l,t[27]=d,t[28]=w}else w=t[28];let T;t[47]!==n||t[48]!==h.chat.followUpQueueAttachmentsNote?(T=n.some(lme)?(0,$.jsx)(`p`,{className:`px-1 pt-0.5 text-[0.65rem] leading-tight text-fg-muted`,children:h.chat.followUpQueueAttachmentsNote}):null,t[47]=n,t[48]=h.chat.followUpQueueAttachmentsNote,t[49]=T):T=t[49];let E;return t[50]!==h.chat.followUpQueueAria||t[51]!==C||t[52]!==w||t[53]!==T?(E=(0,$.jsxs)(`div`,{className:`space-y-0.5 px-2 py-1.5`,role:`list`,"aria-label":b,children:[C,w,T]}),t[50]=h.chat.followUpQueueAria,t[51]=C,t[52]=w,t[53]=T,t[54]=E):E=t[54],E});function sme(e){return e.language}function cme(e){e.preventDefault(),e.dataTransfer.dropEffect=`move`}function lme(e){return e.attachments?.length}function j6(e){let t=(0,Q.c)(10),{attachments:n,topPadded:r,onRemove:i}=e;if(n.length===0)return null;let a=r?`pt-2`:`pt-3`,o;t[0]===a?o=t[1]:(o=u(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,a),t[0]=a,t[1]=o);let s;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=(e,t)=>(0,$.jsxs)(`div`,{className:`flex max-w-[200px] items-center gap-1.5 rounded-lg bg-surface-hover px-2 py-1 text-xs dark:bg-surface-hover/80`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,$.jsx)(Uv,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,$.jsx)(Eg,{className:`size-3.5 shrink-0 text-fg-muted`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:HI(e.size)}),(0,$.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,onClick:()=>i(t),children:`×`})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`),t[5]=i,t[6]=e),s=n.map(e),t[2]=n,t[3]=i,t[4]=s}else s=t[4];let c;return t[7]!==o||t[8]!==s?(c=(0,$.jsx)(`div`,{className:o,children:s}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}var ume=4;function M6(e){return!Number.isFinite(e)||e<=0?0:Math.ceil(e/ume)}function dme(e){return e.inputTokens!=null||e.outputTokens!=null?(e.inputTokens??0)+(e.outputTokens??0):e.totalTokens==null?null:e.totalTokens}function N6(e){let t=0;for(let n of e.content)n.type===`text`||n.type===`thinking`?t+=n.text.length:n.type===`tool_use`&&(t+=JSON.stringify(n.input??``).length,n.result!=null&&(t+=typeof n.result==`string`?n.result.length:JSON.stringify(n.result).length));if(e.attachments?.length)for(let n of e.attachments)t+=(n.extractedText?.length??0)+(n.name?.length??0);return M6(t)}function fme(e,t=0){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.role!==`assistant`||!r.usage)continue;let i=dme(r.usage);if(i==null||i<=0)continue;let a=0;for(let t=n+1;t<e.length;t++)a+=N6(e[t]);return i+a+M6(t)}let n=0;for(let t of e)n+=N6(t);return n+M6(t)}function P6(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var F6=7,I6=2.25,L6=2*Math.PI*F6;function R6(e){if(!Number.isFinite(e)||e<0)return`0`;if(e>=1e6){let t=e/1e6;return`${t>=10?Math.round(t):t.toFixed(1)}M`.replace(/\.0M$/,`M`)}if(e>=1e4)return`${Math.round(e/1e3)}k`;if(e>=1e3){let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`.replace(/\.0k$/,`k`)}return String(Math.round(e))}function pme(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0)return`0`;let n=Math.min(100,Math.max(0,100*e/t));return n>=10||n===0?String(Math.round(n)):n.toFixed(1).replace(/\.0$/,``)}var mme=(0,Z.memo)(function(e){let t=(0,Q.c)(35),{sessionModel:n,messages:r,draftChars:i,chat:a,disabled:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[0]=s):s=t[0];let{data:c}=ie(E3,O3,s),l;t[1]===c?l=t[2]:(l=c===void 0?[]:c,t[1]=c,t[2]=l);let d=l,f;t[3]!==d||t[4]!==n?(f=d.find(e=>e.id===n)?.contextWindow,t[3]=d,t[4]=n,t[5]=f):f=t[5];let p=f,m=fme(r,i),h=(p!=null&&p>0?Math.min(1,Math.max(0,m/p)):0)*L6,g;bb0:{if(p!=null&&p>0){let e;t[6]!==a.contextWindowAriaSummary||t[7]!==p||t[8]!==m?(e=P6(a.contextWindowAriaSummary,{used:R6(m),limit:R6(p)}),t[6]=a.contextWindowAriaSummary,t[7]=p,t[8]=m,t[9]=e):e=t[9],g=e;break bb0}let e;t[10]!==a.contextWindowAriaSummaryNoLimit||t[11]!==m?(e=P6(a.contextWindowAriaSummaryNoLimit,{used:R6(m)}),t[10]=a.contextWindowAriaSummaryNoLimit,t[11]=m,t[12]=e):e=t[12],g=e}let _=g,v;bb1:{if(p!=null&&p>0){let e;t[13]!==a.contextWindowHoverShort||t[14]!==p||t[15]!==m?(e=P6(a.contextWindowHoverShort,{percent:pme(m,p)}),t[13]=a.contextWindowHoverShort,t[14]=p,t[15]=m,t[16]=e):e=t[16],v=e;break bb1}let e;t[17]!==a.contextWindowHoverNoLimit||t[18]!==m?(e=P6(a.contextWindowHoverNoLimit,{used:R6(m)}),t[17]=a.contextWindowHoverNoLimit,t[18]=m,t[19]=e):e=t[19],v=e}let y=v,b=o||void 0,x=o&&`cursor-default opacity-40`,S;t[20]===x?S=t[21]:(S=u(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle`,`hover:bg-surface-hover hover:text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,x),t[20]=x,t[21]=S);let C;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:F6,fill:`none`,stroke:`currentColor`,className:`text-fg-subtle opacity-[0.35]`,strokeWidth:I6}),t[22]=C):C=t[22];let w=`${h} ${L6}`,T;t[23]===w?T=t[24]:(T=(0,$.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 18 18`,className:`shrink-0`,"aria-hidden":!0,children:[C,(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:F6,fill:`none`,stroke:`currentColor`,className:`text-fg-muted`,strokeWidth:I6,strokeLinecap:`round`,strokeDasharray:w,transform:`rotate(-90 9 9)`})]}),t[23]=w,t[24]=T);let E;t[25]!==_||t[26]!==T||t[27]!==b||t[28]!==S?(E=(0,$.jsx)(V$,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-disabled":b,"aria-label":_,className:S,children:T})}),t[25]=_,t[26]=T,t[27]=b,t[28]=S,t[29]=E):E=t[29];let D;t[30]===y?D=t[31]:(D=(0,$.jsx)(H$,{children:(0,$.jsx)(U$,{side:`top`,sideOffset:6,collisionPadding:12,className:`!z-[10000] whitespace-nowrap rounded-lg border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg shadow-md`,children:y})}),t[30]=y,t[31]=D);let O;return t[32]!==E||t[33]!==D?(O=(0,$.jsx)(z$,{delayDuration:280,children:(0,$.jsxs)(B$,{children:[E,D]})}),t[32]=E,t[33]=D,t[34]=O):O=t[34],O});function hme(e){switch(e){case`modal`:return vj;case`page`:return _j;default:return`z-50`}}function gme(e){return`${e.id} ${e.name} ${e.provider}`.toLowerCase()}function _me(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=n.split(/\s+/).filter(Boolean);return e.filter(e=>{let t=gme(e);return r.every(e=>t.includes(e))})}function vme(e,t,n){if(t!==`vision`)return e;let r=e.filter(e=>e.vision===!0);if(!n||r.some(e=>e.id===n))return r;let i=e.find(e=>e.id===n);if(i)return[i,...r];let a=n.indexOf(`/`),o=a>=0?n.slice(0,a):``;return[{id:n,name:(a>=0?n.slice(a+1):n)||n,provider:o||`—`,vision:!1},...r]}function z6(e){let t=(0,Q.c)(85),{value:n,disabled:r,placeholder:i,searchPlaceholder:a,noMatches:o,capabilitiesFilter:s,outOfFilterNote:c,registryEmptyHint:l,compact:d,showProviderInTrigger:f,contentSide:p,contentAlign:h,className:g,popoverContentClassName:v,showProviderSettingsFooter:y,onChange:b}=e,x=f===void 0?!0:f,S=p===void 0?`bottom`:p,C=h===void 0?`end`:h,w=br(),T=_(bme),E;t[0]===T?E=t[1]:(E=m(T),t[0]=T,t[1]=E);let D=E.chat,[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(``),M=Sj(),N=Cj(),P=hme(M),F;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(F={revalidateOnFocus:!1},t[2]=F):F=t[2];let{data:I,isLoading:L,error:R}=ie(E3,O3,F),z;t[3]===I?z=t[4]:(z=I===void 0?[]:I,t[3]=I,t[4]=z);let B=z,V;t[5]===n?V=t[6]:(V=n.trim(),t[5]=n,t[6]=V);let H=V,U;t[7]!==s||t[8]!==B||t[9]!==H?(U=vme(B,s,H),t[7]=s,t[8]=B,t[9]=H,t[10]=U):U=t[10];let W=U,G;t[11]!==W||t[12]!==A?(G=_me(W,A),t[11]=W,t[12]=A,t[13]=G):G=t[13];let K=G,q;t[14]!==B||t[15]!==W||t[16]!==n?(q=B.find(e=>e.id===n)??W.find(e=>e.id===n),t[14]=B,t[15]=W,t[16]=n,t[17]=q):q=t[17];let ee=q,J=ee?x?`${ee.name} (${ee.provider})`:ee.name:n||i,te=!R&&s===`vision`&&W.length===0,Y=NA,ne=r||L,re=ee?`${ee.name} (${ee.provider})`:i,X=d&&`py-1.5 text-[13px]`,ae;t[18]!==g||t[19]!==X?(ae=u(cA,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-left text-sm font-normal text-fg`,lA.transition,`hover:border-edge hover:bg-surface-hover/45`,iA,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,X,g),t[18]=g,t[19]=X,t[20]=ae):ae=t[20];let oe=L?`…`:J,se;t[21]===oe?se=t[22]:(se=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:oe}),t[21]=oe,t[22]=se);let ce;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(id,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[23]=ce):ce=t[23];let le;t[24]!==ne||t[25]!==re||t[26]!==ae||t[27]!==se?(le=(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,disabled:ne,title:re,className:ae,children:[se,ce]})}),t[24]=ne,t[25]=re,t[26]=ae,t[27]=se,t[28]=le):le=t[28];let ue=NA,de=N??void 0,fe=NA,pe=u(P,`w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,v),me;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(me=u(`mb-1 w-full rounded-lg border border-edge-subtle bg-surface-base px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-disabled dark:bg-surface-hover/40`,aA),t[29]=me):me=t[29];let he;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(he=e=>j(e.target.value),t[30]=he):he=t[30];let ge;t[31]!==A||t[32]!==a?(ge=(0,$.jsx)(`input`,{type:`search`,className:me,placeholder:a,value:A,onChange:he}),t[31]=A,t[32]=a,t[33]=ge):ge=t[33];let _e;t[34]===R?_e=t[35]:(_e=R?(0,$.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:R instanceof Error?R.message:`Failed to load models`}):null,t[34]=R,t[35]=_e);let ve;t[36]!==R||t[37]!==o||t[38]!==l||t[39]!==te?(ve=!R&&te?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:l??o}):null,t[36]=R,t[37]=o,t[38]=l,t[39]=te,t[40]=ve):ve=t[40];let ye;t[41]!==R||t[42]!==K.length||t[43]!==o||t[44]!==te?(ye=!R&&!te&&K.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:o}):null,t[41]=R,t[42]=K.length,t[43]=o,t[44]=te,t[45]=ye):ye=t[45];let be;if(t[46]!==s||t[47]!==K||t[48]!==b||t[49]!==c||t[50]!==n||t[51]!==H){let e;t[53]!==s||t[54]!==b||t[55]!==c||t[56]!==n||t[57]!==H?(e=e=>{let t=!!c&&s===`vision`&&e.vision!==!0&&e.id===H;return(0,$.jsxs)(`button`,{type:`button`,className:u(`flex w-full flex-col gap-0.5 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,e.id===n&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{b(e.id),k(!1),j(``)},children:[(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-center gap-2`,children:[(0,$.jsx)(Iu,{className:u(`size-4 shrink-0`,e.id!==n&&`invisible`),"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),` `,(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[`(`,e.provider,`)`]})]})]}),t?(0,$.jsx)(`span`,{className:`pl-6 text-[11px] leading-snug text-amber-700 dark:text-amber-300`,children:c}):null]},e.id)},t[53]=s,t[54]=b,t[55]=c,t[56]=n,t[57]=H,t[58]=e):e=t[58],be=K.map(e),t[46]=s,t[47]=K,t[48]=b,t[49]=c,t[50]=n,t[51]=H,t[52]=be}else be=t[52];let xe;t[59]!==_e||t[60]!==ve||t[61]!==ye||t[62]!==be?(xe=(0,$.jsxs)(`div`,{className:`max-h-60 overflow-auto`,children:[_e,ve,ye,be]}),t[59]=_e,t[60]=ve,t[61]=ye,t[62]=be,t[63]=xe):xe=t[63];let Se;t[64]!==D||t[65]!==w||t[66]!==y?(Se=y?(0,$.jsx)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:(0,$.jsxs)(`button`,{type:`button`,className:u(`flex w-full items-center gap-2 rounded-md p-2 text-left text-sm font-medium text-accent`,lA.transition,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{w(`/settings/credentials`),k(!1),j(``)},children:[(0,$.jsx)(lS,{className:`size-4 shrink-0 opacity-90`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0`,children:D.modelProviderSettingsLink})]})}):null,t[64]=D,t[65]=w,t[66]=y,t[67]=Se):Se=t[67];let Ce;t[68]!==C||t[69]!==S||t[70]!==fe.Content||t[71]!==pe||t[72]!==ge||t[73]!==xe||t[74]!==Se?(Ce=(0,$.jsxs)(fe.Content,{className:pe,side:S,sideOffset:4,align:C,onOpenAutoFocus:yme,children:[ge,xe,Se]}),t[68]=C,t[69]=S,t[70]=fe.Content,t[71]=pe,t[72]=ge,t[73]=xe,t[74]=Se,t[75]=Ce):Ce=t[75];let we;t[76]!==ue.Portal||t[77]!==de||t[78]!==Ce?(we=(0,$.jsx)(ue.Portal,{container:de,children:Ce}),t[76]=ue.Portal,t[77]=de,t[78]=Ce,t[79]=we):we=t[79];let Te;return t[80]!==O||t[81]!==Y.Root||t[82]!==le||t[83]!==we?(Te=(0,$.jsxs)(Y.Root,{open:O,onOpenChange:k,children:[le,we]}),t[80]=O,t[81]=Y.Root,t[82]=le,t[83]=we,t[84]=Te):Te=t[84],Te}function yme(e){return e.preventDefault()}function bme(e){return e.language}async function B6(e){let t=String(e??``).trim();if(!t)return{active:!1};let n=await Y(X(_K(t)));if(!n.ok)return{active:!1};try{return pK(await n.json())}catch{return{active:!1}}}async function xme(e){let t=String(e??``).trim();if(!t)return null;try{let e=await B6(t);if(e.active&&e.runId)return LL(t,e.runId),e.runId}catch{}if(!IL(t))return null;try{let e=sessionStorage.getItem(FL(t));if(!e)return null;let n=JSON.parse(e);return(typeof n.runId==`string`?n.runId.trim():``)||null}catch{return null}}var Sme=3e4,V6=null;function Cme(e){V6={sessions:[...e],fetchedAt:Date.now()}}function wme(e){let t=e.key.trim();if(!t)return;let n=new Date().toISOString();V6={sessions:[{...e,key:t,messageCount:e.messageCount??0,updatedAt:e.updatedAt??n},...(V6?.sessions??[]).filter(e=>e.key.trim()!==t)],fetchedAt:Date.now()}}function Tme(){return V6?Date.now()-V6.fetchedAt>Sme?(V6=null,null):V6.sessions:null}var Eme=`webchat`,H6=new Map,U6=new Map,W6=50,Dme=500,G6=new Map;function Ome(e){let t=e.trim().split(`:`);if(t.length<6)return null;let[n,r,i,a,o,...s]=t,c=s.join(`:`).trim();return n!==`agent`||!r?.trim()||i!==`webchat`||a!=="default"||o!==`direct`||!c?null:{agentId:r.trim().toLowerCase(),channel:i,chatId:c}}async function K6(e){let t=await e.json().catch(()=>({}));return typeof t.error==`string`?t.error:t.error?.message??`HTTP ${e.status}`}var kme=class{async loadSessions(){let e=[],t=0;for(let n=0;n<100;n++){let n=await CK({channel:Eme,limit:100,offset:t});for(let t of n.items)e.push({key:t.key,sessionId:t.sessionId,name:t.name,updatedAt:t.updatedAt,messageCount:t.messageCount,sourceChannel:t.sourceChannel,sourceChatId:t.sourceChatId,projectId:t.projectId,customData:t.customData,routing:t.routing});if(!n.hasMore)break;t+=100}let n=e.sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime());return Cme(n),n}async loadSessionAgentConfig(e){let t=H6.get(e);if(t)return t;let n=(async()=>{let t=await Y(X(`/api/sessions/${encodeURIComponent(e)}/agent-config`));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();return{thinkingLevel:n.payload?.thinkingLevel??`medium`,model:typeof n.payload?.model==`string`?n.payload.model:``,reasoningLevel:n.payload?.reasoningLevel??`stream`,effectiveWorkspacePath:typeof n.payload?.effectiveWorkspacePath==`string`?n.payload.effectiveWorkspacePath:``,workingDirectoryLocked:!!n.payload?.workingDirectoryLocked}})().finally(()=>{H6.delete(e)});return H6.set(e,n),n}async patchSessionAgentConfig(e,t){let n=await Y(X(`/api/sessions/${encodeURIComponent(e)}/agent-config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}}fetchSessionActiveRun(e){return B6(e)}async loadSession(e,t=0,n){let r=`${e}\0${t}\0${n??``}`,i=U6.get(r);if(i)return i;let a=(async()=>{let r=async(t,n)=>{let r=await ue(X(gK(e,{limit:W6,before:n,offset:n?void 0:t})));if(!r.ok)throw Error(`HTTP ${r.status}: ${r.statusText}`);return await r.json()},i=await r(t,n),a=i.session?.messages||[],o=lL(a),s=i.pagination?.hasMore??a.length>=W6,c=i.pagination?.nextBeforeCursor,l=typeof i.session?.name==`string`&&i.session.name.trim()?i.session.name.trim():void 0;for(;t===0&&!n&&s&&c&&a.length<Dme&&o[0]?.role===`assistant`;){i=await r(0,c);let e=i.session?.messages||[];if(e.length===0)break;a=[...e,...a],o=lL(a),s=i.pagination?.hasMore??e.length>=W6,c=i.pagination?.nextBeforeCursor}return{messages:o,hasMore:s,name:l,nextBeforeCursor:c}})().finally(()=>{U6.delete(r)});return U6.set(r,a),a}async loadTimeline(e){let t=G6.get(e);if(t)return t;let n=(async()=>{let t=await ue(X(`/api/sessions/${encodeURIComponent(e)}/timeline`));if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.json();return Array.isArray(n.items)?n.items:[]})().finally(()=>{G6.delete(e)});return G6.set(e,n),n}async createSession(e){let t={channel:`webchat`},n=e?.agentId?.trim();n&&(t.agentId=n.toLowerCase());let r=e?.projectId?.trim();r&&(t.projectId=r);let i=await Y(X(`/api/sessions`),{method:`POST`,body:JSON.stringify(t)});if(!i.ok)throw Error(`HTTP ${i.status}`);return(await i.json()).session}async ensureSessionExists(e){let t=e.trim();if(!t)throw Error(`Session key is required`);let n=await Y(X(`/api/sessions/resolve`),{method:`POST`,body:JSON.stringify({sessionKey:t})});if(n.ok)return;if(n.status!==404)throw Error(await K6(n));let r=Ome(t);if(!r)throw Error(`Session not found`);let i=await Y(X(`/api/sessions`),{method:`POST`,body:JSON.stringify({channel:r.channel,agentId:r.agentId,chat_id:r.chatId})});if(!i.ok)throw Error(await K6(i))}async fetchSessionName(e){let t=await ue(X(`/api/sessions/${encodeURIComponent(e)}?offset=0&limit=1`));if(!t.ok)return;let n=(await t.json()).session?.name;return typeof n==`string`&&n.trim()?n.trim():void 0}updateUrl(e){let t=`#/chat/${encodeURIComponent(e)}`;if(location.hash!==t){let e=window.history.state,n=e&&typeof e==`object`&&!Array.isArray(e)?{...e}:e;history.replaceState(n,``,t)}}parseSessionFromHash(){let e=location.hash.slice(1),t=e.match(/^\/chat\/(.+)$/)||e.match(/^chat\/(.+)$/),n=t?decodeURIComponent(t[1]):null;return n&&n!==`new`?n:null}async deleteMessages(e,t){let n=await Y(X(`/api/sessions/${encodeURIComponent(e)}/messages`),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}}},q6=`xopc.recentWorkspaceDirs.v1`,Ame=10;function jme(){try{let e=localStorage.getItem(q6);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}catch{return[]}}function Mme(e){let t=e.trim();if(t)try{let e=[t,...jme().filter(e=>e!==t)].slice(0,Ame);localStorage.setItem(q6,JSON.stringify(e))}catch{}}function J6(e){let t=e.trim().replace(/[/\\]+$/,``);if(!t)return e;let n=t.split(/[/\\]/);return n[n.length-1]||t}function Y6(e){let t=(0,Q.c)(27),{value:n,onPick:r,disabled:i,placeholder:a,title:o,className:s,maxWidthClass:c,compact:l,"aria-label":d}=e,f=c===void 0?`max-w-[min(12rem,40vw)]`:c,p=l===void 0?!1:l,m,h;t[0]!==a||t[1]!==n?(h=n.trim(),m=h?J6(h):a??``,t[0]=a,t[1]=n,t[2]=m,t[3]=h):(m=t[2],h=t[3]);let g=m,_=o??(h||void 0),v=d??o??g,y=p?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,b=!p&&f,x=i&&`cursor-not-allowed opacity-60`,S;t[4]!==s||t[5]!==y||t[6]!==b||t[7]!==x?(S=u(y,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,lA.transition,lA.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,b,x,s),t[4]=s,t[5]=y,t[6]=b,t[7]=x,t[8]=S):S=t[8];let C;t[9]!==i||t[10]!==r?(C=e=>{e.stopPropagation(),i||r()},t[9]=i,t[10]=r,t[11]=C):C=t[11];let w=p?`size-4`:`size-3.5`,T;t[12]===w?T=t[13]:(T=u(`shrink-0 text-fg-muted`,w),t[12]=w,t[13]=T);let E;t[14]===T?E=t[15]:(E=(0,$.jsx)(u_,{className:T,"aria-hidden":!0}),t[14]=T,t[15]=E);let D;t[16]!==p||t[17]!==g?(D=p?null:(0,$.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:g}),t[16]=p,t[17]=g,t[18]=D):D=t[18];let O;return t[19]!==i||t[20]!==C||t[21]!==E||t[22]!==D||t[23]!==_||t[24]!==v||t[25]!==S?(O=(0,$.jsxs)(`button`,{type:`button`,disabled:i,title:_,"aria-label":v,className:S,onClick:C,children:[E,D]}),t[19]=i,t[20]=C,t[21]=E,t[22]=D,t[23]=_,t[24]=v,t[25]=S,t[26]=O):O=t[26],O}async function Nme(e){let t=typeof window<`u`?window.electronAPI?.file?.openDirectory:void 0;if(!t)return null;let n=e?.trim();return n?t({defaultPath:n}):t()}function X6(e={}){let{initialPath:t,onPicked:n,trackRecent:r=!0}=e,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=typeof window<`u`&&!!window.electronAPI?.file?.openDirectory,l=(0,Z.useCallback)(async e=>{let t=e.trim();t&&(r&&Mme(t),await n?.(t))},[n,r]);return{hasNativePicker:c,modalOpen:i,setModalOpen:a,pick:(0,Z.useCallback)(()=>{if(c){(async()=>{s(!0);try{let e=await Nme(t);e&&await l(e)}finally{s(!1)}})();return}a(!0)},[l,c,t]),confirmPick:l,picking:o}}function Pme(){return function(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e}}}function Z6(e,t){return{...e,...t.patch}}function Fme(e){let{enabled:t,parsed:n,dirty:r,trackedParsedRef:i,dispatch:a,onResetDirty:o}=e;if(!t){i.current!==null&&(i.current=null,a({type:`reset`}),o?.());return}n!==null&&!r&&i.current!==n&&(i.current=n,a({type:`sync`,value:n}))}async function Q6(e){let t=new URLSearchParams;e!=null&&e!==``&&t.set(`path`,e);let n=t.toString();return(await J(X(`/api/host/fs/list${n?`?${n}`:``}`))).payload}async function Ime(){return(await J(X(`/api/host/fs/meta`))).payload}function Lme(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-sm text-fg`,`placeholder:text-fg-subtle`,oA,`dark:border-edge`)}function $6(e){return/^[A-Za-z]:\\?$/.test(e.replace(/\\$/,`\\`))}function Rme(e){return!e||e.currentPath===``?!1:e.parentPath===null?e.currentPath===`/`?!1:!!$6(e.currentPath):!0}var zme={metaHostname:null,listState:null,listLoading:!1,listError:null,manualPath:``};function e8({open:e,onOpenChange:t,initialAbsolutePath:n,onConfirm:r,wd:i}){let a=(0,Z.useId)(),[o,s]=(0,Z.useReducer)(Z6,zme),{metaHostname:c,listState:l,listLoading:d,listError:f,manualPath:p}=o,m=(0,Z.useCallback)(async e=>{s({type:`patch`,patch:{listLoading:!0,listError:null}});try{s({type:`patch`,patch:{listState:await Q6(e)}})}catch(e){s({type:`patch`,patch:{listError:e instanceof Error?e.message:String(e),listState:null}})}finally{s({type:`patch`,patch:{listLoading:!1}})}},[]);(0,Z.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await Ime();t||s({type:`patch`,patch:{metaHostname:e.hostname}})}catch{t||s({type:`patch`,patch:{metaHostname:null}})}})(),()=>{t=!0}},[e]),(0,Z.useEffect)(()=>{if(!e)return;let t=n?.trim()??``;s({type:`patch`,patch:{manualPath:t}});let r=!1;return(async()=>{s({type:`patch`,patch:{listLoading:!0,listError:null}});try{if(t)try{let e=await Q6(t);r||s({type:`patch`,patch:{listState:e}})}catch{let e=await Q6();r||s({type:`patch`,patch:{listState:e}})}else{let e=await Q6();r||s({type:`patch`,patch:{listState:e}})}}catch(e){let t=e instanceof Error?e.message:String(e);r||s({type:`patch`,patch:{listError:t,listState:null}})}finally{r||s({type:`patch`,patch:{listLoading:!1}})}})(),()=>{r=!0}},[e,n]);let h=e=>{e.isDirectory&&m(e.absolutePath)},g=()=>{if(!l)return;let{parentPath:e,currentPath:t}=l;if(e!==null){m(e);return}t===`/`||t===``||$6(t)&&m(void 0)},_=l?.currentPath===``?i.pickerDrives:l?.currentPath??``,v=!!l&&l.currentPath!==``&&!d&&!f,y=async()=>{if(!(!l||l.currentPath===``))try{await r(l.currentPath),t(!1)}catch{}},b=async()=>{let e=p.trim();if(e)try{await r(e),t(!1)}catch{}},x=d&&l;return(0,$.jsx)(FN,{open:e,onOpenChange:t,children:(0,$.jsxs)(LN,{children:[(0,$.jsx)(RN,{className:`fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(zN,{className:u(`fixed left-1/2 top-1/2 z-[101] flex max-h-[min(90vh,32rem)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsx)(BN,{className:`text-base font-semibold text-fg`,children:i.pathModalTitle}),(0,$.jsx)(VN,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:i.pathModalDescription}),c?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:i.pickerHostHint.replace(`{{hostname}}`,c)}):null,(0,$.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(tA,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1 px-2 py-1.5 text-xs`,disabled:d||!Rme(l)||!!f,onClick:()=>g(),title:i.pickerUp,children:[(0,$.jsx)(Xu,{className:`size-4`,"aria-hidden":!0}),i.pickerUp]}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 truncate rounded-md border border-edge-subtle/80 bg-surface-hover/30 px-2 py-1.5 font-mono text-xs text-fg`,title:_,children:d&&!l?i.pickerLoading:_||`—`})]}),(0,$.jsxs)(`div`,{className:u(`relative min-h-[12rem] overflow-y-auto rounded-lg border border-edge-subtle/80 bg-surface-hover/20 p-1 dark:border-edge-subtle`,lA.focusRingPanel),role:`listbox`,"aria-label":i.pathModalTitle,children:[x?(0,$.jsx)(`div`,{className:`absolute inset-0 z-[1] flex items-center justify-center rounded-lg bg-surface-panel/60`,"aria-hidden":!0,children:(0,$.jsx)(Fv,{className:`size-6 animate-spin text-fg-muted`})}):null,d&&!l?(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-12 text-sm text-fg-muted`,children:[(0,$.jsx)(Fv,{className:`size-4 animate-spin`,"aria-hidden":!0}),i.pickerLoading]}):null,f?(0,$.jsx)(`p`,{className:`px-2 py-8 text-center text-sm text-fg-muted`,children:i.pickerListError}):null,!d&&l&&!f&&l.entries.length===0?(0,$.jsx)(`p`,{className:`px-2 py-8 text-center text-sm text-fg-muted`,children:i.pickerEmptyFolder}):null,l?.entries.map(e=>(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":!1,disabled:!e.isDirectory,className:u(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,e.isDirectory?`cursor-pointer text-fg hover:bg-surface-hover`:`cursor-default text-fg-muted opacity-60`),onClick:()=>h(e),children:[(0,$.jsx)(u_,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name})]},e.absolutePath))]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:a,className:`text-xs text-fg-muted`,children:i.pickerManualPath}),(0,$.jsx)(`input`,{id:a,type:`text`,value:p,onChange:e=>s({type:`patch`,patch:{manualPath:e.target.value}}),placeholder:i.pathInputPlaceholder,className:Lme(),autoComplete:`off`,spellCheck:!1,onKeyDown:e=>{e.key===`Enter`&&p.trim()&&(e.preventDefault(),b())}})]})]}),(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[(0,$.jsx)(tA,{type:`button`,variant:`ghost`,onClick:()=>t(!1),children:i.pathModalCancel}),(0,$.jsx)(tA,{type:`button`,variant:`secondary`,disabled:!p.trim(),onClick:()=>void b(),children:i.pickerApplyManual}),(0,$.jsx)(tA,{type:`button`,disabled:!v,onClick:()=>void y(),children:i.pickerUseThisFolder})]})]})]})})}var Bme=(0,Z.memo)(function({sessionKey:e,disabled:t,canSelectWorkingDirectory:n,sessionMgr:r}){let i=m(_(e=>e.language)).chat.workingDirectory,a=O1(e=>e.toggleOpen),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,h]=(0,Z.useState)(null),g=(0,Z.useCallback)(async()=>{if(!e){s(``);return}l(!0);try{s((await r.loadSessionAgentConfig(e)).effectiveWorkspacePath)}catch{s(``)}finally{l(!1)}},[e,r]);(0,Z.useEffect)(()=>{g()},[g]);let v=X6({initialPath:o,onPicked:(0,Z.useCallback)(async t=>{if(!(!e?.trim()||!t.trim()))try{await r.patchSessionAgentConfig(e,{workingDirectory:t.trim()}),await g()}catch(e){throw h(e instanceof Error?e.message:String(e)),f(!0),e}},[e,r,g])}),y=(0,Z.useCallback)(()=>{re({type:`info`,title:i.lockedTapTitle,message:i.lockedTapBody,duration:6500})},[i.lockedTapBody,i.lockedTapTitle]);if(!e)return null;let b=o.trim(),x=!!b,S=x?J6(b):i.notSet,C=u(`inline-flex min-h-8 max-w-[min(12rem,40vw)] min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,lA.transition,lA.focusRingPanel),w=e=>{let{hasPath:t,fullPath:n,canSelect:r}=e,a;return a=!r&&t?i.tooltipOpenProjectFiles:r?t?i.chooseFolder:i.selectWorkingDirectory:i.selectionOnlyAtNewChat,(0,$.jsxs)(`div`,{className:`max-w-[min(22rem,90vw)] space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`font-semibold text-fg`,children:i.tooltipAgentWorkspace}),t?(0,$.jsx)(`p`,{className:`break-words font-mono text-[11px] leading-snug text-fg-muted`,children:n}):(0,$.jsx)(`p`,{className:`text-[11px] text-fg-muted`,children:i.notSet}),(0,$.jsx)(`p`,{className:`text-[11px] leading-snug text-fg-subtle`,children:a})]})},T=(e,t)=>(0,$.jsxs)(B$,{delayDuration:350,children:[(0,$.jsx)(V$,{asChild:!0,children:t}),(0,$.jsx)(H$,{children:(0,$.jsx)(U$,{side:`top`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-w-[min(22rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-snug text-fg shadow-lg`,children:e})})]}),E=()=>T(w({hasPath:!1,fullPath:``,canSelect:!1}),(0,$.jsxs)(`button`,{type:`button`,className:u(C,`cursor-pointer text-left text-fg-muted hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`),"aria-label":`${i.notSet}. ${i.selectionOnlyAtNewChat}`,onClick:e=>{e.stopPropagation(),y()},children:[(0,$.jsx)(u_,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:S})]})),D=()=>T(w({hasPath:!0,fullPath:b,canSelect:!1}),(0,$.jsxs)(`button`,{type:`button`,disabled:t||c||!x,className:u(C,x&&`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,(t||c||!x)&&`cursor-not-allowed opacity-60`),"aria-label":`${i.tooltipAgentWorkspace}: ${b}`,onClick:e=>{e.stopPropagation(),x&&!t&&!c&&a()},children:[(0,$.jsx)(u_,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:S})]}));if(!n)return x?(0,$.jsx)(z$,{delayDuration:350,children:(0,$.jsx)(`div`,{className:`inline-flex items-center`,children:D()})}):(0,$.jsx)(z$,{delayDuration:350,children:(0,$.jsx)(`div`,{className:`inline-flex items-center`,children:E()})});let O=x&&!t&&!c?`${i.tooltipAgentWorkspace}: ${b}. ${i.chooseFolder}`:x?`${i.tooltipAgentWorkspace}: ${b}`:i.selectWorkingDirectory;return(0,$.jsx)(z$,{delayDuration:350,children:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`inline-flex items-center`,children:T(w({hasPath:x,fullPath:b,canSelect:!0}),(0,$.jsx)(Y6,{value:b,onPick:v.pick,disabled:t||c||v.picking,placeholder:i.notSet,"aria-label":O,className:u((t||c||v.picking)&&`cursor-not-allowed opacity-60`)}))}),v.hasNativePicker?null:(0,$.jsx)(e8,{open:v.modalOpen,onOpenChange:v.setModalOpen,initialAbsolutePath:b||void 0,onConfirm:v.confirmPick,wd:i}),(0,$.jsx)(FN,{open:d,onOpenChange:e=>{f(e),e||h(null)},children:(0,$.jsxs)(LN,{children:[(0,$.jsx)(RN,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(zN,{className:u(`fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover`,`dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsx)(BN,{className:`text-base font-semibold text-fg`,children:i.applyErrorTitle}),p?(0,$.jsx)(VN,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:p}):null,(0,$.jsx)(`div`,{className:`mt-4 flex items-center justify-end border-t border-edge-subtle/60 pt-3`,children:(0,$.jsx)(tA,{type:`button`,onClick:()=>f(!1),children:i.applyErrorClose})})]})]})})]})})});function t8(e,t){let n=e.finishedAt??e.startedAt??e.at,r=e.verdict;return{...e,at:n,turnsUsed:t?.turnsUsed??e.turnsUsed??0,maxTurns:t?.maxTurns??e.maxTurns??0,statusAfter:t?.status??e.statusAfter??`active`,willContinue:r===`continue`||r===`decompose`}}function n8(e){if(!e)return null;let t=e.latestRun?t8(e.latestRun,e):void 0;return{...e,checklist:e.checklist??[],latestRun:t,lastTurnAt:e.updatedAt??e.lastTurnAt??e.createdAt,lastVerdict:t?.verdict??e.lastVerdict,lastReason:t?.reason??e.lastReason??e.blockedReason}}async function r8(e,t){return{ok:!0,goal:n8((await J(X(`/api/goals/current?${new URLSearchParams({sessionKey:e}).toString()}`))).goal)}}async function Vme(e,t,n){return{ok:!0,goal:n8((await J(X(`/api/goals`),{method:`POST`,body:JSON.stringify({sessionKey:e,title:t,...n?.uiLocale?{uiLocale:n.uiLocale}:{}})})).goal)}}async function Hme(e){let t=new URLSearchParams;return t.set(`status`,e?.status??`active,paused,blocked,needs_input`),t.set(`limit`,String(e?.limit??50)),e?.sessionKey&&t.set(`sessionKey`,e.sessionKey),{ok:!0,goals:(await J(X(`/api/goals?${t.toString()}`))).goals.map(e=>n8(e)).filter(e=>e!=null)}}async function Ume(e,t,n){let r=(await r8(e,n)).goal;return r?{ok:!0,goal:n8((await J(X(t===`pause`?`/api/goals/${encodeURIComponent(r.id)}/pause`:t===`clear`?`/api/goals/${encodeURIComponent(r.id)}/archive`:t===`detach`?`/api/goals/${encodeURIComponent(r.id)}/detach`:`/api/goals/${encodeURIComponent(r.id)}/continue`),{method:`POST`,body:JSON.stringify({sessionKey:e,...n?.uiLocale?{uiLocale:n.uiLocale}:{}})})).goal)}:{ok:!0,goal:null}}async function Wme(e,t){return{ok:!0,goal:n8((await J(X(`/api/goals/${encodeURIComponent(t)}/attach`),{method:`POST`,body:JSON.stringify({sessionKey:e})})).goal)}}async function Gme(e){return{ok:!0,goal:n8((await J(X(`/api/goals/${encodeURIComponent(e)}/detach`),{method:`POST`,body:JSON.stringify({})})).goal)}}async function Kme(e,t,n){let r=(await r8(e,n)).goal;if(!r)return{ok:!0,goal:null};if(t.op===`reset`)return await Promise.all(r.checklist.map(e=>X(`/api/goals/${encodeURIComponent(r.id)}/checklist/${encodeURIComponent(e.id)}`)).map(e=>J(e,{method:`DELETE`}))),r8(e,n);if(t.op===`add`)return{ok:!0,goal:n8((await J(X(`/api/goals/${encodeURIComponent(r.id)}/checklist`),{method:`POST`,body:JSON.stringify({text:t.text})})).goal)};let i=r.checklist[t.index-1];return i?t.op===`remove`?{ok:!0,goal:n8((await J(X(`/api/goals/${encodeURIComponent(r.id)}/checklist/${encodeURIComponent(i.id)}`),{method:`DELETE`})).goal)}:{ok:!0,goal:n8((await J(X(`/api/goals/${encodeURIComponent(r.id)}/checklist/${encodeURIComponent(i.id)}`),{method:`PATCH`,body:JSON.stringify({status:t.status})})).goal)}:{ok:!0,goal:r}}async function i8(e,t){let n=(await r8(e)).goal;if(!n)return{ok:!0,runs:[]};let r=new URLSearchParams;t?.limit!=null&&Number.isFinite(t.limit)&&r.set(`limit`,String(Math.min(500,Math.max(1,Math.floor(t.limit)))));let i=r.toString()?`?${r.toString()}`:``;return{ok:!0,runs:(await J(X(`/api/goals/${encodeURIComponent(n.id)}/runs${i}`))).runs.map(e=>t8(e,n))}}async function a8(){return(await J(X(`/api/workflows/definitions`))).definitions??[]}async function qme(e,t){return J(X(`/api/workflows/definitions/validate`),{method:`POST`,body:JSON.stringify({name:e,script:t})})}async function Jme(e){return(await J(X(`/api/workflows/definitions/draft`),{method:`POST`,body:JSON.stringify(e)})).draft}async function Yme(e,t){return(await J(X(`/api/workflows/definitions`),{method:`POST`,body:JSON.stringify({name:e,script:t})})).definition}async function Xme(e){await J(X(`/api/workflows/definitions/${encodeURIComponent(e)}`),{method:`DELETE`})}function o8(e,t){let n=t?.ownerAgentId?.trim();n&&e.set(`agentId`,n)}async function Zme(e,t){let n=e?.trim(),r=new URLSearchParams;return n&&r.set(`definitionId`,n),o8(r,t),(await J(X(`/api/workflows/stats${r.size>0?`?${r.toString()}`:``}`))).stats}async function Qme(e=50,t){let n=new URLSearchParams({limit:String(e)});o8(n,t);let r=t?.goalId?.trim();r&&n.set(`goalId`,r);let i=t?.projectId?.trim();return i&&n.set(`projectId`,i),(await J(X(`/api/workflows/runs?${n.toString()}`))).runs??[]}async function $me(e,t){let n=new URLSearchParams;o8(n,t);let r=n.size>0?`?${n.toString()}`:``;return(await J(X(`/api/workflows/runs/${encodeURIComponent(e)}${r}`))).view}async function ehe(e,t){let n=new URLSearchParams;o8(n,t);let r=n.size>0?`?${n.toString()}`:``;return(await J(X(`/api/workflows/runs/${encodeURIComponent(e)}/comparison${r}`))).comparison}async function the(e,t,n){let r=new URLSearchParams;o8(r,n);let i=r.size>0?`?${r.toString()}`:``,a=await Y(X(`/api/workflows/runs/${encodeURIComponent(e)}/artifacts/${encodeURIComponent(t)}${i}`),{headers:{Accept:`*/*`}});if(!a.ok){let e=await a.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message;throw Error(te(a.status,a.statusText,t))}return a.blob()}async function nhe(e){return J(X(`/api/workflows/runs`),{method:`POST`,body:JSON.stringify(e)})}async function rhe(e,t=50){let n=new URLSearchParams({limit:String(t)});return(await J(X(`/api/goals/${encodeURIComponent(e)}/workflow-runs?${n.toString()}`))).runs??[]}async function s8(e){let t=await J(X(`/api/goals/${encodeURIComponent(e.goalId)}/workflows/run`),{method:`POST`,body:JSON.stringify({definitionId:e.definitionId,goal:e.goal,input:e.input,concurrency:e.concurrency,maxSubagents:e.maxSubagents})});return{runId:t.runId,sessionKey:t.sessionKey}}async function c8(e,t){let n=new URLSearchParams;o8(n,t);let r=n.size>0?`?${n.toString()}`:``;await J(X(`/api/workflows/runs/${encodeURIComponent(e)}/cancel${r}`),{method:`POST`})}async function ihe(e,t){let n=new URLSearchParams;o8(n,t);let r=n.size>0?`?${n.toString()}`:``,i=t?.projectId?.trim();return J(X(`/api/workflows/runs/${encodeURIComponent(e)}/retry${r}`),{method:`POST`,body:JSON.stringify(i?{projectId:i}:{})})}async function ahe(e,t,n){let r=new URLSearchParams;o8(r,n);let i=r.size>0?`?${r.toString()}`:``;return J(X(`/api/workflows/runs/${encodeURIComponent(e)}/replay${i}`),{method:`POST`,body:JSON.stringify({scope:t})})}var l8=`min-w-0 rounded-md border border-edge bg-surface-muted px-2.5 py-1.5 text-xs text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`;function u8(e){return`${e.status===`blocked`||e.status===`needs_input`?`${e.status}: `:``}${e.title}`}function ohe({sessionKey:e,disabled:t,onDone:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)([]),[l,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),b=(0,Z.useCallback)(async()=>{if(e){y(null);try{let[t,n]=await Promise.all([r8(e),Hme({limit:100})]);i(t.goal),o(n.goals),p(e=>e||n.goals.find(e=>e.id!==t.goal?.id)?.id||``)}catch(e){y(e instanceof Error?e.message:`Failed to load goals`)}}},[e]);(0,Z.useEffect)(()=>{let e=!1;return a8().then(t=>{e||(c(t),h(e=>e||t[0]?.id||``))}).catch(t=>{e||y(t instanceof Error?t.message:`Failed to load workflows`)}),()=>{e=!0}},[]),(0,Z.useEffect)(()=>{b()},[b]);let x=(0,Z.useMemo)(()=>a.filter(e=>e.id!==r?.id),[a,r?.id]),S=(0,Z.useCallback)(()=>{e&&window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:e}}))},[e]),C=async()=>{if(!e)return;let t=l.trim();if(t){_(`start`),y(null);try{i((await Vme(e,t)).goal),d(``),S(),re({type:`success`,title:`Goal started`,message:t}),n?.()}catch(e){y(e instanceof Error?e.message:`Failed to start goal`)}finally{_(null)}}},w=async()=>{if(!(!e||!f)){_(`attach`),y(null);try{let t=await Wme(e,f);i(t.goal),S(),re({type:`success`,title:`Goal attached`,message:t.goal?.title}),n?.()}catch(e){y(e instanceof Error?e.message:`Failed to attach goal`)}finally{_(null)}}},T=async()=>{if(r){_(`detach`),y(null);try{await Gme(r.id),i(null),S(),re({type:`info`,title:`Goal detached`}),n?.()}catch(e){y(e instanceof Error?e.message:`Failed to detach goal`)}finally{_(null)}}},E=async()=>{if(!(!r||!m)){_(`workflow`),y(null);try{let e=await s8({goalId:r.id,definitionId:m,goal:r.nextAction||r.title});S(),re({type:`success`,title:`Workflow started`,message:r.title}),window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e.sessionKey}})),n?.()}catch(e){y(e instanceof Error?e.message:`Failed to start workflow`)}finally{_(null)}}},D=t||!e||g!=null;return(0,$.jsxs)(`div`,{className:`grid w-72 gap-2 px-1 py-1 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1.5 text-fg`,children:[(0,$.jsx)(rE,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:`Goal`}),(0,$.jsx)(`div`,{className:`truncate text-fg-muted`,children:r?u8(r):`No goal attached`})]})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-edge/70 bg-surface-muted/30 p-2`,children:[(0,$.jsx)(`div`,{className:`font-medium text-fg-muted`,children:`Start goal`}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(`input`,{value:l,onChange:e=>d(e.target.value),className:u(l8,`flex-1`),placeholder:`Goal title`,disabled:D}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-accent text-white disabled:opacity-50`,disabled:D||!l.trim(),title:`Start goal`,"aria-label":`Start goal`,onClick:()=>void C(),children:(0,$.jsx)(Ly,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-edge/70 bg-surface-muted/30 p-2`,children:[(0,$.jsx)(`div`,{className:`font-medium text-fg-muted`,children:r?`Switch goal`:`Attach goal`}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsxs)(Aj,{value:f,onChange:e=>p(e.target.value),className:u(l8,`flex-1`),disabled:D||x.length===0,children:[x.length===0?(0,$.jsx)(Dj,{value:``,children:`No open goals`}):null,x.map(e=>(0,$.jsx)(Dj,{value:e.id,children:u8(e)},e.id))]}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md border border-edge text-fg hover:bg-surface-hover disabled:opacity-50`,disabled:D||!f,title:r?`Switch goal`:`Attach goal`,"aria-label":r?`Switch goal`:`Attach goal`,onClick:()=>void w(),children:(0,$.jsx)(Ov,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center gap-2 rounded-md px-2 text-left text-fg hover:bg-surface-hover disabled:opacity-50`,disabled:D||!r,onClick:()=>void T(),children:[(0,$.jsx)(BD,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),`Detach current goal`]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-edge/70 bg-surface-muted/30 p-2`,children:[(0,$.jsx)(`div`,{className:`font-medium text-fg-muted`,children:`Run workflow`}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsxs)(Aj,{value:m,onChange:e=>h(e.target.value),className:u(l8,`flex-1`),disabled:D||!r||s.length===0,children:[s.length===0?(0,$.jsx)(Dj,{value:``,children:`No workflows`}):null,s.map(e=>(0,$.jsx)(Dj,{value:e.id,children:e.title||e.name},e.id))]}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md border border-edge text-fg hover:bg-surface-hover disabled:opacity-50`,disabled:D||!r||!m,title:`Run workflow`,"aria-label":`Run workflow`,onClick:()=>void E(),children:(0,$.jsx)(rE,{className:`size-4`,"aria-hidden":!0})})]})]}),v?(0,$.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5 text-destructive`,children:v}):null]})}function she(e){return e===`off`?$o:SC}var che=(0,Z.memo)(function(e){let t=(0,Q.c)(104),{sessionKey:n,sessionManager:r,disabled:i,sending:a,streaming:o,canSelectWorkingDirectory:s,runBusy:c,chat:l,hasDraft:d,showSteeringInterrupt:f,attachmentCount:p,maxAttachments:m,onPickFiles:h,onOpenReviewLauncher:g,thinkingLevel:_,showThinkingSelector:v,onThinkingChange:y,voiceActive:b,onStartVoiceInput:x,onSend:S,onAbort:C,onInterrupt:w,sessionModel:T,showModelSelector:E,onModelChange:D,modelDisabled:O,contextUsageMessages:k,composerDraftChars:A}=e,[j,M]=(0,Z.useState)(!1),N=_,P;t[0]===N?P=t[1]:(P=she(N),t[0]=N,t[1]=P);let F=P,I=p>=m,L;t[2]!==p||t[3]!==I||t[4]!==l.attachFile||t[5]!==l.maxAttachmentsReached||t[6]!==m?(L=I?P6(l.maxAttachmentsReached,{max:m}):`${l.attachFile} (${p}/${m})`,t[2]=p,t[3]=I,t[4]=l.attachFile,t[5]=l.maxAttachmentsReached,t[6]=m,t[7]=L):L=t[7];let R=L,z;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(z=u(`flex flex-wrap items-center gap-2 border-t border-edge-subtle/90 px-4 py-2.5 dark:border-edge-subtle`),t[8]=z):z=t[8];let B=i||c,V;t[9]!==s||t[10]!==n||t[11]!==r||t[12]!==B?(V=(0,$.jsx)(Bme,{sessionKey:n,sessionMgr:r,canSelectWorkingDirectory:s,disabled:B}),t[9]=s,t[10]=n,t[11]=r,t[12]=B,t[13]=V):V=t[13];let H;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(H=u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-subtle hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/50`,lA.transition,lA.press,lA.focusRingPanel),t[14]=H):H=t[14];let U;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(Ly,{className:`size-4`}),t[15]=U):U=t[15];let W;t[16]!==l.moreActions||t[17]!==j?(W=(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:H,title:l.moreActions,"aria-label":l.moreActions,"aria-expanded":j,children:U})}),t[16]=l.moreActions,t[17]=j,t[18]=W):W=t[18];let G;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(G=u(`z-50 min-w-[12rem] rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover dark:border-edge`),t[19]=G):G=t[19];let K=i||c,q;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>M(!1),t[20]=q):q=t[20];let ee;t[21]!==n||t[22]!==K?(ee=(0,$.jsx)(ohe,{sessionKey:n,disabled:K,onDone:q}),t[21]=n,t[22]=K,t[23]=ee):ee=t[23];let J;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(J=u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:cursor-not-allowed disabled:opacity-50`),t[24]=J):J=t[24];let te=i||c||!n,Y;t[25]===g?Y=t[26]:(Y=()=>{g(),M(!1)},t[25]=g,t[26]=Y);let ne;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(kv,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[27]=ne):ne=t[27];let re;t[28]===l.reviewLauncher.actionLabel?re=t[29]:(re=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:l.reviewLauncher.actionLabel}),t[28]=l.reviewLauncher.actionLabel,t[29]=re);let X;t[30]!==te||t[31]!==Y||t[32]!==re?(X=(0,$.jsxs)(`button`,{type:`button`,className:J,disabled:te,onClick:Y,children:[ne,re]}),t[30]=te,t[31]=Y,t[32]=re,t[33]=X):X=t[33];let ie;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(`div`,{className:`my-1 h-px bg-edge-subtle`}),t[34]=ie):ie=t[34];let ae;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ae=u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:cursor-not-allowed disabled:opacity-50`),t[35]=ae):ae=t[35];let oe=I||i||c,se;t[36]===h?se=t[37]:(se=()=>{h(),M(!1)},t[36]=h,t[37]=se);let ce;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(Eg,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[38]=ce):ce=t[38];let le;t[39]===l.attachFile?le=t[40]:(le=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:l.attachFile}),t[39]=l.attachFile,t[40]=le);let ue;t[41]!==p||t[42]!==m?(ue=(0,$.jsxs)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:[p,`/`,m]}),t[41]=p,t[42]=m,t[43]=ue):ue=t[43];let de;t[44]!==R||t[45]!==oe||t[46]!==se||t[47]!==le||t[48]!==ue?(de=(0,$.jsxs)(`button`,{type:`button`,className:ae,disabled:oe,title:R,onClick:se,children:[ce,le,ue]}),t[44]=R,t[45]=oe,t[46]=se,t[47]=le,t[48]=ue,t[49]=de):de=t[49];let fe;t[50]!==F||t[51]!==i||t[52]!==l.thinkingLevelLabel||t[53]!==l.thinkingLevels||t[54]!==y||t[55]!==a||t[56]!==v||t[57]!==o||t[58]!==_?(fe=v?(0,$.jsxs)(`label`,{className:u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-sm text-fg`,`hover:bg-surface-hover`),title:`${l.thinkingLevelLabel}: ${l.thinkingLevels[_]??_}`,children:[(0,$.jsx)(F,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:l.thinkingLevelLabel}),(0,$.jsx)(Aj,{className:`min-w-0 flex-1 cursor-pointer appearance-none rounded-md bg-surface-hover/80 px-2 py-0.5 text-sm font-medium text-fg focus:outline-none focus-visible:ring-2 focus-visible:ring-accent`,value:_,disabled:i||a&&!o,onChange:e=>y(e.target.value),children:Object.keys(l.thinkingLevels).map(e=>(0,$.jsx)(Dj,{value:e,children:l.thinkingLevels[e]},e))})]}):null,t[50]=F,t[51]=i,t[52]=l.thinkingLevelLabel,t[53]=l.thinkingLevels,t[54]=y,t[55]=a,t[56]=v,t[57]=o,t[58]=_,t[59]=fe):fe=t[59];let pe;t[60]!==ee||t[61]!==X||t[62]!==de||t[63]!==fe?(pe=(0,$.jsx)(lj,{children:(0,$.jsx)(uj,{className:G,side:`top`,align:`start`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:lhe,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[ee,X,ie,de,fe]})})}),t[60]=ee,t[61]=X,t[62]=de,t[63]=fe,t[64]=pe):pe=t[64];let me;t[65]!==j||t[66]!==pe||t[67]!==W?(me=(0,$.jsxs)(oj,{open:j,onOpenChange:M,children:[W,pe]}),t[65]=j,t[66]=pe,t[67]=W,t[68]=me):me=t[68];let he;t[69]!==A||t[70]!==k||t[71]!==l||t[72]!==O||t[73]!==D||t[74]!==T||t[75]!==E?(he=E?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`min-w-0 w-fit max-w-[min(20rem,calc(100vw-10rem))] shrink-0`,children:(0,$.jsx)(z6,{value:T,disabled:O,placeholder:l.modelPlaceholder,searchPlaceholder:l.modelSearchPlaceholder,noMatches:l.modelNoMatches,compact:!0,showProviderInTrigger:!1,contentSide:`top`,contentAlign:`end`,showProviderSettingsFooter:!0,onChange:D})}),(0,$.jsx)(mme,{sessionModel:T,messages:k,draftChars:A,chat:l,disabled:O})]}):null,t[69]=A,t[70]=k,t[71]=l,t[72]=O,t[73]=D,t[74]=T,t[75]=E,t[76]=he):he=t[76];let ge;t[77]!==i||t[78]!==l.voiceInput||t[79]!==x||t[80]!==b?(ge=b?null:(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-fg-subtle hover:bg-surface-hover hover:text-fg`,lA.transition,lA.press,lA.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),disabled:i,title:l.voiceInput,"aria-label":l.voiceInput,onClick:()=>void x(),children:(0,$.jsx)(Uv,{className:`size-4 stroke-[1.75]`})}),t[77]=i,t[78]=l.voiceInput,t[79]=x,t[80]=b,t[81]=ge):ge=t[81];let _e;t[82]!==i||t[83]!==d||t[84]!==l.abort||t[85]!==l.sendMessage||t[86]!==l.steeringInterruptSend||t[87]!==C||t[88]!==w||t[89]!==S||t[90]!==c||t[91]!==f||t[92]!==b?(_e=c?(0,$.jsxs)($.Fragment,{children:[f&&w?(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-accent-fg hover:bg-accent-soft dark:hover:bg-accent-soft`,lA.transition,lA.press,lA.focusRingPanel),title:l.steeringInterruptSend,"aria-label":l.steeringInterruptSend,onClick:()=>void w(),children:(0,$.jsx)(rS,{className:`size-4 stroke-[1.75]`})}):null,(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/50`,lA.transition,lA.press,lA.focusRingPanel),title:l.abort,"aria-label":l.abort,onClick:C,children:(0,$.jsx)(Yw,{className:`size-4 stroke-[1.75]`})})]}):(0,$.jsx)(`button`,{type:`button`,className:u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border transition-colors duration-150 ease-out`,lA.press,lA.focusRingPanel,d?`border-transparent text-accent-fg hover:bg-accent-soft dark:text-accent-fg dark:hover:bg-accent-soft`:`border-transparent text-fg-disabled`),disabled:i||b||!d,title:l.sendMessage,"aria-label":l.sendMessage,onClick:S,children:(0,$.jsx)(rS,{className:`size-4 stroke-[1.75]`})}),t[82]=i,t[83]=d,t[84]=l.abort,t[85]=l.sendMessage,t[86]=l.steeringInterruptSend,t[87]=C,t[88]=w,t[89]=S,t[90]=c,t[91]=f,t[92]=b,t[93]=_e):_e=t[93];let ve;t[94]!==ge||t[95]!==_e?(ve=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[ge,_e]}),t[94]=ge,t[95]=_e,t[96]=ve):ve=t[96];let ye;t[97]!==he||t[98]!==ve?(ye=(0,$.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-2`,children:[he,ve]}),t[97]=he,t[98]=ve,t[99]=ye):ye=t[99];let be;return t[100]!==me||t[101]!==ye||t[102]!==V?(be=(0,$.jsxs)(`div`,{className:z,children:[V,me,ye]}),t[100]=me,t[101]=ye,t[102]=V,t[103]=be):be=t[103],be});function lhe(e){return e.preventDefault()}function uhe(e){return e.map(e=>({type:e.type===`voice`?`voice`:(e.mimeType??``).startsWith(`image/`)?`image`:`document`,mimeType:e.mimeType??`application/octet-stream`,content:e.data??``,name:e.name??`file`,size:e.size??0,uri:e.uri,...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}}))}var dhe=100,fhe=400,d8=900;function phe(e,t){switch(t.type){case`reset`:return{box:null,hoverPreview:null};case`set-box`:return{...e,box:t.box};case`set-hover`:return{...e,hoverPreview:t.hoverPreview}}}function mhe(e,t){let n=t.trim().toLowerCase();if(!n)return[];let r=e.toLowerCase(),i=[],a=0;for(let e=0;e<r.length&&a<n.length;e++)r[e]===n[a]&&(i.push([e,e+1]),a++);return i}function hhe(e){let t=(0,Q.c)(8),{name:n,query:r}=e,i;t[0]!==n||t[1]!==r?(i=mhe(n,r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i;if(a.length===0){let e;return t[3]===n?e=t[4]:(e=(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:n}),t[3]=n,t[4]=e),e}let o;if(t[5]!==n||t[6]!==a){let e=[],r=0;a.forEach(t=>{let[i,a]=t;i>r&&e.push((0,$.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r,i)},`pre-${i}`)),e.push((0,$.jsx)(`span`,{className:`font-semibold text-accent-fg`,children:n.slice(i,a)},`hl-${i}-${a}`)),r=a}),r<n.length&&e.push((0,$.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r)},`tail`)),o=(0,$.jsx)($.Fragment,{children:e}),t[5]=n,t[6]=a,t[7]=o}else o=t[7];return o}var ghe=(0,Z.memo)(function(e){let t=(0,Q.c)(44),{open:n,anchorRef:r,items:i,selectedIndex:a,loading:o,query:s,noResults:c,sessionKey:l,recentLabel:d,ariaLabel:f,onSelectItem:p,shiftHint:m}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h={box:null,hoverPreview:null},t[0]=h):h=t[0];let[g,_]=(0,Z.useReducer)(phe,h),v=g.box,y=g.hoverPreview,b=(0,Z.useRef)(null),x=(0,Z.useRef)(0),S=(0,Z.useRef)(null),C;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{b.current&&=(clearTimeout(b.current),null)},t[1]=C):C=t[1];let w=C,T;t[2]===l?T=t[3]:(T=(e,t,n)=>{w(),x.current+=1;let r=x.current,i=e.relativePath;if(!l?.trim()||e.isDirectory||e.isBrowseUp||!i){_({type:`set-hover`,hoverPreview:null});return}b.current=setTimeout(()=>{b.current=null,r===x.current&&Pq(i,{sessionKey:l}).then(e=>{let{content:i}=e,a=i.length>d8?`${i.slice(0,d8)}…`:i;r===x.current&&_({type:`set-hover`,hoverPreview:{text:a,x:t,y:n}})}).catch(()=>{r===x.current&&_({type:`set-hover`,hoverPreview:null})})},420)},t[2]=l,t[3]=T);let E=T,D,O;t[4]!==r||t[5]!==n?(D=()=>{if(!n){_({type:`reset`}),w(),x.current+=1;return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();_({type:`set-box`,box:{left:t.left,top:t.top,width:t.width}})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},O=[n,r],t[4]=r,t[5]=n,t[6]=D,t[7]=O):(D=t[6],O=t[7]),(0,Z.useLayoutEffect)(D,O);let k,A;if(t[8]!==i.length||t[9]!==n||t[10]!==a?(k=()=>{!n||a<0||a>=i.length||(S.current?.querySelector(`#at-mention-${a}`))?.scrollIntoView({block:`nearest`})},A=[n,a,i.length],t[8]=i.length,t[9]=n,t[10]=a,t[11]=k,t[12]=A):(k=t[11],A=t[12]),(0,Z.useLayoutEffect)(k,A),!n||typeof document>`u`||v===null)return null;let j=i.length,M=Math.min(v.width,fhe),N;t[13]!==v.left||t[14]!==v.top||t[15]!==M?(N={position:`fixed`,left:v.left,top:v.top,width:M,transform:`translateY(calc(-100% - 8px))`,zIndex:dhe},t[13]=v.left,t[14]=v.top,t[15]=M,t[16]=N):N=t[16];let P=a>=0&&a<j?`at-mention-${a}`:void 0,F;t[17]!==o||t[18]!==j?(F=o&&j===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 text-sm text-fg-muted`,children:[(0,$.jsx)(Fv,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:`…`})]}):null,t[17]=o,t[18]=j,t[19]=F):F=t[19];let I;t[20]!==i||t[21]!==o||t[22]!==c||t[23]!==p||t[24]!==s||t[25]!==d||t[26]!==E||t[27]!==a||t[28]!==j?(I=!o&&j===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-fg-muted`,children:c}):(0,$.jsx)($.Fragment,{children:i.map((e,t)=>(0,$.jsxs)(`div`,{id:`at-mention-${t}`,role:`option`,"aria-selected":a===t,tabIndex:-1,className:u(`flex cursor-pointer items-start gap-2 px-3 py-2 text-left text-sm`,a===t?`bg-surface-hover text-fg`:`text-fg-subtle hover:bg-surface-hover/80`,e.isRecent&&`border-l-2 border-l-accent/60`),onPointerDown:t=>{t.pointerType===`mouse`&&t.button!==0||(t.preventDefault(),p(e,{shiftKey:t.shiftKey}))},onPointerEnter:t=>E(e,t.clientX,t.clientY),onPointerLeave:()=>{w(),x.current+=1,_({type:`set-hover`,hoverPreview:null})},children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.isBrowseUp?(0,$.jsx)(O_,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0}):e.isDirectory?(0,$.jsx)(O_,{className:`size-3.5 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}):(0,$.jsx)(_g,{className:u(`size-3.5`,_q(e.name)),"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:(0,$.jsx)(hhe,{name:e.name,query:s})}),e.isRecent?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-accent-soft px-1 py-0 text-[0.65rem] text-accent-fg`,children:d}):null]}),(0,$.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:e.relativePath||`—`})]})]},`${e.relativePath}-${e.name}`))}),t[20]=i,t[21]=o,t[22]=c,t[23]=p,t[24]=s,t[25]=d,t[26]=E,t[27]=a,t[28]=j,t[29]=I):I=t[29];let L;t[30]!==f||t[31]!==F||t[32]!==I||t[33]!==P?(L=(0,$.jsxs)(`div`,{ref:S,className:`max-h-[min(26rem,54vh)] overflow-y-auto`,role:`listbox`,"aria-label":f,"aria-activedescendant":P,children:[F,I]}),t[30]=f,t[31]=F,t[32]=I,t[33]=P,t[34]=L):L=t[34];let R;t[35]===m?R=t[36]:(R=m?(0,$.jsx)(`div`,{className:`border-t border-edge-subtle px-3 py-1.5 text-[0.65rem] text-fg-muted`,children:m}):null,t[35]=m,t[36]=R);let z;t[37]===y?z=t[38]:(z=y?(0,$.jsx)(`div`,{className:`pointer-events-none fixed z-[200] max-h-48 max-w-sm overflow-auto rounded-md border border-edge bg-surface-panel p-2 font-mono text-[0.7rem] text-fg shadow-lg`,style:{left:Math.min(y.x+12,window.innerWidth-320),top:Math.min(y.y+12,window.innerHeight-200)},children:y.text}):null,t[37]=y,t[38]=z);let B;return t[39]!==L||t[40]!==R||t[41]!==z||t[42]!==N?(B=(0,Xi.createPortal)((0,$.jsxs)(`div`,{className:`pointer-events-auto max-h-[min(28rem,60vh)] min-h-[2.5rem] overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-lg dark:bg-surface-panel/95`,style:N,role:`presentation`,children:[L,R,z]}),document.body),t[39]=L,t[40]=R,t[41]=z,t[42]=N,t[43]=B):B=t[43],B}),f8=new Set([`abort`,`stop`,`cancel`]);function _he(e){if(e.kind!==`command`)return!1;if(f8.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(f8.has(t.toLowerCase()))return!0;return!1}function p8(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}var vhe={skill:(e,t)=>{let n=t.slashRange;if(!n)return;if(e.availability?.status&&e.availability.status!==`available`){t.callbacks.onUnavailableSkill?.(e);return}let r=`/skill:${e.name} `,i=p8(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0})},command:(e,t)=>{let n=t.slashRange;if(!n||n.start!==0)return;if(e.name.toLowerCase()===`review`&&t.callbacks.onReviewLauncher&&!t.runBusy&&t.pendingFollowUpsCount===0){let e=t.editor.valueRef.current,r=e.slice(0,n.start)+e.slice(n.end);t.editor.resetEditor({nextText:r,caretOffset:n.start,focus:!0}),t.callbacks.onReviewLauncher();return}if(e.acceptsArgs===!0){let r=`/${e.name} `,i=p8(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0});return}let r=`/${e.name}`;if(t.runBusy||t.pendingFollowUpsCount>0){if(_he(e)){if(!t.callbacks.onAbort)return;t.callbacks.onAbort();let e=t.editor.valueRef.current,r=e.slice(0,n.start)+e.slice(n.end);t.editor.resetEditor({nextText:r,caretOffset:n.start});return}if(!t.callbacks.onAddPendingFollowUp||t.pendingFollowUpsCount>=t.maxPendingFollowUps)return;t.callbacks.onAddPendingFollowUp(r,void 0),t.callbacks.onUserTextCommitted?.(r),t.attachments.clearAttachments(),t.editor.resetEditor();return}t.callbacks.onSend(r,void 0,t.thinkingLevel),t.callbacks.onUserTextCommitted?.(r),t.attachments.clearAttachments(),t.editor.resetEditor()},agent:(e,t)=>{let n=t.slashRange;if(!n||n.start!==0||!t.callbacks.onChatAgentChange)return;let r=t.editor.valueRef.current,i=r.slice(0,n.start)+r.slice(n.end);t.editor.resetEditor({nextText:i,caretOffset:n.start}),t.attachments.clearAttachments(),t.callbacks.onChatAgentChange(e.name)}};function yhe(e,t){let n=vhe[e.kind];n&&n(e,t)}var m8={new:10,help:11,list:12,clear:13,switch:14,models:15,usage:16,skills:17,settings:18,start:19,think:20,reasoning:21,verbose:22,status:23,tts:24},bhe=new Set([`abort`,`archive`]);function h8(e){if(e.kind===`command`){let t=e.name.toLowerCase();if(m8[t]!==void 0)return 0;if(bhe.has(t))return 2}return 1}function g8(e,t){let n=h8(e),r=h8(t);if(n!==r)return n-r;if(n===0){let n=m8[e.name.toLowerCase()]??999,r=m8[t.name.toLowerCase()]??999;if(n!==r)return n-r}let i=e.name.localeCompare(t.name);return i===0?e.id.localeCompare(t.id):i}var xhe=RegExp(`^@file:${m6}`,`u`);function _8(e){if(e.kind!==`command`)return!1;if(f8.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(f8.has(t.toLowerCase()))return!0;return!1}function v8(e,t){return e.kind!==`command`||e.acceptsArgs===!0||_8(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount>=t.maxPendingFollowUps}function She(e,t){return e.kind!==`command`||e.acceptsArgs===!0||_8(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount<t.maxPendingFollowUps}function Che(e,t){let n=0;for(;n<e.length;){let r=e.indexOf(`@file:`,n);if(r===-1)return null;let i=e.slice(r).match(xhe);if(!i){n=r+1;continue}let a=r+i[0].length;if(t>=r&&t<a)return{start:r,end:a};n=a}return null}var whe=20,y8=3;function The(e){return e.includes(`/`)||/^[A-Za-z]:/u.test(e)?!0:/^(Users|home|var|tmp|etc|opt|private|Volumes|System|Applications|Library|usr|dev|bin|sbin|proc|sys)(\/|$)/iu.test(e)}function Ehe(e,t){if(t===0)return!1;let n=e[t-1];if(n===void 0||n===`.`||n===`:`||n===`/`)return!0;let r=e.slice(0,t);return/[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/u.test(r)}function Dhe(e,t){let n=e.length,r=Math.min(Math.max(t,0),n);if(r<1&&e===`/`&&(r=1),r<1)return null;let i=e.slice(0,r).match(/\/[^\s]*$/);if(!i||i.index===void 0||Che(e,i.index))return null;let a=i.index;if(Ehe(e,a))return null;let o=i[0],s=o.slice(1);return The(s)||o.startsWith(`/skill:`)?null:{start:i.index,end:r,query:s}}function Ohe(e,t){let n=t.trim().toLowerCase();if(!n)return 0;let r=e.name.toLowerCase();if(r===n)return 0;for(let t of e.aliases??[])if(t.toLowerCase()===n)return 1;if(r.startsWith(n))return 2;for(let t of e.aliases??[])if(t.toLowerCase().startsWith(n))return 3;if(r.includes(n))return 4;for(let t of e.aliases??[])if(t.toLowerCase().includes(n))return 5;return(e.description??``).toLowerCase().includes(n)?100:(e.category??``).toLowerCase().includes(n)?101:e.kind===`skill`&&(e.source??``).toLowerCase().includes(n)?102:null}function khe(e,t){return t===0?0:Math.min(e,t-1)}function Ahe(e,t,n){let r=(0,Q.c)(57),[i,a]=(0,Z.useState)(0),[o,s]=(0,Z.useState)(0),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m=_(Ghe);n?.isComposing;let h;r[0]!==t||r[1]!==n?.isComposing||r[2]!==e?(h=n?.isComposing?null:Dhe(e,t),r[0]=t,r[1]=n?.isComposing,r[2]=e,r[3]=h):h=r[3];let g=h,v=!!(g&&!n?.suppress),y,b;r[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&(t.section===`skills`||t.section===`agents`)&&s(Whe)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},b=[],r[4]=y,r[5]=b):(y=r[4],b=r[5]),(0,Z.useEffect)(y,b),!v&&(c||u||f)&&(l(!1),d(!1),p(!1));let x;r[6]===n?.currentAgentId?x=r[7]:(x=async()=>{let[e,t,r]=await Promise.all([D4(),O4(n?.currentAgentId),_I().catch(Uhe)]),i=e.map(Hhe),a=t.skills.map(Vhe),o=r&&r.items.length>1?r.items.map(Bhe):[];return[...a,...i,...o]},r[6]=n?.currentAgentId,r[7]=x);let S=n?.currentAgentId,C;r[8]!==m||r[9]!==o||r[10]!==S?(C=[m,S,o],r[8]=m,r[9]=o,r[10]=S,r[11]=C):C=r[11];let w;r[12]===Symbol.for(`react.memo_cache_sentinel`)?(w=[],r[12]=w):w=r[12];let T;r[13]===Symbol.for(`react.memo_cache_sentinel`)?(T=[],r[13]=T):T=r[13];let E;r[14]===v?E=r[15]:(E={enabled:v,initial:w,errorData:T},r[14]=v,r[15]=E);let D=lP(x,C,E),O=D.data,k=D.error==null?null:D.error instanceof Error?D.error.message:String(D.error),A=g?.query??``,j=g!==null&&g.start===0,M=j,N;r[16]===A?N=r[17]:(N=A.trim(),r[16]=A,r[17]=N);let P=N===``,F=v&&P&&c,I=v&&P&&u,L=v&&P&&f,R;r[18]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{l(!0)},r[18]=R):R=r[18];let z=R,B;r[19]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{d(!0)},r[19]=B):B=r[19];let V=B,H;r[20]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{p(!0)},r[20]=H):H=r[20];let U=H,W;if(r[21]!==M||r[22]!==O||r[23]!==j||r[24]!==L||r[25]!==I||r[26]!==F||r[27]!==P||r[28]!==A||r[29]!==e){bb0:{let t=qpe(e),n=[];for(let e of O){if(e.kind===`command`&&!j||e.kind===`agent`&&!M||e.kind===`skill`&&t.has(e.name)||e.kind===`skill`&&P&&e.availability?.status!==`available`)continue;let r=Ohe(e,A);r!==null&&n.push({item:e,rank:r})}if(P){let e=zhe,t=n.filter(Rhe).sort(e).map(Lhe),r=n.filter(Ihe).sort(e).map(Fhe),i=n.filter(Phe).sort(e).map(Nhe),a=F?t:t.slice(0,y8),o=I?r:r.slice(0,y8),s=L?i:i.slice(0,y8),c=F?0:Math.max(0,t.length-y8),l=I?0:Math.max(0,r.length-y8),u=L?0:Math.max(0,i.length-y8);W={items:[...a,...o,...s],skillRowCount:a.length,commandRowCount:o.length,groupedHasSkills:t.length>0,groupedHasCommands:r.length>0,groupedHasAgents:i.length>0,groupedSkillsMoreCount:c,groupedCommandsMoreCount:l,groupedAgentsMoreCount:u};break bb0}n.sort(Mhe);let i;r[31]===n?i=r[32]:(i={items:n.slice(0,whe).map(jhe),skillRowCount:0,commandRowCount:0,groupedHasSkills:!1,groupedHasCommands:!1,groupedHasAgents:!1,groupedSkillsMoreCount:0,groupedCommandsMoreCount:0,groupedAgentsMoreCount:0},r[31]=n,r[32]=i),W=i}r[21]=M,r[22]=O,r[23]=j,r[24]=L,r[25]=I,r[26]=F,r[27]=P,r[28]=A,r[29]=e,r[30]=W}else W=r[30];let{items:G,skillRowCount:K,commandRowCount:q,groupedHasSkills:ee,groupedHasCommands:J,groupedHasAgents:te,groupedSkillsMoreCount:Y,groupedCommandsMoreCount:ne,groupedAgentsMoreCount:re}=W,X=g?A:``,ie=(0,Z.useRef)(X);ie.current!==X&&(ie.current=X,i!==0&&a(0));let ae;r[33]!==G.length||r[34]!==i?(ae=khe(i,G.length),r[33]=G.length,r[34]=i,r[35]=ae):ae=r[35];let oe=ae,se;r[36]===G.length?se=r[37]:(se=e=>{G.length!==0&&a(t=>e===`down`?(t+1)%G.length:(t-1+G.length)%G.length)},r[36]=G.length,r[37]=se);let ce=se,le;return r[38]!==M||r[39]!==q||r[40]!==j||r[41]!==P||r[42]!==re||r[43]!==ne||r[44]!==te||r[45]!==J||r[46]!==ee||r[47]!==Y||r[48]!==G||r[49]!==k||r[50]!==ce||r[51]!==v||r[52]!==A||r[53]!==oe||r[54]!==K||r[55]!==g?(le={open:v,slashRange:g,commandsAllowed:j,agentsAllowed:M,grouped:P,skillRowCount:K,commandRowCount:q,groupedHasSkills:ee,groupedHasCommands:J,groupedHasAgents:te,groupedSkillsMoreCount:Y,groupedCommandsMoreCount:ne,groupedAgentsMoreCount:re,items:G,selectedIndex:oe,query:A,loadError:k,onNavigate:ce,setSelectedIndex:a,expandGroupedSkills:z,expandGroupedCommands:V,expandGroupedAgents:U},r[38]=M,r[39]=q,r[40]=j,r[41]=P,r[42]=re,r[43]=ne,r[44]=te,r[45]=J,r[46]=ee,r[47]=Y,r[48]=G,r[49]=k,r[50]=ce,r[51]=v,r[52]=A,r[53]=oe,r[54]=K,r[55]=g,r[56]=le):le=r[56],le}function jhe(e){return e.item}function Mhe(e,t){let n=e.item.kind===`skill`&&e.item.availability?.status!==`available`;if(n!==(t.item.kind===`skill`&&t.item.availability?.status!==`available`))return n?1:-1;if(e.rank!==t.rank)return e.rank-t.rank;let r=g8(e.item,t.item);return r===0?0:r}function Nhe(e){return e.item}function Phe(e){return e.item.kind===`agent`}function Fhe(e){return e.item}function Ihe(e){return e.item.kind===`command`}function Lhe(e){return e.item}function Rhe(e){return e.item.kind===`skill`}function zhe(e,t){let n=g8(e.item,t.item);return n===0?e.item.id.localeCompare(t.item.id):n}function Bhe(e){return{kind:`agent`,id:`agent:${e.id}`,name:e.id,description:e.description??``,category:`agent`,...e.avatar?{avatar:e.avatar}:{},...e.name?{aliases:[e.name]}:{}}}function Vhe(e){return{kind:`skill`,id:`skill:${e.name}`,name:e.name,description:e.description,category:`skill`,source:e.source,availability:{status:e.availableForCurrentAgent?`available`:e.unavailableReason??`agent-denied`,reason:e.unavailableReason??void 0}}}function Hhe(e){return{kind:`command`,id:`cmd:${e.id}`,name:e.name,description:e.description,category:e.category,aliases:e.aliases,acceptsArgs:e.acceptsArgs}}function Uhe(){return null}function Whe(e){return e+1}function Ghe(e){return e.language}var Khe=100,qhe=280;function b8(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);if(r>=0)return(0,$.jsxs)($.Fragment,{children:[e.slice(0,r),(0,$.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]});let i=[],a=0,o=0;for(let t of e){let e=n[a],r=`${String(o)}-${t}`;e!==void 0&&t.toLowerCase()===e?(i.push((0,$.jsx)(`span`,{className:`text-accent-fg`,children:t},r)),a+=1):i.push((0,$.jsx)(Z.Fragment,{children:t},r)),o+=1}return(0,$.jsx)($.Fragment,{children:i})}function Jhe(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);return r<0?e:(0,$.jsxs)($.Fragment,{children:[e.slice(0,r),(0,$.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}var Yhe=(0,Z.memo)(function(e){let t=(0,Q.c)(45),{open:n,anchorRef:r,items:i,selectedIndex:a,noResults:o,grouped:s,skillRowCount:c,commandRowCount:l,query:d,skillsLabel:f,commandsLabel:p,agentsLabel:m,groupedHasSkills:h,groupedHasCommands:g,groupedHasAgents:_,groupedSkillsShowMoreLabel:v,groupedCommandsShowMoreLabel:y,groupedAgentsShowMoreLabel:b,currentAgentId:x,currentBadgeLabel:S,runBusy:C,pendingFollowUpsCount:w,maxPendingFollowUps:T,queueBadgeLabel:E,queueFullBadgeLabel:D,queueFullTooltip:O,skillUnavailableLabel:k,skillAgentDeniedLabel:A,onExpandSkills:j,onExpandCommands:M,onExpandAgents:N,onSelectItem:P,panelRef:F}=e,[I,L]=(0,Z.useState)(null),R,z;if(t[0]!==r||t[1]!==n?(R=()=>{if(!n){L(null);return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();L({left:t.left,top:t.top,width:t.width})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},z=[n,r],t[0]=r,t[1]=n,t[2]=R,t[3]=z):(R=t[2],z=t[3]),(0,Z.useLayoutEffect)(R,z),!n||typeof document>`u`||I===null)return null;let B=i.length,V=Math.min(I.width,qhe),H;if(t[4]!==m||t[5]!==l||t[6]!==p||t[7]!==x||t[8]!==S||t[9]!==s||t[10]!==b||t[11]!==y||t[12]!==_||t[13]!==g||t[14]!==h||t[15]!==v||t[16]!==i||t[17]!==T||t[18]!==o||t[19]!==N||t[20]!==M||t[21]!==j||t[22]!==P||t[23]!==w||t[24]!==d||t[25]!==E||t[26]!==D||t[27]!==O||t[28]!==C||t[29]!==a||t[30]!==A||t[31]!==c||t[32]!==k||t[33]!==f||t[34]!==B){let e=d.trim(),n=!s&&e.length>0,r={runBusy:C,pendingFollowUpsCount:w,maxPendingFollowUps:T},F=(t,i)=>{let o=t.kind===`skill`,s=t.kind===`agent`,c=s?(0,$.jsx)(dz,{agentId:t.name,avatar:t.avatar,size:18,className:`size-[18px] shrink-0`}):o?(0,$.jsx)(SC,{className:`size-3 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,$.jsx)(wk,{className:`size-3 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),l=s?n?(0,$.jsx)($.Fragment,{children:b8(t.name,e)}):(0,$.jsx)(`span`,{className:`text-fg`,children:t.name}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-fg`,children:`/`}),b8(t.name,e)]}):(0,$.jsxs)(`span`,{className:`text-fg`,children:[`/`,t.name]}),u=s&&x!=null&&x.length>0&&t.name===x,d=o&&t.availability?.status!==`available`,f=She(t,r),p=v8(t,r),m=null;return u?m=(0,$.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-accent-soft px-1 py-px text-[0.6rem] font-medium leading-none text-accent-fg`,"aria-label":S,children:S}):d?m=(0,$.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":t.availability?.reason??`unavailable`,children:t.availability?.status===`agent-denied`?A:k}):p?m=(0,$.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-red-100 px-1 py-px text-[0.6rem] font-medium leading-none text-red-700 dark:bg-red-900/40 dark:text-red-300`,"aria-label":D,children:D}):f&&(m=(0,$.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":E,children:E})),(0,$.jsx)(Xhe,{item:t,icon:c,selected:a===i,id:`palette-${i}`,nameLine:l,descriptionLine:t.description?n?Jhe(t.description,e):t.description:null,dimCategoryBadge:n,trailingBadge:m,disabled:p,disabledTooltip:p?O:void 0,onSelect:()=>P(t)})};H=B===0?(0,$.jsx)(`div`,{className:`p-2.5 text-xs leading-normal text-fg-muted`,children:o}):s?(0,$.jsxs)($.Fragment,{children:[h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mb-1.5 px-2.5 pt-2.5 text-[0.6rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,"aria-hidden":!0,children:f}),i.slice(0,c).map((e,t)=>(0,$.jsx)(Z.Fragment,{children:F(e,t)},e.id)),v?(0,$.jsx)(`button`,{type:`button`,className:`w-full px-2.5 py-1 text-left text-[11px] leading-tight text-fg-muted transition hover:bg-surface-hover/80 hover:text-fg`,onClick:e=>{e.preventDefault(),j()},children:v}):null]}):null,g?(0,$.jsxs)(`div`,{className:u(h&&`mt-1 border-t border-edge-subtle`),children:[(0,$.jsx)(`div`,{className:`mb-1.5 px-2.5 pt-2.5 text-[0.6rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,"aria-hidden":!0,children:p}),i.slice(c,c+l).map((e,t)=>(0,$.jsx)(Z.Fragment,{children:F(e,c+t)},e.id)),y?(0,$.jsx)(`button`,{type:`button`,className:`w-full px-2.5 py-1 text-left text-[11px] leading-tight text-fg-muted transition hover:bg-surface-hover/80 hover:text-fg`,onClick:e=>{e.preventDefault(),M()},children:y}):null]}):null,_?(0,$.jsxs)(`div`,{className:u((h||g)&&`mt-1 border-t border-edge-subtle`),children:[(0,$.jsx)(`div`,{className:`mb-1.5 px-2.5 pt-2.5 text-[0.6rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,"aria-hidden":!0,children:m}),i.slice(c+l).map((e,t)=>(0,$.jsx)(Z.Fragment,{children:F(e,c+l+t)},e.id)),b?(0,$.jsx)(`button`,{type:`button`,className:`w-full px-2.5 py-1 text-left text-[11px] leading-tight text-fg-muted transition hover:bg-surface-hover/80 hover:text-fg`,onClick:e=>{e.preventDefault(),N()},children:b}):null]}):null]}):i.map((e,t)=>(0,$.jsx)(Z.Fragment,{children:F(e,t)},e.id)),t[4]=m,t[5]=l,t[6]=p,t[7]=x,t[8]=S,t[9]=s,t[10]=b,t[11]=y,t[12]=_,t[13]=g,t[14]=h,t[15]=v,t[16]=i,t[17]=T,t[18]=o,t[19]=N,t[20]=M,t[21]=j,t[22]=P,t[23]=w,t[24]=d,t[25]=E,t[26]=D,t[27]=O,t[28]=C,t[29]=a,t[30]=A,t[31]=c,t[32]=k,t[33]=f,t[34]=B,t[35]=H}else H=t[35];let U=H,W;t[36]!==I.left||t[37]!==I.top||t[38]!==V?(W={position:`fixed`,left:I.left,top:I.top,width:V,transform:`translateY(calc(-100% - 8px))`,zIndex:Khe},t[36]=I.left,t[37]=I.top,t[38]=V,t[39]=W):W=t[39];let G=a>=0&&a<B?`palette-${a}`:void 0,K;return t[40]!==U||t[41]!==F||t[42]!==W||t[43]!==G?(K=(0,Xi.createPortal)((0,$.jsx)(z$,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!1,children:(0,$.jsx)(`div`,{ref:F,className:`pointer-events-auto max-h-[min(24rem,55vh)] min-h-8 overflow-y-auto rounded-md border border-edge bg-surface-panel text-xs leading-4 shadow-lg dark:bg-surface-panel/95`,style:W,role:`listbox`,"aria-label":`Commands`,"aria-activedescendant":G,children:U})}),document.body),t[40]=U,t[41]=F,t[42]=W,t[43]=G,t[44]=K):K=t[44],K}),Xhe=(0,Z.memo)(function(e){let t=(0,Q.c)(39),{item:n,icon:r,selected:i,id:a,nameLine:o,descriptionLine:s,dimCategoryBadge:c,trailingBadge:l,disabled:d,disabledTooltip:f,onSelect:p}=e,m=n.description??``,h;t[0]===m?h=t[1]:(h=m.trim(),t[0]=m,t[1]=h);let g=h,_=g.length>0&&s!=null,v=g.length>0,y=n.description??``,b=n.category&&n.kind!==`skill`&&!c&&!(n.kind===`agent`&&l),x;t[2]===o?x=t[3]:(x=(0,$.jsx)(`span`,{className:`min-w-0 max-w-[min(12rem,46%)] shrink-0 truncate font-semibold text-fg`,children:o}),t[2]=o,t[3]=x);let S;t[4]!==n.category||t[5]!==b?(S=b?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-normal leading-none text-fg-muted`,children:n.category}):null,t[4]=n.category,t[5]=b,t[6]=S):S=t[6];let C;t[7]!==s||t[8]!==_?(C=_?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-normal leading-tight text-fg-muted`,children:s}):null,t[7]=s,t[8]=_,t[9]=C):C=t[9];let w;t[10]!==x||t[11]!==S||t[12]!==C?(w=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1`,children:[x,S,C]}),t[10]=x,t[11]=S,t[12]=C,t[13]=w):w=t[13];let T=w,E=d?`cursor-not-allowed opacity-50 text-fg-muted`:i?`cursor-pointer bg-surface-hover text-fg`:`cursor-pointer text-fg-subtle hover:bg-surface-hover/80`,D;t[14]===E?D=t[15]:(D=u(`flex w-full min-w-0 items-center gap-1.5 px-2.5 py-1 text-left text-xs leading-4`,E),t[14]=E,t[15]=D);let O=D,k;t[16]!==d||t[17]!==p?(k=e=>{d||e.pointerType===`mouse`&&e.button!==0||(e.preventDefault(),p())},t[16]=d,t[17]=p,t[18]=k):k=t[18];let A=k,j;t[19]===r?j=t[20]:(j=(0,$.jsx)(`span`,{className:`shrink-0 [&_svg]:align-middle`,children:r}),t[19]=r,t[20]=j);let M;t[21]!==j||t[22]!==T||t[23]!==l?(M=(0,$.jsxs)($.Fragment,{children:[j,T,l]}),t[21]=j,t[22]=T,t[23]=l,t[24]=M):M=t[24];let N=M,P=d&&f?f:v?y:null,F=d||void 0,I;t[25]!==a||t[26]!==A||t[27]!==O||t[28]!==N||t[29]!==i||t[30]!==F?(I=(0,$.jsx)(`div`,{id:a,role:`option`,"aria-selected":i,"aria-disabled":F,tabIndex:-1,className:O,onPointerDown:A,children:N}),t[25]=a,t[26]=A,t[27]=O,t[28]=N,t[29]=i,t[30]=F,t[31]=I):I=t[31];let L=I;if(P!==null){let e;t[32]===L?e=t[33]:(e=(0,$.jsx)(V$,{asChild:!0,children:L}),t[32]=L,t[33]=e);let n;t[34]===P?n=t[35]:(n=(0,$.jsx)(H$,{children:(0,$.jsx)(U$,{side:`right`,align:`start`,sideOffset:8,collisionPadding:12,className:`!z-[10000] max-h-[min(12rem,40vh)] max-w-sm overflow-y-auto rounded-md border border-edge bg-surface-panel px-2 py-1.5 text-left text-[11px] leading-snug text-fg shadow-lg select-text [max-width:min(20rem,90vw)]`,"data-slash-palette-tooltip":``,children:(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:P})})}),t[34]=P,t[35]=n);let r;return t[36]!==e||t[37]!==n?(r=(0,$.jsxs)(B$,{delayDuration:0,children:[e,n]}),t[36]=e,t[37]=n,t[38]=r):r=t[38],r}return L}),x8=20,Zhe=200,S8=`xopc.composer.inputHistory.v2`,Qhe=`xopc.composer.inputHistory:`;function C8(){try{return globalThis.localStorage===void 0?null:globalThis.localStorage}catch{return null}}function w8(){return{version:2,sessions:{}}}function T8(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).slice(0,x8):[]}function $he(e){if(!e)return w8();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return w8();let n=t.sessions;if(!n||typeof n!=`object`||Array.isArray(n))return w8();let r={};for(let[e,t]of Object.entries(n)){let n=e.trim();if(!n||!t||typeof t!=`object`||Array.isArray(t))continue;let i=T8(t.items);if(i.length===0)continue;let a=t.updatedAt;r[n]={updatedAt:typeof a==`number`&&Number.isFinite(a)?a:0,items:i}}return{version:2,sessions:r}}catch{return w8()}}function E8(e){let t=$he(e.getItem(S8)),n=[];for(let r=0;r<e.length;r++){let i=e.key(r);if(!i?.startsWith(Qhe))continue;let a=i.slice(27).trim();if(a){n.push(i);try{let n=T8(JSON.parse(e.getItem(i)??`null`));if(n.length===0||t.sessions[a])continue;t.sessions[a]={updatedAt:0,items:n}}catch{}}}return{store:t,legacyKeys:n}}function ege(e){let t=[];for(let[n,r]of Object.entries(e.sessions)){let e=T8(r.items);e.length!==0&&t.push([n,{updatedAt:Number.isFinite(r.updatedAt)?r.updatedAt:0,items:e}])}return{version:2,sessions:Object.fromEntries(t.sort((e,t)=>t[1].updatedAt-e[1].updatedAt).slice(0,Zhe))}}function tge(e){let t=Math.max(0,...Object.values(e.sessions).map(e=>e.updatedAt));return Math.max(Date.now(),t+1)}function D8(e,t,n=[]){e.setItem(S8,JSON.stringify(ege(t)));for(let t of n)e.removeItem(t)}function nge(e){let t=e?.trim(),n=C8();if(!t||!n)return[];try{let{store:e,legacyKeys:r}=E8(n);return r.length>0&&D8(n,e,r),e.sessions[t]?.items.slice(0,x8)??[]}catch{return[]}}function rge(e,t){let n=e?.trim(),r=t.trim(),i=C8();if(!(!n||!r||!i))try{let{store:e,legacyKeys:t}=E8(i),a=e.sessions[n]?.items??[],o=tge(e),s=[r,...a].slice(0,x8);e.sessions[n]={updatedAt:o,items:a[0]===r?a:s},D8(i,e,t)}catch{}}function ige(e){let t=(0,Q.c)(17),{sessionKey:n,editorRef:r,valueRef:i,resetEditor:a,onWireInput:o}=e,s=(0,Z.useRef)(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{s.current=null},t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{l()},t[1]=u):u=t[1];let d;t[2]===n?d=t[3]:(d=[n,l],t[2]=n,t[3]=d),(0,Z.useEffect)(u,d);let f;t[4]===n?f=t[5]:(f=e=>{rge(n,e),l()},t[4]=n,t[5]=f);let p=f,m;t[6]===o?m=t[7]:(m=(e,t)=>{s.current=null,o(e,t)},t[6]=o,t[7]=m);let h=m,g;t[8]!==r||t[9]!==a||t[10]!==n||t[11]!==i?(g=e=>{let t=n?.trim();if(!t)return!1;let o=nge(t);if(o.length===0)return!1;let c=s.current,l=r.current,u=l?O6(l):0,d=i.current;if(e===`up`){if(c==null){if(u!==0)return!1;s.current={index:0,stash:d};let e=o[0];return e?(a({nextText:e,caretOffset:e.length,focus:!0}),!0):!1}if(c.index>=o.length-1)return!0;c.index+=1;let e=o[c.index];return e?(a({nextText:e,caretOffset:e.length,focus:!0}),!0):!1}if(c==null)return!1;if(--c.index,c.index<0){let e=c.stash;return s.current=null,a({nextText:e,caretOffset:e.length,focus:!0}),!0}let f=o[c.index];return f?(a({nextText:f,caretOffset:f.length,focus:!0}),!0):!1},t[8]=r,t[9]=a,t[10]=n,t[11]=i,t[12]=g):g=t[12];let _=g,v;return t[13]!==p||t[14]!==h||t[15]!==_?(v={onUserTextCommitted:p,onWireInputClearWalk:h,tryInputHistoryArrow:_},t[13]=p,t[14]=h,t[15]=_,t[16]=v):v=t[16],v}function O8(e){if(e.voiceActive)return e.cancelVoiceInput(),null;let t=e.getTextValue();return!t.trim()&&e.getAttachmentCount()===0?null:{text:t,attachments:e.wireAttachmentsPayload()}}function age(e){let{chat:t,runBusy:n,voiceActive:r,cancelVoiceInput:i,editingFollowUpId:a,getTextValue:o,getAttachmentCount:s,wireAttachmentsPayload:c,getThinkingLevel:l,onSend:u,onAddPendingFollowUp:d,onSteeringInterrupt:f,onCommitEditFollowUp:p,onPendingFollowUpRemove:m,pendingFollowUpsCount:h,resetEditor:g,clearAttachments:_,clearEditFollowUpRef:v,onUserTextCommitted:y}=e,b={getTextValue:o,getAttachmentCount:s,wireAttachmentsPayload:c};return{send:(0,Z.useCallback)(()=>{if(n)return;let e=O8({voiceActive:r,cancelVoiceInput:i,...b});e&&(u(e.text,e.attachments.length>0?e.attachments:void 0,l()),y?.(e.text),g(),_())},[n,r,i,u,l,y,g,_,o,s,c]),flushSteeringDraft:(0,Z.useCallback)(async()=>{if(!n&&h===0)return;let e=O8({voiceActive:r,cancelVoiceInput:i,...b});if(e){if(a){p(a,e.text,e.attachments.length>0?e.attachments:void 0,l()),y?.(e.text),v(),g(),_();return}if(d){if(h>=10){FK(`warning`,t.followUpQueueMaxReached,{max:10});return}await d(e.text,e.attachments.length>0?e.attachments:void 0),y?.(e.text),g(),_()}}},[n,r,i,a,h,d,p,l,t.followUpQueueMaxReached,v,y,g,_,o,s,c]),interruptDraft:(0,Z.useCallback)(()=>{if(!n||!f)return;let e=O8({voiceActive:r,cancelVoiceInput:i,...b});e&&(f(e.text,e.attachments.length>0?e.attachments:void 0),y?.(e.text),a&&(v(),m(a)),g(),_())},[n,r,i,a,m,f,y,v,g,_,o,s,c])}}function k8(e){let{chat:t}=e,[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(null),s=(0,Z.useRef)(n);s.current=n;let l=(0,Z.useCallback)(()=>{r([])},[]),u=(0,Z.useCallback)(e=>{r(t=>t.filter((t,n)=>n!==e))},[]),d=(0,Z.useCallback)(()=>s.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]);return{attachments:n,setAttachments:r,attachmentsRef:s,isDragging:i,setIsDragging:a,fileInputRef:o,processFiles:(0,Z.useCallback)(async e=>{if(e.length===0)return;let n=10-s.current.length;if(n<=0){FK(`warning`,t.maxAttachmentsReached,{max:10});return}let i=e.slice(0,n);e.length>i.length&&FK(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-i.length});let{loadAttachment:a}=await c(async()=>{let{loadAttachment:e}=await import(`./attachment-load-qOtBYR6Y.js`);return{loadAttachment:e}},__vite__mapDeps([93,20])),o=(await Promise.all(i.map(async e=>{if(e.size>33554432)return FK(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:HI(PL)}),null;try{return await a(e,e.name)}catch{return FK(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null);r(e=>[...e,...o])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]),removeAttachment:u,clearAttachments:l,wireAttachmentsPayload:d}}function oge(e){let t=(0,Q.c)(6),{active:n,anchors:r,ignoreSelector:i,onDismiss:a}=e,o,s;t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a?(o=()=>{if(!n)return;let e=e=>{let t=e.target;if(t instanceof Node){for(let e of r){let n=e.current;if(n&&n.contains(t))return}i&&t instanceof Element&&t.closest(i)||a()}};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},s=[n,r,i,a],t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s):(o=t[4],s=t[5]),(0,Z.useEffect)(o,s)}var A8=20,sge=`xopc.atMention.recent:`;function j8(e){return`${sge}${e.trim()}`}function M8(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(j8(t));if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0).slice(0,A8):[]}catch{return[]}}function cge(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=[r,...M8(n).filter(e=>e!==r)].slice(0,A8);localStorage.setItem(j8(n),JSON.stringify(e))}catch{}}var lge=150,uge=15;function N8(e,t){let n=e.length,r=Math.min(Math.max(t,0),n);if(r<1)return null;let i=e.slice(0,r),a=i.match(/@([^\s]*)$/);if(!a||a.index===void 0)return null;let o=a.index;if(o>0&&/[a-zA-Z0-9_]/.test(e[o-1]))return null;let s=i.slice(o);return/^@(file|doc|url|symbol):/.test(s)?null:{start:o,end:r,query:a[1]??``}}function dge(e){let t=e.trim();return t.length>0&&t.endsWith(`/`)&&!/^https?:\/\//i.test(t)}function P8(e){return e.replace(/\/+$/,``).trim()}function fge(e){let t=e.replace(/\/+$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n<=0?``:t.slice(0,n)}function pge(e,t){return t===0?0:Math.min(e,t-1)}function mge(e,t,n){let[r,i]=(0,Z.useState)(0),a=(0,Z.useMemo)(()=>n.precomputedAtRange===void 0?n.isComposing||n.slashPaletteOpen?null:N8(e,t):n.isComposing||n.slashPaletteOpen?null:n.precomputedAtRange,[e,t,n.slashPaletteOpen,n.isComposing,n.precomputedAtRange]),o=a!==null,[s]=XQ(o?a?.query??``:``,lge),c=o?s:``,l=n.sessionKey?.trim()??``,u=lP(async()=>{if(!l)return[];if(dge(c)){let e=P8(c),t=(await Zle(e,{sessionKey:l})).map(e=>({name:e.name,relativePath:e.path,isDirectory:e.isDirectory}));return e?[{name:`..`,relativePath:``,isDirectory:!0,isBrowseUp:!0},...t]:t}let e=await F4(c,{sessionKey:l,limit:uge}),t=M8(l),n=[],r=new Set(e.map(e=>e.relativePath));for(let e of t){if(r.has(e))continue;r.add(e);let t=e.replace(/\/$/,``).split(`/`).pop()??e;if(n.push({name:t,relativePath:e,isDirectory:e.endsWith(`/`),isRecent:!0}),n.length>=5)break}return[...n,...e]},[c,l],{enabled:o&&!!l,initial:[],errorData:[]}),d=o?u.data:[],f=o?u.loading:!1,p=o&&u.error!=null?u.error instanceof Error?u.error.message:String(u.error):null,m=a?.start,h=a?.end,g=`${m??``}:${h??``}:${c}`,_=(0,Z.useRef)(g);_.current!==g&&(_.current=g,r!==0&&i(0));let v=pge(r,d.length),y=(0,Z.useCallback)(e=>{d.length!==0&&i(t=>e===`down`?(t+1)%d.length:(t-1+d.length)%d.length)},[d.length]);return{open:o,atRange:a,items:d,selectedIndex:v,query:a?.query??``,loading:f,error:p,onNavigate:y,setSelectedIndex:i}}function hge(e){let{sessionKey:t,editorValue:n,editorCursor:r,isComposing:i,runBusy:a,thinkingLevel:o,editorRef:s,valueRef:c,resetEditor:l,clearAttachments:u,onSend:d,onUserTextCommitted:f,onChatAgentChange:p,currentAgentId:m,onUnavailableSkill:h,onReviewLauncher:g,onAddPendingFollowUp:_,onAbort:v,pendingFollowUpsCount:y,maxPendingFollowUps:b,commandPalettePanelRef:x}=e,S=(0,Z.useMemo)(()=>N8(n,r),[n,r]),C=Ahe(n,r,{suppress:S!=null,isComposing:i,currentAgentId:m}),w=mge(n,r,{sessionKey:t,slashPaletteOpen:C.open,isComposing:i,precomputedAtRange:S}),T=C.open||w.open||S!=null,E=(0,Z.useCallback)(()=>({slashRange:C.slashRange,runBusy:a,pendingFollowUpsCount:y,maxPendingFollowUps:b,thinkingLevel:o,editor:{valueRef:c,resetEditor:l},attachments:{clearAttachments:u},callbacks:{onSend:d,onUserTextCommitted:f,onChatAgentChange:p,onAddPendingFollowUp:_,onAbort:v,onUnavailableSkill:h,onReviewLauncher:g}}),[C.slashRange,a,y,b,o,c,l,u,d,f,p,_,v,h,g]),D=(0,Z.useCallback)(e=>{yhe(e,E())},[E]),O=(0,Z.useCallback)((e,n)=>{let r=w.atRange;if(!r)return;if(e.isBrowseUp){let e=fge(P8(r.query)),t=`@${e?`${e}/`:``}`;l({nextText:p8(c.current,r.start,r.end,t),caretOffset:r.start+t.length,focus:!0});return}let i=e.isDirectory&&!e.relativePath.endsWith(`/`)?`${e.relativePath}/`:e.relativePath,a=`@file:${g6(i)}`;t&&!e.isDirectory&&cge(t,i.replace(/\/$/,``));let o=a+(n?.stayOpen?` @`:` `);l({nextText:p8(c.current,r.start,r.end,o),caretOffset:r.start+o.length,focus:!0})},[w.atRange,t,c,l]),k=(0,Z.useRef)(C.slashRange);k.current=C.slashRange;let A=c,j=(0,Z.useCallback)(()=>{let e=k.current;if(!e)return;let t=A.current;l({nextText:t.slice(0,e.start)+t.slice(e.end),caretOffset:e.start})},[l,A]),M=(0,Z.useMemo)(()=>[s,x],[s,x]);oge({active:C.open,anchors:M,ignoreSelector:`[data-slash-palette-tooltip]`,onDismiss:j});let N=(0,Z.useRef)(w);N.current=w;let P=(0,Z.useRef)(C);P.current=C;let F=(0,Z.useRef)(i);F.current=i;let I=(0,Z.useRef)(D);I.current=D;let L=(0,Z.useRef)(O);L.current=O;let R=(0,Z.useRef)({runBusy:a,pendingFollowUpsCount:y,maxPendingFollowUps:b});R.current={runBusy:a,pendingFollowUpsCount:y,maxPendingFollowUps:b};let z=(0,Z.useMemo)(()=>({name:`at-mention`,isActive:()=>{let e=N.current;return e.open&&e.atRange!=null&&!F.current},handleKey:e=>{let t=N.current;if(!t.atRange)return!1;if(e.key===`Escape`){e.preventDefault();let n=t.atRange,r=A.current;return l({nextText:p8(r,n.start,n.end,``),caretOffset:n.start,focus:!0}),!0}if(t.items.length===0)return!1;if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let n=t.items[t.selectedIndex];return n&&L.current(n,{stayOpen:e.shiftKey}),!0}return!1}}),[l,A]),B=(0,Z.useMemo)(()=>({name:`slash-palette`,isActive:()=>P.current.open&&!F.current,handleKey:e=>{let t=P.current;if(t.items.length>0){if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){e.preventDefault();let n=t.items[t.selectedIndex];return!n||v8(n,R.current)||I.current(n),!0}}if(e.key===`Escape`){e.preventDefault();let n=t.slashRange;if(n){let e=A.current;l({nextText:p8(e,n.start,n.end,``),caretOffset:n.start,focus:!0})}return!0}return!1}}),[l,A]);return{palette:C,atPicker:w,shouldSyncSelection:T,adapters:(0,Z.useMemo)(()=>[z,B],[z,B]),applyPalette:D,applyAtMention:O}}function gge(e,t){let n=t.trim();if(!n)return e;let r=e.trim();return r?`${r} ${n}`:n}var F8=u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,lA.transition,lA.press,lA.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),_ge=(0,Z.memo)(function(e){let t=(0,Q.c)(30),{phase:n,elapsedLabel:r,disabled:i,chat:a,onCancel:o,onConfirm:s}=e,c=n===`transcribing`,l=a.voiceInput,d=!c&&`animate-pulse`,f;t[0]===d?f=t[1]:(f=u(`size-2 shrink-0 rounded-full bg-red-500`,d),t[0]=d,t[1]=f);let p;t[2]===f?p=t[3]:(p=(0,$.jsx)(`span`,{className:f,"aria-hidden":!0}),t[2]=f,t[3]=p);let m=c?a.voiceTranscribing:a.voiceRecordingStatus,h;t[4]===m?h=t[5]:(h=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg-muted`,children:m}),t[4]=m,t[5]=h);let g=c?``:r,_;t[6]===g?_=t[7]:(_=(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums text-sm text-fg-subtle`,"aria-live":`polite`,children:g}),t[6]=g,t[7]=_);let v=i||c,y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Sk,{className:`size-4`}),t[8]=y):y=t[8];let b;t[9]!==a.voiceInputCancel||t[10]!==o||t[11]!==v?(b=(0,$.jsx)(`button`,{type:`button`,className:F8,disabled:v,title:a.voiceInputCancel,"aria-label":a.voiceInputCancel,onClick:o,children:y}),t[9]=a.voiceInputCancel,t[10]=o,t[11]=v,t[12]=b):b=t[12];let x;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(x=u(F8,`text-fg`),t[13]=x):x=t[13];let S=i||c,C;t[14]===c?C=t[15]:(C=c?(0,$.jsx)(Fv,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Iu,{className:`size-4`}),t[14]=c,t[15]=C);let w;t[16]!==a.voiceInputConfirm||t[17]!==s||t[18]!==S||t[19]!==C?(w=(0,$.jsx)(`button`,{type:`button`,className:x,disabled:S,title:a.voiceInputConfirm,"aria-label":a.voiceInputConfirm,onClick:s,children:C}),t[16]=a.voiceInputConfirm,t[17]=s,t[18]=S,t[19]=C,t[20]=w):w=t[20];let T;t[21]!==b||t[22]!==w?(T=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[b,w]}),t[21]=b,t[22]=w,t[23]=T):T=t[23];let E;return t[24]!==a.voiceInput||t[25]!==T||t[26]!==p||t[27]!==h||t[28]!==_?(E=(0,$.jsxs)(`div`,{className:`flex min-h-10 w-full items-center gap-2 py-2`,role:`region`,"aria-label":l,children:[p,h,_,T]}),t[24]=a.voiceInput,t[25]=T,t[26]=p,t[27]=h,t[28]=_,t[29]=E):E=t[29],E});async function vge(e){return BI(await e.arrayBuffer())}async function yge(e,t){let n=await vge(e),r=await J(X(`/api/voice/transcribe`),{method:`POST`,body:JSON.stringify({audio:n,mimeType:t})});if(!r.payload)throw Error(`Missing transcription payload`);return r.payload}var I8=null;async function bge(){if(I8!==null)return I8;try{I8=(await J(X(`/api/status`))).voice?.sttAvailable===!0}catch{I8=!1}return I8}function xge(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function Sge(e){let{disabled:t,chat:n,onTranscript:r}=e,[i,a]=(0,Z.useState)(`idle`),[o,s]=(0,Z.useState)(0),c=(0,Z.useRef)(null),l=(0,Z.useRef)([]),u=(0,Z.useRef)(null),d=(0,Z.useRef)(``),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!1),m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(r);g.current=r;let _=(0,Z.useCallback)(()=>{h.current!=null&&(clearInterval(h.current),h.current=null)},[]),v=(0,Z.useCallback)(()=>{u.current?.getTracks().forEach(e=>e.stop()),u.current=null},[]),y=(0,Z.useCallback)(()=>{_(),v(),c.current=null,l.current=[],m.current=null,p.current=!1,f.current=!1,s(0),a(`idle`)},[_,v]),b=(0,Z.useCallback)(()=>{let e=c.current;e&&e.state!==`inactive`?e.stop():y(),c.current=null},[y]),x=(0,Z.useCallback)(()=>{f.current=!0,p.current=!1,b()},[b]),S=(0,Z.useCallback)(async(e,t)=>{a(`transcribing`);let r=new Blob(e,{type:t||`audio/webm`});if(r.size<32){FK(`warning`,n.voiceTranscribeEmpty),y();return}try{let e=await yge(r,r.type||t||`audio/webm`),i=(e.refined??e.raw).trim();if(!i){FK(`warning`,n.voiceTranscribeEmpty),y();return}g.current(i),y()}catch(e){let t=e instanceof Error?e.message:String(e);t.includes(`STT is not configured`)||t.includes(`503`)?FK(`error`,n.voiceSttNotConfigured):FK(`error`,n.voiceTranscribeFailed),y()}},[y,n.voiceSttNotConfigured,n.voiceTranscribeEmpty,n.voiceTranscribeFailed]),C=(0,Z.useCallback)(()=>{_(),h.current=setInterval(()=>{let e=m.current;typeof e==`number`&&s(Math.max(0,(performance.now()-e)/1e3))},200)},[_]),w=(0,Z.useCallback)(async()=>{if(!(t||i!==`idle`)){if(!await bge()){FK(`error`,n.voiceSttNotConfigured);return}f.current=!1,p.current=!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});u.current=e;let t=MediaRecorder.isTypeSupported(`audio/webm;codecs=opus`)?`audio/webm;codecs=opus`:MediaRecorder.isTypeSupported(`audio/webm`)?`audio/webm`:``;d.current=t;let n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);l.current=[],n.ondataavailable=e=>{e.data.size>0&&l.current.push(e.data)},n.onstop=()=>{(async()=>{try{let e=l.current;l.current=[];let t=d.current||n.mimeType;if(f.current){y();return}if(p.current){p.current=!1,await S(e,t);return}y()}finally{v()}})()},c.current=n,m.current=performance.now(),s(0),n.start(250),a(`recording`),C()}catch{y(),FK(`error`,n.voiceMicDenied)}}},[t,y,n.voiceMicDenied,n.voiceSttNotConfigured,i,S,C,v]),T=(0,Z.useCallback)(()=>{i===`recording`&&(p.current=!0,f.current=!1,a(`transcribing`),_(),b())},[i,b,_]);return(0,Z.useEffect)(()=>()=>{f.current=!0,p.current=!1,b()},[b]),{phase:i,voiceActive:i!==`idle`,elapsedLabel:xge(o),startVoiceInput:w,cancelVoiceInput:x,confirmVoiceInput:T}}function L8(e){return/^[A-Za-z0-9._/@:-]+$/.test(e)?e:JSON.stringify(e)}function R8(e,t){let n=t?.trim();return n?`${e} --instructions ${L8(n)}`:e}function Cge(e){if(e.preset===`base`){if(!e.baseBranch?.trim())throw Error(`Missing base branch.`);return R8(`/review --base ${L8(e.baseBranch.trim())}`,e.instructions)}if(e.preset===`commit`){if(!e.commitSha?.trim())throw Error(`Missing commit SHA.`);return R8(`/review --commit ${L8(e.commitSha.trim())}`,e.instructions)}return e.preset,R8(`/review --uncommitted`,e.instructions)}async function wge(e){let t=await Y(X(`/api/review/context?${new URLSearchParams({sessionKey:e}).toString()}`)),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(te(t.status,t.statusText,n.error?.message));return n.payload}function Tge(e,t){let n=e?.status;if(!n)return``;if(n.isClean)return t.statusClean;let r=[];return n.changedFiles>0&&r.push(t.statusChanged.replace(`{{count}}`,String(n.changedFiles))),n.untrackedFiles>0&&r.push(t.statusUntracked.replace(`{{count}}`,String(n.untrackedFiles))),r.join(`, `)}function Ege(e,t){let n=t.trim().toLowerCase(),r=[...(e?.branches??[]).filter(e=>!e.current)].sort((t,n)=>t.name===e?.defaultBaseBranch&&n.name!==e.defaultBaseBranch?-1:n.name===e?.defaultBaseBranch&&t.name!==e.defaultBaseBranch?1:t.name.localeCompare(n.name));return n?r.filter(e=>e.name.toLowerCase().includes(n)):r}function Dge(e,t){let n=t.trim().toLowerCase(),r=e?.commits??[];return n?r.filter(e=>`${e.sha} ${e.shortSha} ${e.subject}`.toLowerCase().includes(n)):r}function z8(e){let t=(0,Q.c)(15),{icon:n,title:r,description:i,disabled:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=u(`flex min-h-16 w-full items-center gap-3 rounded-lg border border-edge bg-surface-panel px-3 py-2.5 text-left`,`hover:border-accent/45 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:cursor-not-allowed disabled:opacity-50`,lA.transition),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(`span`,{className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:n}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:r}),t[3]=r,t[4]=l);let d;t[5]===i?d=t[6]:(d=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:i}),t[5]=i,t[6]=d);let f;t[7]!==l||t[8]!==d?(f=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,d]}),t[7]=l,t[8]=d,t[9]=f):f=t[9];let p;return t[10]!==a||t[11]!==o||t[12]!==c||t[13]!==f?(p=(0,$.jsxs)(`button`,{type:`button`,disabled:a,className:s,onClick:o,children:[c,f]}),t[10]=a,t[11]=o,t[12]=c,t[13]=f,t[14]=p):p=t[14],p}function Oge(e){let t=(0,Q.c)(89),{open:n,sessionKey:r,disabled:i,chat:a,onClose:o,onSendCommand:s}=e,c=a.reviewLauncher,[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(`presets`),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),x;t[0]!==c.noSession||t[1]!==r?(x=()=>{if(!r){u(null),m(c.noSession);return}f(!0),m(null),wge(r).then(e=>u(e)).catch(e=>{u(null),m(e instanceof Error?e.message:String(e))}).finally(()=>f(!1))},t[0]=c.noSession,t[1]=r,t[2]=x):x=t[2];let S=x,C,w;t[3]!==S||t[4]!==n?(C=()=>{n&&(g(`presets`),v(``),b(``),S())},w=[S,n],t[3]=S,t[4]=n,t[5]=C,t[6]=w):(C=t[5],w=t[6]),(0,Z.useEffect)(C,w);let T;t[7]!==l||t[8]!==_?(T=Ege(l,_),t[7]=l,t[8]=_,t[9]=T):T=t[9];let E=T,D;t[10]!==l||t[11]!==_?(D=Dge(l,_),t[10]=l,t[11]=_,t[12]=D):D=t[12];let O=D,k;t[13]!==l||t[14]!==c?(k=Tge(l,c),t[13]=l,t[14]=c,t[15]=k):k=t[15];let A=k,j;t[16]!==y||t[17]!==o||t[18]!==s?(j=(e,t)=>{s(Cge({preset:e,baseBranch:t?.branch,commitSha:t?.commit,instructions:y})),o()},t[16]=y,t[17]=o,t[18]=s,t[19]=j):j=t[19];let M=j,N=h===`base`?c.baseTitle:h===`commit`?c.commitTitle:h===`custom`?c.customTitle:c.title,P;t[20]===o?P=t[21]:(P=e=>!e&&o(),t[20]=o,t[21]=P);let F;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(RN,{className:`xopc-dialog-overlay fixed inset-0 z-[120] bg-scrim backdrop-blur-[1px]`}),t[22]=F):F=t[22];let I;t[23]!==c.back||t[24]!==h?(I=h===`presets`?null:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":c.back,onClick:()=>{g(`presets`),v(``)},children:(0,$.jsx)(to,{className:`size-4`})}),t[23]=c.back,t[24]=h,t[25]=I):I=t[25];let L;t[26]===N?L=t[27]:(L=(0,$.jsx)(BN,{className:`truncate text-sm font-semibold text-fg`,children:N}),t[26]=N,t[27]=L);let R=l?.cwd??c.description,z;t[28]===R?z=t[29]:(z=(0,$.jsx)(VN,{className:`truncate text-xs text-fg-muted`,children:R}),t[28]=R,t[29]=z);let B;t[30]!==L||t[31]!==z?(B=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[L,z]}),t[30]=L,t[31]=z,t[32]=B):B=t[32];let V;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(Sk,{className:`size-4`}),t[33]=V):V=t[33];let H;t[34]!==c.close||t[35]!==o?(H=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":c.close,onClick:o,children:V}),t[34]=c.close,t[35]=o,t[36]=H):H=t[36];let U;t[37]!==I||t[38]!==B||t[39]!==H?(U=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-3`,children:[I,B,H]}),t[37]=I,t[38]=B,t[39]=H,t[40]=U):U=t[40];let W;t[41]!==E||t[42]!==O||t[43]!==l||t[44]!==i||t[45]!==p||t[46]!==y||t[47]!==S||t[48]!==d||t[49]!==c.customDescription||t[50]!==c.customPlaceholder||t[51]!==c.defaultBadge||t[52]!==c.errorTitle||t[53]!==c.loading||t[54]!==c.localBadge||t[55]!==c.noBranches||t[56]!==c.noCommits||t[57]!==c.presetBase||t[58]!==c.presetBaseDescription||t[59]!==c.presetBaseDescriptionNoDefault||t[60]!==c.presetCommit||t[61]!==c.presetCommitDescription||t[62]!==c.presetCustom||t[63]!==c.presetCustomDescription||t[64]!==c.presetUncommitted||t[65]!==c.remoteBadge||t[66]!==c.retry||t[67]!==c.searchBranches||t[68]!==c.searchCommits||t[69]!==_||t[70]!==M||t[71]!==A||t[72]!==h?(W=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:d?(0,$.jsxs)(`div`,{className:`flex h-full min-h-56 items-center justify-center text-sm text-fg-muted`,children:[(0,$.jsx)(Lb,{className:`mr-2 size-4 animate-spin`}),c.loading]}):p?(0,$.jsxs)(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.errorTitle}),(0,$.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:p}),(0,$.jsxs)(tA,{type:`button`,className:`mt-4 h-9 rounded-lg`,variant:`secondary`,onClick:S,children:[(0,$.jsx)(Lb,{className:`size-4`}),c.retry]})]}):h===`presets`?(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(z8,{icon:(0,$.jsx)(iv,{className:`size-4`}),title:c.presetBase,description:l?.defaultBaseBranch?c.presetBaseDescription.replace(`{{branch}}`,l.defaultBaseBranch):c.presetBaseDescriptionNoDefault,disabled:i,onClick:()=>g(`base`)}),(0,$.jsx)(z8,{icon:(0,$.jsx)(kv,{className:`size-4`}),title:c.presetUncommitted,description:A,disabled:i,onClick:()=>M(`uncommitted`)}),(0,$.jsx)(z8,{icon:(0,$.jsx)(av,{className:`size-4`}),title:c.presetCommit,description:c.presetCommitDescription.replace(`{{count}}`,String(l?.commits.length??0)),disabled:i,onClick:()=>g(`commit`)}),(0,$.jsx)(z8,{icon:(0,$.jsx)(kv,{className:`size-4`}),title:c.presetCustom,description:c.presetCustomDescription,disabled:i,onClick:()=>g(`custom`)})]}):h===`base`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(B8,{value:_,placeholder:c.searchBranches,onChange:v}),(0,$.jsx)(`div`,{className:`grid gap-1`,children:E.length===0?(0,$.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noBranches}):E.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center justify-between gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:i,onClick:()=>M(`base`,{branch:e.name}),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.name===l?.defaultBaseBranch?c.defaultBadge:e.remote?c.remoteBadge:c.localBadge})]},e.name))})]}):h===`commit`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(B8,{value:_,placeholder:c.searchCommits,onChange:v}),(0,$.jsx)(`div`,{className:`grid gap-1`,children:O.length===0?(0,$.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noCommits}):O.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:i,onClick:()=>M(`commit`,{commit:e.sha}),children:[(0,$.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:e.shortSha}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.subject}),e.date?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.date.slice(0,10)}):null]},e.sha))})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`textarea`,{className:`h-40 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-disabled focus:border-accent focus:ring-2 focus:ring-accent/25`,value:y,placeholder:c.customPlaceholder,onChange:e=>b(e.target.value)}),(0,$.jsx)(`div`,{className:`text-xs text-fg-muted`,children:c.customDescription})]})}),t[41]=E,t[42]=O,t[43]=l,t[44]=i,t[45]=p,t[46]=y,t[47]=S,t[48]=d,t[49]=c.customDescription,t[50]=c.customPlaceholder,t[51]=c.defaultBadge,t[52]=c.errorTitle,t[53]=c.loading,t[54]=c.localBadge,t[55]=c.noBranches,t[56]=c.noCommits,t[57]=c.presetBase,t[58]=c.presetBaseDescription,t[59]=c.presetBaseDescriptionNoDefault,t[60]=c.presetCommit,t[61]=c.presetCommitDescription,t[62]=c.presetCustom,t[63]=c.presetCustomDescription,t[64]=c.presetUncommitted,t[65]=c.remoteBadge,t[66]=c.retry,t[67]=c.searchBranches,t[68]=c.searchCommits,t[69]=_,t[70]=M,t[71]=A,t[72]=h,t[73]=W):W=t[73];let G;t[74]!==i||t[75]!==c.cancel||t[76]!==c.runReview||t[77]!==o||t[78]!==M||t[79]!==h?(G=h===`custom`?(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[(0,$.jsx)(tA,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:o,children:c.cancel}),(0,$.jsx)(tA,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,disabled:i,onClick:()=>M(`custom`),children:c.runReview})]}):null,t[74]=i,t[75]=c.cancel,t[76]=c.runReview,t[77]=o,t[78]=M,t[79]=h,t[80]=G):G=t[80];let K;t[81]!==U||t[82]!==W||t[83]!==G?(K=(0,$.jsxs)(LN,{children:[F,(0,$.jsxs)(zN,{className:`fixed left-1/2 top-1/2 z-[121] flex h-[min(86vh,34rem)] w-[min(100vw-2rem,40rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[U,W,G]})]}),t[81]=U,t[82]=W,t[83]=G,t[84]=K):K=t[84];let q;return t[85]!==n||t[86]!==K||t[87]!==P?(q=(0,$.jsx)(FN,{open:n,onOpenChange:P,children:K}),t[85]=n,t[86]=K,t[87]=P,t[88]=q):q=t[88],q}function B8(e){let t=(0,Q.c)(7),{value:n,placeholder:r,onChange:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Qx,{className:`size-4 shrink-0 text-fg-muted`}),t[0]=a):a=t[0];let o;t[1]===i?o=t[2]:(o=e=>i(e.target.value),t[1]=i,t[2]=o);let s;return t[3]!==r||t[4]!==o||t[5]!==n?(s=(0,$.jsxs)(`label`,{className:`flex h-9 items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/25`,children:[a,(0,$.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent outline-none placeholder:text-fg-disabled`,value:n,placeholder:r,onChange:o})]}),t[3]=r,t[4]=o,t[5]=n,t[6]=s):s=t[6],s}var kge=(0,Z.memo)(function({disabled:e,sending:t,streaming:n,sessionKey:r,sessionManager:i,canSelectWorkingDirectory:a,thinkingLevel:o,showThinkingSelector:s,onThinkingChange:c,onSend:l,onAbort:d,onAddPendingFollowUp:f,onSteeringInterrupt:p,pendingFollowUps:h,editingFollowUpId:g,onBeginEditFollowUp:v,onCancelEditFollowUp:y,onCommitEditFollowUp:b,onPendingFollowUpRemove:x,onPendingFollowUpMove:S,onPendingFollowUpReorder:C,onPendingFollowUpSteer:w,steeringFollowUpId:T,welcomeDraftSeed:E,sessionModel:D,showModelSelector:O,onModelChange:k,modelDisabled:A,contextUsageMessages:j,onChatAgentChange:M,currentAgentId:N}){let P=m(_(e=>e.language));(0,Z.useEffect)(()=>{D4()},[]);let F=(0,Z.useRef)(!1),I=(0,Z.useRef)(null),L=(0,Z.useRef)(null),R=(0,Z.useRef)(null),z=(0,Z.useRef)(!1),[B,V]=(0,Z.useState)(!1),H=(0,Z.useRef)(l),U=(0,Z.useRef)(o);H.current=l,U.current=o;let W=k8({chat:P.chat}),G=(0,Z.useCallback)(()=>{W.clearAttachments()},[W.clearAttachments]),K=(0,Z.useCallback)(e=>{let t=e.availability?.status===`agent-denied`?P.chat.commandPalette.skillAgentDeniedReason:P.chat.commandPalette.skillDisabledReason,n=P6(P.chat.commandPalette.skillUnavailableMessage,{name:e.name,agent:N||`main`,reason:t});if(e.availability?.status===`agent-denied`&&window.confirm(`${n}\n\n${P.chat.commandPalette.skillAddToAllowlistConfirm}`)){Kle(N,e.name).catch(e=>{window.alert(e instanceof Error?e.message:String(e))});return}window.alert(n)},[N,P.chat.commandPalette]),q=ime({disabled:e,autoFocusKey:r,welcomeDraftSeed:E,onExternalTextReplace:G,shouldSyncSelectionRef:F}),{onUserTextCommitted:ee,onWireInputClearWalk:J,tryInputHistoryArrow:te}=ige({sessionKey:r,editorRef:q.editorRef,valueRef:q.valueRef,resetEditor:q.resetEditor,onWireInput:q.onWireInput}),Y=t||n;z.current=Y;let ne=(0,Z.useCallback)(()=>{z.current||V(!0)},[]),re=(0,Z.useCallback)(e=>{H.current(e,void 0,U.current),ee?.(e)},[ee]),X=hge({sessionKey:r,editorValue:q.value,editorCursor:q.cursor,isComposing:q.isComposing,runBusy:Y,thinkingLevel:o,editorRef:q.editorRef,valueRef:q.valueRef,resetEditor:q.resetEditor,clearAttachments:W.clearAttachments,onSend:l,onUserTextCommitted:ee,onChatAgentChange:M,currentAgentId:N,onUnavailableSkill:K,onReviewLauncher:ne,onAddPendingFollowUp:f,onAbort:d,pendingFollowUpsCount:h.length,maxPendingFollowUps:10,commandPalettePanelRef:I});F.current=X.shouldSyncSelection;let ie=(0,Z.useMemo)(()=>q.value.length,[q.value]),ae=Sge({disabled:e,chat:P.chat,onTranscript:e=>{let t=q.valueRef.current,n=gge(t,e);q.resetEditor({nextText:n,caretOffset:n.length,focus:!0})}}),oe=(0,Z.useCallback)(()=>{R.current=null},[]),se=age({chat:P.chat,runBusy:Y,voiceActive:ae.voiceActive,cancelVoiceInput:ae.cancelVoiceInput,editingFollowUpId:g,getTextValue:()=>q.valueRef.current,getAttachmentCount:()=>W.attachmentsRef.current.length,wireAttachmentsPayload:W.wireAttachmentsPayload,getThinkingLevel:()=>U.current,onSend:l,onAddPendingFollowUp:f,onSteeringInterrupt:p,onCommitEditFollowUp:b,onPendingFollowUpRemove:x,pendingFollowUpsCount:h.length,resetEditor:()=>{q.resetEditor()},clearAttachments:W.clearAttachments,clearEditFollowUpRef:oe,onUserTextCommitted:ee});(0,Z.useLayoutEffect)(()=>{if(!g){R.current&&=(W.clearAttachments(),q.resetEditor(),null);return}if(g===R.current)return;let e=h.find(e=>e.id===g);if(!e){y();return}R.current=g,e.thinkingLevel!=null&&s&&c(e.thinkingLevel),W.setAttachments(uhe(e.attachments??[])),q.resetEditor({nextText:e.text,focus:!0})},[W.clearAttachments,W.setAttachments,q.resetEditor,g,y,c,h,s]);let ce=(0,Z.useCallback)(e=>{v(e)},[v]),le=(0,Z.useRef)({});le.current={adapters:X.adapters,send:se.send,runBusy:Y,pendingFollowUpsCount:h.length,flushSteeringDraft:se.flushSteeringDraft,interruptDraft:se.interruptDraft,editingFollowUpId:g,onCancelEditFollowUp:y,attachmentsLen:W.attachments.length,isComposing:q.isComposing,valueRef:q.valueRef,adjustHeight:q.adjustHeight,editorRef:q.editorRef,tryInputHistoryArrow:te};let ue=Y,de=!!q.value.trim()||W.attachments.length>0,fe=de&&!!p;return(0,$.jsxs)(`div`,{className:u(`relative flex min-h-0 w-full flex-col overflow-hidden rounded-xl bg-surface-panel shadow-surface ring-1 ring-inset ring-edge dark:bg-surface-panel/60 dark:shadow-none`,W.isDragging&&`ring-2 ring-accent ring-inset`),onDragOver:e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),W.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&W.setIsDragging(!1)},onDrop:async e=>{e.preventDefault(),W.setIsDragging(!1);let t=e.dataTransfer?.files;t?.length&&await W.processFiles(Array.from(t))},children:[W.isDragging?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-accent-soft/80 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,children:P.chat.dropFiles}):null,h.length>0?(0,$.jsx)(`div`,{className:`max-h-[min(30vh,11rem)] shrink-0 overflow-y-auto overflow-x-hidden border-b border-edge-subtle/80 [scrollbar-gutter:stable] dark:border-edge-subtle/70`,children:(0,$.jsx)(ome,{items:h,disabled:e,editingFollowUpId:g,onEditInComposer:ce,onRemove:x,onMove:S,onReorder:C,onSteer:w,steeringBusyId:T})}):null,(0,$.jsx)(j6,{attachments:W.attachments,topPadded:h.length>0,onRemove:W.removeAttachment}),(0,$.jsxs)(`div`,{className:`flex min-h-0 shrink-0 flex-col`,children:[(0,$.jsx)(`input`,{ref:L,type:`file`,multiple:!0,accept:l6,className:`hidden`,onChange:async e=>{let t=e.target.files;t&&await W.processFiles(Array.from(t)),e.target.value=``}}),(0,$.jsxs)(`div`,{className:u(`relative px-4 pb-0 pt-1`,W.attachments.length>0&&`pt-2`),children:[(0,$.jsx)(ghe,{open:X.atPicker.open,anchorRef:q.editorRef,items:X.atPicker.items,selectedIndex:X.atPicker.selectedIndex,loading:X.atPicker.loading,query:X.atPicker.query,noResults:X.atPicker.error??P.chat.atMention.noResults,sessionKey:r,recentLabel:P.chat.atMention.recentBadge,ariaLabel:P.chat.atMention.placeholder,shiftHint:P.chat.atMention.shiftHint,onSelectItem:(e,t)=>X.applyAtMention(e,{stayOpen:t?.shiftKey===!0})}),(0,$.jsx)(Yhe,{open:X.palette.open,anchorRef:q.editorRef,panelRef:I,items:X.palette.loadError?[]:X.palette.items,selectedIndex:X.palette.selectedIndex,noResults:X.palette.loadError??P.chat.commandPalette.noResults,grouped:X.palette.loadError?!1:X.palette.grouped,skillRowCount:X.palette.loadError?0:X.palette.skillRowCount,commandRowCount:X.palette.loadError?0:X.palette.commandRowCount,query:X.palette.query,skillsLabel:P.chat.commandPalette.skillsSection,commandsLabel:P.chat.commandPalette.commandsSection,agentsLabel:P.chat.commandPalette.agentsSection,groupedHasSkills:X.palette.loadError?!1:X.palette.groupedHasSkills,groupedHasCommands:X.palette.loadError?!1:X.palette.groupedHasCommands,groupedHasAgents:X.palette.loadError?!1:X.palette.groupedHasAgents,groupedSkillsShowMoreLabel:X.palette.loadError||!X.palette.grouped?null:X.palette.groupedSkillsMoreCount>0?P6(P.chat.commandPalette.showGroupedMore,{count:X.palette.groupedSkillsMoreCount}):null,groupedCommandsShowMoreLabel:X.palette.loadError||!X.palette.grouped?null:X.palette.groupedCommandsMoreCount>0?P6(P.chat.commandPalette.showGroupedMore,{count:X.palette.groupedCommandsMoreCount}):null,groupedAgentsShowMoreLabel:X.palette.loadError||!X.palette.grouped?null:X.palette.groupedAgentsMoreCount>0?P6(P.chat.commandPalette.showGroupedMore,{count:X.palette.groupedAgentsMoreCount}):null,onExpandSkills:X.palette.expandGroupedSkills,onExpandCommands:X.palette.expandGroupedCommands,onExpandAgents:X.palette.expandGroupedAgents,currentAgentId:N,currentBadgeLabel:P.chat.commandPalette.currentBadge,runBusy:Y,pendingFollowUpsCount:h.length,maxPendingFollowUps:10,queueBadgeLabel:P.chat.commandPalette.queueBadge,queueFullBadgeLabel:P.chat.commandPalette.queueFullBadge,queueFullTooltip:P.chat.commandPalette.queueFullTooltip,skillUnavailableLabel:P.chat.commandPalette.skillUnavailableBadge,skillAgentDeniedLabel:P.chat.commandPalette.skillAgentDeniedBadge,onSelectItem:X.applyPalette}),ae.voiceActive?(0,$.jsx)(_ge,{phase:ae.phase,elapsedLabel:ae.elapsedLabel,disabled:e,chat:P.chat,onCancel:ae.cancelVoiceInput,onConfirm:ae.confirmVoiceInput}):(0,$.jsx)(ame,{editorRef:q.editorRef,disabled:e,placeholder:ue?g?P.chat.inputPlaceholderSteeringEdit:P.chat.inputPlaceholderSteering:P.chat.inputPlaceholder,onWireInput:J,adjustHeight:q.adjustHeight,processFiles:W.processFiles,setIsComposing:q.setIsComposing,kbdRef:le,chatMessages:P.chat})]}),(0,$.jsx)(che,{sessionKey:r,sessionManager:i,disabled:e,sending:t,streaming:n,canSelectWorkingDirectory:a,runBusy:ue,chat:P.chat,hasDraft:de,showSteeringInterrupt:fe,attachmentCount:W.attachments.length,maxAttachments:10,onPickFiles:()=>L.current?.click(),onOpenReviewLauncher:ne,thinkingLevel:o,showThinkingSelector:s,onThinkingChange:c,voiceActive:ae.voiceActive,onStartVoiceInput:ae.startVoiceInput,onSend:se.send,onAbort:d,onInterrupt:se.interruptDraft,sessionModel:D,showModelSelector:O,onModelChange:k,modelDisabled:A,contextUsageMessages:j,composerDraftChars:ie})]}),(0,$.jsx)(Oge,{open:B,sessionKey:r,disabled:e||ue,chat:P.chat,onClose:()=>V(!1),onSendCommand:re})]})});function Age(e,t){let n=e.createdAt;if(!Number.isFinite(n)||n<=0)return 0;let r=typeof e.lastTurnAt==`number`&&Number.isFinite(e.lastTurnAt)?e.lastTurnAt:0,i=e.status===`done`&&r>=n?r:t;return Math.max(0,i-n)}function jge(e,t){let n=Math.max(0,Math.floor(e/1e3));if(n<60)return t===`zh`?`${n}秒`:`${n}s`;let r=Math.floor(n/60),i=n%60;if(r<60)return t===`zh`?`${r}分${String(i).padStart(2,`0`)}秒`:`${r}m ${i}s`;let a=Math.floor(r/60),o=r%60;return t===`zh`?`${a}小时${o}分`:`${a}h ${o}m`}function Mge(e){let t=(0,Q.c)(52),{goal:n,canEditChecklist:r,mutationBusy:i,t:a,onAction:o,onChecklist:s}=e,c=i||n.status!==`active`,l;t[0]===o?l=t[1]:(l=()=>void o(`pause`),t[0]=o,t[1]=l);let d;t[2]!==a.pause||t[3]!==c||t[4]!==l?(d=(0,$.jsx)(tA,{type:`button`,variant:`primary`,className:`h-8 px-3 text-xs`,disabled:c,onClick:l,children:a.pause}),t[2]=a.pause,t[3]=c,t[4]=l,t[5]=d):d=t[5];let f=i||n.status!==`paused`&&n.status!==`done`,p;t[6]===o?p=t[7]:(p=()=>void o(`resume`),t[6]=o,t[7]=p);let m;t[8]!==a.resume||t[9]!==f||t[10]!==p?(m=(0,$.jsx)(tA,{type:`button`,variant:`secondary`,className:`h-8 px-3 text-xs`,disabled:f,onClick:p,children:a.resume}),t[8]=a.resume,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(h=u(`flex h-8 cursor-pointer list-none items-center rounded-md border border-edge bg-surface-panel px-2.5 text-xs text-fg-muted`,`marker:hidden [&::-webkit-details-marker]:hidden`,`hover:bg-surface-hover hover:text-fg`),t[12]=h):h=t[12];let g;t[13]!==a.moreActions||t[14]!==a.moreHint?(g=(0,$.jsx)(`summary`,{className:h,title:a.moreHint,children:a.moreActions}),t[13]=a.moreActions,t[14]=a.moreHint,t[15]=g):g=t[15];let _;t[16]===o?_=t[17]:(_=()=>void o(`restart`),t[16]=o,t[17]=_);let v;t[18]!==i||t[19]!==a.restart||t[20]!==_?(v=(0,$.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-fg hover:bg-surface-hover`,disabled:i,onClick:_,children:a.restart}),t[18]=i,t[19]=a.restart,t[20]=_,t[21]=v):v=t[21];let y=i||!r,b;t[22]===s?b=t[23]:(b=()=>void s({op:`reset`}),t[22]=s,t[23]=b);let x;t[24]!==a.resetChecklist||t[25]!==y||t[26]!==b?(x=(0,$.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-fg hover:bg-surface-hover`,disabled:y,onClick:b,children:a.resetChecklist}),t[24]=a.resetChecklist,t[25]=y,t[26]=b,t[27]=x):x=t[27];let S;t[28]===o?S=t[29]:(S=()=>void o(`clear`),t[28]=o,t[29]=S);let C;t[30]!==i||t[31]!==a.clear||t[32]!==S?(C=(0,$.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-destructive hover:bg-surface-hover`,disabled:i,onClick:S,children:a.clear}),t[30]=i,t[31]=a.clear,t[32]=S,t[33]=C):C=t[33];let w;t[34]===o?w=t[35]:(w=()=>void o(`detach`),t[34]=o,t[35]=w);let T;t[36]!==i||t[37]!==a.detach||t[38]!==w?(T=(0,$.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-1.5 text-left text-xs text-fg hover:bg-surface-hover`,disabled:i,onClick:w,children:a.detach}),t[36]=i,t[37]=a.detach,t[38]=w,t[39]=T):T=t[39];let E;t[40]!==v||t[41]!==x||t[42]!==C||t[43]!==T?(E=(0,$.jsxs)(`div`,{className:`absolute right-0 z-30 mt-1 min-w-[11rem] rounded-md border border-edge bg-surface-panel py-1 shadow-surface`,children:[v,x,C,T]}),t[40]=v,t[41]=x,t[42]=C,t[43]=T,t[44]=E):E=t[44];let D;t[45]!==E||t[46]!==g?(D=(0,$.jsxs)(`details`,{className:`group relative`,children:[g,E]}),t[45]=E,t[46]=g,t[47]=D):D=t[47];let O;return t[48]!==D||t[49]!==d||t[50]!==m?(O=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[d,m,D]}),t[48]=D,t[49]=d,t[50]=m,t[51]=O):O=t[51],O}function Nge(e){return e!==null&&e.status!==`archived`}function V8(e){let t=e.checklist??[];return{total:t.length,done:t.filter(e=>e.status===`completed`||e.status===`impossible`).length}}function Pge(e){let t=Math.max(0,e.maxTurns),n=Math.max(0,e.turnsUsed);return{used:n,total:t,percent:t>0?Math.min(100,100*n/t):0}}function Fge(e){let{done:t,total:n}=V8(e);return{done:t,total:n,percent:n>0?Math.min(100,100*t/n):0}}function Ige(e,t){return t?`agent_running`:e.status===`paused`||e.status===`blocked`||e.status===`needs_input`?`paused`:e.status===`done`?`done`:e.lastVerdict?`judge_recently_completed`:`idle`}function H8(e,t){return e===`agent_running`?t.phaseAgentRunning:e===`paused`?t.phasePaused:e===`done`?t.phaseDone:e===`judge_recently_completed`?t.phaseJudged:t.missionHeading}function U8(e,t){return e.status===`active`?t.statusActive:e.status===`paused`||e.status===`blocked`||e.status===`needs_input`?t.statusPaused:e.status===`done`?t.statusDone:e.status}function W8(e,t){return e===`done`?t.verdictDone:e===`continue`?t.verdictContinue:e===`decompose`?t.verdictDecompose:e===`blocked`||e===`needs_input`?t.statusPaused:e??``}function G8(e,t){return e?W8(e,t):``}function K8(e,t){return e===`active`?t.statusActive:e===`paused`?t.statusPaused:e===`done`?t.statusDone:e}function q8(e){return`xopc:goalBannerCollapsed:${e}`}function Lge(e){return e.status===`completed`?`✓`:e.status===`impossible`?`!`:`○`}function Rge(e){let t={pending:[],completed:[],impossible:[]};return e.forEach((e,n)=>{t[e.status].push({...e,index1Based:n+1})}),t}function zge(e){let t=(0,Q.c)(42),{goal:n,canEdit:r,mutationBusy:i,t:a,onMutate:o}=e,[s,c]=(0,Z.useState)(``),l,d,f;if(t[0]!==r||t[1]!==n.checklist||t[2]!==i||t[3]!==o||t[4]!==a.checklistEmpty||t[5]!==a.checklistHeading||t[6]!==a.completedGroup||t[7]!==a.evidenceLabel||t[8]!==a.impossibleGroup||t[9]!==a.judgeGenerated||t[10]!==a.markBlocked||t[11]!==a.markDone||t[12]!==a.pendingGroup||t[13]!==a.removeItem||t[14]!==a.userAdded){let e=n.checklist??[],s=Rge(e),c;t[18]!==r||t[19]!==i||t[20]!==o||t[21]!==a.evidenceLabel||t[22]!==a.judgeGenerated||t[23]!==a.markBlocked||t[24]!==a.markDone||t[25]!==a.removeItem||t[26]!==a.userAdded?(c=(e,t)=>t.length===0?null:(0,$.jsxs)(`section`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:[(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(`span`,{children:t.length})]}),(0,$.jsx)(`ul`,{className:`space-y-1.5`,children:t.map(e=>(0,$.jsx)(`li`,{className:`rounded-md border border-transparent px-1.5 py-1 hover:border-edge/60 hover:bg-surface-panel/70`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 w-4 shrink-0 text-center text-fg-muted`,title:e.status,children:Lge(e)}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5 text-[10px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`rounded-full bg-surface-panel px-1.5 py-0.5`,children:e.addedBy===`user`?a.userAdded:a.judgeGenerated}),e.evidenceSummary?(0,$.jsxs)(`span`,{className:`min-w-0 break-words`,children:[a.evidenceLabel,`: `,e.evidenceSummary]}):null]})]}),r&&e.status===`pending`?(0,$.jsxs)(`span`,{className:`flex shrink-0 flex-wrap justify-end gap-0.5`,children:[(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`h-7 px-1.5 text-[11px] text-accent`,disabled:i,onClick:()=>void o({op:`mark`,index:e.index1Based,status:`completed`}),children:a.markDone}),(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`h-7 px-1.5 text-[11px] text-fg-muted`,disabled:i,onClick:()=>void o({op:`mark`,index:e.index1Based,status:`impossible`}),children:a.markBlocked}),(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`h-7 px-1.5 text-[11px] text-destructive`,disabled:i,onClick:()=>void o({op:`remove`,index:e.index1Based}),children:a.removeItem})]}):null]})},`${e.index1Based}-${e.text.slice(0,24)}`))})]}),t[18]=r,t[19]=i,t[20]=o,t[21]=a.evidenceLabel,t[22]=a.judgeGenerated,t[23]=a.markBlocked,t[24]=a.markDone,t[25]=a.removeItem,t[26]=a.userAdded,t[27]=c):c=t[27];let u=c;l=`rounded-xl bg-surface-muted/70 px-2.5 py-2 dark:bg-surface-muted/40`,t[28]===a.checklistHeading?d=t[29]:(d=(0,$.jsx)(`p`,{className:`mb-1.5 text-[11px] font-medium uppercase tracking-wide text-fg-muted`,children:a.checklistHeading}),t[28]=a.checklistHeading,t[29]=d),f=e.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.checklistEmpty}):(0,$.jsxs)(`div`,{className:`max-h-48 space-y-2 overflow-y-auto pr-0.5 text-xs`,children:[u(a.pendingGroup,s.pending),u(a.completedGroup,s.completed),u(a.impossibleGroup,s.impossible)]}),t[0]=r,t[1]=n.checklist,t[2]=i,t[3]=o,t[4]=a.checklistEmpty,t[5]=a.checklistHeading,t[6]=a.completedGroup,t[7]=a.evidenceLabel,t[8]=a.impossibleGroup,t[9]=a.judgeGenerated,t[10]=a.markBlocked,t[11]=a.markDone,t[12]=a.pendingGroup,t[13]=a.removeItem,t[14]=a.userAdded,t[15]=l,t[16]=d,t[17]=f}else l=t[15],d=t[16],f=t[17];let p;t[30]!==r||t[31]!==i||t[32]!==s||t[33]!==o||t[34]!==a.addCriterion||t[35]!==a.addCriterionPlaceholder?(p=r?(0,$.jsxs)(`div`,{className:`mt-2 flex gap-1.5`,children:[(0,$.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:a.addCriterionPlaceholder,className:u(`min-w-0 flex-1 rounded-md border border-edge bg-surface-muted px-2 py-1.5 text-xs text-fg`,`placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`),onKeyDown:e=>{e.key===`Enter`&&s.trim()&&(e.preventDefault(),Promise.resolve(o({op:`add`,text:s.trim()})).then(()=>c(``)))}}),(0,$.jsx)(tA,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:i||!s.trim(),onClick:()=>void Promise.resolve(o({op:`add`,text:s.trim()})).then(()=>c(``)),children:a.addCriterion})]}):null,t[30]=r,t[31]=i,t[32]=s,t[33]=o,t[34]=a.addCriterion,t[35]=a.addCriterionPlaceholder,t[36]=p):p=t[36];let m;return t[37]!==l||t[38]!==d||t[39]!==f||t[40]!==p?(m=(0,$.jsxs)(`div`,{className:l,children:[d,f,p]}),t[37]=l,t[38]=d,t[39]=f,t[40]=p,t[41]=m):m=t[41],m}function Bge(e){let t=(0,Q.c)(23),{goal:n,agentBusy:r,pillTitle:i,phase:a,statusShort:o,turnsShort:s,clLine:c,t:l,onExpand:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=u(`pointer-events-none absolute z-30`,`right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(0.5rem,env(safe-area-inset-top,0px))]`,`sm:right-[max(1.25rem,env(safe-area-inset-right,0px))] xl:right-[max(1.5rem,env(safe-area-inset-right,0px))]`),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=u(`pointer-events-auto flex h-11 min-w-11 max-w-[min(calc(100vw-1.5rem),16rem)] items-center gap-1.5 rounded-full border border-edge/60 bg-surface-panel/95 px-2.5 py-1 text-left shadow-elevated backdrop-blur-sm`,`transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[1]=p):p=t[1];let m=`${i}${c?` · ${c}`:``}${n.lastVerdict?`\n${l.lastVerdict}: ${n.lastVerdict}`:``}${n.lastReason?`\n${l.lastReason}: ${n.lastReason}`:``}\n${n.title}`,h=l.expandAria,g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(rE,{className:`size-4 text-accent`,"aria-hidden":!0}),t[2]=g):g=t[2];let _;t[3]!==r||t[4]!==n.status?(_=(0,$.jsxs)(`span`,{className:`relative flex size-8 shrink-0 items-center justify-center rounded-full bg-surface-muted`,children:[g,r?(0,$.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 flex size-2.5 rounded-full border-2 border-surface-panel bg-accent motion-safe:animate-pulse`}):(0,$.jsx)(`span`,{className:u(`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-surface-panel`,n.status===`active`&&`bg-accent`,n.status===`paused`&&`bg-fg-muted`,n.status===`done`&&`bg-fg-muted`)})]}),t[3]=r,t[4]=n.status,t[5]=_):_=t[5];let v;t[6]!==a||t[7]!==l?(v=H8(a,l),t[6]=a,t[7]=l,t[8]=v):v=t[8];let y;t[9]!==o||t[10]!==v?(y=(0,$.jsxs)(`span`,{className:`block truncate text-[10px] font-medium leading-tight text-fg`,children:[v,` · `,o]}),t[9]=o,t[10]=v,t[11]=y):y=t[11];let b=c?`${s} · ${c}`:s,x;t[12]===b?x=t[13]:(x=(0,$.jsx)(`span`,{className:`block truncate text-[10px] leading-tight text-fg-muted`,children:b}),t[12]=b,t[13]=x);let S;t[14]!==x||t[15]!==y?(S=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 pr-0.5`,children:[y,x]}),t[14]=x,t[15]=y,t[16]=S):S=t[16];let C;return t[17]!==d||t[18]!==l.expandAria||t[19]!==S||t[20]!==m||t[21]!==_?(C=(0,$.jsx)(`div`,{className:`relative h-0 shrink-0 overflow-visible`,children:(0,$.jsx)(`div`,{className:f,children:(0,$.jsxs)(`button`,{type:`button`,className:p,title:m,"aria-label":h,onClick:d,children:[_,S]})})}),t[17]=d,t[18]=l.expandAria,t[19]=S,t[20]=m,t[21]=_,t[22]=C):C=t[22],C}function Vge(e){let t=(0,Q.c)(36),{goal:n,t:r}=e,[i,a]=(0,Z.useState)(!1);if(!(n.lastVerdict||n.lastReason||n.blockedReason))return null;let o;t[0]!==n.lastVerdict||t[1]!==r?(o=n.lastVerdict?W8(n.lastVerdict,r):``,t[0]=n.lastVerdict,t[1]=r,t[2]=o):o=t[2];let s=o,c=n.blockedReason||n.lastReason,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>a(Hge),t[3]=l):l=t[3];let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-panel text-accent`,children:(0,$.jsx)(Dx,{className:`size-3.5`,"aria-hidden":!0})}),t[4]=u):u=t[4];let d;t[5]===r.lastJudgementTitle?d=t[6]:(d=(0,$.jsx)(`span`,{className:`font-medium`,children:r.lastJudgementTitle}),t[5]=r.lastJudgementTitle,t[6]=d);let f;t[7]===s?f=t[8]:(f=s?(0,$.jsx)(`span`,{className:`rounded-full border border-edge px-1.5 py-0.5 text-[10px] text-fg-muted`,children:s}):null,t[7]=s,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5 text-fg`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===c?m=t[13]:(m=c?(0,$.jsx)(`span`,{className:`mt-0.5 line-clamp-2 block text-fg-muted`,children:c}):null,t[12]=c,t[13]=m);let h;t[14]!==p||t[15]!==m?(h=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16];let g=i?r.hideDetails:r.showDetails,_;t[17]===g?_=t[18]:(_=(0,$.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-muted`,children:g}),t[17]=g,t[18]=_);let v;t[19]!==_||t[20]!==h?(v=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full min-w-0 items-start gap-2 text-left`,onClick:l,children:[u,h,_]}),t[19]=_,t[20]=h,t[21]=v):v=t[21];let y;t[22]!==n.blockedReason||t[23]!==n.judgeModelRef||t[24]!==n.lastReason||t[25]!==n.lastVerdict||t[26]!==i||t[27]!==r.judgeModel||t[28]!==r.lastReason||t[29]!==r.lastVerdict||t[30]!==r.pausedReason||t[31]!==s?(y=i?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1.5 rounded-lg border border-edge/70 bg-surface-panel px-2 py-1.5 text-fg-muted`,children:[n.lastVerdict?(0,$.jsxs)(`p`,{children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.lastVerdict,`:`]}),` `,s]}):null,n.lastReason?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap break-words`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.lastReason,`:`]}),` `,n.lastReason]}):null,n.blockedReason?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap break-words`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.pausedReason,`:`]}),` `,n.blockedReason]}):null,n.judgeModelRef?(0,$.jsxs)(`p`,{className:`break-words`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.judgeModel,`:`]}),` `,n.judgeModelRef]}):null]}):null,t[22]=n.blockedReason,t[23]=n.judgeModelRef,t[24]=n.lastReason,t[25]=n.lastVerdict,t[26]=i,t[27]=r.judgeModel,t[28]=r.lastReason,t[29]=r.lastVerdict,t[30]=r.pausedReason,t[31]=s,t[32]=y):y=t[32];let b;return t[33]!==v||t[34]!==y?(b=(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge/70 bg-surface-muted/45 px-2.5 py-2 text-xs dark:bg-surface-muted/25`,children:[v,y]}),t[33]=v,t[34]=y,t[35]=b):b=t[35],b}function Hge(e){return!e}function Uge(e){let t=(0,Q.c)(3),{goal:n,t:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Vge,{goal:n,t:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var Wge=new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),Gge=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});function Kge(e,t){let n=typeof e==`string`?new Date(e):e;return(t===`zh`?Wge:Gge).format(n)}function J8(e){let t=(0,Q.c)(23),{sessionKey:n,goal:r,language:i,t:a}=e,o;t[0]===n?o=t[1]:(o=async()=>(await i8(n,{limit:1})).runs,t[0]=n,t[1]=o);let s;t[2]!==r.lastTurnAt||t[3]!==r.lastVerdict||t[4]!==r.turnsUsed||t[5]!==n?(s=[n,r.turnsUsed,r.lastTurnAt,r.lastVerdict],t[2]=r.lastTurnAt,t[3]=r.lastVerdict,t[4]=r.turnsUsed,t[5]=n,t[6]=s):s=t[6];let c;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[7]=c):c=t[7];let l;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(l={initial:c,errorData:[]},t[8]=l):l=t[8];let{data:u,loading:d}=lP(o,s,l),f=u[0];if(!f&&!d)return null;let p;t[9]===a.latestRunTitle?p=t[10]:(p=(0,$.jsx)(`span`,{className:`font-medium uppercase tracking-wide`,children:a.latestRunTitle}),t[9]=a.latestRunTitle,t[10]=p);let m;t[11]!==i||t[12]!==f?(m=f?(0,$.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(f.at).toISOString(),children:Kge(f.at,i)}):null,t[11]=i,t[12]=f,t[13]=m):m=t[13];let h;t[14]!==p||t[15]!==m?(h=(0,$.jsxs)(`div`,{className:`mb-1 flex flex-wrap items-center justify-between gap-2 text-[10px] text-fg-muted`,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]!==f||t[18]!==a?(g=f?(0,$.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[auto_1fr_auto] sm:items-start`,children:[(0,$.jsx)(`div`,{className:`rounded-full border border-edge bg-surface-muted px-2 py-0.5 text-[10px] text-fg-muted`,children:a.runHistoryTurns.replace(`{{used}}`,String(f.turnsUsed)).replace(`{{max}}`,String(f.maxTurns))}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-fg`,children:[(0,$.jsx)(`span`,{children:G8(f.verdict,a)}),(0,$.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,$.jsx)(`span`,{children:K8(f.statusAfter,a)}),f.checklistProgress?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,$.jsx)(`span`,{children:a.checklistProgress.replace(`{{done}}`,String(f.checklistProgress.done)).replace(`{{total}}`,String(f.checklistProgress.total))})]}):null]}),f.reason?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-fg-muted`,children:f.reason}):null]}),(0,$.jsx)(`div`,{className:`text-[10px] text-accent sm:text-right`,children:f.willContinue?a.nextStepContinue:a.nextStepStop})]}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:a.runHistoryLoading}),t[17]=f,t[18]=a,t[19]=g):g=t[19];let _;return t[20]!==h||t[21]!==g?(_=(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge/70 bg-surface-panel px-2.5 py-2 text-xs`,children:[h,g]}),t[20]=h,t[21]=g,t[22]=_):_=t[22],_}function qge(e){let t=(0,Q.c)(20),{goal:n,t:r}=e,i;t[0]===n?i=t[1]:(i=Pge(n),t[0]=n,t[1]=i);let a=i,o;t[2]===n?o=t[3]:(o=Fge(n),t[2]=n,t[3]=o);let s=o,c=r.heading,l=n.status===`done`?`bg-accent`:`bg-accent/75`,d;t[4]===l?d=t[5]:(d=u(`h-full rounded-full transition-[width] duration-300`,l),t[4]=l,t[5]=d);let f=`${a.percent}%`,p;t[6]===f?p=t[7]:(p={width:f},t[6]=f,t[7]=p);let m;t[8]!==d||t[9]!==p?(m=(0,$.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-elevated`,children:(0,$.jsx)(`div`,{className:d,style:p})}),t[8]=d,t[9]=p,t[10]=m):m=t[10];let h;t[11]!==s.done||t[12]!==s.percent||t[13]!==s.total||t[14]!==r.checklistProgress?(h=s.total>0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:r.checklistProgress.replace(`{{done}}`,String(s.done)).replace(`{{total}}`,String(s.total))}),(0,$.jsx)(`div`,{className:`h-1 min-w-10 flex-1 overflow-hidden rounded-full bg-surface-muted`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-fg-muted/55 transition-[width] duration-300`,style:{width:`${s.percent}%`}})})]}):null,t[11]=s.done,t[12]=s.percent,t[13]=s.total,t[14]=r.checklistProgress,t[15]=h):h=t[15];let g;return t[16]!==r.heading||t[17]!==m||t[18]!==h?(g=(0,$.jsxs)(`div`,{className:`space-y-1.5`,"aria-label":c,children:[m,h]}),t[16]=r.heading,t[17]=m,t[18]=h,t[19]=g):g=t[19],g}var Jge=new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),Yge=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});function Xge(e,t){let n=typeof e==`string`?new Date(e):e;return(t===`zh`?Jge:Yge).format(n)}function Zge(e){let t=(0,Q.c)(25),{sessionKey:n,goal:r,language:i,t:a}=e,[o,s]=(0,Z.useState)(!1),c;t[0]===n?c=t[1]:(c=async()=>(await i8(n,{limit:40})).runs,t[0]=n,t[1]=c);let l;t[2]!==r.lastTurnAt||t[3]!==r.lastVerdict||t[4]!==r.turnsUsed||t[5]!==o||t[6]!==n?(l=[o,n,r.turnsUsed,r.lastTurnAt,r.lastVerdict],t[2]=r.lastTurnAt,t[3]=r.lastVerdict,t[4]=r.turnsUsed,t[5]=o,t[6]=n,t[7]=l):l=t[7];let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=[],t[9]=d):d=t[9];let f;t[10]===o?f=t[11]:(f={enabled:o,initial:u,errorData:d},t[10]=o,t[11]=f);let{data:p,loading:m,error:h}=lP(c,l,f),g=h==null?null:h instanceof Error?h.message:a.runHistoryLoadFailed,_;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>s(Qge),t[12]=_):_=t[12];let v;t[13]===a.runHistory?v=t[14]:(v=(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted underline-offset-2 hover:underline`,onClick:_,children:a.runHistory}),t[13]=a.runHistory,t[14]=v);let y;t[15]!==i||t[16]!==p||t[17]!==g||t[18]!==m||t[19]!==o||t[20]!==a?(y=o?(0,$.jsxs)(`div`,{className:`mt-1 max-h-52 space-y-2 overflow-y-auto rounded-md border border-edge bg-surface-panel p-2 text-xs text-fg-muted`,children:[m?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:a.runHistoryLoading}):null,g?(0,$.jsx)(`p`,{className:`text-destructive`,children:g}):null,!m&&!g&&p.length===0?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:a.runHistoryEmpty}):null,!m&&p.length>0?(0,$.jsx)(`ul`,{className:`space-y-2`,children:p.map(e=>(0,$.jsxs)(`li`,{className:`rounded-md border border-edge/80 bg-surface-muted/40 px-2 py-1.5 dark:bg-surface-muted/25`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-2 gap-y-0.5 text-[10px] text-fg-muted`,children:[(0,$.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(e.at).toISOString(),children:Xge(e.at,i)}),(0,$.jsx)(`span`,{children:a.runHistoryTurns.replace(`{{used}}`,String(e.turnsUsed)).replace(`{{max}}`,String(e.maxTurns))})]}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-fg`,children:[(0,$.jsx)(`span`,{children:G8(e.verdict,a)}),(0,$.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,$.jsx)(`span`,{children:K8(e.statusAfter,a)}),(0,$.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,$.jsx)(`span`,{children:e.willContinue?a.runHistoryContinue:a.runHistoryStop}),e.checklistProgress?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:`·`}),(0,$.jsx)(`span`,{children:a.checklistProgress.replace(`{{done}}`,String(e.checklistProgress.done)).replace(`{{total}}`,String(e.checklistProgress.total))})]}):null]}),e.reason?(0,$.jsxs)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-fg-muted`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[a.lastReason,`:`]}),` `,e.reason]}):null,e.assistantPreview?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-[10px] leading-snug text-fg-muted`,children:e.assistantPreview}):null]},e.id))}):null]}):null,t[15]=i,t[16]=p,t[17]=g,t[18]=m,t[19]=o,t[20]=a,t[21]=y):y=t[21];let b;return t[22]!==v||t[23]!==y?(b=(0,$.jsxs)(`div`,{children:[v,y]}),t[22]=v,t[23]=y,t[24]=b):b=t[24],b}function Qge(e){return!e}function $ge(e,t){switch(t.type){case`start`:return{busy:!0,error:null};case`error`:return{busy:!1,error:t.error};case`done`:return{busy:!1,error:null}}}function e_e(e){try{return sessionStorage.getItem(q8(e))===`1`}catch{return!1}}function Y8(e){let t=(0,Q.c)(3),{onTick:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{let e=window.setInterval(n,1e3);return()=>clearInterval(e)},i=[n],t[0]=n,t[1]=r,t[2]=i),(0,Z.useEffect)(r,i),null}function t_e(e){let t=(0,Q.c)(61),{goal:n,agentBusy:r,phase:i,statusShort:a,turnsShort:o,clLine:s,elapsedStr:c,mutationBusy:l,t:d,onAction:f,onOpenDetails:p,onMinimize:m}=e,h=n.status===`active`,g=n.status===`paused`||n.status===`done`||n.status===`blocked`||n.status===`needs_input`,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(rE,{className:`size-4 text-accent`,"aria-hidden":!0}),t[0]=_):_=t[0];let v=r&&`bg-accent motion-safe:animate-pulse`,y=!r&&n.status===`active`&&`bg-accent`,b=!r&&n.status!==`active`&&`bg-fg-muted`,x;t[1]!==v||t[2]!==y||t[3]!==b?(x=u(`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-surface-panel`,v,y,b),t[1]=v,t[2]=y,t[3]=b,t[4]=x):x=t[4];let S;t[5]===x?S=t[6]:(S=(0,$.jsxs)(`span`,{className:`relative flex size-8 shrink-0 items-center justify-center rounded-full bg-surface-muted`,children:[_,(0,$.jsx)(`span`,{className:x})]}),t[5]=x,t[6]=S);let C;t[7]!==i||t[8]!==d?(C=H8(i,d),t[7]=i,t[8]=d,t[9]=C):C=t[9];let w;t[10]===C?w=t[11]:(w=(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:C}),t[10]=C,t[11]=w);let T;t[12]===a?T=t[13]:(T=(0,$.jsx)(`span`,{className:`rounded-full border border-edge px-1.5 py-0.5`,children:a}),t[12]=a,t[13]=T);let E;t[14]===o?E=t[15]:(E=(0,$.jsx)(`span`,{children:o}),t[14]=o,t[15]=E);let D;t[16]===s?D=t[17]:(D=s?(0,$.jsx)(`span`,{children:s}):null,t[16]=s,t[17]=D);let O;t[18]!==c||t[19]!==n.status||t[20]!==d.elapsedLabel?(O=n.status!==`done`&&n.status!==`archived`?(0,$.jsxs)(`span`,{children:[d.elapsedLabel,`: `,(0,$.jsx)(`span`,{className:`text-fg`,children:c})]}):null,t[18]=c,t[19]=n.status,t[20]=d.elapsedLabel,t[21]=O):O=t[21];let k;t[22]!==E||t[23]!==D||t[24]!==O||t[25]!==w||t[26]!==T?(k=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-fg-muted`,children:[w,T,E,D,O]}),t[22]=E,t[23]=D,t[24]=O,t[25]=w,t[26]=T,t[27]=k):k=t[27];let A;t[28]===n.title?A=t[29]:(A=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-medium leading-tight text-fg`,children:n.title}),t[28]=n.title,t[29]=A);let j;t[30]!==k||t[31]!==A?(j=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 py-0.5`,children:[k,A]}),t[30]=k,t[31]=A,t[32]=j):j=t[32];let M;t[33]!==p||t[34]!==j||t[35]!==S?(M=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 rounded-lg text-left outline-none hover:bg-surface-hover/70 focus-visible:ring-2 focus-visible:ring-accent`,onClick:p,children:[S,j]}),t[33]=p,t[34]=j,t[35]=S,t[36]=M):M=t[36];let N=l||!h&&!g,P;t[37]!==h||t[38]!==f?(P=()=>void f(h?`pause`:`resume`),t[37]=h,t[38]=f,t[39]=P):P=t[39];let F;t[40]===h?F=t[41]:(F=h?(0,$.jsx)(ry,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(Py,{className:`size-3.5`,"aria-hidden":!0}),t[40]=h,t[41]=F);let I=h?d.pause:d.resume,L;t[42]!==N||t[43]!==P||t[44]!==F||t[45]!==I?(L=(0,$.jsxs)(tA,{type:`button`,variant:`ghost`,className:`hidden h-8 px-2 text-xs sm:inline-flex`,disabled:N,onClick:P,children:[F,I]}),t[42]=N,t[43]=P,t[44]=F,t[45]=I,t[46]=L):L=t[46];let R;t[47]!==p||t[48]!==d.details?(R=(0,$.jsx)(tA,{type:`button`,variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:p,children:d.details}),t[47]=p,t[48]=d.details,t[49]=R):R=t[49];let z;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(Gv,{className:`size-4`,"aria-hidden":!0}),t[50]=z):z=t[50];let B;t[51]!==m||t[52]!==d.collapseAria?(B=(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0 text-fg-muted hover:text-fg`,"aria-label":d.collapseAria,onClick:m,children:z}),t[51]=m,t[52]=d.collapseAria,t[53]=B):B=t[53];let V;t[54]!==L||t[55]!==R||t[56]!==B?(V=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[L,R,B]}),t[54]=L,t[55]=R,t[56]=B,t[57]=V):V=t[57];let H;return t[58]!==M||t[59]!==V?(H=(0,$.jsx)(`div`,{className:`shrink-0 w-full px-3 pt-1.5 sm:px-5 sm:pt-2 xl:px-6`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex min-h-12 w-full max-w-[var(--max-width-chat)] items-center gap-2 rounded-xl border border-edge bg-surface-panel px-2.5 py-2 shadow-surface sm:px-3`,children:[M,V]})}),t[58]=M,t[59]=V,t[60]=H):H=t[60],H}function X8(e){let t=(0,Q.c)(99),{open:n,sessionKey:r,goal:i,language:a,activeTab:o,canEditChecklist:s,mutationBusy:c,error:l,t:d,onOpenChange:f,onTabChange:p,onAction:m,onChecklist:h}=e,g;t[0]===d.tabOverview?g=t[1]:(g={id:`overview`,label:d.tabOverview},t[0]=d.tabOverview,t[1]=g);let _;t[2]===d.tabCriteria?_=t[3]:(_={id:`criteria`,label:d.tabCriteria},t[2]=d.tabCriteria,t[3]=_);let v;t[4]===d.tabRuns?v=t[5]:(v={id:`runs`,label:d.tabRuns},t[4]=d.tabRuns,t[5]=v);let y;t[6]!==g||t[7]!==_||t[8]!==v?(y=[g,_,v],t[6]=g,t[7]=_,t[8]=v,t[9]=y):y=t[9];let b=y,x=i.blockedReason||i.nextAction||d.noNextAction||``,S;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(RN,{className:`xopc-dialog-overlay fixed inset-0 z-[120] bg-scrim backdrop-blur-[1px]`}),t[10]=S):S=t[10];let C;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(rE,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=C):C=t[11];let w;t[12]===d.detailsTitle?w=t[13]:(w=(0,$.jsx)(BN,{className:`truncate text-sm font-semibold text-fg`,children:d.detailsTitle}),t[12]=d.detailsTitle,t[13]=w);let T;t[14]!==i||t[15]!==d?(T=U8(i,d),t[14]=i,t[15]=d,t[16]=T):T=t[16];let E;t[17]===T?E=t[18]:(E=(0,$.jsx)(`span`,{className:`rounded-full border border-edge px-1.5 py-0.5 text-[10px] text-fg-muted`,children:T}),t[17]=T,t[18]=E);let D;t[19]!==w||t[20]!==E?(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[C,w,E]}),t[19]=w,t[20]=E,t[21]=D):D=t[21];let O;t[22]===i.title?O=t[23]:(O=(0,$.jsx)(VN,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:i.title}),t[22]=i.title,t[23]=O);let k;t[24]!==D||t[25]!==O?(k=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[24]=D,t[25]=O,t[26]=k):k=t[26];let A=`/goals/${encodeURIComponent(i.id)}`,j;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(gh,{className:`size-3.5`,"aria-hidden":!0}),t[27]=j):j=t[27];let M;t[28]!==d.openFullGoal||t[29]!==A?(M=(0,$.jsx)(tA,{asChild:!0,type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,children:(0,$.jsxs)(Hi,{to:A,children:[j,d.openFullGoal]})}),t[28]=d.openFullGoal,t[29]=A,t[30]=M):M=t[30];let N;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(Sk,{className:`size-4`,"aria-hidden":!0}),t[31]=N):N=t[31];let P;t[32]===d.closeDetails?P=t[33]:(P=(0,$.jsx)(HN,{asChild:!0,children:(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`size-8 p-0`,"aria-label":d.closeDetails,children:N})}),t[32]=d.closeDetails,t[33]=P);let F;t[34]!==M||t[35]!==P?(F=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[M,P]}),t[34]=M,t[35]=P,t[36]=F):F=t[36];let I;t[37]!==k||t[38]!==F?(I=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[k,F]}),t[37]=k,t[38]=F,t[39]=I):I=t[39];let L=d.detailsTitle,R;t[40]!==o||t[41]!==p||t[42]!==b?(R=b.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":o===e.id,className:u(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,o===e.id?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>p(e.id),children:e.label},e.id)),t[40]=o,t[41]=p,t[42]=b,t[43]=R):R=t[43];let z;t[44]!==d.detailsTitle||t[45]!==R?(z=(0,$.jsx)(`div`,{className:`flex shrink-0 gap-1 border-b border-edge px-4 py-2`,role:`tablist`,"aria-label":L,children:R}),t[44]=d.detailsTitle,t[45]=R,t[46]=z):z=t[46];let B;t[47]!==o||t[48]!==i||t[49]!==a||t[50]!==r||t[51]!==x||t[52]!==d?(B=o===`overview`?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(kv,{className:`size-4 text-accent`,"aria-hidden":!0}),d.currentState]}),(0,$.jsx)(`p`,{className:u(`break-words text-sm`,i.blockedReason?`text-warning`:`text-fg`),children:x})]}),(0,$.jsx)(qge,{goal:i,t:d}),(0,$.jsx)(Uge,{goal:i,t:d}),(0,$.jsx)(J8,{sessionKey:r,goal:i,language:a,t:d})]}):null,t[47]=o,t[48]=i,t[49]=a,t[50]=r,t[51]=x,t[52]=d,t[53]=B):B=t[53];let V;t[54]!==o||t[55]!==s||t[56]!==i||t[57]!==c||t[58]!==h||t[59]!==d?(V=o===`criteria`?(0,$.jsx)(zge,{goal:i,canEdit:s,mutationBusy:c,t:d,onMutate:h}):null,t[54]=o,t[55]=s,t[56]=i,t[57]=c,t[58]=h,t[59]=d,t[60]=V):V=t[60];let H;t[61]!==o||t[62]!==i||t[63]!==a||t[64]!==r||t[65]!==d?(H=o===`runs`?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(J8,{sessionKey:r,goal:i,language:a,t:d}),(0,$.jsx)(Zge,{sessionKey:r,goal:i,language:a,t:d})]}):null,t[61]=o,t[62]=i,t[63]=a,t[64]=r,t[65]=d,t[66]=H):H=t[66];let U;t[67]===l?U=t[68]:(U=l?(0,$.jsx)(`p`,{className:`mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:l}):null,t[67]=l,t[68]=U);let W;t[69]!==B||t[70]!==V||t[71]!==H||t[72]!==U?(W=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:[B,V,H,U]}),t[69]=B,t[70]=V,t[71]=H,t[72]=U,t[73]=W):W=t[73];let G;t[74]!==i.maxTurns||t[75]!==i.turnsUsed||t[76]!==d.turns?(G=d.turns.replace(`{{used}}`,String(i.turnsUsed)).replace(`{{max}}`,String(i.maxTurns)),t[74]=i.maxTurns,t[75]=i.turnsUsed,t[76]=d.turns,t[77]=G):G=t[77];let K;t[78]===G?K=t[79]:(K=(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:G}),t[78]=G,t[79]=K);let q;t[80]!==s||t[81]!==i||t[82]!==c||t[83]!==m||t[84]!==h||t[85]!==d?(q=(0,$.jsx)(Mge,{goal:i,canEditChecklist:s,mutationBusy:c,t:d,onAction:m,onChecklist:h}),t[80]=s,t[81]=i,t[82]=c,t[83]=m,t[84]=h,t[85]=d,t[86]=q):q=t[86];let ee;t[87]!==K||t[88]!==q?(ee=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-edge px-4 py-3`,children:[K,q]}),t[87]=K,t[88]=q,t[89]=ee):ee=t[89];let J;t[90]!==I||t[91]!==z||t[92]!==W||t[93]!==ee?(J=(0,$.jsxs)(LN,{children:[S,(0,$.jsxs)(zN,{className:`fixed left-1/2 top-1/2 z-[121] flex h-[min(82vh,42rem)] w-[min(100vw-2rem,48rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[I,z,W,ee]})]}),t[90]=I,t[91]=z,t[92]=W,t[93]=ee,t[94]=J):J=t[94];let te;return t[95]!==f||t[96]!==n||t[97]!==J?(te=(0,$.jsx)(FN,{open:n,onOpenChange:f,children:J}),t[95]=f,t[96]=n,t[97]=J,t[98]=te):te=t[98],te}function n_e({sessionKey:e,streaming:t,sending:n}){let r=_(e=>e.language),i=m(r).chat.goal,[a,o]=(0,Z.useState)(()=>e_e(e)),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`overview`),[d,f]=(0,Z.useReducer)($ge,{busy:!1,error:null}),[p,h]=(0,Z.useState)(()=>Date.now()),g=(0,Z.useRef)(t||n),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!1),b=t||n;g.current&&!b&&(y.current=!0),g.current=b;let x=(0,Z.useCallback)(t=>{o(t);try{t?sessionStorage.setItem(q8(e),`1`):sessionStorage.removeItem(q8(e))}catch{}},[e]),{data:S,loading:C,error:w,setData:T}=lP(async()=>(await r8(e,{uiLocale:r})).goal,[e,r],{initial:null,errorData:null}),E=(0,Z.useCallback)(async()=>{try{T((await r8(e,{uiLocale:r})).goal)}catch(e){f({type:`error`,error:e instanceof Error?e.message:i.loadFailed})}},[e,r,T,i.loadFailed]),D=(0,Z.useEffectEvent)(()=>{E()});(0,Z.useEffect)(()=>{if(!S){v.current=null;return}let e=v.current;if(v.current={goalId:S.id,status:S.status},!(!e||e.goalId!==S.id||e.status===S.status)){if(S.status===`done`){re({type:`success`,title:`Goal completed`,message:S.title,duration:0});return}if(S.status===`blocked`){re({type:`warning`,title:`Goal blocked`,message:S.blockedReason||S.title,duration:0});return}S.status===`needs_input`&&re({type:`warning`,title:`Goal needs input`,message:S.blockedReason||S.title,duration:0})}},[S?.id,S?.status,S?.updatedAt,S?.title,S?.blockedReason]),(0,Z.useEffect)(()=>{let t=t=>{t.detail?.key===e&&D()};return window.addEventListener(`session-updated`,t),()=>window.removeEventListener(`session-updated`,t)},[e]),(0,Z.useLayoutEffect)(()=>{y.current&&(y.current=!1,D())});let O=(0,Z.useCallback)(()=>{h(Date.now())},[]),k=async t=>{f({type:`start`});try{await Ume(e,t,{uiLocale:r}),await E(),f({type:`done`})}catch(e){f({type:`error`,error:e instanceof Error?e.message:i.loadFailed})}},A=async t=>{f({type:`start`});try{await Kme(e,t,{uiLocale:r}),await E(),f({type:`done`})}catch(e){f({type:`error`,error:e instanceof Error?e.message:i.loadFailed})}},j=!C||w!=null||S!=null,M=d.error??(w==null?null:w instanceof Error?w.message:i.loadFailed);if(!j||!Nge(S))return null;let N=S,P=t||n,F=`${N.turnsUsed}/${N.maxTurns}`,I=U8(N,i),{total:L,done:R}=V8(N),z=L>0?i.checklistProgress.replace(`{{done}}`,String(R)).replace(`{{total}}`,String(L)):``,B=jge(Age(N,p),r),V=Ige(N,P),H=i.pillTitle.replace(`{{status}}`,I).replace(`{{turns}}`,F),U=N.status!==`done`&&N.status!==`archived`;if(a)return(0,$.jsxs)($.Fragment,{children:[U?(0,$.jsx)(Y8,{onTick:O}):null,(0,$.jsx)(Bge,{goal:N,agentBusy:P,pillTitle:H,phase:V,statusShort:I,turnsShort:F,clLine:z,t:i,onExpand:()=>c(!0)}),(0,$.jsx)(X8,{open:s,sessionKey:e,goal:N,language:r,activeTab:l,canEditChecklist:N.status===`active`||N.status===`paused`,mutationBusy:d.busy,error:M,t:i,onOpenChange:c,onTabChange:u,onAction:k,onChecklist:A})]});let W=N.status===`active`||N.status===`paused`;return(0,$.jsxs)($.Fragment,{children:[U?(0,$.jsx)(Y8,{onTick:O}):null,(0,$.jsx)(t_e,{goal:N,agentBusy:P,phase:V,statusShort:I,turnsShort:F,clLine:z,elapsedStr:B,mutationBusy:d.busy,t:i,onAction:k,onOpenDetails:()=>c(!0),onMinimize:()=>x(!0)}),(0,$.jsx)(X8,{open:s,sessionKey:e,goal:N,language:r,activeTab:l,canEditChecklist:W,mutationBusy:d.busy,error:M,t:i,onOpenChange:c,onTabChange:u,onAction:k,onChecklist:A})]})}function r_e(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(n_e,{...e},e.sessionKey),t[0]=e,t[1]=n),n}function i_e(e,t){let n=V4(e,t),r=H4(e,t);return`${e.id} ${n} ${r}`.toLowerCase()}function a_e(e,t,n){let r=t.trim().toLowerCase();if(!r)return e;let i=r.split(/\s+/).filter(Boolean);return e.filter(e=>{let t=i_e(e,n);return i.every(e=>t.includes(e))})}function o_e(e){let t=(0,Q.c)(56),{items:n,value:r,disabled:i,placeholder:a,searchPlaceholder:o,noMatches:s,compact:c,contentSide:l,contentAlign:d,className:f,onChange:p}=e,h=l===void 0?`bottom`:l,g=d===void 0?`end`:d,v=_(c_e),y;t[0]===v?y=t[1]:(y=m(v),t[0]=v,t[1]=y);let b=y.agentsSettings,[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(``),T;t[2]!==b||t[3]!==n||t[4]!==C?(T=a_e(n,C,b),t[2]=b,t[3]=n,t[4]=C,t[5]=T):T=t[5];let E=T,D,O,k;if(t[6]!==b||t[7]!==n||t[8]!==a||t[9]!==r){let e;t[13]===r?e=t[14]:(e=e=>e.id===r,t[13]=r,t[14]=e),O=n.find(e),D=O?V4(O,b):r||a,k=O?[V4(O,b),H4(O,b)].filter(Boolean).join(` — `):void 0,t[6]=b,t[7]=n,t[8]=a,t[9]=r,t[10]=D,t[11]=O,t[12]=k}else D=t[10],O=t[11],k=t[12];let A=k??a,j=c&&`min-w-0 max-w-[min(calc(15ch+3rem),calc(100vw-8rem))] py-1.5 text-[13px]`,M;t[15]!==f||t[16]!==j?(M=u(cA,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-2 text-left text-sm font-normal text-fg`,lA.transition,`hover:border-edge hover:bg-surface-hover/45`,aA,iA,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,j,f),t[15]=f,t[16]=j,t[17]=M):M=t[17];let N;t[18]!==O?.avatar||t[19]!==r?(N=r?(0,$.jsx)(dz,{agentId:r,avatar:O?.avatar,size:28,className:`shrink-0`}):null,t[18]=O?.avatar,t[19]=r,t[20]=N):N=t[20];let P=c?`max-w-[15ch] shrink`:`flex-1`,F;t[21]===P?F=t[22]:(F=u(`min-w-0 truncate text-left`,P),t[21]=P,t[22]=F);let I;t[23]!==D||t[24]!==F?(I=(0,$.jsx)(`span`,{className:F,children:D}),t[23]=D,t[24]=F,t[25]=I):I=t[25];let L;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(id,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[26]=L):L=t[26];let R;t[27]!==i||t[28]!==I||t[29]!==A||t[30]!==M||t[31]!==N?(R=(0,$.jsx)(cj,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,disabled:i,title:A,className:M,children:[N,I,L]})}),t[27]=i,t[28]=I,t[29]=A,t[30]=M,t[31]=N,t[32]=R):R=t[32];let z;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(z=u(`z-50 w-[var(--radix-popover-trigger-width)] min-w-[12rem] max-h-[min(20rem,calc(100vh-6rem))] overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-md`,lA),t[33]=z):z=t[33];let B;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>w(e.target.value),t[34]=B):B=t[34];let V;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(V=u(`w-full rounded-md border border-edge bg-surface-elevated px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-muted`,aA),t[35]=V):V=t[35];let H;t[36]!==C||t[37]!==o?(H=(0,$.jsx)(`div`,{className:`border-b border-edge p-2`,children:(0,$.jsx)(`input`,{type:`search`,value:C,onChange:B,placeholder:o,className:V,"aria-label":o})}),t[36]=C,t[37]=o,t[38]=H):H=t[38];let U;t[39]!==b||t[40]!==E||t[41]!==s||t[42]!==p||t[43]!==r?(U=E.length===0?(0,$.jsx)(`li`,{className:`p-2 text-sm text-fg-muted`,children:s}):E.map(e=>{let t=e.id===r,n=V4(e,b),i=H4(e,b),a=i.length>0?i:void 0;return(0,$.jsx)(`li`,{role:`option`,"aria-selected":t,children:(0,$.jsxs)(`button`,{type:`button`,className:u(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg`,t?`bg-surface-hover`:`hover:bg-surface-hover`),onClick:()=>{p(e.id),S(!1),w(``)},children:[(0,$.jsx)(Iu,{className:u(`size-4 shrink-0`,t?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,$.jsx)(dz,{agentId:e.id,avatar:e.avatar,size:32,className:`shrink-0`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate font-medium leading-tight`,title:n,children:n}),i?(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs leading-tight text-fg-muted`,title:a,children:i}):null]})]})},e.id)}),t[39]=b,t[40]=E,t[41]=s,t[42]=p,t[43]=r,t[44]=U):U=t[44];let W;t[45]===U?W=t[46]:(W=(0,$.jsx)(`ul`,{className:`max-h-[min(16rem,calc(100vh-10rem))] overflow-y-auto p-1`,role:`listbox`,children:U}),t[45]=U,t[46]=W);let G;t[47]!==g||t[48]!==h||t[49]!==H||t[50]!==W?(G=(0,$.jsx)(lj,{children:(0,$.jsxs)(uj,{side:h,align:g,sideOffset:4,collisionPadding:8,className:z,onOpenAutoFocus:s_e,children:[H,W]})}),t[47]=g,t[48]=h,t[49]=H,t[50]=W,t[51]=G):G=t[51];let K;return t[52]!==x||t[53]!==R||t[54]!==G?(K=(0,$.jsxs)(oj,{open:x,onOpenChange:S,children:[R,G]}),t[52]=x,t[53]=R,t[54]=G,t[55]=K):K=t[55],K}function s_e(e){return e.preventDefault()}function c_e(e){return e.language}var l_e=`(max-width: 767px)`,u_e=(0,Z.memo)(function(e){let t=(0,Q.c)(23),{chatHeadline:n,chatAgents:r,showChatAgentSelector:i,chatAgentId:a,onChatAgentChange:o,chatAgentDisabled:s}=e,c=_(d_e),l;t[0]===c?l=t[1]:(l=m(c),t[0]=c,t[1]=l);let d=l,f=FM(f_e),p=O1(p_e),h=O1(m_e),g=UM(h_e),v=YM(g_e),y=YM(__e),b=e6(l_e),x;t[2]!==g||t[3]!==f?(x=mM({runtime:pM(),sidebarCollapsed:f,mobileNavOpen:g}),t[2]=g,t[3]=f,t[4]=x):x=t[4];let S=b?!g:x.collapsedNewChatVisible,C,w;return t[5]!==s||t[6]!==a||t[7]!==r||t[8]!==n||t[9]!==y||t[10]!==d.chat.agentNoMatches||t[11]!==d.chat.agentPlaceholder||t[12]!==d.chat.agentSearchPlaceholder||t[13]!==d.sidebar.newTask||t[14]!==d.workspace.openFiles||t[15]!==o||t[16]!==v||t[17]!==i||t[18]!==S||t[19]!==h||t[20]!==p?(C=()=>(v({className:`bg-surface-panel`,startExtra:S?(0,$.jsx)(Hi,{to:`/chat/new`,className:u(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-panel text-sm font-medium leading-none text-fg transition-colors hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,uM),title:d.sidebar.newTask,children:(0,$.jsx)(Ly,{className:`size-4 shrink-0 text-accent-fg`,strokeWidth:2,"aria-hidden":!0})}):null,main:(0,$.jsx)(`div`,{className:`w-full min-w-0 max-w-(--max-width-chat) px-3 sm:px-5 xl:px-6`,children:(0,$.jsx)(`h1`,{className:u(`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,S?`text-left md:text-center`:`text-left`),title:n,children:n})}),end:(0,$.jsxs)(`div`,{className:u(`flex min-w-0 max-w-[min(32rem,calc(100vw-8rem))] shrink-0 items-center justify-end gap-2`,uM),children:[i?(0,$.jsx)(`div`,{className:`min-w-0 w-fit shrink-0`,children:(0,$.jsx)(o_e,{items:r,value:a,disabled:s,placeholder:d.chat.agentPlaceholder,searchPlaceholder:d.chat.agentSearchPlaceholder,noMatches:d.chat.agentNoMatches,compact:!0,contentSide:`bottom`,contentAlign:`end`,onChange:o})}):null,(0,$.jsx)(`button`,{type:`button`,className:u(`rounded-md p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,p&&`bg-surface-hover text-fg`),title:d.workspace.openFiles,"aria-label":d.workspace.openFiles,"aria-pressed":p,onClick:h,children:(0,$.jsx)(__,{className:`size-4`})})]})}),()=>y()),w=[n,r,i,a,o,s,S,d.chat.agentPlaceholder,d.chat.agentSearchPlaceholder,d.chat.agentNoMatches,d.sidebar.newTask,d.workspace.openFiles,p,h,v,y],t[5]=s,t[6]=a,t[7]=r,t[8]=n,t[9]=y,t[10]=d.chat.agentNoMatches,t[11]=d.chat.agentPlaceholder,t[12]=d.chat.agentSearchPlaceholder,t[13]=d.sidebar.newTask,t[14]=d.workspace.openFiles,t[15]=o,t[16]=v,t[17]=i,t[18]=S,t[19]=h,t[20]=p,t[21]=C,t[22]=w):(C=t[21],w=t[22]),(0,Z.useLayoutEffect)(C,w),null});function d_e(e){return e.language}function f_e(e){return e.collapsed}function p_e(e){return e.open}function m_e(e){return e.toggleOpen}function h_e(e){return e.mobileNavOpen}function g_e(e){return e.setPageHeader}function __e(e){return e.clearPageHeader}var v_e=(0,Z.memo)(function(){let e=(0,Q.c)(13),t=_(y_e),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n,i=d3(b_e),a=d3(x_e);if(i===`idle`)return null;if(i===`error`&&a){let t;e[2]===a?t=e[3]:(t=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}),e[2]=a,e[3]=t);let n;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=u(`shrink-0 rounded-xl border border-red-200 bg-white px-2.5 py-1 text-xs font-medium text-red-700`,`hover:bg-red-50 dark:border-red-800 dark:bg-red-950/40 dark:text-red-300 dark:hover:bg-red-950/70`,lA.transition,lA.press,lA.focusRingPanel),e[4]=n):n=e[4];let i;e[5]===r.connection.reconnect?i=e[6]:(i=(0,$.jsx)(`button`,{type:`button`,className:n,onClick:S_e,children:r.connection.reconnect}),e[5]=r.connection.reconnect,e[6]=i);let o;return e[7]!==t||e[8]!==i?(o=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-red-100 bg-red-50 px-4 py-2 text-sm text-red-600 dark:border-red-900/40 dark:bg-red-950/50 dark:text-red-400`,children:[t,i]}),e[7]=t,e[8]=i,e[9]=o):o=e[9],o}if(i===`connecting`||i===`reconnecting`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`span`,{className:`inline-block size-3 animate-spin rounded-full border-2 border-amber-500 border-t-transparent`,"aria-hidden":!0}),e[10]=t):t=e[10];let n=i===`reconnecting`?r.connection.reconnecting:r.connection.connecting,a;return e[11]===n?a=e[12]:(a=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-4 py-2 text-sm text-amber-800 dark:border-amber-900/40 dark:bg-amber-950/50 dark:text-amber-200`,children:[t,(0,$.jsx)(`span`,{children:n})]}),e[11]=n,e[12]=a),a}return null});function y_e(e){return e.language}function b_e(e){return e.connectionState}function x_e(e){return e.error}function S_e(){return pde()}var C_e={folder:__,content:hT,documents:Mh,globe:ov};function w_e(e){let t=(0,Q.c)(2),{name:n}=e,r=C_e[n]??__,i;return t[0]===r?i=t[1]:(i=(0,$.jsx)(r,{className:`size-[1.125rem] text-accent-fg sm:size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=r,t[1]=i),i}var T_e=(0,Z.memo)(function(e){let t=(0,Q.c)(28),{chat:n,onPickPrompt:r}=e,i=n.welcomeSpotlight,a=(0,Z.useId)(),[o,s]=(0,Z.useState)(null),c;t[0]!==i?.categories||t[1]!==o?(c=i?.categories.find(e=>e.id===o),t[0]=i?.categories,t[1]=o,t[2]=c):c=t[2];let l=c;if(!i)return null;let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(Hk,{className:`size-12 shrink-0 sm:size-14`,"aria-hidden":!0}),t[3]=d):d=t[3];let f;t[4]===i.headline?f=t[5]:(f=(0,$.jsx)(`h1`,{className:`text-balance text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:i.headline}),t[4]=i.headline,t[5]=f);let p;t[6]===i.tagline?p=t[7]:(p=(0,$.jsx)(`p`,{className:`max-w-md text-pretty text-sm leading-snug text-fg-muted sm:text-[0.9375rem]`,children:i.tagline}),t[6]=i.tagline,t[7]=p);let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 px-1 pt-8 text-center sm:gap-2 sm:pt-10`,children:[d,f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;if(t[11]!==a||t[12]!==i.categories||t[13]!==o){let e;t[15]!==a||t[16]!==o?(e=e=>{let t=o===e.id;return(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":t?a:void 0,onClick:()=>s(t=>t===e.id?null:e.id),className:u(`flex flex-row items-start gap-2.5 rounded-xl border bg-surface-panel p-2.5 text-left shadow-surface sm:flex-col sm:gap-2`,lA.transition,lA.press,lA.focusRingPanel,t?`border-accent ring-1 ring-accent/25`:`border-edge hover:border-edge-strong hover:bg-surface-hover/40 dark:hover:bg-surface-hover/30`),children:[(0,$.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-accent-soft sm:size-10`,children:(0,$.jsx)(w_e,{name:e.icon})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium leading-snug text-fg sm:text-[0.9375rem]`,children:e.title}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs leading-snug text-fg-muted sm:text-sm`,children:e.description})]})]},e.id)},t[15]=a,t[16]=o,t[17]=e):e=t[17],h=i.categories.map(e),t[11]=a,t[12]=i.categories,t[13]=o,t[14]=h}else h=t[14];let g;t[18]===h?g=t[19]:(g=(0,$.jsx)(`div`,{className:`mt-10 grid w-full grid-cols-1 gap-2 sm:mt-12 sm:grid-cols-2 sm:gap-2.5 lg:grid-cols-4`,children:h}),t[18]=h,t[19]=g);let _;t[20]!==r||t[21]!==a||t[22]!==l?(_=l&&l.scenarios.length>0?(0,$.jsx)(`div`,{id:a,role:`region`,"aria-label":l.title,className:`flex flex-col gap-1.5 rounded-xl border border-edge bg-surface-base/80 p-2.5 dark:bg-surface-hover/20`,children:(0,$.jsx)(`ul`,{className:`flex flex-col gap-1`,children:l.scenarios.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(e.prompt),className:u(`flex w-full gap-2 rounded-lg border border-transparent px-2 py-1.5 text-left text-sm leading-snug text-fg`,lA.transition,lA.press,lA.focusRingPanel,`hover:border-edge hover:bg-surface-panel dark:hover:bg-surface-panel/40`),children:[(0,$.jsx)(Bv,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-pretty`,children:e.prompt})]})},e.prompt))})}):null,t[20]=r,t[21]=a,t[22]=l,t[23]=_):_=t[23];let v;return t[24]!==m||t[25]!==g||t[26]!==_?(v=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3.5 pb-2 sm:gap-4 sm:pb-3`,children:[m,g,_]}),t[24]=m,t[25]=g,t[26]=_,t[27]=v):v=t[27],v});function E_e(e){let t=[];for(let n of e.content??[])(n.type===`thinking`||n.type===`tool_use`)&&t.push(n);return t.length>0?t:[]}function D_e(e,t){switch(e){case`pdf`:return t.attachmentPreviewPdf;case`docx`:return t.attachmentPreviewDocument;case`pptx`:return t.attachmentPreviewPresentation;case`spreadsheet`:return t.attachmentPreviewSpreadsheet;default:return``}}function Z8({open:e,attachment:t,authToken:n,sessionKey:r,layerClassName:i=`z-[81]`,onClose:a}){let o=_(e=>e.language),s=m(o).chat,c=qQ({open:e,attachment:t,authToken:n,sessionKey:r,language:o}),l=RQ(c.descriptor),{rootRef:d,active:f,enter:p,exit:h}=y3(),{preview:g,fileType:v,hasExtractedText:y,showExtractedText:b}=c,x=v!==`image`&&v!==`text`&&v!==`pptx`&&y,S=!!(g&&!c.loading&&!c.loadError),C=()=>{h(),a()},w=()=>{if(!g)return;let e=g.mimeType||`application/octet-stream`,t=null;if(c.binaryBuffer)t=new Blob([c.binaryBuffer],{type:e});else{let n=FI(g);if(!n)return;try{let r=atob(n.replace(/\s/g,``)),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);t=new Blob([i],{type:e})}catch{return}}let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=g.name??`download`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},T=!!(c.binaryBuffer||FI(g??{})),E={onDownload:w,canDownload:T},D=u(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,lA.focusRingBase);return(0,$.jsx)(FN,{open:e,onOpenChange:e=>!e&&C(),children:(0,$.jsx)(LN,{children:(0,$.jsxs)(zN,{className:u(`xopc-dialog-content-fullscreen fixed inset-0 flex h-[100dvh] w-full flex-row overflow-hidden`,i,`border-0 bg-transparent p-0 shadow-none outline-none`),children:[(0,$.jsx)(`button`,{type:`button`,className:D,onClick:C,"aria-label":s.attachmentPreviewClose}),(0,$.jsxs)(`div`,{ref:d,className:u(`flex h-full min-h-0 w-[min(100%,var(--max-width-app-main))] shrink-0 flex-col overflow-hidden`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),children:[(0,$.jsxs)(`div`,{className:u(`flex shrink-0 items-start gap-2 border-b border-edge px-4 py-2 dark:border-edge`,uM),children:[(0,$.jsx)(BN,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,children:g?.name??``}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[x?(0,$.jsxs)(`div`,{className:`mr-2 flex rounded-lg border border-edge p-0.5 dark:border-edge`,role:`group`,"aria-label":s.attachmentPreviewText,children:[(0,$.jsx)(`button`,{type:`button`,className:`rounded-md px-2.5 py-1 text-xs font-medium ${b?`text-fg-muted hover:text-fg`:`bg-surface-hover text-fg`}`,onClick:()=>{c.setShowExtractedText(!1),c.clearLoadError()},children:D_e(v,s)}),(0,$.jsx)(`button`,{type:`button`,className:`rounded-md px-2.5 py-1 text-xs font-medium ${b?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`}`,onClick:()=>{c.setShowExtractedText(!0),c.clearLoadError()},children:s.attachmentPreviewText})]}):null,g?(0,$.jsx)(HQ,{controller:l,actions:E}):null,S?(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,title:f?s.attachmentPreviewExitFullscreen:s.attachmentPreviewFullscreen,"aria-label":f?s.attachmentPreviewExitFullscreen:s.attachmentPreviewFullscreen,onClick:()=>void(f?h():p()),children:f?(0,$.jsx)(Wv,{className:`size-4`}):(0,$.jsx)(Rv,{className:`size-4`})}):null,(0,$.jsx)(HN,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,title:s.attachmentPreviewClose,"aria-label":s.attachmentPreviewClose,children:(0,$.jsx)(Sk,{className:`size-4`})})})]})]}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4 pt-2 sm:px-8`,children:g?(0,$.jsx)(UQ,{language:o,descriptor:c.descriptor,loading:c.loading,loadError:c.loadError,textContent:c.textContent,binaryBuffer:c.binaryBuffer,showExtractedText:c.showExtractedText,extractedText:c.extractedText,extractedTextTruncated:c.extractedTextTruncated,actions:{onDownload:w,canDownload:T},controller:l,renderToolbar:()=>null}):null})]}),(0,$.jsx)(`button`,{type:`button`,className:D,onClick:C,"aria-label":s.attachmentPreviewClose})]})})})}function O_e(e,t){let n=t?.split(`;`)[0]?.trim();return!n?.startsWith(`image/`)||e.type===n?e:new Blob([e],{type:n})}function k_e(e,t){let n=(0,Q.c)(22),r;n[0]!==e.mimeType||n[1]!==e.type?(r=e.type===`image`||e.mimeType?.startsWith(`image/`)===!0,n[0]=e.mimeType,n[1]=e.type,n[2]=r):r=n[2];let i=r,a;n[3]!==e||n[4]!==i?(a=i?FI(e):void 0,n[3]=e,n[4]=i,n[5]=a):a=n[5];let o=a,s;bb0:{if(!o){s=void 0;break bb0}let t=e.mimeType?.startsWith(`image/`)?e.mimeType:`image/png`,r;n[6]!==o||n[7]!==t?(r=zI(t,o),n[6]=o,n[7]=t,n[8]=r):r=n[8],s=r}let c=s,[l,u]=(0,Z.useState)(),d;n[9]!==e.mimeType||n[10]!==e.uri||n[11]!==c||n[12]!==i||n[13]!==t.authToken||n[14]!==t.sessionKey?(d=()=>{if(c||!e.uri||!i){u(void 0);return}if(!String(t.authToken??``).trim()){u(void 0);return}let n,r=!1;return(async()=>{let i=await nJ({uri:e.uri,sessionKey:t.sessionKey});if(!i.ok||r)return;let a=URL.createObjectURL(O_e(i.blob,e.mimeType));n=a,u(a)})(),()=>{r=!0,n&&URL.revokeObjectURL(n)}},n[9]=e.mimeType,n[10]=e.uri,n[11]=c,n[12]=i,n[13]=t.authToken,n[14]=t.sessionKey,n[15]=d):d=n[15];let f;return n[16]!==e.uri||n[17]!==c||n[18]!==i||n[19]!==t.authToken||n[20]!==t.sessionKey?(f=[c,e.uri,i,t.authToken,t.sessionKey],n[16]=e.uri,n[17]=c,n[18]=i,n[19]=t.authToken,n[20]=t.sessionKey,n[21]=f):f=n[21],(0,Z.useEffect)(d,f),c??l??``}function Q8(e){let t=(0,Q.c)(43),{attachment:n,authToken:r,sessionKey:i,showDelete:a,onDelete:o,imageSize:s,compact:c,gridCellFill:l,className:d,overflowLabel:f,onOpen:p}=e,h=a===void 0?!1:a,g=s===void 0?`thumbnail`:s,v=c===void 0?!1:c,y=_(A_e),b;t[0]===y?b=t[1]:(b=m(y),t[0]=y,t[1]=b);let x=b,S=(0,Z.useId)(),C;t[2]!==n.mimeType||t[3]!==n.type?(C=n.mimeType?.startsWith(`image/`)||n.type===`image`,t[2]=n.mimeType,t[3]=n.type,t[4]=C):C=t[4];let w=C,T;t[5]!==r||t[6]!==i?(T={authToken:r,sessionKey:i},t[5]=r,t[6]=i,t[7]=T):T=t[7];let E=k_e(n,T),D=w&&!!E,O;t[8]===n?O=t[9]:(O=!!n.uri&&!FI(n),t[8]=n,t[9]=O);let k=O,A;t[10]!==r||t[11]!==k?(A=k&&!String(r??``).trim(),t[10]=r,t[11]=k,t[12]=A):A=t[12];let j=A,M=n.mimeType===`application/pdf`,N;t[13]!==n.mimeType||t[14]!==n.name?(N=n.mimeType?.includes(`spreadsheetml`)||n.name?.toLowerCase().endsWith(`.xlsx`)||n.name?.toLowerCase().endsWith(`.xls`),t[13]=n.mimeType,t[14]=n.name,t[15]=N):N=t[15];let P=N,F=n.name??`file`,I=j?`${F} — ${x.chat.attachmentPreviewMissingAuth}`:F,L=x.chat.attachmentPreviewMissingAuth,R=g===`single`?v?`max-h-28 w-full max-w-[9rem] object-contain`:`max-h-36 w-full max-w-44 object-contain`:g===`grid-cell`?`size-full object-cover`:`max-h-16 w-full object-cover`,z=g===`single`?v?`max-w-[9rem]`:`max-w-44`:g===`grid-cell`?`min-h-0 w-full`:`max-w-[10rem]`,B=g===`grid-cell`?`relative block aspect-square w-full min-w-0 overflow-hidden rounded-md border border-edge dark:border-edge`:`block w-full overflow-hidden rounded-md border border-edge dark:border-edge`,V=g===`grid-cell`?`w-full min-h-0`:`inline-block`,H;t[16]!==d||t[17]!==V?(H=u(`group relative min-w-0`,V,d),t[16]=d,t[17]=V,t[18]=H):H=t[18];let U;t[19]!==n||t[20]!==F||t[21]!==B||t[22]!==R||t[23]!==z||t[24]!==P||t[25]!==M||t[26]!==I||t[27]!==S||t[28]!==L||t[29]!==p||t[30]!==f||t[31]!==D||t[32]!==j||t[33]!==E?(U=D?(0,$.jsxs)(`div`,{className:z,children:[(0,$.jsxs)(`div`,{className:`relative size-full min-h-0`,children:[(0,$.jsxs)(`button`,{type:`button`,className:u(B,lA.transition,lA.press,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:()=>p(n),title:I,"aria-label":I,"aria-describedby":j?S:void 0,children:[(0,$.jsx)(`img`,{src:E,alt:F,className:R}),f?(0,$.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/55 text-lg font-semibold text-white`,children:f}):null]}),M?(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-1 right-1 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-semibold text-white`,"aria-hidden":!0,children:`PDF`}):null]}),j?(0,$.jsx)(`p`,{id:S,className:`mt-1 line-clamp-2 text-[10px] leading-snug text-amber-600 dark:text-amber-500`,children:L}):null]}):(0,$.jsx)(`div`,{className:`max-w-[14rem]`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>p(n),title:I,"aria-label":I,"aria-describedby":j?S:void 0,className:u(`flex w-full min-w-0 gap-2 rounded-md border border-edge bg-surface-hover px-2 py-1.5 text-left text-xs text-fg-muted hover:bg-surface-active dark:border-edge`,j?`items-start`:`items-center`,lA.transition,lA.press,lA.focusRingPanel),children:[P?(0,$.jsx)(pg,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}):(0,$.jsx)(_g,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-fg`,children:F}),j?(0,$.jsx)(`span`,{id:S,className:`mt-0.5 line-clamp-2 block text-[10px] font-normal leading-snug text-amber-600 dark:text-amber-500`,children:L}):null]})]})}),t[19]=n,t[20]=F,t[21]=B,t[22]=R,t[23]=z,t[24]=P,t[25]=M,t[26]=I,t[27]=S,t[28]=L,t[29]=p,t[30]=f,t[31]=D,t[32]=j,t[33]=E,t[34]=U):U=t[34];let W;t[35]!==x.chat.attachmentPreviewRemove||t[36]!==o||t[37]!==h?(W=h?(0,$.jsx)(`button`,{type:`button`,className:u(`absolute -right-1 -top-1 flex size-5 items-center justify-center rounded-full border border-edge bg-surface-panel text-fg-muted shadow-surface hover:text-fg dark:border-edge`,lA.transition,lA.press,lA.focusRingPanel),onClick:e=>{e.stopPropagation(),o?.()},title:x.chat.attachmentPreviewRemove,"aria-label":x.chat.attachmentPreviewRemove,children:(0,$.jsx)(Sk,{className:`size-3`})}):null,t[35]=x.chat.attachmentPreviewRemove,t[36]=o,t[37]=h,t[38]=W):W=t[38];let G;return t[39]!==H||t[40]!==U||t[41]!==W?(G=(0,$.jsxs)(`div`,{className:H,children:[U,W]}),t[39]=H,t[40]=U,t[41]=W,t[42]=G):G=t[42],G}function A_e(e){return e.language}function j_e(e){return typeof e==`number`&&Number.isFinite(e)&&e>0&&e!==1/0}function $8(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function M_e(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}function N_e({att:e,align:t=`start`,variant:n=`default`,sessionKey:r}){let i=m(_(e=>e.language)),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(),[c,l]=(0,Z.useState)(!1),d=(0,Z.useMemo)(()=>{let t=e.durationSeconds;return typeof t==`number`&&Number.isFinite(t)&&t>0?t:0},[e.durationSeconds]),[f,p]=(0,Z.useState)(d),h=(0,Z.useRef)(d);h.current!==d&&(h.current=d,p(d));let[g,v]=(0,Z.useState)(0),y=(0,Z.useCallback)(()=>{let e=a.current;if(!e)return;let t=e.duration;j_e(t)&&p(t)},[]),b=`${e.uri??``}:${e.content?.length??0}:${e.mimeType??``}`,x=(0,Z.useRef)(b);x.current!==b&&(x.current=b,v(0),l(!1)),(0,Z.useEffect)(()=>{let t,n=!1;return(async()=>{let i=e.content??e.data;if(i){s(`data:${e.mimeType?.includes(`/`)?e.mimeType:`audio/mpeg`};base64,${i.replace(/\s/g,``)}`);return}if(e.uri)try{let i=await Y(X(PI(e.uri,r)));if(!i.ok||n)return;let a=await i.blob(),o=URL.createObjectURL(a);t=o,s(o)}catch{}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e,r]);let S=(0,Z.useCallback)(()=>{let e=a.current;!e||!o||(c?e.pause():e.play().catch(()=>{}))},[c,o]);if(!M_e(e))return null;let C=f>0?Math.min(100,Number.isFinite(f)?g/f*100:0):0,w=typeof f==`number`&&f>0&&Number.isFinite(f),T=!!(o&&!w),E=o?(0,$.jsxs)(`span`,{className:`tabular-nums tracking-tight text-fg-muted`,"aria-live":`polite`,children:[(0,$.jsx)(`span`,{children:$8(g)}),(0,$.jsx)(`span`,{className:`mx-0.5 text-fg-subtle`,children:`/`}),w?(0,$.jsx)(`span`,{children:$8(f)}):(0,$.jsx)(`span`,{className:`text-fg-subtle`,title:i.chat.voiceAwaitingMeta,children:`—`})]}):(0,$.jsx)(`span`,{className:`tabular-nums tracking-tight text-fg-subtle`,children:`— / —`}),D=o?(0,$.jsx)(`audio`,{ref:a,src:o,preload:`metadata`,className:`hidden`,onLoadedMetadata:y,onLoadedData:y,onDurationChange:y,onTimeUpdate:e=>v(e.currentTarget.currentTime),onPlay:()=>l(!0),onPause:()=>l(!1),onEnded:()=>{l(!1),v(0)}}):(0,$.jsx)(`span`,{className:`sr-only`,children:i.chat.voiceLoading}),O=(0,$.jsx)(`button`,{type:`button`,onClick:S,disabled:!o,className:u(`flex size-8 shrink-0 items-center justify-center rounded-full border text-accent-fg`,`border-edge-subtle bg-surface-panel transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`motion-safe:active:scale-[0.97]`,`dark:bg-surface-panel/90 dark:border-edge`,n===`compact`&&u(`border-white/55 bg-white/92 shadow-[inset_0_1px_0_rgb(255_255_255/0.65)]`,`dark:border-white/14 dark:bg-surface-hover/98 dark:shadow-none`),!o&&`opacity-50`),"aria-label":c?i.chat.voicePause:i.chat.voicePlay,title:c?i.chat.voicePause:i.chat.voicePlay,children:c?(0,$.jsx)(ry,{className:`size-[14px]`,strokeWidth:2}):(0,$.jsx)(Py,{className:`size-[14px] ml-px`,strokeWidth:2})}),k=u(`relative h-0.5 min-h-[2px] w-full overflow-hidden rounded-full bg-edge-subtle dark:bg-edge/65`,n===`compact`&&`bg-white/45 dark:bg-white/14`),A=u(`inline-flex min-w-0 items-center rounded-full border`,n===`compact`?`max-w-[min(220px,88vw)] gap-2 px-2 py-1.5 backdrop-blur-[2px]`:`min-w-[min(160px,80vw)] max-w-[17rem] gap-2 px-2 py-1.5`,n===`compact`?`border-white/58 bg-white/86 shadow-none dark:border-white/13 dark:bg-black/[0.22] dark:backdrop-blur-sm`:`border-edge-subtle bg-surface-panel/[0.96] shadow-surface dark:border-edge dark:bg-surface-panel/92`),j=`${i.chat.voiceAriaRegion}${e.name?` · ${e.name}`:``}`;return(0,$.jsx)(`div`,{className:u(`flex min-w-0`,t===`end`&&`justify-end`,t===`center`&&`justify-center`),children:(0,$.jsxs)(`div`,{role:`group`,"aria-label":j,className:A,children:[O,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-1 py-px`,children:[n==="default"?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] leading-snug tracking-tight text-fg-muted`,children:[(0,$.jsx)(Uv,{className:`size-3 shrink-0 opacity-90 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate font-normal`,children:i.chat.voiceMessage})]}):(0,$.jsx)(`span`,{className:`sr-only`,children:i.chat.voiceMessage}),(0,$.jsx)(`div`,{className:k,"aria-hidden":!0,children:o?T?(0,$.jsx)(`span`,{className:u(`absolute inset-y-0 left-[18%] w-[42%] max-w-[4.5rem] rounded-full bg-accent/45 motion-safe:animate-pulse`)}):(0,$.jsx)(`div`,{className:u(`h-full rounded-full bg-accent motion-safe:transition-[width] motion-safe:duration-150 motion-safe:ease-linear`),style:{width:`${C}%`}}):null}),(0,$.jsx)(`div`,{className:u(`flex justify-end text-[10px] leading-snug tracking-tight text-fg-muted`),children:E})]}),D]})})}function e5(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}var t5=9;function P_e(e,t){let n=t?`max-w-[11rem]`:`max-w-52`,r=`gap-1`;return e===1?{container:`grid grid-cols-1 ${n} ${r}`,tileSize:`single`}:e===2?{container:`grid grid-cols-2 ${n} ${r}`,tileSize:`grid-cell`}:e===3?{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`}:e===4?{container:`grid grid-cols-2 ${n} ${r}`,tileSize:`grid-cell`}:e<=t5?{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`}:{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`,overflowCount:e-(t5-1)}}function n5(e){let t=(0,Q.c)(23),{attachments:n,authToken:r,sessionKey:i,layout:a,centerUserVoiceRow:o}=e,s=a===void 0?`assistant`:a,c=o===void 0?!1:o,[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null);if(!n?.length)return null;let m,h,g,_;if(t[0]!==n||t[1]!==r||t[2]!==c||t[3]!==s||t[4]!==i){let e=n.filter(I_e),a=n.filter(e5),o=n.filter(F_e);m=`flex flex-col gap-2`,h=e.length>0?(()=>{let t=P_e(e.length,s===`user`),n=t.overflowCount==null?e:e.slice(0,t5-1);return(0,$.jsxs)(`div`,{className:u(`w-full min-w-0`,t.container),children:[n.map((e,n)=>(0,$.jsx)(Q8,{attachment:e,authToken:r,sessionKey:i,imageSize:t.tileSize,compact:s===`user`,onOpen:e=>{p(e),d(!0)}},e.id??`${e.name}-${n}`)),t.overflowCount==null?null:(0,$.jsx)(Q8,{attachment:e[t5-1],authToken:r,sessionKey:i,imageSize:`grid-cell`,compact:s===`user`,gridCellFill:`square`,overflowLabel:`+${t.overflowCount}`,onOpen:e=>{p(e),d(!0)}},e[t5-1]?.id??`overflow-${t5-1}`)]})})():null,g=a.length>0?(0,$.jsx)(`div`,{className:u(`flex flex-col gap-2`,s===`user`&&(c?`items-center`:`items-end`)),children:a.map((e,t)=>(0,$.jsx)(N_e,{att:e,sessionKey:i,align:s===`user`?c?`center`:`end`:`start`,variant:s===`user`?`compact`:`default`},e.id??`${e.name}-${t}`))}):null,_=o.length>0?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.map((e,t)=>(0,$.jsx)(Q8,{attachment:e,authToken:r,sessionKey:i,onOpen:e=>{p(e),d(!0)}},e.id??`${e.name}-${t}`))}):null,t[0]=n,t[1]=r,t[2]=c,t[3]=s,t[4]=i,t[5]=m,t[6]=h,t[7]=g,t[8]=_}else m=t[5],h=t[6],g=t[7],_=t[8];let v;t[9]!==m||t[10]!==h||t[11]!==g||t[12]!==_?(v=(0,$.jsxs)(`div`,{className:m,children:[h,g,_]}),t[9]=m,t[10]=h,t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{d(!1),p(null)},t[14]=y):y=t[14];let b;t[15]!==f||t[16]!==r||t[17]!==l||t[18]!==i?(b=(0,$.jsx)(Z8,{open:l,attachment:f,authToken:r,sessionKey:i,onClose:y}),t[15]=f,t[16]=r,t[17]=l,t[18]=i,t[19]=b):b=t[19];let x;return t[20]!==v||t[21]!==b?(x=(0,$.jsxs)($.Fragment,{children:[v,b]}),t[20]=v,t[21]=b,t[22]=x):x=t[22],x}function F_e(e){return e.type!==`image`&&!e.mimeType?.startsWith(`image/`)&&!e5(e)}function I_e(e){return e.type===`image`||e.mimeType?.startsWith(`image/`)}function L_e(e){let t=[];for(let n of e)if(!(!n.name.toLowerCase().includes(`search`)||n.result==null))try{let e=typeof n.result==`string`?JSON.parse(n.result):n.result,r=Array.isArray(e)?e:e?.results??[];for(let e of r)e.url&&t.push({url:e.url,title:e.title??e.url,snippet:e.snippet})}catch{}return t}function R_e(e){let t=(0,Q.c)(16),{blocks:n}=e,r=_(V_e),i,a,o,s,c;if(t[0]!==n||t[1]!==r){c=Symbol.for(`react.early_return_sentinel`);bb0:{let e=m(r),l=L_e(n.filter(B_e));if(l.length===0){c=null;break bb0}o=`mt-6`;let u=e.chat.searchSourcesHeading.replace(`{{count}}`,String(l.length));t[7]===u?s=t[8]:(s=(0,$.jsx)(`p`,{className:`mb-3 text-xs font-medium text-fg-muted`,children:u}),t[7]=u,t[8]=s),i=`space-y-3`,a=l.map(z_e)}t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];if(c!==Symbol.for(`react.early_return_sentinel`))return c;let l;t[9]!==i||t[10]!==a?(l=(0,$.jsx)(`ol`,{className:i,children:a}),t[9]=i,t[10]=a,t[11]=l):l=t[11];let u;return t[12]!==o||t[13]!==s||t[14]!==l?(u=(0,$.jsxs)(`div`,{className:o,children:[s,l]}),t[12]=o,t[13]=s,t[14]=l,t[15]=u):u=t[15],u}function z_e(e,t){let n=(()=>{try{return new URL(e.url).hostname}catch{return``}})(),r=n?`https://www.google.com/s2/favicons?domain=${n}&sz=16`:void 0;return(0,$.jsxs)(`li`,{className:`flex min-w-0 gap-2.5`,children:[(0,$.jsxs)(`span`,{className:`mt-0.5 shrink-0 text-xs text-fg-disabled`,children:[t+1,`.`]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-1.5`,children:[r?(0,$.jsx)(`img`,{src:r,alt:``,className:`mt-0.5 size-3.5 shrink-0 rounded-sm`,"aria-hidden":!0}):null,(0,$.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 break-words text-xs font-medium text-accent-fg [overflow-wrap:anywhere] hover:underline`,children:e.title})]}),e.snippet?(0,$.jsx)(`p`,{className:`mt-0.5 line-clamp-4 text-xs break-words text-fg-muted [overflow-wrap:anywhere]`,children:e.snippet}):null]})]},e.url)}function B_e(e){return e.type===`tool_use`}function V_e(e){return e.language}var H_e=String.raw`png|jpe?g|gif|webp|bmp|svg|pdf|docx?|xlsx?|pptx?|txt|md|json|html?|css|mjs?|cjs|js|ts|mp3|wav|ogg|m4a|mp4|mov|webm`;function r5(){return`(?:${H_e})`}var U_e=RegExp(`(/[^\\s"'"<>|*?\\n]+?\\.(?:${r5()}))`,`gi`),W_e=RegExp(`([A-Za-z]:[\\\\/][^"'\`<>*?\\n|=]+?\\.(?:${r5()}))`,`gi`),G_e={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`,svg:`image/svg+xml`,pdf:`application/pdf`,doc:`application/msword`,docx:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,xls:`application/vnd.ms-excel`,xlsx:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,ppt:`application/vnd.ms-powerpoint`,pptx:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,txt:`text/plain`,md:`text/markdown`,json:`application/json`,html:`text/html`,htm:`text/html`,css:`text/css`,mjs:`text/javascript`,cjs:`text/javascript`,js:`text/javascript`,ts:`text/typescript`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,m4a:`audio/mp4`,mp4:`video/mp4`,mov:`video/quicktime`,webm:`video/webm`};function i5(e){let t=e.lastIndexOf(`.`);return t<0?`application/octet-stream`:G_e[e.slice(t+1).toLowerCase()]??`application/octet-stream`}function a5(e){return e.startsWith(`image/`)}function o5(e){let t=e.trim();if(t.length<4||t.startsWith(`//`)&&!t.startsWith(`//Users`)||t.startsWith(`http:`)||t.startsWith(`https:`)||t.startsWith(`data:`)||t.startsWith(`file://`))return!1;if(t.startsWith(`/`))return/^\/(?:Users|usr|var|opt|tmp|home|root|System|private|dev|media|mnt|Volumes|data)(?:\/|[\s]|$)/i.test(t);if(/^[A-Za-z]:[\\/]/.test(t)){let e=t.replace(/\\/g,`/`);return!/^[A-Za-z]:\/{2,}/.test(e)}return!!t.startsWith(`\\\\`)}function s5(e){let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);return t[t.length-1]||e}function c5(e){let t=e.trim();return t.includes(`
227
227
  `)||t.includes(`\r`)?t:t.replace(/^(?:File written|File edited)\s*:\s*/i,``).replace(/^Saved\s*:\s*/i,``).trim()}function l5(e){let t=e.trim();if(t.includes(`
228
228
  `)||t.includes(`\r`))return t;let n=t.match(/^[fd?] (.+)$/);return n?n[1].trim():t}function u5(e,t,n,r,i){let a=e.trim();if(!a||!o5(a)||!/\.(png|jpe?g|gif|webp|bmp|svg|pdf|docx?|xlsx?|pptx?|txt|md|json|html?|css|mjs?|cjs|js|ts|mp3|wav|ogg|m4a|mp4|mov|webm)$/i.test(a))return;let o=s5(a);t.push({absolutePath:a,fileName:o,mimeType:i5(o),startIndex:r,endIndex:i})}var K_e=new Set([`SOUL.md`,`IDENTITY.md`,`TOOLS.md`,`AGENTS.md`,`HEARTBEAT.md`,`MEMORY.md`].map(e=>e.toLowerCase()));function q_e(e){let t=s5(e.replace(/\\/g,`/`));return!t||t===`.`||t===`..`?!1:K_e.has(t.toLowerCase())}function J_e(e){let t=e.trim();return t.includes(`
229
229
  `)||t.includes(`\r`)?!1:/^[fd?] .+$/i.test(t)}function d5(e){let t=e.trim().replace(/\\/g,`/`);return t.length<4||t.includes(`..`)||t.startsWith(`/`)||/^[A-Za-z]:/i.test(t)||t.startsWith(`\\\\`)||/^[a-z][a-z0-9+.-]*:/i.test(t)||q_e(t)?!1:/\.(png|jpe?g|gif|webp|bmp|svg|pdf|docx?|xlsx?|pptx?|txt|md|json|html?|css|mjs?|cjs|js|ts|mp3|wav|ogg|m4a|mp4|mov|webm)$/i.test(t)}function f5(e,t,n){let r=l5(c5(e)).trim().replace(/\\/g,`/`);if(!d5(r))return;let i=s5(r);t.push({absolutePath:`rel:${r}`,fileName:i,mimeType:i5(i),workspaceRelativePath:r,startIndex:0,endIndex:0})}function p5(e,t,n){if(typeof e==`string`){if(J_e(e)){let r=l5(c5(e)).trim().replace(/\\/g,`/`);if(o5(r)&&/\.[a-z0-9]+$/i.test(r)){let i=n.indexOf(e);i>=0?u5(r,t,n,i,i+e.length):u5(r,t,n,0,0)}return}let r=l5(c5(e)).trim().replace(/\\/g,`/`);if(o5(r)&&/\.[a-z0-9]+$/i.test(r)){let i=n.indexOf(e);i>=0?u5(r,t,n,i,i+e.length):u5(r,t,n,0,0);return}let i=t.length;if(m5(r,t),t.length>i)return;d5(r)&&f5(e,t,n);return}if(Array.isArray(e)){for(let r of e)p5(r,t,n);return}if(e&&typeof e==`object`){let r=e,i=r.workspaceRelativePaths,a=Array.isArray(i)&&i.length>0&&i.every(e=>typeof e==`string`);if(a)for(let e of i)f5(e,t,n);for(let[e,i]of Object.entries(r))a&&e===`paths`||p5(i,t,n)}}function m5(e,t){for(let n of[U_e,W_e]){n.lastIndex=0;let r;for(;(r=n.exec(e))!==null;){let n=r[1];if(n){let i=r.indices?.[1]?.[0]??r.index??0;u5(n,t,e,i,i+n.length)}}}}function Y_e(){return`(?:[A-Za-z0-9_.-]+\\/)*[A-Za-z0-9_.-]+\\.(?:${r5()})`}function X_e(e){let t=`(${Y_e()})`,n=[RegExp(`\\*\\*${t}\\*\\*`,`gi`),RegExp("`"+t+"`",`gi`),RegExp(`\\]\\(${t}\\)`,`gi`)],r=[];for(let t of n){t.lastIndex=0;let n;for(;(n=t.exec(e))!==null;){let t=n[1]?.trim().replace(/^<|>$/g,``);if(t)try{f5(decodeURIComponent(t),r,e)}catch{f5(t,r,e)}}}let i=new Set;return r.reduce((e,t)=>{let n=t.workspaceRelativePath??t.absolutePath;return i.has(n)?e:(i.add(n),e.push({...t,origin:`assistant-markdown`}),e)},[])}function h5(e,t){let n=e.trim().replace(/\\/g,`/`),r=t.trim().replace(/\\/g,`/`).replace(/^\/+/,``);return!r||n.length<r.length?!1:n===r||n.endsWith(`/${r}`)}function Z_e(e){let t=e.map(e=>e.workspaceRelativePath).filter(e=>!!e);return t.length===0?e:e.filter(e=>e.workspaceRelativePath||!o5(e.absolutePath)?!0:!t.some(t=>h5(e.absolutePath,t)))}function g5(e){let t=[];if(!e?.trim())return[];try{p5(JSON.parse(e),t,e)}catch{}t.some(e=>e.workspaceRelativePath)||m5(e,t);let n=Z_e(t),r=new Set;return n.reduce((e,t)=>{let n=t.absolutePath;return r.has(n)?e:(r.add(n),e.push({...t,origin:`tool-result`}),e)},[])}function Q_e({workspaceRel:e,sessionKey:t,onOpen:n,className:r}){let[i,a]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let n=null,r=!1;return(async()=>{try{let i=await Lq(e,{sessionKey:t?.trim()||void 0});if(r)return;let o=URL.createObjectURL(i);n=o,a(o)}catch{r||a(null)}})(),()=>{r=!0,n&&URL.revokeObjectURL(n)}},[e,t]),i?(0,$.jsxs)(`button`,{type:`button`,onClick:n,className:u(`group relative size-20 overflow-hidden rounded-lg border border-edge-subtle text-left`,lA.press,lA.focusRingPanel,`hover:border-accent`,r),title:e,"aria-label":e,children:[(0,$.jsx)(`img`,{src:i,className:`size-full object-cover`,alt:``}),(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 transition-colors group-hover:bg-black/25`,children:(0,$.jsx)(bh,{className:`size-4 text-white opacity-0 transition-opacity group-hover:opacity-100`,strokeWidth:1.75})})]}):null}function _5(e){let t=(0,Q.c)(10),{icon:n,label:r,copiedLabel:i,onClick:a,copied:o}=e,s=i??r,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=u(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,lA.focusRingPanel,lA.press),t[0]=c):c=t[0];let l;t[1]!==o||t[2]!==n?(l=o?(0,$.jsx)(Iu,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}):n,t[1]=o,t[2]=n,t[3]=l):l=t[3];let d=o?s:r,f;t[4]===d?f=t[5]:(f=(0,$.jsx)(`span`,{children:d}),t[4]=d,t[5]=f);let p;return t[6]!==a||t[7]!==l||t[8]!==f?(p=(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:c,children:[l,f]}),t[6]=a,t[7]=l,t[8]=f,t[9]=p):p=t[9],p}function $_e(e){return e===`external`||e===`agent-profile`||e===`session-artifact`}function eve(e,t){return e?t.locationKind[e]??t.externalBadge:t.externalBadge}function tve(e){let t=(0,Q.c)(71),{path:n,refInfo:r,sessionKey:i,onImported:a}=e,o=br(),s=m(_(nve)).chat,c=s.fileReference,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=fM()&&!!window.electronAPI?.shell,t[0]=l):l=t[0];let d=l,f=r.absolutePath??n.absolutePath,[p,h]=(0,Z.useState)(!1),g;t[1]!==d||t[2]!==r.fileRefId||t[3]!==i?(g=async e=>{if(!r.fileRefId||!d)return;let t=await Iq(r.fileRefId,e,{sessionKey:i?.trim()||void 0});t&&(e===`openExternal`?await window.electronAPI?.shell?.openPath(t.absolutePath):await window.electronAPI?.shell?.showItemInFolder(t.absolutePath))},t[1]=d,t[2]=r.fileRefId,t[3]=i,t[4]=g):g=t[4];let v=g,y;t[5]===f?y=t[6]:(y=()=>{mA(f).then(e=>{e&&(h(!0),window.setTimeout(()=>h(!1),2e3))})},t[5]=f,t[6]=y);let b=y,[x,S]=(0,Z.useState)(!1),C;t[7]!==r.capabilities||t[8]!==r.fileRefId?(C=r.capabilities.includes(`importToWorkspace`)&&!!r.fileRefId,t[7]=r.capabilities,t[8]=r.fileRefId,t[9]=C):C=t[9];let w=C,T=`imports/${n.fileName||r.displayName}`,E=r.scope===`missing`,D=r.scope===`invalid`,O=$_e(r.scope)&&r.exists,k=E?c.missingDescription:D?c.invalidDescription:O?d?c.offWorkspaceBaseDescription:c.browserOffWorkspaceDescription:d?c.externalDescription:c.browserExternalDescription,A=O||r.scope===`external`||r.scope===`agent-profile`?eve(r.locationKind,c):null,j=E||D?`border-warning/30 bg-warning/5 text-fg-muted`:`border-edge-subtle bg-surface-panel text-fg`,M;t[10]===j?M=t[11]:(M=u(`flex max-w-xl min-w-0 flex-col gap-1 rounded-lg border px-2.5 py-2 text-xs`,j),t[10]=j,t[11]=M);let N;t[12]!==D||t[13]!==E?(N=E||D?(0,$.jsx)(ld,{className:`size-3.5 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Eg,{className:`size-3.5 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=D,t[13]=E,t[14]=N):N=t[14];let P=n.fileName||r.displayName,F;t[15]===P?F=t[16]:(F=(0,$.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:P}),t[15]=P,t[16]=F);let I;t[17]===A?I=t[18]:(I=A?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] text-fg-muted`,children:A}):null,t[17]=A,t[18]=I);let L;t[19]!==I||t[20]!==N||t[21]!==F?(L=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[N,F,I]}),t[19]=I,t[20]=N,t[21]=F,t[22]=L):L=t[22];let R;t[23]===k?R=t[24]:(R=(0,$.jsx)(`p`,{className:`line-clamp-2 text-[11px] leading-snug text-fg-muted`,children:k}),t[23]=k,t[24]=R);let z;t[25]!==c||t[26]!==o||t[27]!==r.manageRoute?(z=r.manageRoute?(0,$.jsx)(_5,{icon:(0,$.jsx)(lS,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.openInSettings,onClick:()=>o(r.manageRoute)}):null,t[25]=c,t[26]=o,t[27]=r.manageRoute,t[28]=z):z=t[28];let B;t[29]!==d||t[30]!==c||t[31]!==v||t[32]!==r.capabilities?(B=d&&r.capabilities.includes(`openExternal`)?(0,$.jsx)(_5,{icon:(0,$.jsx)(gh,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.openExternal,onClick:()=>void v(`openExternal`)}):null,t[29]=d,t[30]=c,t[31]=v,t[32]=r.capabilities,t[33]=B):B=t[33];let V;t[34]!==d||t[35]!==c||t[36]!==v||t[37]!==r.capabilities?(V=d&&r.capabilities.includes(`revealInFolder`)?(0,$.jsx)(_5,{icon:(0,$.jsx)(__,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.revealInFolder,onClick:()=>void v(`revealInFolder`)}):null,t[34]=d,t[35]=c,t[36]=v,t[37]=r.capabilities,t[38]=V):V=t[38];let H;t[39]!==s||t[40]!==b||t[41]!==c||t[42]!==p||t[43]!==r.capabilities?(H=r.capabilities.includes(`copyPath`)?(0,$.jsx)(_5,{icon:(0,$.jsx)(Fp,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.copyPath,copiedLabel:s.messageCopied,copied:p,onClick:b}):null,t[39]=s,t[40]=b,t[41]=c,t[42]=p,t[43]=r.capabilities,t[44]=H):H=t[44];let U;t[45]!==w||t[46]!==c||t[47]!==S?(U=w?(0,$.jsx)(_5,{icon:(0,$.jsx)(qa,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),label:c.importToWorkspace,onClick:()=>S(!0)}):null,t[45]=w,t[46]=c,t[47]=S,t[48]=U):U=t[48];let W;t[49]!==z||t[50]!==B||t[51]!==V||t[52]!==H||t[53]!==U?(W=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1 pt-0.5`,children:[z,B,V,H,U]}),t[49]=z,t[50]=B,t[51]=V,t[52]=H,t[53]=U,t[54]=W):W=t[54];let G;t[55]!==w||t[56]!==T||t[57]!==f||t[58]!==x||t[59]!==a||t[60]!==r.fileRefId||t[61]!==i||t[62]!==S?(G=w&&x?(0,$.jsx)(rve,{open:!0,onOpenChange:S,fileRefId:r.fileRefId,sessionKey:i,sourceLabel:f,defaultDestination:T,onImported:e=>{S(!1),a(e)}},`${r.fileRefId}:${T}`):null,t[55]=w,t[56]=T,t[57]=f,t[58]=x,t[59]=a,t[60]=r.fileRefId,t[61]=i,t[62]=S,t[63]=G):G=t[63];let K;return t[64]!==f||t[65]!==L||t[66]!==R||t[67]!==W||t[68]!==G||t[69]!==M?(K=(0,$.jsxs)(`div`,{className:M,title:f,children:[L,R,W,G]}),t[64]=f,t[65]=L,t[66]=R,t[67]=W,t[68]=G,t[69]=M,t[70]=K):K=t[70],K}function nve(e){return e.language}function rve(e){let t=(0,Q.c)(68),{open:n,onOpenChange:r,fileRefId:i,sessionKey:a,sourceLabel:o,defaultDestination:s,onImported:c}=e,l=_(ave),d;t[0]===l?d=t[1]:(d=m(l),t[0]=l,t[1]=d);let f=d.chat.fileReference,p=f.importErrors,[h,g]=(0,Z.useState)(s),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),S;t[2]!==h||t[3]!==p||t[4]!==i||t[5]!==c||t[6]!==a?(S=async()=>{y(!0),x(null);let e=await Rq(i,{sessionKey:a?.trim()||void 0,destination:h.trim()||void 0,onConflict:`rename`});if(e.ok){c(e.payload);return}y(!1);let t=p;x(t[e.error.code]??t.UNKNOWN??e.error.message)},t[2]=h,t[3]=p,t[4]=i,t[5]=c,t[6]=a,t[7]=S):S=t[7];let C=S,w;t[8]!==v||t[9]!==r?(w=e=>{v||r(e)},t[8]=v,t[9]=r,t[10]=w):w=t[10];let T;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(RN,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,hj)}),t[11]=T):T=t[11];let E;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(E=u(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,gj,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),t[12]=E):E=t[12];let D;t[13]===f.importDialogTitle?D=t[14]:(D=(0,$.jsx)(BN,{className:`text-base font-semibold text-fg`,children:f.importDialogTitle}),t[13]=f.importDialogTitle,t[14]=D);let O;t[15]===f.importDialogSourceLabel?O=t[16]:(O=(0,$.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-fg-disabled`,children:f.importDialogSourceLabel}),t[15]=f.importDialogSourceLabel,t[16]=O);let k;t[17]===o?k=t[18]:(k=(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg-muted`,children:o}),t[17]=o,t[18]=k);let A;t[19]!==O||t[20]!==k?(A=(0,$.jsxs)(`div`,{children:[O,k]}),t[19]=O,t[20]=k,t[21]=A):A=t[21];let j;t[22]===f.importDialogDestinationLabel?j=t[23]:(j=(0,$.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-fg-disabled`,children:f.importDialogDestinationLabel}),t[22]=f.importDialogDestinationLabel,t[23]=j);let M;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(M=e=>g(e.target.value),t[24]=M):M=t[24];let N=f.importDialogDestinationLabel,P;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(P=u(`mt-1 w-full rounded-md border border-edge bg-surface px-2 py-1.5 font-mono text-xs text-fg outline-none`,`focus:border-accent focus:ring-1 focus:ring-accent disabled:opacity-60`),t[25]=P):P=t[25];let F;t[26]!==v||t[27]!==h||t[28]!==f.importDialogDestinationLabel?(F=(0,$.jsx)(`input`,{type:`text`,value:h,onChange:M,disabled:v,"aria-label":N,className:P,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`}),t[26]=v,t[27]=h,t[28]=f.importDialogDestinationLabel,t[29]=F):F=t[29];let I;t[30]!==j||t[31]!==F?(I=(0,$.jsxs)(`label`,{className:`block`,children:[j,F]}),t[30]=j,t[31]=F,t[32]=I):I=t[32];let L;t[33]===b?L=t[34]:(L=b?(0,$.jsx)(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2 py-1.5 text-xs text-danger`,children:b}):null,t[33]=b,t[34]=L);let R;t[35]!==I||t[36]!==L||t[37]!==A?(R=(0,$.jsxs)(`div`,{className:`mt-3 space-y-3 text-sm`,children:[A,I,L]}),t[35]=I,t[36]=L,t[37]=A,t[38]=R):R=t[38];let z;t[39]===r?z=t[40]:(z=()=>r(!1),t[39]=r,t[40]=z);let B;t[41]!==v||t[42]!==f.importDialogCancel||t[43]!==z?(B=(0,$.jsx)(tA,{type:`button`,variant:`secondary`,onClick:z,disabled:v,children:f.importDialogCancel}),t[41]=v,t[42]=f.importDialogCancel,t[43]=z,t[44]=B):B=t[44];let V;t[45]===C?V=t[46]:(V=()=>void C(),t[45]=C,t[46]=V);let H;t[47]!==v||t[48]!==h?(H=v||!h.trim(),t[47]=v,t[48]=h,t[49]=H):H=t[49];let U;t[50]===v?U=t[51]:(U=v?(0,$.jsx)(Fv,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t[50]=v,t[51]=U);let W=v?f.importInProgress:f.importDialogConfirm,G;t[52]!==V||t[53]!==H||t[54]!==U||t[55]!==W?(G=(0,$.jsxs)(tA,{type:`button`,variant:`secondary`,onClick:V,disabled:H,className:`inline-flex items-center gap-1.5`,children:[U,W]}),t[52]=V,t[53]=H,t[54]=U,t[55]=W,t[56]=G):G=t[56];let K;t[57]!==B||t[58]!==G?(K=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[B,G]}),t[57]=B,t[58]=G,t[59]=K):K=t[59];let q;t[60]!==R||t[61]!==K||t[62]!==D?(q=(0,$.jsxs)(LN,{children:[T,(0,$.jsxs)(zN,{className:E,onOpenAutoFocus:ive,children:[D,R,K]})]}),t[60]=R,t[61]=K,t[62]=D,t[63]=q):q=t[63];let ee;return t[64]!==n||t[65]!==q||t[66]!==w?(ee=(0,$.jsx)(FN,{open:n,onOpenChange:w,children:q}),t[64]=n,t[65]=q,t[66]=w,t[67]=ee):ee=t[67],ee}function ive(e){return e.preventDefault()}function ave(e){return e.language}function v5(e){let t=(0,Q.c)(29),{paths:n,sessionKey:r}=e,i=k1(dve),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={},t[0]=a):a=t[0];let[o,s]=(0,Z.useState)(a),c;t[1]===n?c=t[2]:(c=n.map(uve).join(`
@@ -254,4 +254,4 @@ Sharp, direct, slightly nerdy. The kind of engineer you'd want on your team —
254
254
  `);return n!==-1&&(t=t.slice(0,n).trim()),t.length>i9&&(t=t.slice(0,i9-1).trimEnd()+`…`),t}function vSe(e){let t=e.trimStart();if(!/^##\s+Skill:\s*\S+/i.test(t))return e;let n=/(?:^|\r?\n)\*\*Arguments\*\*:\s*/gi,r=-1;for(;n.exec(t)!==null;)r=n.lastIndex;if(r!==-1){let e=t.slice(r).trim();if(e)return e}return(t.split(/\r?\n/)[0]?.trim()??``).replace(/^##\s+Skill:\s*/i,``).trim()}function ySe(e){let t=e.trimStart().match(/^\/skill:([^\s]+)(?:\s+([\s\S]*))?$/i);return t&&(t[2]?.trim()||t[1]?.trim())||e}function bSe(e){let t=ySe(vSe(wL([{type:`text`,text:e}]))).split(/\n/)[0]?.trim();if(!t)return null;let n=_Se(t);return n.length>0?n:null}function xSe(e,t){let n=e.trim(),r=t.trim();!n||!r||window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:n,name:r},bubbles:!0}))}function a9(e){let t=e.trim();t&&window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:t},bubbles:!0}))}var o9=`main`,SSe=/^[a-z0-9][a-z0-9_-]{0,63}$/i,CSe=/[^a-z0-9_-]+/g,wSe=/^-+/,TSe=/-+$/,s9=/^[a-z0-9][a-z0-9_-]{0,63}$/,c9=new Set([`con`,`prn`,`aux`,`nul`,`com1`,`com2`,`com3`,`com4`,`com5`,`com6`,`com7`,`com8`,`com9`,`lpt1`,`lpt2`,`lpt3`,`lpt4`,`lpt5`,`lpt6`,`lpt7`,`lpt8`,`lpt9`]);function l9(e){let t=(e??``).trim();if(!t)return o9;let n=t.toLowerCase();return SSe.test(t)?n:n.replace(CSe,`-`).replace(wSe,``).replace(TSe,``).slice(0,64)||o9}function ESe(e,t){let n=e?.trim();if(n){let e=n.toLowerCase();return s9.test(e)?e===o9?{ok:!1,error:`"${o9}" is reserved`}:c9.has(e)?{ok:!1,error:`Agent id "${e}" is reserved (Windows device name).`}:{ok:!0,agentId:e}:{ok:!1,error:`Invalid agent id: use 1-64 characters; letters, digits, underscores, and hyphens only; start with a letter or digit.`}}let r=l9(t.trim());return r===o9?{ok:!1,error:`Display name cannot produce a valid agent folder id. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}:c9.has(r)?{ok:!1,error:`That display name resolves to "${r}", which is reserved. Use a different display name or set an explicit Agent id.`}:s9.test(r)?{ok:!0,agentId:r}:{ok:!1,error:`Could not derive a folder-safe agent id from the display name. Set an explicit Agent id (letters, digits, underscores, hyphens only).`}}function DSe(e){let t=e.trim().split(`:`);if(t.length<6)return null;let[n,r,i,a,o,...s]=t;if(n!==`agent`||!r||!i||a!=="default"||o!==`direct`)return null;let c=s.join(`:`).trim();return c?{agentId:r,sourceChannel:i,peerId:c}:null}function OSe(e){let t=e?.sourceBinding;return!!(t&&typeof t==`object`)}function kSe(e){return!!e?.trim().startsWith(`chat_`)}function u9(e){return e?.trim()||void 0}function d9(e,t){let n=e.key?.trim();if(!n)return!1;let r=DSe(n);if(!r||(e.sourceChannel?.trim().toLowerCase()??r?.sourceChannel.toLowerCase())!==`webchat`||e.customData?.genericNewChatShell===!1||OSe(e.customData)||!kSe(r.peerId)||(e.messageCount??0)!==0)return!1;let i=(e.routing?.agentId??r?.agentId)?.trim().toLowerCase();if(!i||i!==l9(t.agentId))return!1;let a=u9(t.projectId),o=u9(e.projectId);return!((a?o!==a:o)||TR(n))}function ASe(e,t){let n={...t,agentId:l9(t.agentId)};return e.filter(e=>d9(e,n)).sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime())[0]??null}function jSe(e,t){let n=t.trim();return e.find(e=>e.key.trim()===n)}function MSe(e,t,n,r){if(!t?.length)return e;let i=new Map(e.map(e=>[e.key.trim(),e]));for(let e of t){let t=e.key.trim();!t||i.has(t)||d9(e,{agentId:n,projectId:r})&&i.set(t,e)}return[...i.values()].toSorted((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime())}async function NSe(e,t,n){let r=Tme();try{return MSe(await e.loadSessions(),r,t,n)}catch{return r?.filter(e=>d9(e,{agentId:t,projectId:n}))??[]}}async function PSe(e){let t=l9(e.agentId),n=e.projectId?.trim()||void 0,r=e.currentSessionKey?.trim()||null;if(e.forceNew){let r=await e.sessionMgr.createSession({agentId:t,projectId:n});return{kind:`create`,sessionKey:r.key,session:r}}let i=await NSe(e.sessionMgr,t,n);if(r){let e=jSe(i,r);if(e&&d9(e,{agentId:t,projectId:n}))return{kind:`noop`,sessionKey:r}}let a=ASe(i,{agentId:t,projectId:n});if(a&&a.key.trim()!==r)return{kind:`reuse`,sessionKey:a.key,session:a};let o=await e.sessionMgr.createSession({agentId:t,projectId:n});return{kind:`create`,sessionKey:o.key,session:o}}var f9=null;function p9(e){if(f9)return f9;let t=(async()=>{let t=e.agentId??void 0,n=await PSe({sessionMgr:e.sessionMgr,agentId:t?.trim()||`main`,projectId:e.projectId,currentSessionKey:e.currentSessionKey,forceNew:e.forceNew});if(n.kind===`noop`)return r9(n.sessionKey),e.onOpened(n.sessionKey),(e.routeSessionKey?.trim()||null)!==n.sessionKey&&e.navigateToSession(n.sessionKey,e.replaceNavigate??!1,e.search),n.sessionKey;if(n.kind===`reuse`)return r9(n.sessionKey),e.onOpened(n.sessionKey),e.navigateToSession(n.sessionKey,e.replaceNavigate??!1,e.search),a9(n.sessionKey),n.sessionKey;let{sessionKey:r,session:i}=n;return wme({key:r,sessionId:i.sessionId,name:i.name,messageCount:0,updatedAt:i.updatedAt||new Date().toISOString(),sourceChannel:i.sourceChannel,sourceChatId:i.sourceChatId,projectId:i.projectId,routing:i.routing}),r9(r),e.onOpened(r),e.navigateToSession(r,e.replaceNavigate??!1,e.search),a9(r),r})().finally(()=>{f9=null});return f9=t,t}var m9={current:null},h9={current:null};function FSe(){let e=_r(),{sessionKey:t}=wr(),n=e.pathname.endsWith(`/new`),r=t?decodeURIComponent(t):void 0,i=eSe(n,r),a=K7(i),o=n?null:r??null,s=(0,Z.useRef)(i);return s.current=i,m9.current=o,!n&&r&&(h9.current=r),(0,Z.useLayoutEffect)(()=>{xR.getState().focusedSessionKey!==o&&xR.getState().setFocusedSessionKey(o)},[o]),{isNewRoute:n,decodedKey:r,routedSessionKey:i,viewSessionKey:a,routedFocusedSessionKey:o,routeSessionKeyRef:s,locationSearch:e.search,locationState:e.state}}var ISe={get current(){return h9.current}},g9={get current(){return m9.current},set current(e){m9.current=e,xR.getState().setFocusedSessionKey(e)}};function LSe(e){let t=(0,Q.c)(15),{token:n,isNewRoute:r,decodedKey:i,locationSearch:a,sessionMgrRef:o,resolveAgentIdForPost:s,navigateToSession:c,loadSessionById:l,tryResumeAgentRun:u,restoreLiveCacheIfNeeded:d,adoptEmptySession:f,applyAgentConfig:p,patchInitUi:m}=e,h=(0,Z.useRef)(0),g=r?a:``,_,v;t[0]!==f||t[1]!==p||t[2]!==i||t[3]!==r||t[4]!==l||t[5]!==c||t[6]!==g||t[7]!==m||t[8]!==s||t[9]!==d||t[10]!==o||t[11]!==n||t[12]!==u?(_=()=>{if(!n){m({loading:!1});return}let e=h.current+=1,t=!1,a=()=>!t&&e===h.current,_=e=>{a()&&o.current.loadSessionAgentConfig(e).then(t=>{a()&&p(e,t)}).catch(VSe)},v=()=>{if(!a())return Promise.resolve();let e=s();return p9({sessionMgr:o.current,agentId:e,currentSessionKey:ISe.current,routeSessionKey:null,navigateToSession:c,replaceNavigate:!0,search:hSe(g),onOpened:e=>f(e,null)}).then(BSe)},y=(e,t)=>a()?(d(e),u(e,CR(e)?.messages??t??wR(e))):Promise.resolve();return m({loading:i===void 0&&!r,error:null}),(r?v():i?(e=>a()?gSe(e)?(_(e),y(e,wR(e))):l(e,0).then(t=>{if(a())return y(e,t??wR(e))}):Promise.resolve())(i):a()?o.current.loadSessions().then(e=>{if(!a())return;let t=e.filter(zSe)[0]??e[0];if(t)return a()?l(t.key,0).then(e=>{if(!a())return;d(t.key);let n=CR(t.key)?.messages??e??wR(t.key);return o.current.parseSessionFromHash()||c(t.key,!0),u(t.key,n)}):void 0;if(!a())return;let n=s();return p9({sessionMgr:o.current,agentId:n,currentSessionKey:null,routeSessionKey:null,navigateToSession:c,onOpened:e=>f(e,null)}).then(RSe)}):Promise.resolve()).then(()=>{a()&&m({loading:!1})}).catch(e=>{t?a()&&m({loading:!1}):m({error:e instanceof Error?e.message:`Chat init failed`,loading:!1})}),()=>{t=!0}},v=[n,r,i,g,o,s,c,l,u,d,f,p,m],t[0]=f,t[1]=p,t[2]=i,t[3]=r,t[4]=l,t[5]=c,t[6]=g,t[7]=m,t[8]=s,t[9]=d,t[10]=o,t[11]=n,t[12]=u,t[13]=_,t[14]=v):(_=t[13],v=t[14]),(0,Z.useEffect)(_,v)}function RSe(){}function zSe(e){return(e.messageCount??0)>0}function BSe(){}function VSe(){}async function HSe(e){let t=e.trim();if(!t)return!1;try{return!!(await O3()).find(e=>e.id===t)?.reasoning}catch{return!1}}function USe(e){let{sessionMgrRef:t,routeSessionKeyRef:n,sendingRef:r,streamingRef:i,activeStreamSessionKeyRef:a,loadingSessionRef:o,messagesLenRef:s,thinkingSupportGenRef:c,navigateToSession:l,resolveAgentIdForPost:u,dismissClarifyOnSessionLoad:d,detachForNewConversation:f,sessionKey:p,hasMore:m}=e,h=()=>xR.getState(),g=(0,Z.useRef)(Promise.resolve(void 0)),_=(0,Z.useRef)(null),v=(0,Z.useRef)(0),y=(0,Z.useCallback)(e=>{let t=h().focusedSessionKey;if(!e.trim())return++c.current===c.current&&t&&h().patchSessionMeta(t,{modelSupportsThinking:!1}),Promise.resolve();let n=++c.current;return HSe(e).then(e=>{if(n!==c.current)return;let t=h().focusedSessionKey;t&&h().patchSessionMeta(t,{modelSupportsThinking:e})})},[c]),b=(0,Z.useCallback)(async e=>{try{let n=await t.current.loadSessionAgentConfig(e);h().patchSessionMeta(e,{model:n.model,thinkingLevel:n.thinkingLevel||`medium`,reasoningLevel:q7(n.reasoningLevel),workingDirectoryLocked:n.workingDirectoryLocked}),y(n.model)}catch{}},[t,y]),x=(0,Z.useCallback)(()=>{let e=h().focusedSessionKey;if(!e||(h().sessions[e]?.name)?.trim())return;let n=++v.current,r=[700,900,900,1e3,1e3],i=a=>{a>=5||n===v.current&&h().focusedSessionKey===e&&(h().sessions[e]?.name?.trim()||window.setTimeout(()=>{n===v.current&&h().focusedSessionKey===e&&(h().sessions[e]?.name?.trim()||t.current.fetchSessionName(e).then(t=>{if(n===v.current){if(t){h().patchSessionMeta(e,{name:t});return}i(a+1)}}).catch(()=>{i(a+1)}))},r[a]??900))};i(0)},[t]),S=(0,Z.useCallback)(e=>$xe({chatId:e,routeSessionKey:n.current}),[n]),C=(0,Z.useCallback)((e,t)=>{let n=h().getSessionSnapshot(e);n&&(n.streaming||n.sending||n.streamingMsg)?(h().mergeCommittedFromServer(e,t.messages,t.hasMore),t.name!==void 0&&h().patchSessionMeta(e,{name:t.name||null})):h().setCommittedSnapshot(e,{messages:t.messages,hasMore:t.hasMore,name:t.name}),S(e)&&(_.current=t.nextBeforeCursor??null)},[S]),w=(0,Z.useCallback)(async(e,r=0,i)=>{let a=async(e,r,i)=>{let s=r===0&&!i;s&&!IL(e)&&d(),o.current=!0,s&&h().setLoadingSessionKey(e);try{let{messages:n,hasMore:a,name:o,nextBeforeCursor:c}=await t.current.loadSession(e,r,i);if(s){if(h().setCommittedSnapshot(e,{messages:n,hasMore:a,name:o??null}),!S(e))return n;_.current=c??null,h().setShellError(null);try{let r=await t.current.loadSessionAgentConfig(e);if(!S(e))return n;h().patchSessionMeta(e,{model:r.model,thinkingLevel:r.thinkingLevel||`medium`,reasoningLevel:q7(r.reasoningLevel),workingDirectoryLocked:r.workingDirectoryLocked}),y(r.model)}catch{}return n}if(_.current=c??null,!S(e))return;h().prependHistoryMessages(e,n,a);return}catch{if(r===0&&!i){_.current=null,h().setShellError(`Failed to load session`);let r=K7(n.current);if(r&&r===e)return;let i=await t.current.loadSessions().catch(()=>[]),o=i.filter(e=>(e.messageCount??0)>0)[0]??i[0];if(o)return l(o.key,!0),await a(o.key,0,null);{_.current=null;let e=u();p9({sessionMgr:t.current,agentId:e,currentSessionKey:null,routeSessionKey:null,navigateToSession:l,replaceNavigate:!0,onOpened:e=>{h().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),b(e)}})}}return}finally{o.current=!1,s&&h().loadingSessionKey===e&&h().setLoadingSessionKey(null)}},s=g.current,c,f=new Promise(e=>{c=e});g.current=s.then(()=>f),await s;try{return await a(e,r,i)}finally{c()}},[n,S,r,i,a,o,d,l,y,u,t]);return{refreshModelThinkingSupport:y,pollSessionNameAfterTurn:x,applyLoadedSessionSnapshot:C,loadSessionById:w,loadMoreMessages:(0,Z.useCallback)(async()=>{let e=h().focusedSessionKey;if(!(!e||h().loadingMore||!m)){h().setLoadingMore(!0);try{await w(e,s.current,_.current)}finally{h().setLoadingMore(!1)}}},[m,w,s]),onSessionModelChange:(0,Z.useCallback)(async e=>{if(p)try{h().setShellError(null),await t.current.patchSessionAgentConfig(p,{model:e}),h().patchSessionMeta(p,{model:e}),y(e)}catch(e){h().setShellError(e instanceof Error?e.message:`Failed to switch model`)}},[p,t,y]),onSessionThinkingLevelChange:(0,Z.useCallback)(async e=>{if(p)try{h().setShellError(null),await t.current.patchSessionAgentConfig(p,{thinkingLevel:e}),h().patchSessionMeta(p,{thinkingLevel:e})}catch(e){h().setShellError(e instanceof Error?e.message:`Failed to update thinking level`)}},[p,t]),createNewSession:(0,Z.useCallback)(async e=>{d(),f(),_.current=null,h().setShellError(null);let n=u();await p9({sessionMgr:t.current,agentId:n,currentSessionKey:p,routeSessionKey:p,forceNew:e?.forceNew,navigateToSession:l,onOpened:e=>{h().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),b(e)}})},[d,f,l,u,p,t,b])}}function _9(e){let{chatId:t,shouldApplyStreamUpdate:n,beforeAssistantDelta:r,setStreamingOnStreamStart:i,clearResumeRunIdOnBackgroundTerminal:a,clearResumeRunIdOnVisibleError:o,setError:s,sessionMgrRef:c,applyLoadedSessionSnapshot:l,finalizeMessage:u,fq:d}=e,f=()=>xR.getState(),p=()=>{c.current.loadSession(t,0).then(e=>l(t,e)).catch(()=>{})},m=()=>{f().clearStreamingState(t),qL.clearActiveStreamSessionKey(t),a&&(qL.activeResumeRunId=null),f().setSessionFlags(t,{sending:!1,streaming:!1}),f().setSessionProgress(t,null),d.dismissClarifyForSession(t),p()};return{onUserMessage:e=>{n(t)&&f().appendUserMessageIfMissing(t,e)},onWorkflowRunStarted:()=>{window.dispatchEvent(new CustomEvent(`workflow-run-started-from-chat`,{detail:{sessionKey:t}}))},onStreamStart:()=>{r(),f().mutateSessionStreaming(t,()=>{}),f().setSessionFlags(t,{streaming:!0})},onToken:e=>{r(),f().mutateSessionStreaming(t,t=>{oR(t.content,e)}),n(t)&&f().setSessionFlags(t,{streaming:!0})},onThinking:(e,n)=>{r(),f().mutateSessionStreaming(t,t=>{!n&&e===``?tR(t.content):nR(t.content,e,n)})},onThinkingEnd:()=>{r(),f().mutateSessionStreaming(t,e=>{rR(e.content)})},onToolStart:(e,n,i)=>{r(),f().mutateSessionStreaming(t,t=>{lR(t.content,e,n,i)}),f().setSessionFlags(t,{streaming:!0})},onToolEnd:(e,n,i)=>{e===`clarify`&&d.onClarifyToolEnd(t),r(),f().mutateSessionStreaming(t,t=>{uR(t.content,e,n,i)})},onToolUpdate:(e,n,i)=>{r(),f().mutateSessionStreaming(t,t=>{dR(t.content,e,n,i)})},onReview:({review:e})=>{r(),f().mutateSessionStreaming(t,t=>{cR(t.content,e)}),n(t)&&f().setSessionFlags(t,{streaming:!0})},onProgress:e=>{f().setSessionProgress(t,e)},onTtsAudio:e=>{n(t)&&f().appendAttachmentToCurrentAssistant(t,{name:e.name,mimeType:e.mimeType,type:`voice`,uri:e.uri,size:0},{attachTo:e.attachTo,messageId:e.messageId})},onCompaction:e=>{if(n(t))if(e.status===`started`)f().setSessionProgress(t,{stage:`compaction`,message:`Compacting context…`,timestamp:Date.now()});else if(e.status===`completed`){let n=e.tokensBefore&&e.tokensAfter?` (${Math.round((e.tokensBefore-e.tokensAfter)/1e3)}k tokens freed)`:``;f().setSessionProgress(t,{stage:`compaction`,message:`Context compacted${n}`,timestamp:Date.now()})}else f().setSessionProgress(t,null)},onClarifyRequest:d.makeOnClarifyRequest(t),onResult:()=>{if(!n(t)){m();return}if(qL.userAborted){qL.userAborted=!1;return}u()},onError:e=>{if(!n(t)){m();return}f().clearStreamingState(t),o&&(qL.activeResumeRunId=null),f().setSessionFlags(t,{sending:!1,streaming:!1}),f().setSessionProgress(t,null),s(e),d.dismissClarifyForSession(t)}}}function WSe(e){return CR(e)?.streamingMsg??null}function GSe(e){let{sessionKey:t,thinkingLevel:n,modelSupportsThinking:r,sessionKeyRef:i,sendingRef:a,streamingRef:o,sessionMgrRef:s,sendMessageRef:c,shouldApplyStreamUpdate:l,fq:u,applyLoadedSessionSnapshot:d,loadSessionById:f,createNewSession:p,pollSessionNameAfterTurn:m}=e,h=(0,Z.useRef)(u.flushSteeringQueue);h.current=u.flushSteeringQueue;let g=()=>xR.getState(),_=e=>g().setShellError(e),v=()=>g().setShellError(null),y=(0,Z.useCallback)(e=>{let t=qL.activeStreamSessionKey??i.current;if(t&&!l(t))return;let n=t?WSe(t):null,r=null;if(n){let e=ZL(n,Date.now());rR(e.content),iR(e.content),r=QL(e)}if(r&&XL(r)&&t){let e=CR(t)?.messages??wR(t);g().finalizeStreamingTurn(t,cL([...e,r]))}else t&&g().clearStreamingState(t);if(a.current=!1,o.current=!1,qL.resetRunTracking(),u.dismissClarify(),m(),!e?.skipSteeringQueueFlush){let e=t??i.current;e&&window.setTimeout(()=>{h.current(e)},72)}let s=i.current;s&&window.setTimeout(()=>{i.current===s&&(a.current||o.current||u.pendingFollowUpsRef.current.length>0||f(s,0))},400)},[a,o,i,u.dismissClarify,u.pendingFollowUpsRef,m,f,l]),b=(0,Z.useCallback)(async(e,t)=>{if(!l(e)||qL.isStreamingFor(e)||qL.isSending)return;let n=await xme(e);if(!n||qL.activeResumeRunId===n)return;let r=t??wR(e),i=CR(e)?.hasMore??!1;try{let t=await s.current.loadSession(e,0);g().mergeCommittedFromServer(e,t.messages,t.hasMore),r=t.messages,i=t.hasMore}catch{}qL.userAborted=!1,qL.activeResumeRunId=n,qL.activeStreamSessionKey=e,a.current=!0,o.current=!0,g().seedSessionIfEmpty(e,r,!0,!0,i),g().setSessionFlags(e,{sending:!0,streaming:!0}),g().setSessionProgress(e,null);let c=!1,f=()=>{if(c||!l(e))return;c=!0;let t=wR(e);if(t.length===0)return;let n=t[t.length-1];if(n?.role!==`assistant`)return;let r=QL(n),i=t.slice(0,-1);g().applyHydratedTail(e,i,r)};try{let t=_9({chatId:e,shouldApplyStreamUpdate:l,beforeAssistantDelta:f,setStreamingOnStreamStart:!1,clearResumeRunIdOnBackgroundTerminal:!0,clearResumeRunIdOnVisibleError:!0,setError:_,sessionMgrRef:s,applyLoadedSessionSnapshot:d,finalizeMessage:y,fq:u});await qL.sender.resume(n,e,t)}catch(t){if(t.name!==`AbortError`&&console.error(`[chat] resume failed:`,t),g().clearStreamingState(e),qL.activeResumeRunId=null,!l(e)){qL.clearActiveStreamSessionKey(e);return}a.current=!1,o.current=!1,qL.clearActiveStreamSessionKey(e)}},[a,o,l,s,d,y]),x=(0,Z.useCallback)(async(e,t,s)=>{if(!e.trim()&&!t?.length||!a.current&&!o.current&&!qL.isSending)return;if(e.trim()===`/new`&&!t?.length){await p({forceNew:!0});return}if(!i.current)return;u.dismissClarifyAndClearPending();let l=r?s??n:`off`;qL.userAborted=!0,qL.resetRunTracking(),qL.abort(),a.current=!1,o.current=!1,y({skipSteeringQueueFlush:!0}),queueMicrotask(()=>{c.current(e,t,l)})},[a,o,i,u.dismissClarifyAndClearPending,r,n,y,c,p]);return{finalizeMessage:y,tryResumeAgentRun:b,sendMessage:(0,Z.useCallback)(async(e,i,c)=>{if(!t||!l(t)||!e.trim()&&!i?.length||qL.activeStreamSessionKey===t&&(a.current||o.current))return;let f=e.trim();if(f===`/new`&&!i?.length){await p({forceNew:!0});return}let m=r?c??n:`off`,h=t;qL.userAborted=!1,qL.activeStreamSessionKey=h,a.current=!0,o.current=!1,v(),u.dismissClarify();let b=[...wR(h),{role:`user`,content:e?[{type:`text`,text:e}]:[],attachments:i,timestamp:Date.now()}],x=CR(h);if(g().initSessionSnapshot(h,{...x??{...WL(),hasMore:!1,streamingMsg:null,progress:null,sending:!1,streaming:!1},messages:b,hasMore:x?.hasMore??!1,streamingMsg:null,progress:null,sending:!0,streaming:!1}),!x?.name?.trim()&&f){let e=bSe(f);e&&(g().patchSessionMeta(h,{name:e}),xSe(h,e))}try{await s.current.ensureSessionExists(h);let t=_9({chatId:h,shouldApplyStreamUpdate:l,beforeAssistantDelta:()=>{},setStreamingOnStreamStart:!0,clearResumeRunIdOnBackgroundTerminal:!1,clearResumeRunIdOnVisibleError:!1,setError:_,sessionMgrRef:s,applyLoadedSessionSnapshot:d,finalizeMessage:y,fq:u});await qL.sender.send(e,h,i,m,t)}catch(e){e.name!==`AbortError`&&(g().clearStreamingState(h),_(JSON.stringify(CI())))}finally{a.current=!1,o.current=!1,g().setSessionFlags(h,{sending:!1}),qL.clearActiveStreamSessionKey(h)}},[t,n,r,a,o,l,s,d,y,u.dismissClarify,p]),interruptAndSend:x,abort:(0,Z.useCallback)(()=>{qL.userAborted=!0,qL.resetRunTracking(),u.dismissClarifyAndClearPending(),qL.abort(),a.current=!1,o.current=!1,y({skipSteeringQueueFlush:!0});let e=i.current;e&&window.setTimeout(()=>{f(e,0)},300)},[u.dismissClarifyAndClearPending,a,o,y,i,f]),deleteMessageRound:(0,Z.useCallback)(e=>{let t=i.current;if(!t||a.current||o.current)return;let n=wR(t),r=n[e];if(!r||!DL(r.role))return;let c=OL(n,e);if(c===null)return;let l=kL(n,e),u=[...n];u.splice(e,l),g().updateSessionMessages(t,()=>u),s.current.deleteMessages(t,{userRoundIndex:c}).catch(()=>{f(t,0)})},[i,a,o,s,f]),retryUserMessageRound:(0,Z.useCallback)(e=>{let t=i.current;if(!t||a.current||o.current)return;let n=wR(t),r=n[e];if(!r||!DL(r.role))return;for(let t=e+1;t<n.length;t++){let e=n[t];if(e&&DL(e.role))return}let l=wL(r.content),u=EL(r.attachments);if(!l.trim()&&!u?.length)return;let d=OL(n,e);if(d===null)return;let p=kL(n,e),m=[...n];m.splice(e,p),g().updateSessionMessages(t,()=>m),(async()=>{try{await s.current.deleteMessages(t,{userRoundIndex:d}),await c.current(l,u)}catch{f(t,0)}})()},[i,a,o,s,f,c])}}function KSe(e){let t=(0,Q.c)(11),{sessionKey:n,sessionKeyRef:r,sessionMgrRef:i,loadSessionById:a,loadTimelineById:o,applyAgentConfig:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[0]=c):c=t[0],(0,Z.useEffect)(JSe,c);let l,u;t[1]!==a||t[2]!==o||t[3]!==n?(l=()=>{let e=e=>{let t=e.detail;!t?.key||t.key!==n||(a(n,0),o(n))};return window.addEventListener(`session-transcript-updated`,e),()=>window.removeEventListener(`session-transcript-updated`,e)},u=[n,a,o],t[1]=a,t[2]=o,t[3]=n,t[4]=l,t[5]=u):(l=t[4],u=t[5]),(0,Z.useEffect)(l,u);let d,f;t[6]!==s||t[7]!==r||t[8]!==i?(d=()=>{let e=e=>{if(ce(e.detail))return;let t=r.current;t&&i.current.loadSessionAgentConfig(t).then(e=>{s(t,e)}).catch(qSe)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},f=[r,i,s],t[6]=s,t[7]=r,t[8]=i,t[9]=d,t[10]=f):(d=t[9],f=t[10]),(0,Z.useEffect)(d,f)}function qSe(){}function JSe(){let e=YSe;return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)}function YSe(e){let t=e.detail;!t?.key||t.name===void 0||xR.getState().patchSessionMeta(t.key,{name:t.name||null})}function XSe(){let e=br(),{isNewRoute:t,decodedKey:n,viewSessionKey:r,routedFocusedSessionKey:i,routeSessionKeyRef:a,locationSearch:o,locationState:s}=FSe(),c=(0,Z.useRef)(new kme),l=(0,Z.useRef)(!1),u=(0,Z.useRef)(!1),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(0),p=(0,Z.useRef)(!1),[m,h]=(0,Z.useState)([]),g=(0,Z.useRef)(async()=>{}),_=(0,Z.useRef)(0),v=i,y=xR(e=>e.initLoading),b=xR(e=>e.loadingSessionKey),x=xR(e=>e.loadingMore),S=xR(e=>e.shellError),C=r,w=xR(e=>C?e.sessions[C]:void 0),T=C?SR(w):!1,E=T?w?.streaming??!1:!1,D=T?w?.sending??!1:!1,O=T?w?.progress??null:null,k=w?.hasMore??!1,A=w?.name??null,j=w?.model??``,M=w?.thinkingLevel??`medium`,N=w?.reasoningLevel??`stream`,P=w?.modelSupportsThinking??!1,F=w?.workingDirectoryLocked??!1;(0,Z.useEffect)(()=>{_.current=w?.messages.length??0},[w?.messages.length]),(0,Z.useEffect)(()=>{u.current=D,d.current=E},[D,E]);let{token:I,chatAgentsData:L,resolveAgentIdForPost:R,onChatAgentChange:z,displayAgentId:B,showChatAgentSelector:V}=mSe({navigate:e,sessionKeyRef:g9,sessionKey:v,isNewRoute:t,locationState:s}),H=n!==void 0&&v!==n,U=!!(n&&b===n&&!H),W=(0,Z.useMemo)(()=>y&&(v==null||n===void 0),[y,v,n]),G=(0,Z.useCallback)((t,n=!1,r)=>{let i=r??``;e({pathname:`/chat/${encodeURIComponent(t)}`,search:i},{replace:n})},[e]),K=(0,Z.useCallback)(e=>Zxe({streamSessionKey:e,routeSessionKey:a.current}),[a]),q=(0,Z.useCallback)(()=>{iSe({sendingRef:u,streamingRef:d})},[]),ee=pSe({sessionKey:v,decodedKey:n,sessionKeyRef:g9,activeStreamSessionKeyRef:JL,sendingRef:u,streamingRef:d,modelSupportsThinking:P,thinkingLevel:M,shouldApplyStreamUpdate:K,sendMessageRef:g}),J=(0,Z.useCallback)(()=>{ee.clearVisibleClarify(),qL.activeResumeRunId=null,qL.userAborted=!1,nSe(q)},[ee.clearVisibleClarify,q]),{refreshModelThinkingSupport:te,pollSessionNameAfterTurn:Y,applyLoadedSessionSnapshot:ne,loadSessionById:re,loadMoreMessages:X,onSessionModelChange:ie,onSessionThinkingLevelChange:ae,createNewSession:oe}=USe({sessionMgrRef:c,routeSessionKeyRef:a,sendingRef:u,streamingRef:d,activeStreamSessionKeyRef:JL,loadingSessionRef:l,messagesLenRef:_,thinkingSupportGenRef:f,navigateToSession:G,resolveAgentIdForPost:R,dismissClarifyOnSessionLoad:ee.clearVisibleClarify,detachForNewConversation:J,sessionKey:v,hasMore:k}),se=(0,Z.useCallback)(e=>{if(!Qxe({cacheSessionKey:e,routeSessionKey:a.current}))return!1;let t=CR(e);return!t||!SR(t)&&!IL(e)&&!qL.isStreamingFor(e)?!1:(qL.activeStreamSessionKey=e,u.current=t.sending,d.current=t.streaming,!0)},[a]),{tryResumeAgentRun:ce,sendMessage:le,interruptAndSend:ue,abort:de,deleteMessageRound:fe,retryUserMessageRound:pe}=GSe({sessionKey:v,thinkingLevel:M,modelSupportsThinking:P,sessionKeyRef:g9,sendingRef:u,streamingRef:d,sessionMgrRef:c,sendMessageRef:g,shouldApplyStreamUpdate:K,fq:ee,applyLoadedSessionSnapshot:ne,loadSessionById:re,createNewSession:oe,pollSessionNameAfterTurn:Y});(0,Z.useEffect)(()=>{t&&J()},[t,J]);let me=(0,Z.useMemo)(()=>tSe({viewSessionKey:r,sessionKey:C,messages:w?.messages??[],streamingMsg:T?w?.streamingMsg??null:null}),[r,C,w?.messages,w?.streamingMsg,T]),he=(0,Z.useCallback)((e,t)=>{xR.getState().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t}),q()},[q]),ge=(0,Z.useCallback)((e,t)=>{rSe(e,t),te(t.model)},[te]),_e=(0,Z.useCallback)(e=>{let t=xR.getState();e.loading!==void 0&&t.setInitLoading(e.loading),e.error!==void 0&&t.setShellError(e.error)},[]),ve=(0,Z.useCallback)(async e=>{try{let t=await c.current.loadTimeline(e);if(a.current!==e)return;h(t)}catch{a.current===e&&h([])}},[a]);return(0,Z.useEffect)(()=>{if(t||!v){h([]);return}ve(v)},[v,t,ve]),KSe({sessionKey:v,sessionKeyRef:g9,sendingRef:u,streamingRef:d,sessionMgrRef:c,loadSessionById:re,loadTimelineById:ve,applyAgentConfig:ge}),LSe({token:I,isNewRoute:t,decodedKey:n,locationSearch:o,sessionMgrRef:c,resolveAgentIdForPost:R,navigateToSession:G,loadSessionById:re,tryResumeAgentRun:ce,restoreLiveCacheIfNeeded:se,adoptEmptySession:he,applyAgentConfig:ge,patchInitUi:_e}),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;if(!t?.sessionKey)return;let n=t.event;if(!n||typeof n.type!=`string`)return;let r=t.sessionKey;if(n.type===`user_message`||n.type===`user_transcript`){let e=AL(n);e&&K(r)&&xR.getState().appendUserMessageIfMissing(r,e);return}if(n.type===`tool_update`){let e=typeof n.toolName==`string`?n.toolName:``;if(e!==`workflow`||!K(r)||qL.isStreamingFor(r))return;let t=typeof n.toolCallId==`string`?n.toolCallId:void 0,i=n.details;xR.getState().mutateSessionStreaming(r,n=>{dR(n.content,e,t,i)});return}n.type!==`status`||typeof n.runId!=`string`||!n.runId.trim()||(LL(r,n.runId),K(r)&&(qL.isStreamingFor(r)||queueMicrotask(()=>{K(r)&&(qL.isStreamingFor(r)||ce(r,wR(r)))})))};return window.addEventListener(`agent-stream`,e),()=>window.removeEventListener(`agent-stream`,e)},[ce,K]),(0,Z.useEffect)(()=>{let e=E||D,t=p.current;if(p.current=e,!t||e)return;let n=g9.current;n&&queueMicrotask(()=>{!n||!K(n)||qL.isStreamingFor(n)||IL(n)&&ce(n,wR(n))})},[E,D,ce,K]),g.current=le,{auth:{hasToken:!!I},session:{sessionKey:v,sessionName:A,decodedKey:n,sessionRoutePending:H,sessionContentLoading:U,showSessionLoading:W,loading:y,sessionModel:j,thinkingLevel:M,onSessionThinkingLevelChange:ae,reasoningLevel:N,modelSupportsThinking:P,workingDirectoryLocked:F,hasMore:k,loadingMore:x,loadMoreMessages:X,onSessionModelChange:ie,createNewSession:oe,sessionManager:c.current},messages:{items:me},timeline:{items:m,refresh:ve},stream:{error:S,streaming:E,sending:D,progress:O,sendMessage:le,abort:de,interruptAndSend:ue,deleteMessageRound:fe,retryUserMessageRound:pe},followUp:{addPendingFollowUp:ee.addPendingFollowUp,pendingFollowUps:ee.pendingFollowUps,editingFollowUpId:ee.editingFollowUpId,beginEditFollowUp:ee.beginEditFollowUp,cancelEditFollowUp:ee.cancelEditFollowUp,commitEditFollowUp:ee.commitEditFollowUp,removePendingFollowUp:ee.removePendingFollowUp,movePendingFollowUp:ee.movePendingFollowUp,reorderPendingFollowUp:ee.reorderPendingFollowUp,steerPendingFollowUp:ee.steerPendingFollowUp,steeringFollowUpId:ee.steeringFollowUpId},clarify:{clarifyPrompt:ee.clarifyPrompt,clarifySubmitting:ee.clarifySubmitting,clarifySubmitError:ee.clarifySubmitError,submitClarifyAnswer:ee.submitClarifyAnswer,cancelClarifyAnswer:ee.cancelClarifyAnswer},agents:{chatAgents:L,displayAgentId:B,showChatAgentSelector:V,onChatAgentChange:z}}}function v9(e,t){if(!e)return``;let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-3)).trimEnd()}...`}function ZSe(e,t){return v9(CL(e??``),t)}function QSe(e,t){let n=e.toLowerCase().replace(/[-.]/g,`_`);return n.includes(`search`)?t.searchedWeb:n.includes(`read`)?t.readFile:n.includes(`bash`)||n.includes(`shell`)||n.includes(`command`)?t.runCommand:n===`ls`||n.includes(`list`)?t.listDirectory:n.includes(`write`)||n.includes(`save`)?t.writeFile:n.includes(`edit`)||n.includes(`patch`)?t.editFile:n.includes(`open`)?t.openUrl:n.includes(`fetch`)?t.fetchUrl:t.unknownTool.replace(`{{name}}`,e)}function $Se(e){return e===`context`||e===`branch`||e===`compaction`?e:null}function eCe(e){return v9(e.preview||e.title,72)||e.kind}function y9(e,t){let n=[],r=null,i=0;for(let a of e){if(a.displayIndex!==void 0&&(i=a.displayIndex),a.kind===`turn`&&a.role===`user`){let e=a.turn||n.length+1;r={id:a.id,messageIndex:a.displayIndex??i,ordinal:e,title:t.turn.replace(`{{count}}`,String(e)),preview:ZSe(a.preview||a.title,88)||t.messageFallback,...a.timestamp===void 0?{}:{timestamp:a.timestamp},tools:[],events:[]},n.push(r);continue}if(!r)continue;if(a.kind===`tool`||a.kind===`file`||a.kind===`command`){let e=a.meta?.toolName||a.title||a.kind,n=a.kind===`file`||a.kind===`command`?a.title:QSe(e,t),i=`${a.id}:${e}`;r.tools.some(e=>e.key===i)||r.tools.push({key:i,label:n,running:a.status===`running`});continue}let e=$Se(a.kind);if(!e)continue;let o=`${a.id}:${a.kind}`;r.events.some(e=>e.key===o)||r.events.push({key:o,label:eCe(a),tone:e})}return n}function b9(e,t){return(e===1?t.toolCount_one:t.toolCount_other).replace(`{{count}}`,String(e))}function tCe(e,t){let n=e[0]?.id;for(let r of e)r.messageIndex<=t&&(n=r.id);return n}function nCe(e){let t=(0,Q.c)(53),{turn:n,active:r,labels:i,currentLabel:a,onSelect:o}=e,s,c,l,d,f,p,m,h;if(t[0]!==r||t[1]!==a||t[2]!==i||t[3]!==o||t[4]!==n.events||t[5]!==n.preview||t[6]!==n.timestamp||t[7]!==n.title||t[8]!==n.tools){let e=n.tools.slice(0,2),g=n.events.slice(0,Math.max(0,3-e.length)),_=Math.max(0,n.tools.length-e.length)+Math.max(0,n.events.length-g.length);f=`button`;let v=r&&`bg-accent-soft/70`;t[17]===v?p=t[18]:(p=u(`flex w-full min-w-0 items-start gap-3 border-b border-edge-subtle px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,v),t[17]=v,t[18]=p),m=o;let y=r&&`border-accent bg-accent`,b;t[19]===y?b=t[20]:(b=u(`mt-1 size-2.5 shrink-0 rounded-full border border-edge-strong bg-surface-panel`,y),t[19]=y,t[20]=b),t[21]===b?h=t[22]:(h=(0,$.jsx)(`span`,{className:b,"aria-hidden":!0}),t[21]=b,t[22]=h),s=`min-w-0 flex-1`;let x;t[23]===n.preview?x=t[24]:(x=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:n.preview}),t[23]=n.preview,t[24]=x);let S;t[25]!==r||t[26]!==a?(S=r?(0,$.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent px-1.5 py-0.5 text-[10px] font-medium text-white`,children:a}):null,t[25]=r,t[26]=a,t[27]=S):S=t[27],t[28]!==x||t[29]!==S?(c=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[x,S]}),t[28]=x,t[29]=S,t[30]=c):c=t[30];let C;t[31]===n.title?C=t[32]:(C=(0,$.jsx)(`span`,{children:n.title}),t[31]=n.title,t[32]=C);let w;t[33]===n.timestamp?w=t[34]:(w=n.timestamp?(0,$.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(n.timestamp).toISOString(),children:V7(n.timestamp)}):null,t[33]=n.timestamp,t[34]=w);let T;t[35]!==i||t[36]!==n.tools.length?(T=n.tools.length>0?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(bk,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),b9(n.tools.length,i)]}):null,t[35]=i,t[36]=n.tools.length,t[37]=T):T=t[37],t[38]!==C||t[39]!==w||t[40]!==T?(l=(0,$.jsxs)(`span`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[C,w,T]}),t[38]=C,t[39]=w,t[40]=T,t[41]=l):l=t[41],d=e.length>0||n.events.length>0?(0,$.jsxs)(`span`,{className:`mt-2 flex min-w-0 flex-wrap gap-1.5`,children:[e.map(iCe),g.map(rCe),_>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:[`+`,_]}):null]}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o,t[4]=n.events,t[5]=n.preview,t[6]=n.timestamp,t[7]=n.title,t[8]=n.tools,t[9]=s,t[10]=c,t[11]=l,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h}else s=t[9],c=t[10],l=t[11],d=t[12],f=t[13],p=t[14],m=t[15],h=t[16];let g;t[42]!==s||t[43]!==c||t[44]!==l||t[45]!==d?(g=(0,$.jsxs)(`span`,{className:s,children:[c,l,d]}),t[42]=s,t[43]=c,t[44]=l,t[45]=d,t[46]=g):g=t[46];let _;return t[47]!==f||t[48]!==p||t[49]!==m||t[50]!==h||t[51]!==g?(_=(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:f,className:p,onClick:m,children:[h,g]})}),t[47]=f,t[48]=p,t[49]=m,t[50]=h,t[51]=g,t[52]=_):_=t[52],_}function rCe(e){return(0,$.jsxs)(`span`,{className:`inline-flex max-w-[10rem] items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function iCe(e){return(0,$.jsxs)(`span`,{className:u(`inline-flex max-w-[9rem] items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,e.running&&`text-accent-fg`),children:[(0,$.jsx)(bk,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function aCe(e){let t=(0,Q.c)(39),{items:n,activeMessageIndex:r,labels:i,openLabel:a,closeLabel:o,currentLabel:s,onSelectMessage:c}=e,l;t[0]!==n||t[1]!==i?(l=y9(n,i),t[0]=n,t[1]=i,t[2]=l):l=t[2];let d=l,[f,p]=(0,Z.useState)(!1);if(d.length<4)return null;let m;t[3]!==r||t[4]!==d?(m=tCe(d,r),t[3]=r,t[4]=d,t[5]=m):m=t[5];let h=m,g;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(mv,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[6]=g):g=t[6];let _;t[7]===a?_=t[8]:(_=(0,$.jsx)(IN,{asChild:!0,children:(0,$.jsx)(tA,{type:`button`,variant:`secondary`,className:`fixed bottom-[calc(env(safe-area-inset-bottom)+5.5rem)] right-4 z-40 size-11 rounded-full p-0 shadow-popover md:right-6 xl:hidden`,"aria-label":a,title:a,children:g})}),t[7]=a,t[8]=_);let v;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(RN,{className:`fixed inset-0 z-[80] bg-scrim/70 backdrop-blur-[1px] xl:hidden`}),t[9]=v):v=t[9];let y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=u(`fixed bottom-0 left-0 right-0 z-[90] flex h-[min(72dvh,34rem)] flex-col overflow-hidden`,`rounded-t-xl border border-edge bg-surface-panel shadow-popover outline-none`,`md:bottom-auto md:left-auto md:right-4 md:top-20 md:h-[min(calc(100dvh-7rem),40rem)] md:w-[22rem] md:rounded-xl`,`xl:hidden`),t[10]=y):y=t[10];let b;t[11]===i.title?b=t[12]:(b=(0,$.jsx)(BN,{className:`min-w-0 truncate text-base font-semibold text-fg`,children:i.title}),t[11]=i.title,t[12]=b);let x;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(Sk,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=x):x=t[13];let S;t[14]===o?S=t[15]:(S=(0,$.jsx)(HN,{asChild:!0,children:(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o,children:x})}),t[14]=o,t[15]=S);let C;t[16]!==b||t[17]!==S?(C=(0,$.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[b,S]}),t[16]=b,t[17]=S,t[18]=C):C=t[18];let w;if(t[19]!==h||t[20]!==s||t[21]!==i||t[22]!==c||t[23]!==d){let e;t[25]!==h||t[26]!==s||t[27]!==i||t[28]!==c?(e=e=>(0,$.jsx)(nCe,{turn:e,active:e.id===h,labels:i,currentLabel:s,onSelect:()=>{c(e.messageIndex),p(!1)}},e.id),t[25]=h,t[26]=s,t[27]=i,t[28]=c,t[29]=e):e=t[29],w=d.map(e),t[19]=h,t[20]=s,t[21]=i,t[22]=c,t[23]=d,t[24]=w}else w=t[24];let T;t[30]===w?T=t[31]:(T=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(`ol`,{className:`min-w-0`,children:w})}),t[30]=w,t[31]=T);let E;t[32]!==C||t[33]!==T?(E=(0,$.jsxs)(LN,{children:[v,(0,$.jsxs)(zN,{className:y,"aria-describedby":void 0,children:[C,T]})]}),t[32]=C,t[33]=T,t[34]=E):E=t[34];let D;return t[35]!==f||t[36]!==E||t[37]!==_?(D=(0,$.jsxs)(FN,{open:f,onOpenChange:p,children:[_,E]}),t[35]=f,t[36]=E,t[37]=_,t[38]=D):D=t[38],D}function oCe(e){let{active:t,scrubbing:n,distance:r}=e;return n?r===0?`w-7 bg-fg`:r===1?`w-5 bg-fg-muted`:r===2?`w-4 bg-edge-strong/70`:t?`w-3.5 bg-fg-muted`:`w-2.5 bg-edge-strong/45`:t?`w-3.5 bg-fg-muted`:`w-2.5 bg-edge-strong/45`}function sCe(e){let t=(0,Q.c)(40),{turn:n,labels:r}=e,i,a,o,s,c,l,d,f,p;if(t[0]!==r||t[1]!==n.events||t[2]!==n.preview||t[3]!==n.timestamp||t[4]!==n.title||t[5]!==n.tools){let e=n.tools.slice(0,3),m=Math.max(0,n.tools.length-e.length),h=n.events.slice(0,Math.max(0,3-e.length));i=m+Math.max(0,n.events.length-h.length);let g=n.tools.length>0||n.events.length>0?[...e.map(dCe),...h.map(uCe),...i>0?[`+${i}`]:[]].join(` · `):n.title;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=u(`pointer-events-auto absolute right-12 top-1/2 z-[100] w-[min(25rem,calc(100vw-8rem))] -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-panel/95 p-3 text-left shadow-popover backdrop-blur`),t[15]=l):l=t[15],t[16]===n.timestamp?d=t[17]:(d=n.timestamp?(0,$.jsx)(`div`,{className:`mb-1 flex min-w-0 justify-end text-xs`,children:(0,$.jsx)(`time`,{suppressHydrationWarning:!0,className:`shrink-0 tabular-nums text-fg-disabled`,dateTime:new Date(n.timestamp).toISOString(),children:V7(n.timestamp)})}):null,t[16]=n.timestamp,t[17]=d),t[18]===n.preview?f=t[19]:(f=(0,$.jsx)(`div`,{className:`min-w-0 text-sm font-semibold leading-5 text-fg`,children:(0,$.jsx)(`span`,{className:`line-clamp-1`,children:n.preview})}),t[18]=n.preview,t[19]=f),t[20]===g?p=t[21]:(p=(0,$.jsx)(`div`,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:g}),t[20]=g,t[21]=p),a=`mt-3 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 text-sm text-fg-subtle`,t[22]!==r||t[23]!==n.title||t[24]!==n.tools.length?(o=n.tools.length>0?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(bk,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:b9(n.tools.length,r)})]}):(0,$.jsx)(`span`,{children:n.title}),t[22]=r,t[23]=n.title,t[24]=n.tools.length,t[25]=o):o=t[25],s=e.map(lCe),c=h.map(cCe),t[0]=r,t[1]=n.events,t[2]=n.preview,t[3]=n.timestamp,t[4]=n.title,t[5]=n.tools,t[6]=i,t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=l,t[12]=d,t[13]=f,t[14]=p}else i=t[6],a=t[7],o=t[8],s=t[9],c=t[10],l=t[11],d=t[12],f=t[13],p=t[14];let m;t[26]===i?m=t[27]:(m=i>0?(0,$.jsxs)(`span`,{children:[`+`,i]}):null,t[26]=i,t[27]=m);let h;t[28]!==a||t[29]!==o||t[30]!==s||t[31]!==c||t[32]!==m?(h=(0,$.jsxs)(`div`,{className:a,children:[o,s,c,m]}),t[28]=a,t[29]=o,t[30]=s,t[31]=c,t[32]=m,t[33]=h):h=t[33];let g;return t[34]!==h||t[35]!==l||t[36]!==d||t[37]!==f||t[38]!==p?(g=(0,$.jsxs)(`div`,{className:l,children:[d,f,p,h]}),t[34]=h,t[35]=l,t[36]=d,t[37]=f,t[38]=p,t[39]=g):g=t[39],g}function cCe(e){return(0,$.jsxs)(`span`,{className:u(`inline-flex min-w-0 max-w-[10rem] items-center gap-1.5`,e.tone===`branch`&&`text-accent`,e.tone===`compaction`&&`text-fg-muted`),children:[(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function lCe(e){return(0,$.jsxs)(`span`,{className:u(`inline-flex min-w-0 max-w-[9rem] items-center gap-1.5`,e.running&&`text-accent`),children:[(0,$.jsx)(bk,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function uCe(e){return e.label}function dCe(e){return e.label}function fCe(e){let t=(0,Q.c)(51),{items:n,activeMessageIndex:r,labels:i,onSelectMessage:a}=e,o;t[0]!==n||t[1]!==i?(o=y9(n,i),t[0]=n,t[1]=i,t[2]=o):o=t[2];let s=o,[c,l]=(0,Z.useState)(null),d=(0,Z.useRef)(null),f=(0,Z.useRef)(0),p,m;if(t[3]===c?(p=t[4],m=t[5]):(p=()=>{if(!c)return;let e=()=>{f.current=0,l(null)},t=t=>{let n=t.target;n instanceof Node&&(d.current?.contains(n)||e())},n=t=>{t.key===`Escape`&&e()};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,n)}},m=[c],t[3]=c,t[4]=p,t[5]=m),(0,Z.useEffect)(p,m),s.length<4)return null;let h;if(t[6]!==r||t[7]!==s){h=s[0]?.id;for(let e of s)e.messageIndex<=r&&(h=e.id);t[6]=r,t[7]=s,t[8]=h}else h=t[8];let g=c??h,_;t[9]!==c||t[10]!==s?(_=c?s.find(e=>e.id===c):null,t[9]=c,t[10]=s,t[11]=_):_=t[11];let v=_,y=c!==null,b;if(t[12]!==g||t[13]!==s){let e;t[15]===g?e=t[16]:(e=e=>e.id===g,t[15]=g,t[16]=e),b=s.findIndex(e),t[12]=g,t[13]=s,t[14]=b}else b=t[14];let x=Math.max(0,b),S;t[17]!==a||t[18]!==s?(S=e=>{let t=s[Math.min(s.length-1,Math.max(0,e))];t&&(l(t.id),a(t.messageIndex))},t[17]=a,t[18]=s,t[19]=S):S=t[19];let C=S,w;t[20]!==C||t[21]!==x?(w=e=>{if(Math.abs(e.deltaY)<Math.abs(e.deltaX)||(e.preventDefault(),e.stopPropagation(),f.current+=e.deltaY,Math.abs(f.current)<48))return;let t=f.current>0?1:-1;f.current=0,C(x+t)},t[20]=C,t[21]=x,t[22]=w):w=t[22];let T=w,E=i.title,D,O;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>{f.current=0,l(null)},D=e=>{let t=e.relatedTarget;(!(t instanceof Node)||!e.currentTarget.contains(t))&&(f.current=0,l(null))},t[23]=D,t[24]=O):(D=t[23],O=t[24]);let k;t[25]===h?k=t[26]:(k=()=>l(e=>e??h??null),t[25]=h,t[26]=k);let A;if(t[27]!==a||t[28]!==y||t[29]!==g||t[30]!==x||t[31]!==s){let e;t[33]!==a||t[34]!==y||t[35]!==g||t[36]!==x?(e=(e,t)=>{let n=e.id===g,r=Math.abs(t-x);return(0,$.jsx)(`li`,{className:`group relative flex h-3.5 w-full items-center justify-end`,onMouseEnter:()=>l(e.id),onFocus:()=>l(e.id),children:(0,$.jsx)(`button`,{type:`button`,className:u(`flex h-3.5 w-full items-center justify-end rounded-sm pr-1.5`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),onClick:()=>a(e.messageIndex),"aria-label":`${e.title}: ${e.preview}`,children:(0,$.jsx)(`span`,{className:u(`block h-0.5 rounded-full transition-[width,background-color] duration-150 ease-out`,oCe({active:n,scrubbing:y,distance:r}),`group-hover:bg-fg`),"aria-hidden":!0})})},e.id)},t[33]=a,t[34]=y,t[35]=g,t[36]=x,t[37]=e):e=t[37],A=s.map(e),t[27]=a,t[28]=y,t[29]=g,t[30]=x,t[31]=s,t[32]=A}else A=t[32];let j;t[38]!==T||t[39]!==k||t[40]!==A?(j=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 w-full flex-col overflow-y-auto overflow-x-hidden`,children:(0,$.jsx)(`ol`,{className:`my-auto flex w-full flex-col items-end py-1`,onMouseEnter:k,onWheel:T,children:A})}),t[38]=T,t[39]=k,t[40]=A,t[41]=j):j=t[41];let M;t[42]!==i||t[43]!==v?(M=v?(0,$.jsx)(sCe,{turn:v,labels:i}):null,t[42]=i,t[43]=v,t[44]=M):M=t[44];let N;t[45]!==j||t[46]!==M?(N=(0,$.jsxs)(`div`,{className:`relative z-[90] flex h-full min-h-0 justify-end overflow-visible`,children:[j,M]}),t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==i.title||t[49]!==N?(P=(0,$.jsx)(`aside`,{ref:d,className:`hidden h-full w-12 shrink-0 overflow-visible py-4 xl:block`,"aria-label":E,onMouseLeave:O,onBlur:D,children:N}),t[48]=i.title,t[49]=N,t[50]=P):P=t[50],P}var x9=300*1e3,pCe=Math.round(x9/6e4);function mCe(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function hCe(e){let t=(0,Q.c)(7),{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s}=e;if(!n)return null;let c;return t[0]!==a||t[1]!==s||t[2]!==o||t[3]!==n||t[4]!==i||t[5]!==r?(c=(0,$.jsx)(gCe,{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s},n.requestId),t[0]=a,t[1]=s,t[2]=o,t[3]=n,t[4]=i,t[5]=r,t[6]=c):c=t[6],c}function gCe(e){let t=(0,Q.c)(70),{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onCancel:s}=e,[c,l]=(0,Z.useState)(``),[d]=(0,Z.useState)(vCe),[f,p]=(0,Z.useState)(0),m=(0,Z.useRef)(null),h,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{let e=window.setInterval(()=>p(_Ce),1e3);return()=>window.clearInterval(e)},g=[],t[0]=h,t[1]=g):(h=t[0],g=t[1]),(0,Z.useEffect)(h,g);let _,v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{m.current?.focus()},v=[],t[2]=_,t[3]=v):(_=t[2],v=t[3]),(0,Z.useEffect)(_,v);let y;t[4]===o?y=t[5]:(y=e=>{o(e)},t[4]=o,t[5]=y);let b=y,x=Math.max(0,Math.ceil((d-Date.now())/1e3)),S=`clarify-meta-${n.requestId}`,C=i?`clarify-err-${n.requestId}`:void 0,w;t[6]!==s||t[7]!==r?(w=e=>{e.key===`Escape`&&!r&&(e.preventDefault(),e.stopPropagation(),s())},t[6]=s,t[7]=r,t[8]=w):w=t[8];let T=w,E=Array.isArray(n.choices)&&n.choices.length>=2,D;t[9]!==a.clarifyDefaultChoice||t[10]!==n.default?(D=n.default?a.clarifyDefaultChoice.replace(`{{text}}`,n.default):null,t[9]=a.clarifyDefaultChoice,t[10]=n.default,t[11]=D):D=t[11];let O=D,k;t[12]===a.clarifyServerTimeout?k=t[13]:(k=a.clarifyServerTimeout.replace(`{{minutes}}`,String(pCe)),t[12]=a.clarifyServerTimeout,t[13]=k);let A=k,j;t[14]!==a.clarifyTimeRemaining||t[15]!==x?(j=a.clarifyTimeRemaining.replace(`{{time}}`,mCe(x)),t[14]=a.clarifyTimeRemaining,t[15]=x,t[16]=j):j=t[16];let M=j,N=a.clarifyRegionAria,P;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(P=u(`mb-4 rounded-lg border border-edge bg-surface-elevated px-4 py-3 text-sm text-fg shadow-sm outline-none`,lA.focusRingPanel),t[17]=P):P=t[17];let F;t[18]===a.clarifyResumeHint?F=t[19]:(F=(0,$.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:a.clarifyResumeHint}),t[18]=a.clarifyResumeHint,t[19]=F);let I;t[20]===n.question?I=t[21]:(I=(0,$.jsx)(gQ,{content:n.question,compact:!0,className:`mb-3`}),t[20]=n.question,t[21]=I);let L;t[22]===A?L=t[23]:(L=(0,$.jsx)(`li`,{children:A}),t[22]=A,t[23]=L);let R;t[24]!==a.clarifyDefaultTimeoutNote||t[25]!==n.default?(R=n.default?(0,$.jsx)(`li`,{children:a.clarifyDefaultTimeoutNote}):null,t[24]=a.clarifyDefaultTimeoutNote,t[25]=n.default,t[26]=R):R=t[26];let z;t[27]===a.clarifySkipNote?z=t[28]:(z=(0,$.jsx)(`li`,{children:a.clarifySkipNote}),t[27]=a.clarifySkipNote,t[28]=z);let B;t[29]===M?B=t[30]:(B=(0,$.jsx)(`li`,{children:M}),t[29]=M,t[30]=B);let V;t[31]!==S||t[32]!==L||t[33]!==R||t[34]!==z||t[35]!==B?(V=(0,$.jsxs)(`ul`,{id:S,className:`mb-3 list-inside list-disc space-y-1 text-xs text-fg-muted`,children:[L,R,z,B]}),t[31]=S,t[32]=L,t[33]=R,t[34]=z,t[35]=B,t[36]=V):V=t[36];let H;t[37]!==C||t[38]!==i?(H=i?(0,$.jsx)(`div`,{id:C,role:`alert`,className:`mb-3 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:i}):null,t[37]=C,t[38]=i,t[39]=H):H=t[39];let U;t[40]!==c||t[41]!==O||t[42]!==E||t[43]!==a.clarifyChoicesGroupAria||t[44]!==a.clarifyCustomLabel||t[45]!==a.clarifyPlaceholder||t[46]!==a.clarifySend||t[47]!==a.clarifyUseDefault||t[48]!==o||t[49]!==b||t[50]!==n.choices||t[51]!==n.default||t[52]!==r?(U=E?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`max-h-[min(40vh,16rem)] overflow-y-auto overflow-x-hidden pr-1 [scrollbar-gutter:stable]`,"aria-label":a.clarifyChoicesGroupAria,children:(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[n.choices.map(e=>(0,$.jsx)(tA,{type:`button`,variant:`secondary`,disabled:r,className:u(`min-h-9 w-full justify-start rounded-lg px-3 py-2 text-left text-sm font-normal shadow-none`,`hover:border-edge`),onClick:()=>b(e),children:e},e)),n.default?(0,$.jsx)(tA,{type:`button`,variant:`ghost`,disabled:r,className:u(`min-h-9 w-full justify-start rounded-lg border border-dashed border-edge px-3 py-2 text-left text-sm font-normal text-fg-muted`,`hover:border-edge hover:text-fg`),onClick:()=>b(n.default),children:O}):null]})}),(0,$.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:a.clarifyCustomLabel}),(0,$.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&o(t)},children:[(0,$.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:r,placeholder:a.clarifyPlaceholder,"aria-label":a.clarifyPlaceholder,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,$.jsx)(tA,{type:`submit`,variant:`primary`,disabled:r||!c.trim(),className:`shrink-0 rounded-lg px-4 py-2 shadow-surface`,children:a.clarifySend})]})]})]}):(0,$.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault();let t=c.trim();t&&(o(t),l(``))},children:[(0,$.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),disabled:r,placeholder:a.clarifyPlaceholder,"aria-label":a.clarifyPlaceholder,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,$.jsx)(tA,{type:`submit`,variant:`primary`,disabled:r||!c.trim(),className:`shrink-0 rounded-lg px-4 py-2 shadow-surface`,children:a.clarifySend}),n.default?(0,$.jsx)(tA,{type:`button`,variant:`secondary`,disabled:r,className:`shrink-0 rounded-lg px-3 py-2 text-sm font-normal text-fg-muted shadow-none hover:text-fg`,onClick:()=>b(n.default),children:a.clarifyUseDefault}):null]}),t[40]=c,t[41]=O,t[42]=E,t[43]=a.clarifyChoicesGroupAria,t[44]=a.clarifyCustomLabel,t[45]=a.clarifyPlaceholder,t[46]=a.clarifySend,t[47]=a.clarifyUseDefault,t[48]=o,t[49]=b,t[50]=n.choices,t[51]=n.default,t[52]=r,t[53]=U):U=t[53];let W;t[54]===s?W=t[55]:(W=()=>void s(),t[54]=s,t[55]=W);let G;t[56]!==a.clarifySkip||t[57]!==r||t[58]!==W?(G=(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle pt-3`,children:(0,$.jsx)(tA,{type:`button`,variant:`ghost`,disabled:r,className:`text-fg-muted hover:text-fg`,onClick:W,children:a.clarifySkip})}),t[56]=a.clarifySkip,t[57]=r,t[58]=W,t[59]=G):G=t[59];let K;return t[60]!==a.clarifyRegionAria||t[61]!==S||t[62]!==T||t[63]!==F||t[64]!==I||t[65]!==V||t[66]!==H||t[67]!==U||t[68]!==G?(K=(0,$.jsxs)(`section`,{ref:m,tabIndex:-1,"aria-label":N,"aria-describedby":S,onKeyDown:T,className:P,children:[F,I,V,H,U,G]}),t[60]=a.clarifyRegionAria,t[61]=S,t[62]=T,t[63]=F,t[64]=I,t[65]=V,t[66]=H,t[67]=U,t[68]=G,t[69]=K):K=t[69],K}function _Ce(e){return e+1}function vCe(){return Date.now()+x9}function yCe(e,t){return e===`running`||e===`queued`?t.runLinkRunning:e===`succeeded`?t.runLinkCompleted:t.runLinkFinished}var bCe=(0,Z.memo)(function(e){let t=(0,Q.c)(29),{link:n,className:r}=e,i=m(_(xCe)).workflows,a=br(),o;t[0]!==n.definitionId||t[1]!==n.goal?(o=n.goal.trim()||n.definitionId,t[0]=n.definitionId,t[1]=n.goal,t[2]=o):o=t[2];let s=o,c;t[3]!==n.ownerAgentId||t[4]!==n.runId||t[5]!==a?(c=()=>a(M7(n.runId,{ownerAgentId:n.ownerAgentId})),t[3]=n.ownerAgentId,t[4]=n.runId,t[5]=a,t[6]=c):c=t[6];let l;t[7]===r?l=t[8]:(l=u(`flex w-full items-start gap-3 rounded-2xl border border-edge bg-surface-panel px-4 py-3 text-left`,`transition-colors hover:bg-surface-hover/60`,lA.focusRingPanel,r),t[7]=r,t[8]=l);let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`span`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:(0,$.jsx)(iv,{className:`size-4`,"aria-hidden":!0})}),t[9]=d):d=t[9];let f=yCe(n.status,i),p;t[10]===f?p=t[11]:(p=(0,$.jsx)(`span`,{className:`block text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:f}),t[10]=f,t[11]=p);let h;t[12]===n.definitionId?h=t[13]:(h=(0,$.jsx)(`span`,{className:`mt-1 block text-sm font-semibold text-fg`,children:n.definitionId}),t[12]=n.definitionId,t[13]=h);let g;t[14]===s?g=t[15]:(g=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-sm text-fg-muted`,children:s}),t[14]=s,t[15]=g);let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(ho,{className:`size-3.5`,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]===i.taskOpenDetails?y=t[18]:(y=(0,$.jsxs)(`span`,{className:`mt-2 inline-flex items-center gap-1 text-xs font-medium text-accent-fg`,children:[i.taskOpenDetails,v]}),t[17]=i.taskOpenDetails,t[18]=y);let b;t[19]!==h||t[20]!==g||t[21]!==y||t[22]!==p?(b=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[p,h,g,y]}),t[19]=h,t[20]=g,t[21]=y,t[22]=p,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==c||t[26]!==l||t[27]!==d?(x=(0,$.jsxs)(`button`,{type:`button`,onClick:c,className:l,children:[d,b]}),t[24]=b,t[25]=c,t[26]=l,t[27]=d,t[28]=x):x=t[28],x});function xCe(e){return e.language}function SCe(e,t){let n=Number.parseInt(e,10);return Number.isFinite(n)?n:t+1}function S9(e){let t=new Map(e.phases.map(e=>[e.id,e.title])),n=e.phases.find(e=>e.status===`running`),r=e.agents.map((e,n)=>({id:SCe(e.id,n),label:e.label,phase:e.phaseId?t.get(e.phaseId):void 0,prompt:e.prompt??``,invocation:e.invocation,sessionKey:e.sessionKey,transcriptMessageCount:e.transcriptMessageCount,status:e.status,resultPreview:e.resultPreview,error:e.error,startedAtMs:e.startedAtMs,durationMs:e.startedAtMs!=null&&e.completedAtMs!=null?e.completedAtMs-e.startedAtMs:void 0,currentStep:e.currentStep,steps:e.steps?.map(e=>({id:e.id,kind:e.kind,toolName:e.toolName,label:e.label,detail:e.detail,status:e.status,resultPreview:e.resultPreview,error:e.error,startedAtMs:e.startedAtMs,durationMs:e.startedAtMs!=null&&e.completedAtMs!=null?e.completedAtMs-e.startedAtMs:void 0}))})),{metrics:i}=e.run;return{runId:e.run.id,name:e.run.definitionId,description:e.run.goal||e.run.title,phases:e.phases.map(e=>e.title),currentPhase:n?.title,logs:e.logs.map(e=>e.message),agents:r,agentCount:i.agentCount,runningCount:Math.max(0,i.agentCount-i.doneAgentCount-i.errorAgentCount-i.skippedAgentCount),doneCount:i.doneAgentCount,errorCount:i.errorAgentCount,skippedCount:i.skippedAgentCount,durationMs:i.durationMs,result:e.run.result}}function C9(e){return e===`succeeded`?`border-emerald-500/30 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`border-destructive/40 text-destructive`:e===`cancelled`?`border-warning/40 text-warning`:`border-accent/40 text-accent`}var CCe=(0,Z.memo)(function(e){let t=(0,Q.c)(241),{view:n,onAbortCurrentTurn:r}=e,i=H7(_(wCe)),a=i.live,o;t[0]===n?o=t[1]:(o=S9(n),t[0]=n,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=m7(s),t[2]=s,t[3]=c);let l=c,d;t[4]===n.run.status?d=t[5]:(d=k7.has(n.run.status),t[4]=n.run.status,t[5]=d);let f=d,[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(`overview`),[v,y]=(0,Z.useState)(null),[,b]=(0,Z.useState)(0),x;t[6]!==f||t[7]!==b?(x=()=>{if(!f)return;let e=window.setInterval(()=>b(TCe),1e3);return()=>window.clearInterval(e)},t[6]=f,t[7]=b,t[8]=x):x=t[8];let S;t[9]===f?S=t[10]:(S=[f],t[9]=f,t[10]=S),(0,Z.useEffect)(x,S);let C=f&&n.run.startedAtMs?Date.now()-n.run.startedAtMs:n.run.metrics.durationMs??s.durationMs??0,w;t[11]===C?w=t[12]:(w=C?g7(C):``,t[11]=C,t[12]=w);let T=w,E=a.progress(s.doneCount,s.agentCount),D=s.currentPhase||a.activeFallback,O;t[13]!==n.run.definitionId||t[14]!==n.run.goal||t[15]!==n.run.title?(O=n.run.goal.trim()||n.run.title||n.run.definitionId,t[13]=n.run.definitionId,t[14]=n.run.goal,t[15]=n.run.title,t[16]=O):O=t[16];let k=O,A=n.run.metadata?.agentId,j,M,N,P,F,I,L,R,z,B,V,H,U,W,G,K;if(t[17]!==h||t[18]!==D||t[19]!==p||t[20]!==T||t[21]!==f||t[22]!==i||t[23]!==a.agents||t[24]!==a.close||t[25]!==a.currentState||t[26]!==a.details||t[27]!==a.elapsed||t[28]!==a.logs||t[29]!==a.openRun||t[30]!==a.overview||t[31]!==a.result||t[32]!==a.runId||t[33]!==a.status||t[34]!==a.stop||t[35]!==a.title||t[36]!==r||t[37]!==A||t[38]!==E||t[39]!==l||t[40]!==v||t[41]!==g||t[42]!==m||t[43]!==y||t[44]!==s||t[45]!==k||t[46]!==n.logs||t[47]!==n.run.error||t[48]!==n.run.id||t[49]!==n.run.status){let e=n.logs.map(ECe).filter(Boolean),o;t[66]!==f||t[67]!==r||t[68]!==A||t[69]!==n.run.id?(o=()=>{f&&c8(n.run.id,{ownerAgentId:A}).catch(DCe),r?.()},t[66]=f,t[67]=r,t[68]=A,t[69]=n.run.id,t[70]=o):o=t[70],P=o;let c;t[71]===a.overview?c=t[72]:(c={id:`overview`,label:a.overview},t[71]=a.overview,t[72]=c);let d;t[73]===a.agents?d=t[74]:(d={id:`agents`,label:a.agents},t[73]=a.agents,t[74]=d);let _;t[75]===a.logs?_=t[76]:(_={id:`logs`,label:a.logs},t[75]=a.logs,t[76]=_);let b;t[77]===a.result?b=t[78]:(b={id:`result`,label:a.result},t[77]=a.result,t[78]=b);let x;t[79]!==c||t[80]!==d||t[81]!==_||t[82]!==b?(x=[c,d,_,b],t[79]=c,t[80]=d,t[81]=_,t[82]=b,t[83]=x):x=t[83];let S=x;U=`mb-6`;let C;t[84]===m?C=t[85]:(C=()=>m(!0),t[84]=m,t[85]=C);let w;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(iv,{className:`size-4`,"aria-hidden":!0}),t[86]=w):w=t[86];let O;t[87]===f?O=t[88]:(O=f?(0,$.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-surface-panel bg-accent motion-safe:animate-pulse`}):null,t[87]=f,t[88]=O);let q;t[89]===O?q=t[90]:(q=(0,$.jsxs)(`span`,{className:`relative flex size-8 shrink-0 items-center justify-center rounded-full bg-accent-soft text-accent-fg`,children:[w,O]}),t[89]=O,t[90]=q);let ee=a.status[n.run.status],J;t[91]===ee?J=t[92]:(J=(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:ee}),t[91]=ee,t[92]=J);let te;t[93]===n.run.status?te=t[94]:(te=u(`rounded-full border px-1.5 py-0.5`,C9(n.run.status)),t[93]=n.run.status,t[94]=te);let Y;t[95]!==E||t[96]!==te?(Y=(0,$.jsx)(`span`,{className:te,children:E}),t[95]=E,t[96]=te,t[97]=Y):Y=t[97];let ne;t[98]===D?ne=t[99]:(ne=(0,$.jsx)(`span`,{className:`truncate`,children:D}),t[98]=D,t[99]=ne);let re;t[100]!==T||t[101]!==a.elapsed?(re=T?(0,$.jsxs)(`span`,{children:[a.elapsed,`: `,(0,$.jsx)(`span`,{className:`text-fg`,children:T})]}):null,t[100]=T,t[101]=a.elapsed,t[102]=re):re=t[102];let X;t[103]!==J||t[104]!==Y||t[105]!==ne||t[106]!==re?(X=(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-fg-muted`,children:[J,Y,ne,re]}),t[103]=J,t[104]=Y,t[105]=ne,t[106]=re,t[107]=X):X=t[107];let ie;t[108]===k?ie=t[109]:(ie=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-medium leading-tight text-fg`,children:k}),t[108]=k,t[109]=ie);let ae;t[110]!==X||t[111]!==ie?(ae=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[X,ie]}),t[110]=X,t[111]=ie,t[112]=ae):ae=t[112];let oe;t[113]!==C||t[114]!==q||t[115]!==ae?(oe=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 rounded-lg text-left outline-none hover:bg-surface-hover/70 focus-visible:ring-2 focus-visible:ring-accent`,onClick:C,children:[q,ae]}),t[113]=C,t[114]=q,t[115]=ae,t[116]=oe):oe=t[116];let se;t[117]!==P||t[118]!==f||t[119]!==a.stop?(se=f?(0,$.jsxs)(tA,{type:`button`,variant:`ghost`,className:`hidden h-8 px-2 text-xs sm:inline-flex`,onClick:P,children:[(0,$.jsx)(Xd,{className:`size-3.5`,"aria-hidden":!0}),a.stop]}):null,t[117]=P,t[118]=f,t[119]=a.stop,t[120]=se):se=t[120];let ce;t[121]===m?ce=t[122]:(ce=()=>m(!0),t[121]=m,t[122]=ce);let le;t[123]!==a.details||t[124]!==ce?(le=(0,$.jsx)(tA,{type:`button`,variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:ce,children:a.details}),t[123]=a.details,t[124]=ce,t[125]=le):le=t[125];let ue;t[126]!==se||t[127]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[se,le]}),t[126]=se,t[127]=le,t[128]=ue):ue=t[128],t[129]!==oe||t[130]!==ue?(W=(0,$.jsxs)(`div`,{className:`flex min-h-12 items-center gap-2 rounded-xl border border-edge bg-surface-panel px-2.5 py-2 shadow-surface sm:px-3`,children:[oe,ue]}),t[129]=oe,t[130]=ue,t[131]=W):W=t[131],N=FN,V=p,H=m,M=LN,t[132]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(RN,{className:`xopc-dialog-overlay fixed inset-0 z-[120] bg-scrim backdrop-blur-[1px]`}),t[132]=B):B=t[132],j=zN,L=`fixed left-1/2 top-1/2 z-[121] flex h-[min(84vh,44rem)] w-[min(100vw-2rem,54rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`;let Z;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,$.jsx)(iv,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[133]=Z):Z=t[133];let de;t[134]===a.title?de=t[135]:(de=(0,$.jsx)(BN,{className:`truncate text-sm font-semibold text-fg`,children:a.title}),t[134]=a.title,t[135]=de);let fe;t[136]===n.run.status?fe=t[137]:(fe=u(`rounded-full border px-1.5 py-0.5 text-[10px]`,C9(n.run.status)),t[136]=n.run.status,t[137]=fe);let pe=a.status[n.run.status],me;t[138]!==fe||t[139]!==pe?(me=(0,$.jsx)(`span`,{className:fe,children:pe}),t[138]=fe,t[139]=pe,t[140]=me):me=t[140];let he;t[141]!==de||t[142]!==me?(he=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Z,de,me]}),t[141]=de,t[142]=me,t[143]=he):he=t[143];let ge;t[144]===k?ge=t[145]:(ge=(0,$.jsx)(VN,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:k}),t[144]=k,t[145]=ge);let _e;t[146]!==he||t[147]!==ge?(_e=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[he,ge]}),t[146]=he,t[147]=ge,t[148]=_e):_e=t[148];let ve;t[149]!==A||t[150]!==n.run.id?(ve=M7(n.run.id,{ownerAgentId:A}),t[149]=A,t[150]=n.run.id,t[151]=ve):ve=t[151];let ye;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(gh,{className:`size-3.5`,"aria-hidden":!0}),t[152]=ye):ye=t[152];let be;t[153]!==a.openRun||t[154]!==ve?(be=(0,$.jsx)(tA,{asChild:!0,type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,children:(0,$.jsxs)(Hi,{to:ve,children:[ye,a.openRun]})}),t[153]=a.openRun,t[154]=ve,t[155]=be):be=t[155];let xe;t[156]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,$.jsx)(Sk,{className:`size-4`,"aria-hidden":!0}),t[156]=xe):xe=t[156];let Se;t[157]===a.close?Se=t[158]:(Se=(0,$.jsx)(HN,{asChild:!0,children:(0,$.jsx)(tA,{type:`button`,variant:`ghost`,className:`size-8 p-0`,"aria-label":a.close,children:xe})}),t[157]=a.close,t[158]=Se);let Ce;t[159]!==be||t[160]!==Se?(Ce=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[be,Se]}),t[159]=be,t[160]=Se,t[161]=Ce):Ce=t[161],t[162]!==_e||t[163]!==Ce?(R=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[_e,Ce]}),t[162]=_e,t[163]=Ce,t[164]=R):R=t[164];let we=a.title,Te;t[165]!==h||t[166]!==g||t[167]!==S?(Te=S.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":h===e.id,className:u(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,h===e.id?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>g(e.id),children:e.label},e.id)),t[165]=h,t[166]=g,t[167]=S,t[168]=Te):Te=t[168],t[169]!==a.title||t[170]!==Te?(z=(0,$.jsx)(`div`,{className:`flex shrink-0 gap-1 border-b border-edge px-4 py-2`,role:`tablist`,"aria-label":we,children:Te}),t[169]=a.title,t[170]=Te,t[171]=z):z=t[171],G=`min-h-0 flex-1 overflow-y-auto px-4 py-3`,t[172]!==h||t[173]!==D||t[174]!==T||t[175]!==a.currentState||t[176]!==a.elapsed||t[177]!==a.runId||t[178]!==a.status||t[179]!==E||t[180]!==n.run.error||t[181]!==n.run.id||t[182]!==n.run.status?(K=h===`overview`?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(kv,{className:`size-4 text-accent`,"aria-hidden":!0}),a.currentState]}),(0,$.jsxs)(`div`,{className:`grid gap-2 text-sm text-fg-muted sm:grid-cols-2`,children:[(0,$.jsxs)(`p`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:a.status[n.run.status]}),(0,$.jsx)(`span`,{className:`mx-1 text-fg-subtle`,children:`·`}),D]}),(0,$.jsx)(`p`,{children:E}),T?(0,$.jsxs)(`p`,{children:[a.elapsed,`: `,(0,$.jsx)(`span`,{className:`text-fg`,children:T})]}):null,(0,$.jsxs)(`p`,{className:`break-all`,children:[a.runId,`: `,(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:n.run.id})]})]})]}),n.run.error?.message?(0,$.jsx)(`p`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:n.run.error.message}):null]}):null,t[172]=h,t[173]=D,t[174]=T,t[175]=a.currentState,t[176]=a.elapsed,t[177]=a.runId,t[178]=a.status,t[179]=E,t[180]=n.run.error,t[181]=n.run.id,t[182]=n.run.status,t[183]=K):K=t[183],t[184]!==h||t[185]!==i||t[186]!==l||t[187]!==v||t[188]!==y||t[189]!==s?(F=h===`agents`?(0,$.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(18rem,24rem)]`,children:[(0,$.jsx)(S7,{rollup:l,currentPhase:s.currentPhase,labels:i.phase,recentLogs:[],recentLogsHeading:i.recentLogsHeading,showAllLogsLabel:i.showAllLogs,logsExpanded:!1,onToggleLogs:OCe,selectedAgentId:v?.id,onSelectAgent:y}),(0,$.jsx)(v7,{agent:v,snapshot:s,labels:i.checkDetail,onClose:()=>y(null)})]}):null,t[184]=h,t[185]=i,t[186]=l,t[187]=v,t[188]=y,t[189]=s,t[190]=F):F=t[190],I=h===`logs`?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Gx,{className:`size-4 text-accent`,"aria-hidden":!0}),a.logs]}),e.length?(0,$.jsx)(`div`,{className:`space-y-1`,children:e.map(kCe)}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.error.noExtraDetails})]}):null,t[17]=h,t[18]=D,t[19]=p,t[20]=T,t[21]=f,t[22]=i,t[23]=a.agents,t[24]=a.close,t[25]=a.currentState,t[26]=a.details,t[27]=a.elapsed,t[28]=a.logs,t[29]=a.openRun,t[30]=a.overview,t[31]=a.result,t[32]=a.runId,t[33]=a.status,t[34]=a.stop,t[35]=a.title,t[36]=r,t[37]=A,t[38]=E,t[39]=l,t[40]=v,t[41]=g,t[42]=m,t[43]=y,t[44]=s,t[45]=k,t[46]=n.logs,t[47]=n.run.error,t[48]=n.run.id,t[49]=n.run.status,t[50]=j,t[51]=M,t[52]=N,t[53]=P,t[54]=F,t[55]=I,t[56]=L,t[57]=R,t[58]=z,t[59]=B,t[60]=V,t[61]=H,t[62]=U,t[63]=W,t[64]=G,t[65]=K}else j=t[50],M=t[51],N=t[52],P=t[53],F=t[54],I=t[55],L=t[56],R=t[57],z=t[58],B=t[59],V=t[60],H=t[61],U=t[62],W=t[63],G=t[64],K=t[65];let q;t[191]!==h||t[192]!==i||t[193]!==a.noResult||t[194]!==n.run.result?(q=h===`result`?j7(n.run.result)?(0,$.jsx)(w7,{result:n.run.result,labels:i.result}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.noResult}):null,t[191]=h,t[192]=i,t[193]=a.noResult,t[194]=n.run.result,t[195]=q):q=t[195];let ee;t[196]!==F||t[197]!==I||t[198]!==q||t[199]!==G||t[200]!==K?(ee=(0,$.jsxs)(`div`,{className:G,children:[K,F,I,q]}),t[196]=F,t[197]=I,t[198]=q,t[199]=G,t[200]=K,t[201]=ee):ee=t[201];let J;t[202]===n.run.definitionId?J=t[203]:(J=(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n.run.definitionId}),t[202]=n.run.definitionId,t[203]=J);let te;t[204]!==P||t[205]!==f||t[206]!==a.stop?(te=f?(0,$.jsxs)(tA,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:P,children:[(0,$.jsx)(Xd,{className:`size-3.5`,"aria-hidden":!0}),a.stop]}):null,t[204]=P,t[205]=f,t[206]=a.stop,t[207]=te):te=t[207];let Y;t[208]!==A||t[209]!==n.run.id?(Y=M7(n.run.id,{ownerAgentId:A}),t[208]=A,t[209]=n.run.id,t[210]=Y):Y=t[210];let ne;t[211]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(gh,{className:`size-3.5`,"aria-hidden":!0}),t[211]=ne):ne=t[211];let re;t[212]!==a.openRun||t[213]!==Y?(re=(0,$.jsx)(tA,{asChild:!0,type:`button`,variant:`primary`,className:`h-8 text-xs`,children:(0,$.jsxs)(Hi,{to:Y,children:[ne,a.openRun]})}),t[212]=a.openRun,t[213]=Y,t[214]=re):re=t[214];let X;t[215]!==te||t[216]!==re?(X=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[te,re]}),t[215]=te,t[216]=re,t[217]=X):X=t[217];let ie;t[218]!==J||t[219]!==X?(ie=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-edge px-4 py-3`,children:[J,X]}),t[218]=J,t[219]=X,t[220]=ie):ie=t[220];let ae;t[221]!==j||t[222]!==L||t[223]!==R||t[224]!==z||t[225]!==ee||t[226]!==ie?(ae=(0,$.jsxs)(j,{className:L,children:[R,z,ee,ie]}),t[221]=j,t[222]=L,t[223]=R,t[224]=z,t[225]=ee,t[226]=ie,t[227]=ae):ae=t[227];let oe;t[228]!==M||t[229]!==B||t[230]!==ae?(oe=(0,$.jsxs)(M,{children:[B,ae]}),t[228]=M,t[229]=B,t[230]=ae,t[231]=oe):oe=t[231];let se;t[232]!==N||t[233]!==V||t[234]!==H||t[235]!==oe?(se=(0,$.jsx)(N,{open:V,onOpenChange:H,children:oe}),t[232]=N,t[233]=V,t[234]=H,t[235]=oe,t[236]=se):se=t[236];let ce;return t[237]!==U||t[238]!==W||t[239]!==se?(ce=(0,$.jsxs)(`div`,{className:U,children:[W,se]}),t[237]=U,t[238]=W,t[239]=se,t[240]=ce):ce=t[240],ce});function wCe(e){return e.language}function TCe(e){return e+1}function ECe(e){return e.message}function DCe(){}function OCe(){}function kCe(e,t){return(0,$.jsx)(`p`,{className:`break-words font-mono text-xs leading-5 text-fg-muted`,children:e},`${t}:${e}`)}var w9={list:e=>{let t=new URLSearchParams;e?.projectId&&t.set(`projectId`,e.projectId);let n=t.toString();return J(X(`/api/automations${n?`?${n}`:``}`))},metrics:()=>J(X(`/api/automations/metrics`)),draft:e=>J(X(`/api/automations/draft`),{method:`POST`,body:JSON.stringify(e)}),simulate:e=>J(X(`/api/automations/simulate`),{method:`POST`,body:JSON.stringify(e)}),create:e=>J(X(`/api/automations`),{method:`POST`,body:JSON.stringify(e)}),update:(e,t)=>J(X(`/api/automations/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)}),remove:e=>J(X(`/api/automations/${encodeURIComponent(e)}`),{method:`DELETE`}),runNow:e=>J(X(`/api/automations/${encodeURIComponent(e)}/run`),{method:`POST`}),pause:e=>J(X(`/api/automations/${encodeURIComponent(e)}/pause`),{method:`POST`}),resume:e=>J(X(`/api/automations/${encodeURIComponent(e)}/resume`),{method:`POST`}),runs:(e=50,t,n)=>{let r=new URLSearchParams({limit:String(e)});return t&&r.set(`automationId`,t),!t&&n?.projectId&&r.set(`projectId`,n.projectId),J(X(`/api/automation-runs?${r.toString()}`))},productEventRuns:e=>{let t=new URLSearchParams({eventType:e.eventType,limit:String(e.limit??5)});return e.source&&t.set(`source`,e.source),e.payloadKey&&t.set(`payloadKey`,e.payloadKey),e.payloadValue!==void 0&&t.set(`payloadValue`,e.payloadValue),J(X(`/api/automation-runs/product-events?${t.toString()}`))},runEvents:e=>J(X(`/api/automation-runs/${encodeURIComponent(e)}/events`)),rerun:e=>J(X(`/api/automation-runs/${encodeURIComponent(e)}/rerun`),{method:`POST`}),repairDraft:(e,t)=>J(X(`/api/automation-runs/${encodeURIComponent(e)}/repair-draft`),{method:`POST`,body:JSON.stringify(t)}),cancelRun:e=>J(X(`/api/automation-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})};function T9(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,String(n)),e)}function ACe(e,t){if(!e.enabled||e.trigger.kind!==`event`||e.trigger.eventType!==t.eventType||e.trigger.source&&e.trigger.source!==t.source)return!1;let n=e.trigger.payloadMatch;if(!n)return!0;let r=t.eventPayload??{};return Object.entries(n).every(([e,t])=>Object.is(r[e],t))}function jCe(e,t){let n=e.trigger,r=t.explain;return n.kind===`event`?[E9(n.eventType,n.source,t),D9(n.payloadMatch,t),k9(e.safety,t),O9(e.action,t)]:[r.triggerMatched,O9(e.action,t)]}function MCe(e,t,n){let r=e.triggerSnapshot,i=PCe(t),a=n.explain;return r.kind===`event`?[i?E9(i.type,i.source,n):E9(r.eventType,r.source,n),D9(r.payloadMatch,n),k9(NCe(t),n),O9(e.actionSnapshot,n)]:r.kind===`manual`?[a.manual,O9(e.actionSnapshot,n)]:r.kind===`webhook`?[a.webhook,O9(e.actionSnapshot,n)]:[a.schedule,O9(e.actionSnapshot,n)]}function E9(e,t,n){let r=n.explain;return t?T9(r.eventFrom,{eventType:e,source:t}):T9(r.event,{eventType:e})}function D9(e,t){if(!e||Object.keys(e).length===0)return t.explain.noPayloadFilter;let n=Object.entries(e).slice(0,3).map(([e,t])=>`${e}=${String(t)}`).join(`, `);return T9(t.explain.payloadMatched,{pairs:n})}function O9(e,t){return e.kind===`workflow`?T9(t.explain.actionWorkflow,{workflowId:e.workflowId}):t.explain.actionAgent}function k9(e,t){let n=e?.mode??`auto_apply`;return T9(t.explain.safetyMode,{mode:t.safety[n]})}function NCe(e){if(!e.data||typeof e.data!=`object`||Array.isArray(e.data))return;let t=e.data.safety;if(!t||typeof t!=`object`||Array.isArray(t))return;let n=t.mode;return n===`suggest_only`||n===`ask_before_apply`||n===`auto_apply`?{mode:n}:void 0}function PCe(e){if(!e.data||typeof e.data!=`object`||Array.isArray(e.data))return null;let t=e.data.event;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;return typeof n.type!=`string`||!n.type.trim()?null:{type:n.type,source:typeof n.source==`string`?n.source:void 0}}function FCe(e){return e===`succeeded`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300`:e===`cancelled`?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300`}function ICe(e,t){return new Date(e).toLocaleString(t,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function LCe(e){return e.some(e=>e.run.status===`queued`||e.run.status===`running`)}function A9(e){return e===`failed`||e===`timeout`||e===`cancelled`}function RCe(e){let t=new Map;for(let{run:n}of e){let e=t.get(n.automationId),r=!e||n.createdAtMs>e.latest.createdAtMs?n:e.latest;t.set(n.automationId,{latest:r,hadAttention:!!e?.hadAttention||A9(n.status)})}let n={total:t.size,succeeded:0,active:0,attention:0,recovered:0};for(let{latest:e,hadAttention:r}of t.values())e.status===`succeeded`&&(n.succeeded+=1),e.status===`succeeded`&&r&&(n.recovered+=1),(e.status===`queued`||e.status===`running`)&&(n.active+=1),A9(e.status)&&(n.attention+=1,n.latestAttentionRun??=e);return n}function zCe(e){let t=new Map;for(let{run:n}of e){let e=t.get(n.automationId);(!e||n.createdAtMs>e.createdAtMs)&&t.set(n.automationId,n)}return t}function j9(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,String(n)),e)}function BCe(e){let t=(0,Q.c)(47),{health:n,labels:r,primaryRepairBusy:i,onPrimaryRepair:a}=e,o=n.attention>0,s=n.active>0,c=n.recovered>0,l;t[0]!==s||t[1]!==c||t[2]!==n.active||t[3]!==n.attention||t[4]!==n.latestAttentionRun?.automationName||t[5]!==n.recovered||t[6]!==n.succeeded||t[7]!==n.total||t[8]!==r.feedback.summaryHealthy||t[9]!==r.feedback.summaryNeedsAttention||t[10]!==r.feedback.summaryRecovered||t[11]!==r.feedback.summaryRunning||t[12]!==r.feedback.thisAutomation||t[13]!==o?(l=o?j9(r.feedback.summaryNeedsAttention,{total:n.total,attention:n.attention,name:n.latestAttentionRun?.automationName??r.feedback.thisAutomation}):s?j9(r.feedback.summaryRunning,{total:n.total,active:n.active}):c?j9(r.feedback.summaryRecovered,{total:n.total,recovered:n.recovered,succeeded:n.succeeded}):j9(r.feedback.summaryHealthy,{total:n.total,succeeded:n.succeeded}),t[0]=s,t[1]=c,t[2]=n.active,t[3]=n.attention,t[4]=n.latestAttentionRun?.automationName,t[5]=n.recovered,t[6]=n.succeeded,t[7]=n.total,t[8]=r.feedback.summaryHealthy,t[9]=r.feedback.summaryNeedsAttention,t[10]=r.feedback.summaryRecovered,t[11]=r.feedback.summaryRunning,t[12]=r.feedback.thisAutomation,t[13]=o,t[14]=l):l=t[14];let d=l,f=o?`text-amber-800 dark:text-amber-200`:`text-fg-muted`,p;t[15]===f?p=t[16]:(p=u(`break-words text-xs leading-5`,f),t[15]=f,t[16]=p);let m;t[17]!==d||t[18]!==p?(m=(0,$.jsx)(`p`,{className:p,children:d}),t[17]=d,t[18]=p,t[19]=m):m=t[19];let h;t[20]!==n.succeeded||t[21]!==r.feedback.succeededCount?(h=n.succeeded?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-xs text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(yd,{className:`size-3`,"aria-hidden":!0}),j9(r.feedback.succeededCount,{count:n.succeeded})]}):null,t[20]=n.succeeded,t[21]=r.feedback.succeededCount,t[22]=h):h=t[22];let g;t[23]!==n.active||t[24]!==r.feedback.activeCount?(g=n.active?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-blue-500/25 bg-blue-500/10 px-2 py-0.5 text-xs text-blue-700 dark:text-blue-300`,children:[(0,$.jsx)(Sf,{className:`size-3`,"aria-hidden":!0}),j9(r.feedback.activeCount,{count:n.active})]}):null,t[23]=n.active,t[24]=r.feedback.activeCount,t[25]=g):g=t[25];let _;t[26]!==n.attention||t[27]!==r.feedback.attentionCount?(_=n.attention?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-amber-500/25 bg-amber-500/10 px-2 py-0.5 text-xs text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(mD,{className:`size-3`,"aria-hidden":!0}),j9(r.feedback.attentionCount,{count:n.attention})]}):null,t[26]=n.attention,t[27]=r.feedback.attentionCount,t[28]=_):_=t[28];let v;t[29]!==n.recovered||t[30]!==r.feedback.recoveredCount?(v=n.recovered?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-xs text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(yd,{className:`size-3`,"aria-hidden":!0}),j9(r.feedback.recoveredCount,{count:n.recovered})]}):null,t[29]=n.recovered,t[30]=r.feedback.recoveredCount,t[31]=v):v=t[31];let y;t[32]!==h||t[33]!==g||t[34]!==_||t[35]!==v?(y=(0,$.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:[h,g,_,v]}),t[32]=h,t[33]=g,t[34]=_,t[35]=v,t[36]=y):y=t[36];let b;t[37]!==r.feedback.primaryRepair||t[38]!==r.feedback.primaryRepairing||t[39]!==o||t[40]!==a||t[41]!==i?(b=o&&a?(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(tA,{variant:`secondary`,className:`h-7 rounded-md px-2 text-xs`,disabled:i,onClick:a,children:[(0,$.jsx)(SC,{className:`size-3.5`,"aria-hidden":!0}),i?r.feedback.primaryRepairing:r.feedback.primaryRepair]})}):null,t[37]=r.feedback.primaryRepair,t[38]=r.feedback.primaryRepairing,t[39]=o,t[40]=a,t[41]=i,t[42]=b):b=t[42];let x;return t[43]!==b||t[44]!==m||t[45]!==y?(x=(0,$.jsxs)(`div`,{className:`mb-3 border-l-2 border-accent/50 pl-3`,children:[m,y,b]}),t[43]=b,t[44]=m,t[45]=y,t[46]=x):x=t[46],x}function M9({eventType:e,source:t,payloadKey:n,payloadValue:r,limit:i=3,className:a,onSaveInsight:o,isInsightSaved:s}){let c=_(e=>e.language),l=m(c).automations,d=c===`zh`?`zh-CN`:`en-US`,f=[`product-automation-feedback`,e,t??``,n??``,r??``,i],[p,h]=(0,Z.useState)(null),{data:g,mutate:v}=ie(e&&(!n||r!==void 0)?f:null,()=>w9.productEventRuns({eventType:e,source:t,payloadKey:n,payloadValue:r,limit:i}),{revalidateOnFocus:!1,refreshInterval:e=>e?.items&&LCe(e.items)?3e3:15e3}),[y,b]=(0,Z.useState)({}),[x,S]=(0,Z.useState)({}),C=g?.items??[],w=RCe(C),T=zCe(C);if(!C.length)return null;let E=async(e,t,n)=>{h(e);try{await t(),await v(),re({type:`success`,title:n})}catch(e){re({type:`error`,title:l.feedback.actionFailed,message:e instanceof Error?e.message:String(e)})}finally{h(null)}},D=async e=>{h(`${e.id}:repair`);try{let t=await w9.repairDraft(e.id,{language:c});b(n=>({...n,[e.id]:t.repair})),S(t=>({...t,[e.id]:!1}))}catch(e){re({type:`error`,title:l.feedback.actionFailed,message:e instanceof Error?e.message:String(e)})}finally{h(null)}},O=async(e,t,n=!1)=>{h(n?`${e.id}:applyAndRerun`:`${e.id}:applyRepair`);try{await w9.update(e.automationId,t.patch),n&&await w9.rerun(e.id),await v(),b(t=>{let n={...t};return delete n[e.id],n}),S(t=>{let n={...t};return delete n[e.id],n}),re({type:`success`,title:n?l.feedback.repairAppliedAndQueued:l.feedback.repairApplied})}catch(e){re({type:`error`,title:l.feedback.actionFailed,message:e instanceof Error?e.message:String(e)})}finally{h(null)}},k=w.latestAttentionRun&&!y[w.latestAttentionRun.id]?w.latestAttentionRun:void 0,A=k?p===`${k.id}:repair`:!1;return(0,$.jsxs)(`section`,{className:u(`rounded-lg border border-edge bg-surface-panel p-3`,a),children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`h3`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(wk,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:l.feedback.title})]}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:C.length})]}),(0,$.jsx)(BCe,{health:w,labels:l,primaryRepairBusy:A,onPrimaryRepair:k?()=>void D(k):void 0}),(0,$.jsx)(`ul`,{className:`grid gap-2`,children:C.map(({run:e,triggerEvent:t})=>{let n=T.get(e.automationId),r=n?.id===e.id,i=A9(e.status)&&!r,a=i&&n?.status===`succeeded`,c=y[e.id],f=x[e.id]??!1,m=p===`${e.id}:repair`,h=p===`${e.id}:applyRepair`,g=p===`${e.id}:applyAndRerun`,_=MCe(e,t,l),v=s?.(e)??!1,C=e.status===`succeeded`&&!!e.summary&&!!o&&!v,w=p===`${e.id}:saveInsight`;return(0,$.jsxs)(`li`,{className:`rounded-md border border-edge/70 bg-surface-muted/35 px-2.5 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(zc,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.automationName})]}),(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-xs text-fg-muted`,children:e.error||e.summary||t.message})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,$.jsx)(`span`,{className:u(`rounded-full border px-2 py-0.5 text-xs`,FCe(e.status)),children:l.status[e.status]}),i?(0,$.jsx)(`span`,{className:`rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-xs text-emerald-700 dark:text-emerald-300`,children:a?l.feedback.recovered:l.feedback.historical}):null]})]}),(0,$.jsx)(`div`,{className:`mt-2 flex items-center justify-between gap-2 text-xs text-fg-muted`,children:(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[(0,$.jsx)(Zi,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:ICe(t.createdAtMs,d)})]})}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/60 bg-surface-base/45 px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:l.explain.whyRan}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:_.map(e=>(0,$.jsx)(`span`,{className:`rounded-full border border-edge/70 bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e))})]}),c?(0,$.jsxs)(`div`,{className:`mt-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-semibold text-amber-800 dark:text-amber-200`,children:[(0,$.jsx)(SC,{className:`size-3.5`,"aria-hidden":!0}),l.repair.title]}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg`,children:c.explanation}),c.expectedEffect?(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:c.expectedEffect}):null,c.risks.length?(0,$.jsx)(`ul`,{className:`mt-2 list-disc space-y-1 pl-4 text-xs text-fg-muted`,children:c.risks.slice(0,3).map(e=>(0,$.jsx)(`li`,{children:e},e))}):null,c.requiresApproval?(0,$.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-fg`,children:[(0,$.jsx)(`input`,{className:`mt-0.5`,type:`checkbox`,checked:f,onChange:t=>{S(n=>({...n,[e.id]:t.target.checked}))}}),(0,$.jsx)(`span`,{children:l.repair.approval})]}):null,(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1.5`,children:[(0,$.jsx)(tA,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,onClick:()=>{b(t=>{let n={...t};return delete n[e.id],n})},children:l.draft.discard}),(0,$.jsx)(tA,{variant:`secondary`,className:`h-7 rounded-md px-2 text-xs`,disabled:c.requiresApproval&&!f||p!==null,onClick:()=>void O(e,c),children:h?l.feedback.working:l.repair.apply}),(0,$.jsxs)(tA,{variant:`primary`,className:`h-7 rounded-md px-2 text-xs`,disabled:c.requiresApproval&&!f||p!==null,onClick:()=>void O(e,c,!0),children:[(0,$.jsx)(cx,{className:`size-3.5`,"aria-hidden":!0}),g?l.feedback.working:l.feedback.applyAndRerun]})]})]}):null,(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[v?(0,$.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1 rounded-md border border-emerald-500/25 bg-emerald-500/10 px-2 text-xs text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(yd,{className:`size-3.5`,"aria-hidden":!0}),l.feedback.savedInsight]}):null,C?(0,$.jsxs)(tA,{variant:`secondary`,className:`h-7 rounded-md px-2 text-xs`,disabled:p!==null,onClick:()=>void E(`${e.id}:saveInsight`,()=>Promise.resolve(o(e)),l.feedback.insightSaved),children:[(0,$.jsx)(yd,{className:`size-3.5`,"aria-hidden":!0}),w?l.feedback.savingInsight:l.feedback.saveInsight]}):null,e.sessionKey?(0,$.jsx)(tA,{asChild:!0,variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,children:(0,$.jsxs)(Hi,{to:`/chat/${encodeURIComponent(e.sessionKey)}`,children:[(0,$.jsx)(Hv,{className:`size-3.5`,"aria-hidden":!0}),l.feedback.chat]})}):null,e.workflowRunId?(0,$.jsx)(tA,{asChild:!0,variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,children:(0,$.jsxs)(Hi,{to:`/workflows?run=${encodeURIComponent(e.workflowRunId)}`,children:[(0,$.jsx)(iv,{className:`size-3.5`,"aria-hidden":!0}),l.feedback.workflow]})}):null,r&&A9(e.status)&&!c?(0,$.jsxs)(tA,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,disabled:p!==null,onClick:()=>void D(e),children:[(0,$.jsx)(SC,{className:`size-3.5`,"aria-hidden":!0}),m?l.repair.generating:l.repair.suggest]}):null,(0,$.jsxs)(tA,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,disabled:p!==null,onClick:()=>void E(`${e.id}:rerun`,()=>w9.rerun(e.id),l.feedback.rerunQueued),children:[(0,$.jsx)(cx,{className:`size-3.5`,"aria-hidden":!0}),p===`${e.id}:rerun`?l.feedback.working:l.feedback.rerun]}),(0,$.jsxs)(tA,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,disabled:p!==null,onClick:()=>void E(`${e.id}:pause`,()=>w9.pause(e.automationId),l.feedback.paused),children:[(0,$.jsx)(Rd,{className:`size-3.5`,"aria-hidden":!0}),p===`${e.id}:pause`?l.feedback.working:l.feedback.pause]}),(0,$.jsx)(tA,{asChild:!0,variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,children:(0,$.jsxs)(Hi,{to:`/automations?run=${encodeURIComponent(e.id)}`,children:[(0,$.jsx)(gh,{className:`size-3.5`,"aria-hidden":!0}),l.feedback.open]})})]})]},e.id)})})]})}function VCe(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.kind!==`context`)return null;let n=t.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:null;if(!n||n.kind!==`workflow-run-link`)return null;let r=typeof n.runId==`string`?n.runId.trim():``,i=typeof n.workflowSessionKey==`string`?n.workflowSessionKey.trim():``,a=typeof n.ownerAgentId==`string`?n.ownerAgentId.trim():``,o=typeof n.definitionId==`string`?n.definitionId.trim():``;if(!r||!i||!o)return null;let s=typeof n.goal==`string`?n.goal:``,c=typeof n.status==`string`?n.status:`running`,l=typeof t.id==`string`&&t.id.trim()?t.id.trim():`workflow-run-link:${r}`,u=typeof t.createdAt==`string`?Date.parse(t.createdAt):void 0;return{id:l,runId:r,ownerAgentId:a||void 0,workflowSessionKey:i,definitionId:o,goal:s,status:c,createdAtMs:Number.isFinite(u)?u:void 0}}function HCe(e){if(!e?.length)return[];let t=new Map;for(let n of e){let e=VCe(n);if(!e)continue;let r=t.get(e.runId);t.set(e.runId,{...r,...e,ownerAgentId:e.ownerAgentId??r?.ownerAgentId,workflowSessionKey:e.workflowSessionKey||r?.workflowSessionKey||``,definitionId:e.definitionId||r?.definitionId||``,goal:e.goal||r?.goal||``})}return[...t.values()].toSorted((e,t)=>(e.createdAtMs??0)-(t.createdAtMs??0))}function UCe(e){let t=(0,Q.c)(8),n=q(WCe),r;t[0]===e?r=t[1]:(r=e?.trim()||null,t[0]=e,t[1]=r);let i=r,a;t[2]!==n||t[3]!==i?(a=n&&i?[`session-workflow-run-links`,i,n]:null,t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=async()=>HCe((await EK(i,{includeTranscriptRows:!0})).transcriptRows),t[5]=i,t[6]=o);let s;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[7]=s):s=t[7],ie(a,o,s)}function WCe(e){return e.token}function N9(e,t){let n=(0,Q.c)(26),r=q(KCe),i=!!r,a;n[0]===e?a=n[1]:(a=e?.trim()||null,n[0]=e,n[1]=a);let o=a,s;n[2]===t?.ownerAgentId?s=n[3]:(s=t?.ownerAgentId?.trim()||void 0,n[2]=t?.ownerAgentId,n[3]=s);let c=s,l;n[4]!==i||n[5]!==c||n[6]!==r||n[7]!==o?(l=i&&o?[`workflow-run-live`,o,c??``,r]:null,n[4]=i,n[5]=c,n[6]=r,n[7]=o,n[8]=l):l=n[8];let u;n[9]!==c||n[10]!==o?(u=()=>$me(o,{ownerAgentId:c}),n[9]=c,n[10]=o,n[11]=u):u=n[11];let d;n[12]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!1,refreshInterval:GCe},n[12]=d):d=n[12];let f=ie(l,u,d),p;n[13]!==c||n[14]!==f||n[15]!==o?(p=()=>{if(!o)return;let e=e=>{let t=e.detail;if(t?.runId!==o)return;let n=t.view?.run.metadata?.agentId;if(!(c&&n&&n!==c)){if(t.view){f.mutate(t.view,{revalidate:!1});return}f.mutate()}};return window.addEventListener(`workflow-run-updated`,e),()=>window.removeEventListener(`workflow-run-updated`,e)},n[13]=c,n[14]=f,n[15]=o,n[16]=p):p=n[16];let m;n[17]!==c||n[18]!==f.mutate||n[19]!==o?(m=[c,f.mutate,o],n[17]=c,n[18]=f.mutate,n[19]=o,n[20]=m):m=n[20],(0,Z.useEffect)(p,m);let h;return n[21]!==f.data||n[22]!==f.error||n[23]!==f.isLoading||n[24]!==f.mutate?(h={view:f.data,loading:f.isLoading,error:f.error,mutate:f.mutate},n[21]=f.data,n[22]=f.error,n[23]=f.isLoading,n[24]=f.mutate,n[25]=h):h=n[25],h}function GCe(e){return e&&k7.has(e.run.status)?3e3:0}function KCe(e){return e.token}function qCe(e){let t=(0,Q.c)(8),n=q(JCe),r;t[0]===e?r=t[1]:(r=e?.trim()||null,t[0]=e,t[1]=r);let i=r,a;t[2]!==n||t[3]!==i?(a=n&&i?[`workflow-session-meta`,i,n]:null,t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=async()=>{let e=await EK(i),t=e.customData?.workflowRunId,n=typeof t==`string`&&t.trim()?t.trim():null,r=typeof e.sessionType==`string`&&e.sessionType.trim()?e.sessionType.trim():null,a=typeof e.routing?.agentId==`string`&&e.routing.agentId.trim()?e.routing.agentId.trim():null,o=e.customData?.sourceBinding,s=o&&typeof o==`object`?o:null;return{workflowRunId:n,ownerAgentId:a,sessionType:r,sourceNoteId:s?.kind===`note`&&typeof s.sourceId==`string`&&s.sourceId.trim()?s.sourceId.trim():null,sourceNoteTitle:null,sourceWorkItemId:s?.kind===`work_item`&&typeof s.sourceId==`string`&&s.sourceId.trim()?s.sourceId.trim():null}},t[5]=i,t[6]=o);let s;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[7]=s):s=t[7],ie(a,o,s)}function JCe(e){return e.token}async function YCe(e,t){let n=new URLSearchParams;t?.status?.length&&n.set(`status`,t.status.join(`,`)),t?.includeArchived&&n.set(`includeArchived`,`true`),t?.search?.trim()&&n.set(`search`,t.search.trim()),t?.sortBy&&n.set(`sortBy`,t.sortBy),t?.sortOrder&&n.set(`sortOrder`,t.sortOrder),t?.limit&&n.set(`limit`,String(t.limit)),t?.offset&&n.set(`offset`,String(t.offset));let r=n.toString();return J(X(`/api/projects/${encodeURIComponent(e)}/work-items${r?`?${r}`:``}`))}function P9(e,t,n){n!==void 0&&e.append(t,String(n))}async function XCe(e,t){if(t.attachments?.length){let n=new FormData;P9(n,`title`,t.title),P9(n,`description`,t.description),P9(n,`status`,t.status),P9(n,`priority`,t.priority),P9(n,`ownerAgentId`,t.ownerAgentId),P9(n,`nextAction`,t.nextAction),P9(n,`blockedReason`,t.blockedReason),P9(n,`dueAt`,t.dueAt);for(let e of t.attachments)n.append(`file`,e);return J(X(`/api/projects/${encodeURIComponent(e)}/work-items`),{method:`POST`,body:n})}return J(X(`/api/projects/${encodeURIComponent(e)}/work-items`),{method:`POST`,body:JSON.stringify({title:t.title,description:t.description,status:t.status,priority:t.priority,ownerAgentId:t.ownerAgentId,nextAction:t.nextAction,blockedReason:t.blockedReason,dueAt:t.dueAt})})}async function F9(e){return J(X(`/api/work-items/${encodeURIComponent(e)}`))}async function ZCe(e,t){return J(X(`/api/work-items/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})}async function QCe(e){return J(X(`/api/work-items/${encodeURIComponent(e)}/start-chat`),{method:`POST`,body:JSON.stringify({})})}async function $Ce(e){return J(X(`/api/work-items/${encodeURIComponent(e)}/create-goal`),{method:`POST`,body:JSON.stringify({})})}async function ewe(e){return J(X(`/api/work-items/${encodeURIComponent(e)}/events`))}async function twe(e,t){let n=new FormData;for(let e of t)n.append(`file`,e);return J(X(`/api/work-items/${encodeURIComponent(e)}/attachments`),{method:`POST`,body:n})}async function nwe(e,t){return J(X(`/api/work-items/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}`),{method:`DELETE`})}function I9(e,t){return X(`/api/work-items/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}/content`)}async function rwe(e,t){let n=await Y(I9(e,t.id));if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.blob(),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t.fileName,document.body.append(a),a.click(),a.remove(),URL.revokeObjectURL(i)}async function iwe(e,t){return J(X(`/api/work-items/${encodeURIComponent(e)}/update-suggestions`),{method:`POST`,body:JSON.stringify(t)})}async function awe(e){return J(X(`/api/work-item-update-suggestions/${encodeURIComponent(e)}/apply`),{method:`POST`})}async function owe(e){return J(X(`/api/work-item-update-suggestions/${encodeURIComponent(e)}/dismiss`),{method:`POST`})}var L9=`/agents`;function R9(e){return`${L9}/${encodeURIComponent(e)}`}var swe=[`backlog`,`todo`,`in_progress`,`blocked`,`needs_input`,`in_review`,`done`,`cancelled`];function cwe(e,t=1400){return e.replace(/```[\s\S]*?```/g,e=>e.slice(0,400)).replace(/\n{3,}/g,`
255
255
 
256
256
  `).trim().slice(0,t).trim()}function z9(e,t){let n=e.split(/\r?\n/).map(e=>e.replace(/^[-*#>\s]+/,``).trim());for(let e of n)for(let n of t){let t=RegExp(`^${n}\\s*[::-]\\s*(.+)$`,`i`),r=e.match(t);if(r?.[1]?.trim())return r[1].trim()}return``}function lwe(e){let t=e.toLowerCase();return/needs?\s+(user\s+)?input|需要.*(确认|输入|反馈)/i.test(e)?`needs_input`:/blocked|blocker|无法继续|阻塞|卡住/i.test(e)?`blocked`:/ready\s+for\s+review|in\s+review|等待.*(检查|验收|review)|待验收/i.test(e)||/done|completed|已完成|完成了/i.test(e)?`in_review`:t.includes(`next step`)||e.includes(`下一步`)?`in_progress`:``}function uwe(e){let t=cwe(e),n=z9(e,[`next action`,`next step`,`下一步`,`后续动作`]),r=z9(e,[`blocked reason`,`blocker`,`阻塞`,`阻塞原因`]),i=lwe(e);return{statusEnabled:!!i,status:i,nextActionEnabled:!!n,nextAction:n,blockedReasonEnabled:!!r,blockedReason:r,progressNoteEnabled:!!t,progressNote:t,rationale:``}}function B9(){let e=_(e=>e.language),t=m(e),n=q(e=>e.token),r=br(),i=_r(),{pathname:a}=i,[o]=Ki(),s=(0,Z.useRef)(null),c=(0,Z.useRef)(0),l=(0,Z.useRef)(null),[d,f]=(0,Z.useState)(null),[p,h]=(0,Z.useState)(null),[g,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(!1),{auth:k,session:A,messages:j,timeline:M,stream:N,followUp:P,clarify:F,agents:I}=XSe(),L=o.get(`skill`)?.trim()??``,R=o.get(`slash`)?.trim()??``,z=o.get(`draft`)??``,B=A.decodedKey??A.sessionKey,{data:V}=qCe(B),H=V?.workflowRunId??null,{view:U}=N9(H,{ownerAgentId:V?.ownerAgentId??void 0}),{data:W=[],mutate:G}=UCe(B),K=!!(H&&U&&k7.has(U.run.status));(0,Z.useEffect)(()=>{if(!B)return;let e=e=>{let t=e.detail;(t?.key??t?.sessionKey)===B&&G()};return window.addEventListener(`session-transcript-updated`,e),window.addEventListener(`workflow-run-started-from-chat`,e),()=>{window.removeEventListener(`session-transcript-updated`,e),window.removeEventListener(`workflow-run-started-from-chat`,e)}},[B,G]),(0,Z.useEffect)(()=>{s.current=null},[A.sessionKey]),(0,Z.useEffect)(()=>{if(!k.hasToken||!L&&!R&&!z||A.showSessionLoading||A.sessionRoutePending||!A.sessionKey)return;let e=()=>{let e=new URLSearchParams(o);e.delete(`skill`),e.delete(`slash`),e.delete(`draft`);let t=e.toString();r({pathname:a,search:t?`?${t}`:``},{replace:!0})},t=(t,n)=>{s.current!==n&&(s.current=n,queueMicrotask(()=>{c.current+=1,f({id:c.current,text:t}),e()}))};if(L){if(!Fle(L)){e();return}let n=`${A.sessionKey}:skill:${L}`;t(`/skill:${L} `,n);return}let n=z.trim();if(n){t(n,`${A.sessionKey}:draft:${n}`);return}if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(R)){e();return}let i=`${A.sessionKey}:slash:${R}`;s.current!==i&&queueMicrotask(()=>{(async()=>{try{let e=await D4(),t=R.toLowerCase(),n=e.find(e=>e.name.toLowerCase()===t||Array.isArray(e.aliases)&&e.aliases.some(e=>e.toLowerCase()===t));if(n){if(s.current===i)return;s.current=i,c.current+=1,f({id:c.current,text:M4(n)})}}finally{e()}})()})},[k.hasToken,L,R,z,o,A.showSessionLoading,A.sessionRoutePending,A.sessionKey,r,a]);let{scrollRef:ee,atBottom:J,registerListContentRef:te,scrollToBottom:Y,onScroll:ne}=Xxe({hasToken:k.hasToken,showSessionLoading:A.showSessionLoading,sessionKey:A.sessionKey,sending:N.sending,chatMessages:j.items,hasMore:A.hasMore,loadingMore:A.loadingMore,loadMoreMessages:A.loadMoreMessages}),X=!!F.clarifyPrompt,ie=(0,Z.useRef)(X);(0,Z.useLayoutEffect)(()=>{let e=ie.current;if(ie.current=X,e===X||A.showSessionLoading||A.sessionRoutePending)return;Y(!1);let t=requestAnimationFrame(()=>Y(!1));return()=>cancelAnimationFrame(t)},[X,Y,A.showSessionLoading,A.sessionRoutePending]);let[ae,oe]=(0,Z.useState)(0),se=(0,Z.useRef)(null),ce=(0,Z.useRef)(null),le=(0,Z.useMemo)(()=>{let e=-1;for(let t of M.items)typeof t.displayIndex==`number`&&Number.isFinite(t.displayIndex)&&(e=Math.max(e,t.displayIndex));return e<0?0:Math.max(0,e+1-j.items.length)},[j.items.length,M.items]),ue=(0,Z.useCallback)(e=>{let t=ee.current;if(!t)return!1;let n=t.querySelector(`[data-chat-message-index="${e}"]`);if(!n)return!1;oe(e);let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=t.scrollTop+i.top-r.top-16;return t.scrollTo({top:Math.max(0,a),behavior:`smooth`}),!0},[ee]),de=(0,Z.useCallback)(()=>{let e=ee.current;if(!e)return;let t=Array.from(e.querySelectorAll(`[data-chat-message-index]`));if(t.length===0){oe(0);return}let n=e.getBoundingClientRect(),r=n.top+Math.min(180,n.height*.35),i=t[0];for(let e of t){if(e.getBoundingClientRect().top<=r){i=e;continue}break}let a=i.dataset.chatMessageIndex,o=a?Number.parseInt(a,10):0;Number.isFinite(o)&&oe(e=>e===o?e:o)},[ee]),fe=(0,Z.useCallback)(()=>{se.current!=null&&cancelAnimationFrame(se.current),se.current=requestAnimationFrame(()=>{se.current=null,de()})},[de]),pe=(0,Z.useCallback)(()=>{ne(),fe()},[ne,fe]),me=(0,Z.useCallback)(e=>{let t=e-le;if(t<0||t>=j.items.length){t<0&&A.hasMore&&!A.loadingMore&&(ce.current=e,A.loadMoreMessages());return}ce.current=null,ue(t)},[j.items.length,ue,A.hasMore,A.loadMoreMessages,A.loadingMore,le]);(0,Z.useEffect)(()=>{let e=ce.current;if(e==null)return;let t=e-le;if(t>=0&&t<j.items.length){ce.current=null,requestAnimationFrame(()=>ue(t));return}if(t<0&&A.hasMore&&!A.loadingMore){A.loadMoreMessages();return}(t>=j.items.length||!A.hasMore)&&(ce.current=null)},[j.items.length,ue,A.hasMore,A.loadMoreMessages,A.loadingMore,le]),(0,Z.useEffect)(()=>{fe()},[j.items.length,fe,A.sessionKey,le]),(0,Z.useEffect)(()=>()=>{se.current!=null&&cancelAnimationFrame(se.current)},[]),(0,Z.useEffect)(()=>{f(null)},[A.sessionKey]);let he=(0,Z.useCallback)(e=>{c.current+=1,f({id:c.current,text:e})},[]),ge=(0,Z.useMemo)(()=>!!A.sessionKey&&!A.showSessionLoading&&!A.sessionRoutePending&&!A.workingDirectoryLocked&&j.items.length===0,[A.sessionKey,A.showSessionLoading,A.sessionRoutePending,A.workingDirectoryLocked,j.items.length]),_e=b1(e=>e.setAgentId);(0,Z.useEffect)(()=>{if(k.hasToken)return _e(I.displayAgentId),()=>_e(``)},[k.hasToken,I.displayAgentId,_e]);let ve=!(A.showSessionLoading||A.sessionContentLoading)&&j.items.length===0&&!N.streaming,ye=(0,Z.useMemo)(()=>(A.sessionRoutePending&&A.decodedKey?A.decodedKey:A.sessionKey)?A.sessionName?.trim()||t.chat.newSession:t.nav.chat,[A.sessionKey,A.sessionName,A.sessionRoutePending,A.decodedKey,t.nav.chat,t.chat.newSession]),be=V?.sourceNoteId??null,xe=V?.sourceWorkItemId??null;(0,Z.useEffect)(()=>{let e=!1;if(h(null),be)return o3(be).then(t=>{e||h(t?.title?.trim()||null)}).catch(()=>{e||h(null)}),()=>{e=!0}},[be]),(0,Z.useEffect)(()=>{let e=!1;if(v(null),b(!1),xe)return F9(xe).then(t=>{e||v(t.item)}).catch(()=>{e||v(null)}),()=>{e=!0}},[xe]);let Se=p||V?.sourceNoteTitle||t.chat.sourceNoteFallbackTitle,Ce=(0,Z.useCallback)(()=>{l.current?.reject(),l.current=null,E(null),O(!1)},[]);(0,Z.useEffect)(()=>{Ce()},[Ce,be]);let we=(0,Z.useMemo)(()=>({title:t.chat.timelineTitle,turn:t.chat.timelineTurn,messageFallback:t.chat.timelineMessageFallback,toolCount_one:t.chat.timelineToolCount_one,toolCount_other:t.chat.timelineToolCount_other,searchedWeb:t.chat.stepSearchedWeb,readFile:t.chat.stepReadFile,runCommand:t.chat.stepRunCommand,listDirectory:t.chat.stepListDirectory,writeFile:t.chat.stepWriteFile,editFile:t.chat.stepEditFile,openUrl:t.chat.stepOpenUrl,fetchUrl:t.chat.stepFetchUrl,unknownTool:t.chat.stepUnknownTool}),[t.chat.timelineTitle,t.chat.timelineTurn,t.chat.timelineMessageFallback,t.chat.timelineToolCount_one,t.chat.timelineToolCount_other,t.chat.stepSearchedWeb,t.chat.stepReadFile,t.chat.stepRunCommand,t.chat.stepListDirectory,t.chat.stepWriteFile,t.chat.stepEditFile,t.chat.stepOpenUrl,t.chat.stepFetchUrl,t.chat.stepUnknownTool]),Te=(0,Z.useCallback)(async n=>{if(!be)return;l.current?.reject(),O(!1);let r=t.chat.sourceNoteAppendSourceLine.replace(`{{time}}`,new Date().toLocaleString(e));return E({heading:t.chat.sourceNoteAppendHeading,content:`${r}\n\n${n.trim()}`}),new Promise((e,t)=>{l.current={sourceNoteId:be,resolve:e,reject:t}})},[e,t.chat.sourceNoteAppendHeading,t.chat.sourceNoteAppendSourceLine,be]),Ee=(0,Z.useCallback)(async()=>{let e=l.current;if(!e||!T)return;let n=T.heading.trim()||t.chat.sourceNoteAppendHeading,r=T.content.trim();if(r){O(!0);try{await Xue(e.sourceNoteId,r,n),re({type:`success`,title:t.chat.sourceNoteSaveSuccess}),window.dispatchEvent(new CustomEvent(`note-updated`,{detail:{noteId:e.sourceNoteId,source:`chat`,sessionKey:B}})),e.resolve(),l.current=null,E(null)}catch(e){re({type:`error`,title:t.chat.sourceNoteSaveFailed,message:e instanceof Error?e.message:void 0})}finally{O(!1)}}},[B,t.chat.sourceNoteAppendHeading,t.chat.sourceNoteSaveFailed,t.chat.sourceNoteSaveSuccess,T]),De=(0,Z.useCallback)(async e=>{if(!be)return;let n=e.trim().split(/\n+/)[0]?.replace(/^[-#*>\s]+/,``).trim()||t.chat.sourceNoteTaskFallbackTitle;try{await Zue(n.slice(0,120),{sourceNoteId:be,sourceSessionKey:B}),re({type:`success`,title:t.chat.sourceNoteTaskSuccess})}catch(e){throw re({type:`error`,title:t.chat.sourceNoteTaskFailed,message:e instanceof Error?e.message:void 0}),e}},[B,t.chat.sourceNoteTaskFailed,t.chat.sourceNoteTaskFallbackTitle,t.chat.sourceNoteTaskSuccess,be]),Oe=(0,Z.useCallback)(()=>{if(!be)return;let e=t.chat.sourceNoteDigestPrompt.replace(`{{title}}`,Se);if(N.streaming||N.sending){P.addPendingFollowUp(e),re({type:`info`,title:t.chat.sourceNoteDigestQueued});return}N.sendMessage(e)},[P,t.chat.sourceNoteDigestPrompt,t.chat.sourceNoteDigestQueued,be,Se,N]),ke=(0,Z.useCallback)(e=>{if(N.streaming||N.sending){P.addPendingFollowUp(e);return}N.sendMessage(e)},[P,N]),Ae=(0,Z.useCallback)(()=>{g&&ke(t.chat.workItemSummarizePrompt.replace(`{{title}}`,g.title))},[t.chat.workItemSummarizePrompt,ke,g]),je=(0,Z.useCallback)(()=>{g&&ke(t.chat.workItemNextStepPrompt.replace(`{{title}}`,g.title))},[t.chat.workItemNextStepPrompt,ke,g]),Me=(0,Z.useCallback)(async e=>{!g||!B||S(uwe(e))},[B,g]),Ne=(0,Z.useCallback)(()=>{let e=x?.suggestion;e?.status===`pending`&&owe(e.id).catch(()=>void 0),S(null),w(!1)},[x?.suggestion]),Pe=(0,Z.useCallback)(async()=>{if(!g||!B||!x)return;let e={...x.statusEnabled&&x.status?{status:x.status}:{},...x.nextActionEnabled?{nextAction:x.nextAction.trim()||null}:{},...x.blockedReasonEnabled?{blockedReason:x.blockedReason.trim()||null}:{}},n=x.progressNoteEnabled?x.progressNote.trim():``;if(!(Object.keys(e).length===0&&!n)){w(!0);try{v((await awe((x.suggestion??(await iwe(g.id,{sourceKind:`chat`,sourceId:B,patch:e,progressNote:n||void 0,rationale:x.rationale.trim()||void 0})).suggestion).id)).item),S(null)}catch(e){re({type:`error`,title:t.chat.workItemUpdateFailed,message:e instanceof Error?e.message:void 0})}finally{w(!1)}}},[B,t.chat.workItemUpdateFailed,g,x]);return k.hasToken?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,$.jsx)(v_e,{}),(0,$.jsx)(u_e,{chatHeadline:ye,chatAgents:I.chatAgents?.items??[],showChatAgentSelector:I.showChatAgentSelector,chatAgentId:I.displayAgentId,onChatAgentChange:I.onChatAgentChange,chatAgentDisabled:A.showSessionLoading||A.sessionRoutePending}),(0,$.jsxs)(`div`,{className:`relative mx-auto flex min-h-0 w-full max-w-[calc(var(--max-width-chat)+8rem)] flex-1 flex-col`,children:[i.state?.fromAgentEditor&&I.displayAgentId?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,$.jsxs)(Hi,{to:R9(I.displayAgentId),className:`inline-flex items-center gap-1 text-xs font-medium text-accent transition-colors hover:text-accent-fg`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`←`}),t.agentsSettings.backToEditor]})}):null,be?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t.chat.sourceNoteBanner.replace(`{{title}}`,Se)}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-edge-subtle px-2 font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:Oe,children:[(0,$.jsx)(_g,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t.chat.sourceNoteDigestAction})]}),(0,$.jsx)(Hi,{to:`/notes/${encodeURIComponent(be)}`,className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:t.chat.sourceNoteOpen})]})]})}):null,g?(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/90 px-3 py-1.5 sm:px-5 xl:px-6`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-2 text-left`,onClick:()=>b(e=>!e),"aria-expanded":y,children:[(0,$.jsx)(Qc,{className:`size-3.5 shrink-0 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t.chat.workItemBanner.replace(`{{title}}`,g.title)}),(0,$.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-1.5 py-0.5 text-[11px] text-fg-muted`,children:g.status.replace(/_/g,` `)}),(0,$.jsx)(Gu,{className:u(`size-3.5 shrink-0 transition-transform`,y?`rotate-180`:``),strokeWidth:1.75,"aria-hidden":!0})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-edge-subtle px-2 font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:je,children:[(0,$.jsx)(rE,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t.chat.workItemNextStepAction})]}),(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-edge-subtle px-2 font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:Ae,children:[(0,$.jsx)(_g,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t.chat.workItemSummarizeAction})]}),(0,$.jsx)(Hi,{to:`/work-items/${encodeURIComponent(g.id)}`,className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:t.chat.workItemOpenItem}),(0,$.jsx)(Hi,{to:`/projects/${encodeURIComponent(g.projectId)}/work-items`,className:`font-medium text-fg-muted transition-colors hover:text-fg`,children:t.chat.workItemOpenProject})]})]}),y?(0,$.jsxs)(`div`,{className:`mt-2 grid gap-2 rounded-md border border-edge-subtle bg-surface-base px-3 py-2 text-xs leading-5 text-fg-muted sm:grid-cols-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[t.chat.workItemPriorityLabel,`: `]}),g.priority]}),(0,$.jsxs)(`p`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[t.chat.workItemUpdatedLabel,`: `]}),new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(g.updatedAt))]}),g.description?(0,$.jsxs)(`p`,{className:`min-w-0 sm:col-span-2`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[t.chat.workItemDescriptionLabel,`: `]}),g.description]}):null,g.nextAction?(0,$.jsxs)(`p`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[t.chat.workItemNextActionLabel,`: `]}),g.nextAction]}):null,g.blockedReason?(0,$.jsxs)(`p`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[t.chat.workItemBlockedLabel,`: `]}),g.blockedReason]}):null,!g.description&&!g.nextAction&&!g.blockedReason?(0,$.jsx)(`p`,{className:`min-w-0 sm:col-span-2`,children:t.chat.workItemNoDetails}):null]}):null]}):null,A.sessionKey&&!A.showSessionLoading&&!A.sessionRoutePending?(0,$.jsx)(r_e,{sessionKey:A.sessionKey,streaming:N.streaming,sending:N.sending}):null,(0,$.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 px-3 sm:px-5 xl:px-6`,children:[(0,$.jsx)(aCe,{items:M.items,activeMessageIndex:ae+le,labels:we,openLabel:t.chat.timelineOpen,closeLabel:t.chat.timelineClose,currentLabel:t.chat.timelineCurrent,onSelectMessage:me}),(0,$.jsx)(`div`,{className:`absolute inset-y-0 right-0 hidden xl:block`,children:(0,$.jsx)(fCe,{items:M.items,activeMessageIndex:ae+le,labels:we,onSelectMessage:me})}),(0,$.jsxs)(`div`,{className:`mx-auto flex min-h-0 min-w-0 flex-1 flex-col xl:max-w-[58rem]`,children:[(0,$.jsx)(`div`,{ref:ee,className:u(`chat-messages min-h-0 flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none] [scrollbar-gutter:stable_both-edges]`,ve?`chat-messages--compact-welcome pt-5 pb-2`:`py-4`),onScroll:pe,children:A.showSessionLoading?(0,$.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] w-full flex-col gap-10 py-8`,"aria-busy":`true`,children:[(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(uI,{className:`h-11 w-[min(70%,22rem)] rounded-2xl`})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(uI,{className:`h-4 w-24`}),(0,$.jsx)(uI,{className:`h-4 w-[min(82%,36rem)]`}),(0,$.jsx)(uI,{className:`h-4 w-[min(74%,32rem)]`}),(0,$.jsx)(uI,{className:`h-4 w-[min(48%,22rem)]`})]}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(uI,{className:`h-11 w-[min(62%,18rem)] rounded-2xl`})})]}):(0,$.jsxs)($.Fragment,{children:[A.loadingMore?(0,$.jsx)(`div`,{className:`mb-3 text-center text-xs text-fg-muted`,children:t.chat.loadOlder}):null,N.error?(0,$.jsx)($be,{errorText:N.error}):null,W.length>0?(0,$.jsx)(`div`,{className:`mb-6 flex flex-col gap-3`,children:W.map(e=>(0,$.jsx)(bCe,{link:e},e.id))}):null,K&&U?(0,$.jsx)(CCe,{view:U,sessionKey:B,onAbortCurrentTurn:N.abort}):null,B?(0,$.jsx)(M9,{eventType:`session.transcript.updated`,source:`sessions`,payloadKey:`sessionKey`,payloadValue:B,className:`mb-6`}):null,(0,$.jsx)(Hxe,{messages:j.items,authToken:n??void 0,sessionKey:A.decodedKey??A.sessionKey,streaming:N.streaming,progress:N.progress,loading:A.sessionContentLoading,reasoningLevel:A.reasoningLevel,registerListContentRef:te,onPickWelcomePrompt:he,onDeleteRound:N.deleteMessageRound,onRetryUserMessageRound:N.retryUserMessageRound,deleteRoundDisabled:N.streaming||N.sending,onAbortCurrentTurn:N.abort,onSaveAssistantToSourceNote:be?Te:void 0,onExtractAssistantTask:be?De:void 0,onSuggestWorkItemUpdate:g?Me:void 0},A.decodedKey??`new`)]})}),(0,$.jsxs)(`div`,{className:u(`sticky bottom-0 z-10 shrink-0 bg-surface-panel`,ve?`py-2.5`:`py-4`),children:[(0,$.jsx)(hCe,{prompt:F.clarifyPrompt,submitting:F.clarifySubmitting,submitError:F.clarifySubmitError,labels:t.chat,onSubmit:F.submitClarifyAnswer,onCancel:F.cancelClarifyAnswer}),(0,$.jsx)(kge,{disabled:A.showSessionLoading||A.sessionContentLoading||A.sessionRoutePending||!!F.clarifyPrompt,sending:N.sending,streaming:N.streaming,sessionKey:A.sessionKey,sessionManager:A.sessionManager,welcomeDraftSeed:d,canSelectWorkingDirectory:ge,thinkingLevel:A.thinkingLevel,showThinkingSelector:A.modelSupportsThinking,onThinkingChange:A.onSessionThinkingLevelChange,onSend:N.sendMessage,onAbort:N.abort,onAddPendingFollowUp:(e,t)=>void P.addPendingFollowUp(e,t),onSteeringInterrupt:(e,t)=>void N.interruptAndSend(e,t),pendingFollowUps:P.pendingFollowUps,editingFollowUpId:P.editingFollowUpId,onBeginEditFollowUp:P.beginEditFollowUp,onCancelEditFollowUp:P.cancelEditFollowUp,onCommitEditFollowUp:(e,t,n,r)=>void P.commitEditFollowUp(e,t,n,r),onPendingFollowUpRemove:P.removePendingFollowUp,onPendingFollowUpMove:P.movePendingFollowUp,onPendingFollowUpReorder:P.reorderPendingFollowUp,onPendingFollowUpSteer:e=>void P.steerPendingFollowUp(e),steeringFollowUpId:P.steeringFollowUpId,sessionModel:A.sessionModel,showModelSelector:!!(A.sessionKey&&!A.sessionRoutePending),onModelChange:A.onSessionModelChange,modelDisabled:A.showSessionLoading||A.sessionRoutePending||N.streaming,contextUsageMessages:j.items,onChatAgentChange:I.showChatAgentSelector?I.onChatAgentChange:void 0,currentAgentId:I.displayAgentId})]})]})]})]}),(0,$.jsx)(FN,{open:T!==null,onOpenChange:e=>{!e&&!D&&Ce()},children:(0,$.jsxs)(LN,{children:[(0,$.jsx)(RN,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[1px]`}),(0,$.jsxs)(zN,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(82vh,42rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(BN,{className:`text-base font-semibold text-fg`,children:t.chat.sourceNoteSaveDialogTitle}),(0,$.jsx)(VN,{className:`mt-1 text-sm text-fg-muted`,children:t.chat.sourceNoteSaveDialogDescription.replace(`{{title}}`,Se)})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:t.chat.sourceNoteSaveDialogHeadingLabel}),(0,$.jsx)(`input`,{value:T?.heading??``,onChange:e=>E(t=>t&&{...t,heading:e.target.value}),className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm font-normal text-fg outline-none transition-colors focus:border-accent focus:ring-2 focus:ring-accent/20`,disabled:D})]}),(0,$.jsxs)(`label`,{className:`flex min-h-0 flex-1 flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:t.chat.sourceNoteSaveDialogContentLabel}),(0,$.jsx)(`textarea`,{value:T?.content??``,onChange:e=>E(t=>t&&{...t,content:e.target.value}),className:`min-h-[18rem] flex-1 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg outline-none transition-colors focus:border-accent focus:ring-2 focus:ring-accent/20`,disabled:D})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(tA,{type:`button`,variant:`secondary`,onClick:Ce,disabled:D,children:t.chat.sourceNoteSaveDialogCancel}),(0,$.jsx)(tA,{type:`button`,variant:`primary`,onClick:()=>void Ee(),disabled:D||!T?.content.trim(),children:D?t.chat.sourceNoteSaveDialogSaving:t.chat.sourceNoteSaveDialogConfirm})]})]})]})}),(0,$.jsx)(Wxe,{visible:!A.showSessionLoading&&!J,onClick:()=>Y(!0)}),(0,$.jsx)(FN,{open:x!==null,onOpenChange:e=>{!e&&!C&&Ne()},children:(0,$.jsxs)(LN,{children:[(0,$.jsx)(RN,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[1px]`}),(0,$.jsxs)(zN,{className:`fixed right-0 top-0 z-[90] flex h-dvh w-[min(100%,32rem)] flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(BN,{className:`text-base font-semibold text-fg`,children:t.chat.workItemUpdateDialogTitle}),(0,$.jsx)(VN,{className:`mt-1 text-sm text-fg-muted`,children:g?t.chat.workItemUpdateDialogDescription.replace(`{{title}}`,g.title):t.chat.workItemUpdateDialogDescriptionFallback})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge-subtle bg-surface-base px-3 py-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-4`,checked:!!x?.statusEnabled,onChange:e=>S(t=>t&&{...t,statusEnabled:e.target.checked}),disabled:C}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.chat.workItemUpdateStatusLabel}),(0,$.jsxs)(Aj,{value:x?.status??``,onChange:e=>S(t=>t&&{...t,status:e.target.value}),disabled:C||!x?.statusEnabled,className:`h-9 rounded-lg border border-edge bg-surface-panel px-2 text-sm text-fg outline-none focus:border-accent`,children:[(0,$.jsx)(Dj,{value:``,children:t.chat.workItemUpdateStatusUnchanged}),swe.map(e=>(0,$.jsx)(Dj,{value:e,children:e.replace(/_/g,` `)},e))]})]})]}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge-subtle bg-surface-base px-3 py-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-4`,checked:!!x?.nextActionEnabled,onChange:e=>S(t=>t&&{...t,nextActionEnabled:e.target.checked}),disabled:C}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.chat.workItemUpdateNextActionLabel}),(0,$.jsx)(`textarea`,{value:x?.nextAction??``,onChange:e=>S(t=>t&&{...t,nextAction:e.target.value}),disabled:C||!x?.nextActionEnabled,className:`min-h-20 resize-none rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm leading-6 text-fg outline-none focus:border-accent`})]})]}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge-subtle bg-surface-base px-3 py-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-4`,checked:!!x?.blockedReasonEnabled,onChange:e=>S(t=>t&&{...t,blockedReasonEnabled:e.target.checked}),disabled:C}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.chat.workItemUpdateBlockedReasonLabel}),(0,$.jsx)(`textarea`,{value:x?.blockedReason??``,onChange:e=>S(t=>t&&{...t,blockedReason:e.target.value}),disabled:C||!x?.blockedReasonEnabled,className:`min-h-20 resize-none rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm leading-6 text-fg outline-none focus:border-accent`})]})]}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge-subtle bg-surface-base px-3 py-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-1 size-4`,checked:!!x?.progressNoteEnabled,onChange:e=>S(t=>t&&{...t,progressNoteEnabled:e.target.checked}),disabled:C}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.chat.workItemUpdateProgressNoteLabel}),(0,$.jsx)(`textarea`,{value:x?.progressNote??``,onChange:e=>S(t=>t&&{...t,progressNote:e.target.value}),disabled:C||!x?.progressNoteEnabled,className:`min-h-40 resize-none rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm leading-6 text-fg outline-none focus:border-accent`})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(tA,{type:`button`,variant:`secondary`,onClick:Ne,disabled:C,children:t.chat.workItemUpdateDialogCancel}),(0,$.jsx)(tA,{type:`button`,variant:`primary`,onClick:()=>void Pe(),disabled:C,children:C?t.chat.workItemUpdateDialogApplying:t.chat.workItemUpdateDialogApply})]})]})]})})]}):(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-[var(--max-width-chat)] px-3 py-16 text-center text-sm leading-relaxed text-fg-muted sm:px-5`,children:t.chat.needToken})}function dwe(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(ai,{})}),e[0]=t):t=e[0],t}function V9(e){return e?.trim().toLowerCase().replace(/[.:/\\]+/g,`_`)??``}function H9(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function U9(e,...t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim())return t.trim()}}function fwe(e){if(!e||e.includes(`
257
- `)||e.includes(`\r`))return;let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean).at(-1);if(!(!t||t.length>80||/(?:token|api[_-]?key|password|secret)=/i.test(t)))return t}function pwe(e){if(e)try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.host:void 0}catch{return}}function mwe(e){let t=V9(e);return t===`update_plan`||t.includes(`plan`)?`planning`:t.includes(`browser`)||t.includes(`playwright`)||t.includes(`chrome`)?`browsing`:t.includes(`search`)||t.includes(`image_query`)||t.includes(`web_fetch`)?`researching`:t.includes(`read_file`)||t.includes(`file_read`)||t.includes(`list_dir`)?`reading`:t.includes(`patch`)||t.includes(`edit_file`)||t.includes(`write_file`)?`editing`:t.includes(`exec_command`)||t.includes(`run_command`)||t.includes(`shell`)?`running`:t.includes(`open_url`)||t.includes(`fetch_url`)?`browsing`:`preparing`}function hwe(e,t){let n=V9(e),r=H9(t),i={phase:mwe(e)};return i.phase===`reading`||i.phase===`editing`?i.detail=fwe(U9(r,`path`,`filePath`,`file`)):i.phase===`browsing`&&(i.detail=pwe(U9(r,`url`,`href`))),(n.includes(`exec_command`)||n.includes(`search`)||n.includes(`query`))&&delete i.detail,i}function gwe(e){let t=H9(e),n=U9(t,`stage`)?.toLowerCase(),r=n===`compaction`?`compacting`:n===`planning`?`planning`:n===`research`||n===`search`?`researching`:n===`verification`||n===`running`?`running`:n===`waiting`||n===`clarifying`?`waiting`:`preparing`,i=Number(t.completed),a=Number(t.total);return{phase:r,...Number.isFinite(i)&&i>=0?{completed:i}:{},...Number.isFinite(a)&&a>0?{total:a}:{}}}function W9(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n.trim():void 0}function _we(e){return e.payload&&typeof e.payload==`object`&&!Array.isArray(e.payload)?e.payload:{}}function G9(e,t,n){return W9(t,n)??W9(e,n)}function vwe(e){let t=e.event;if(!t||typeof t!=`object`)return null;let n=t,r=W9(n,`type`);if(!r)return null;let i=_we(n),a=e.sessionKey?`/chat/${e.sessionKey}`:`/chat`,o=W9(n,`runId`);if(r===`run_start`||r===`assistant_message_start`)return{kind:`agent-start`,sessionKey:e.sessionKey,runId:o,route:a};if(r===`tool_start`){let t=G9(n,i,`toolName`)??G9(n,i,`name`);return{kind:`agent-tool`,toolName:t,activity:hwe(t,i.args),sessionKey:e.sessionKey,runId:o,route:a}}return r===`progress`||r===`compaction`?{kind:`agent-progress`,activity:r===`compaction`?{phase:`compacting`}:gwe(i),sessionKey:e.sessionKey,runId:o,route:a}:r===`run_end`||r===`assistant_message_end`?{kind:`agent-success`,severity:`success`,sessionKey:e.sessionKey,runId:o,route:a}:r===`clarify_request`?{kind:`agent-progress`,severity:`warning`,activity:{phase:`waiting`},sessionKey:e.sessionKey,runId:o,route:a}:r===`error`?{kind:`agent-error`,severity:`error`,sessionKey:e.sessionKey,runId:o,route:a}:null}function ywe(){let e=(0,Q.c)(2),t=(0,Z.useRef)(null),n,r;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{if(!fM()||!window.electronAPI?.pet)return;let e=e=>{let n=`${e.kind}:${e.sessionKey??``}:${e.message??``}:${e.toolName??``}`,r=Date.now(),i=t.current;i&&i.key===n&&r-i.at<1600||(t.current={key:n,at:r},window.electronAPI?.pet?.sendEvent(e).catch(bwe))},n=t=>{let n=vwe(t.detail);n&&e(n)},r=t=>{let n=t.detail;!n?.title&&!n?.message||e({kind:`toast`,severity:n.type,title:n.title,message:n.message??n.title,route:`/chat`})};return window.addEventListener(`agent-stream-event`,n),window.addEventListener(ne,r),()=>{window.removeEventListener(`agent-stream-event`,n),window.removeEventListener(ne,r)}},r=[],e[0]=n,e[1]=r):(n=e[0],r=e[1]),(0,Z.useEffect)(n,r),null}function bwe(){}async function xwe(e){let t=await Y(e);if(!t.ok){let e=await t.json().catch(()=>({})),n=te(t.status,t.statusText,e.error?.message);throw Error(n)}return t.json()}function Swe(e){let t=(0,Q.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={fetcher:xwe,revalidateOnFocus:!1,dedupingInterval:2e3,shouldRetryOnError:!0,errorRetryCount:2},t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsx)(ae,{value:r,children:n}),t[1]=n,t[2]=i),i}var Cwe=(0,Z.lazy)(()=>FP().then(e=>({default:e.SessionsPage}))),wwe=(0,Z.lazy)(()=>IP().then(e=>({default:e.AutomationsPage}))),Twe=(0,Z.lazy)(()=>LP().then(e=>({default:e.ProjectsPage}))),K9=(0,Z.lazy)(()=>RP().then(e=>({default:e.ProjectDetailPage}))),Ewe=(0,Z.lazy)(()=>zP().then(e=>({default:e.WorkItemDetailPage}))),Dwe=(0,Z.lazy)(()=>BP().then(e=>({default:e.GoalsPage}))),Owe=(0,Z.lazy)(()=>VP().then(e=>({default:e.GoalDetailPage}))),q9=(0,Z.lazy)(()=>HP().then(e=>({default:e.NotesPage}))),kwe=(0,Z.lazy)(()=>UP().then(e=>({default:e.WorkflowsPage}))),Awe=(0,Z.lazy)(()=>WP().then(e=>({default:e.SkillsPage}))),jwe=(0,Z.lazy)(()=>GP().then(e=>({default:e.ConnectorsPage}))),Mwe=(0,Z.lazy)(()=>KP().then(e=>({default:e.LogsPage}))),Nwe=(0,Z.lazy)(()=>qP().then(e=>({default:e.SettingsPage}))),J9=(0,Z.lazy)(()=>JP().then(e=>({default:e.AgentsSettingsPanel}))),Pwe=(0,Z.lazy)(()=>YP().then(e=>({default:e.AgentBrowserSettingsPage}))),Y9=(0,Z.lazy)(()=>XP().then(e=>({default:e.ChannelsSettingsPanel}))),Fwe=(0,Z.lazy)(()=>ZP().then(e=>({default:e.ExtensionsPage}))),X9=(0,Z.lazy)(()=>QP().then(e=>({default:e.ExtensionPage}))),Z9=(0,Z.lazy)(()=>$P().then(e=>({default:e.ExtensionSettingsPage}))),Iwe=(0,Z.lazy)(()=>eF().then(e=>({default:e.ExtensionDebugPage}))),Lwe=(0,Z.lazy)(()=>tF().then(e=>({default:e.SharePreviewPage}))),Rwe=(0,Z.lazy)(()=>c(()=>import(`./desktop-pet-MnqKnEgd.js`).then(e=>({default:e.DesktopPetPage})),__vite__mapDeps([94,1,2,7,3,69,4,11])));function Q9(){let e=(0,Q.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,$.jsx)(uI,{className:`h-5 w-44`}),(0,$.jsx)(uI,{className:`h-3 w-64 max-w-full`})]}),(0,$.jsx)(uI,{className:`h-9 w-24 shrink-0 rounded-lg`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:Array.from({length:4}).map(Bwe)}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel`,"aria-busy":!0,children:(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[t,n,(0,$.jsx)(`div`,{className:`grid gap-3 lg:grid-cols-3`,children:Array.from({length:6}).map(zwe)})]})}),e[2]=r):r=e[2],r}function zwe(e,t){return(0,$.jsx)(uI,{className:`h-36 rounded-lg`},t)}function Bwe(e,t){return(0,$.jsx)(uI,{className:`h-20 rounded-lg`},t)}function $9(){let e=(0,Q.c)(4),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(uI,{className:`h-8 w-48 max-w-full`}),n=(0,$.jsx)(uI,{className:`mt-6 h-36 rounded-xl`}),r=(0,$.jsx)(uI,{className:`mt-4 h-24 rounded-xl`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"aria-busy":!0,children:(0,$.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,$.jsxs)(`div`,{className:`mt-6 grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(uI,{className:`h-20 rounded-xl`}),(0,$.jsx)(uI,{className:`h-20 rounded-xl`})]})]})}),e[3]=i):i=e[3],i}var Vwe=xee([{path:`/desktop-pet`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Rwe,{})})},{path:`/share/:token`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Lwe,{})})},{path:`/`,element:(0,$.jsx)(npe,{}),children:[{index:!0,element:(0,$.jsx)(ii,{to:`/chat`,replace:!0})},{path:`chat`,element:(0,$.jsx)(dwe,{}),children:[{index:!0,element:(0,$.jsx)(B9,{})},{path:`new`,element:(0,$.jsx)(B9,{})},{path:`:sessionKey`,element:(0,$.jsx)(B9,{})}]},{path:`automations`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(wwe,{})})},{path:`projects`,children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Twe,{})})},{path:`:projectId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(K9,{})})},{path:`:projectId/:tabId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(K9,{})})},{path:`:projectId/notes/:noteId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(K9,{})})}]},{path:`work-items/:workItemId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Ewe,{})})},{path:`goals`,children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Dwe,{})})},{path:`:goalId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Owe,{})})}]},{path:`notes`,children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(q9,{})})},{path:`:noteId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(q9,{})})}]},{path:`workflows`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(kwe,{})})},{path:`skills`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Awe,{})})},{path:`connectors`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(jwe,{})})},{path:`channels`,children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Y9,{})})},{path:`:channelId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Y9,{})})}]},{path:`agents`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(J9,{})})},{path:`agents/:agentId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(J9,{})})},{path:`extensions`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Fwe,{})})},{path:`extensions/:extensionId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(X9,{})})},{path:`extensions/:extensionId/:pageId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(X9,{})})},{path:`settings`,element:(0,$.jsx)(Ope,{children:(0,$.jsx)(Cpe,{})}),children:[{index:!0,element:(0,$.jsx)(ii,{to:`overview`,replace:!0})},{path:`sessions`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Cwe,{})})},{path:`logs`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Mwe,{})})},{path:`agent-browser`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)($9,{}),children:(0,$.jsx)(Pwe,{})})},{path:`extensions/debug`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)($9,{}),children:(0,$.jsx)(Iwe,{})})},{path:`ext/:extensionId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)($9,{}),children:(0,$.jsx)(Z9,{})})},{path:`ext/:extensionId/:panelId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)($9,{}),children:(0,$.jsx)(Z9,{})})},{path:`:section`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)($9,{}),children:(0,$.jsx)(Nwe,{})})}]}]}]);function Hwe(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(Uwe,t),null}function Uwe(){let e=x.persist.onFinishHydration(Gwe),t=jA.persist.onFinishHydration(Wwe),n=y(),r=S();return()=>{e?.(),t?.(),n(),r()}}function Wwe(){MA()}function Gwe(){C()}function Kwe(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Hwe,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Swe,{children:(0,$.jsx)(LF,{children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col *:min-h-0 *:flex-1`,children:[(0,$.jsx)(ywe,{}),(0,$.jsx)(Iee,{router:Vwe})]})]})})}),e[1]=n):n=e[1],n}document.documentElement.setAttribute(`lang`,v(g())),w(),AA(),ee(),(0,Vk.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Kwe,{})}));export{S7 as $,Yj as $a,vd as $c,BR as $i,sue as $n,ew as $o,U$ as $r,Dv as $s,U3 as $t,Ibe as A,hF as Aa,sh as Ac,NK as Ai,Vue as An,bk as Ao,nle as Ar,ry as As,z6 as At,xbe as B,HN as Ba,np as Bc,sz as Bi,Bue as Bn,mD as Bo,b1 as Br,Hv as Bs,q3 as Bt,U7 as C,FF as Ca,p_ as Cc,PK as Ci,Hi as Cl,Hue as Cn,aA as Co,$ce as Cr,Iy as Cs,qme as Ct,Rbe as D,sF as Da,Eh as Dc,MK as Di,wr as Dl,nde as Dn,tA as Do,sle as Dr,Ey as Ds,Z6 as Dt,Gbe as E,gF as Ea,ag as Ec,CK as Ei,br as El,Jue as En,oA as Eo,ele as Er,Oy as Es,Fme as Et,Nbe as F,nF as Fa,Fp as Fc,nz as Fi,Yue as Fn,lO as Fo,z2 as Fr,Yv as Fs,Y3 as Ft,Cbe as G,FN as Ga,ef as Gc,qR as Gi,Y4 as Gn,rE as Go,m1 as Gr,Fv as Gs,W3 as Gt,E7 as H,VN as Ha,Sf as Hc,FR as Hi,r3 as Hn,EE as Ho,v1 as Hr,Bv as Hs,J3 as Ht,A7 as I,pF as Ia,jp as Ic,ez as Ii,Gue as In,ZD as Io,L2 as Ir,Jv as Is,X3 as It,Dbe as J,fM as Ja,Xd as Jc,OR as Ji,H4 as Jn,hT as Jo,i1 as Jr,Mv as Js,xfe as Jt,Tbe as K,BN as Ka,$d as Kc,KR as Ki,X4 as Kn,OT as Ko,u1 as Kr,Pv as Ks,Dfe as Kt,M7 as L,oF as La,lp as Lc,QR as Li,rde as Ln,HD as Lo,F2 as Lr,Kv as Ls,Z3 as Lt,zbe as M,iF as Ma,Bm as Mc,fz as Mi,a3 as Mn,HO as Mo,Pce as Mr,ey as Ms,t6 as Mt,Bbe as N,lF as Na,sm as Nc,dz as Ni,$ue as Nn,MO as No,Ice as Nr,Qv as Ns,Lfe as Nt,Mbe as O,mF as Oa,bh as Oc,DK as Oi,Ki as Ol,tde as On,wk as Oo,tle as Or,oy as Os,X6 as Ot,Ube as P,fF as Pa,Gp as Pc,rz as Pi,ede as Pn,uO as Po,R2 as Pr,Zv as Ps,Ife as Pt,w7 as Q,Zj as Qa,yd as Qc,kR as Qi,tue as Qn,Dw as Qo,W$ as Qr,Ov as Qs,Tfe as Qt,Vbe as R,aF as Ra,sp as Rc,oz as Ri,s3 as Rn,VD as Ro,B2 as Rr,Gv as Rs,Nfe as Rt,ESe as S,NF as Sa,__ as Sc,OK as Si,Zi as Sl,Wue as Sn,sA as So,ale as Sr,Ly as Ss,nhe as St,Wbe as T,rF as Ta,_g as Tc,TK as Ti,_r as Tl,o3 as Tn,rA as To,ile as Tr,Ny as Ts,Pme as Tt,Ebe as U,RN as Ua,uf as Uc,jR as Ui,i3 as Un,TE as Uo,p1 as Ur,Lv as Us,G3 as Ut,kbe as V,zN as Va,Ff as Vc,XR as Vi,Lue as Vn,aD as Vo,y1 as Vr,Vv as Vs,Afe as Vt,Obe as W,LN as Wa,sf as Wc,HR as Wi,Z4 as Wn,sE as Wo,d1 as Wr,Iv as Ws,K3 as Wt,bbe as X,Xj as Xa,Vd as Xc,WR as Xi,$le as Xn,oT as Xo,e1 as Xr,Av as Xs,H3 as Xt,Sbe as Y,uM as Ya,Gd as Yc,AR as Yi,V4 as Yn,lT as Yo,c1 as Yr,jv as Ys,V3 as Yt,gbe as Z,Jj as Za,Rd as Zc,UR as Zi,fue as Zn,Yw as Zo,J$ as Zr,kv as Zs,Sfe as Zt,T9 as _,uI as _a,iv as _c,Pq as _i,to as _l,M3 as _n,mA as _o,n4 as _r,jb as _s,Qme as _t,nwe as a,GR as aa,bv as ac,XQ as ai,gl as al,hfe as an,xj as ao,rue as ar,_S as as,F5 as at,S9 as b,zF as ba,O_ as bc,FK as bi,ka as bl,b3 as bn,uA as bo,cle as br,$y as bs,Yme as bt,F9 as c,GL as ca,_v as cc,Uq as ci,Wc as cl,B3 as cn,_j as co,cue as cr,cS as cs,k8 as ct,QCe as d,UI as da,mv as dc,Qq as di,bc as dl,ife as dn,oj as do,due as dr,Gx as ds,Xme as dt,DR as ea,Ev as ec,H$ as ei,ld as el,wfe as en,Pj as eo,oue as er,SC as es,$ye as et,twe as f,WI as fa,fv as fc,$q as fi,ec as fl,ofe as fn,cj as fo,s4 as fr,Px as fs,the as ft,jCe as g,mI as ga,ov as gc,Lq as gi,ao as gl,j3 as gn,xA as go,t4 as gr,Lb as gs,a8 as gt,M9 as h,hI as ha,lv as hc,Bq as hi,yo as hl,cfe as hn,wA as ho,ble as hr,ax as hs,rhe as ht,$Ce as i,VR as ia,xv as ic,JQ as ii,Iu as il,gfe as in,Dj as io,R4 as ir,yS as is,$5 as it,Abe as j,dF as ja,oh as jc,pz as ji,Kue as jn,ek as jo,rle as jr,ny as js,j6 as jt,jbe as k,uF as ka,gh as kc,jK as ki,que as kn,Sk as ko,ole as kr,ay as ks,Y6 as kt,ewe as l,NI as la,gv as lc,Hq as li,zc as ll,sfe as ln,uj as lo,z4 as lr,rS as ls,c8 as lt,N9 as m,pI as ma,uv as mc,Vq as mi,$o as ml,afe as mn,CA as mo,r4 as mr,cx as ms,Zme as mt,R9 as n,LR as na,wv as nc,B$ as ni,Ju as nl,Cfe as nn,Aj as no,L4 as nr,aC as ns,m7 as nt,rwe as o,RR as oa,yv as oc,UQ as oi,Qc as ol,z3 as on,gj as oo,iue as or,uS as os,E5 as ot,I9 as p,_I as pa,dv as pc,tJ as pi,Ns as pl,P3 as pn,SA as po,o4 as pr,Ex as ps,ehe as pt,wbe as q,YM as qa,Qd as qc,zR as qi,G4 as qn,ST as qo,f1 as qr,Nv as qs,Efe as qt,XCe as r,IR as ra,Cv as rc,V$ as ri,Gu as rl,mfe as rn,Oj as ro,aue as rr,kS as rs,a7 as rt,YCe as s,NR as sa,vv as sc,gQ as si,Jc as sl,R3 as sn,hj as so,nue as sr,lS as ss,Z8 as st,L9 as t,MR as ta,Tv as tc,z$ as ti,Yu as tl,_fe as tn,wj as to,Qle as tr,lC as ts,_7 as tt,ZCe as u,BI as ua,hv as uc,eJ as ui,Fc as ul,N3 as un,lj as uo,eue as ur,Qx as us,Jme as ut,ACe as v,lI as va,X_ as vc,Oq as vi,Za as vl,E3 as vn,gA as vo,yle as vr,nb as vs,ahe as vt,H7 as w,cF as wa,Eg as wc,EK as wi,ii as wl,Uue as wn,nA as wo,J2 as wr,Py as ws,e8 as wt,l9 as x,VF as xa,x_ as xc,AK as xi,Da as xl,d3 as xn,lA as xo,lle as xr,qy as xs,s8 as xt,w9 as y,HF as ya,V_ as yc,gq as yi,qa as yl,O3 as yn,dA as yo,Y2 as yr,tb as ys,ihe as yt,k7 as z,lP as za,op as zc,iz as zi,Que as zn,MD as zo,I2 as zr,Uv as zs,kfe as zt};
257
+ `)||e.includes(`\r`))return;let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean).at(-1);if(!(!t||t.length>80||/(?:token|api[_-]?key|password|secret)=/i.test(t)))return t}function pwe(e){if(e)try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.host:void 0}catch{return}}function mwe(e){let t=V9(e);return t===`update_plan`||t.includes(`plan`)?`planning`:t.includes(`browser`)||t.includes(`playwright`)||t.includes(`chrome`)?`browsing`:t.includes(`search`)||t.includes(`image_query`)||t.includes(`web_fetch`)?`researching`:t.includes(`read_file`)||t.includes(`file_read`)||t.includes(`list_dir`)?`reading`:t.includes(`patch`)||t.includes(`edit_file`)||t.includes(`write_file`)?`editing`:t.includes(`exec_command`)||t.includes(`run_command`)||t.includes(`shell`)?`running`:t.includes(`open_url`)||t.includes(`fetch_url`)?`browsing`:`preparing`}function hwe(e,t){let n=V9(e),r=H9(t),i={phase:mwe(e)};return i.phase===`reading`||i.phase===`editing`?i.detail=fwe(U9(r,`path`,`filePath`,`file`)):i.phase===`browsing`&&(i.detail=pwe(U9(r,`url`,`href`))),(n.includes(`exec_command`)||n.includes(`search`)||n.includes(`query`))&&delete i.detail,i}function gwe(e){let t=H9(e),n=U9(t,`stage`)?.toLowerCase(),r=n===`compaction`?`compacting`:n===`planning`?`planning`:n===`research`||n===`search`?`researching`:n===`verification`||n===`running`?`running`:n===`waiting`||n===`clarifying`?`waiting`:`preparing`,i=Number(t.completed),a=Number(t.total);return{phase:r,...Number.isFinite(i)&&i>=0?{completed:i}:{},...Number.isFinite(a)&&a>0?{total:a}:{}}}function W9(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n.trim():void 0}function _we(e){return e.payload&&typeof e.payload==`object`&&!Array.isArray(e.payload)?e.payload:{}}function G9(e,t,n){return W9(t,n)??W9(e,n)}function vwe(e){let t=e.event;if(!t||typeof t!=`object`)return null;let n=t,r=W9(n,`type`);if(!r)return null;let i=_we(n),a=e.sessionKey?`/chat/${e.sessionKey}`:`/chat`,o=W9(n,`runId`);if(r===`run_start`||r===`assistant_message_start`)return{kind:`agent-start`,sessionKey:e.sessionKey,runId:o,route:a};if(r===`tool_start`){let t=G9(n,i,`toolName`)??G9(n,i,`name`);return{kind:`agent-tool`,toolName:t,activity:hwe(t,i.args),sessionKey:e.sessionKey,runId:o,route:a}}return r===`progress`||r===`compaction`?{kind:`agent-progress`,activity:r===`compaction`?{phase:`compacting`}:gwe(i),sessionKey:e.sessionKey,runId:o,route:a}:r===`run_end`||r===`assistant_message_end`?{kind:`agent-success`,severity:`success`,sessionKey:e.sessionKey,runId:o,route:a}:r===`clarify_request`?{kind:`agent-progress`,severity:`warning`,activity:{phase:`waiting`},sessionKey:e.sessionKey,runId:o,route:a}:r===`error`?{kind:`agent-error`,severity:`error`,sessionKey:e.sessionKey,runId:o,route:a}:null}function ywe(){let e=(0,Q.c)(2),t=(0,Z.useRef)(null),n,r;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{if(!fM()||!window.electronAPI?.pet)return;let e=e=>{let n=`${e.kind}:${e.sessionKey??``}:${e.message??``}:${e.toolName??``}`,r=Date.now(),i=t.current;i&&i.key===n&&r-i.at<1600||(t.current={key:n,at:r},window.electronAPI?.pet?.sendEvent(e).catch(bwe))},n=t=>{let n=vwe(t.detail);n&&e(n)},r=t=>{let n=t.detail;!n?.title&&!n?.message||e({kind:`toast`,severity:n.type,title:n.title,message:n.message??n.title,route:`/chat`})};return window.addEventListener(`agent-stream-event`,n),window.addEventListener(ne,r),()=>{window.removeEventListener(`agent-stream-event`,n),window.removeEventListener(ne,r)}},r=[],e[0]=n,e[1]=r):(n=e[0],r=e[1]),(0,Z.useEffect)(n,r),null}function bwe(){}async function xwe(e){let t=await Y(e);if(!t.ok){let e=await t.json().catch(()=>({})),n=te(t.status,t.statusText,e.error?.message);throw Error(n)}return t.json()}function Swe(e){let t=(0,Q.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={fetcher:xwe,revalidateOnFocus:!1,dedupingInterval:2e3,shouldRetryOnError:!0,errorRetryCount:2},t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsx)(ae,{value:r,children:n}),t[1]=n,t[2]=i),i}var Cwe=(0,Z.lazy)(()=>FP().then(e=>({default:e.SessionsPage}))),wwe=(0,Z.lazy)(()=>IP().then(e=>({default:e.AutomationsPage}))),Twe=(0,Z.lazy)(()=>LP().then(e=>({default:e.ProjectsPage}))),K9=(0,Z.lazy)(()=>RP().then(e=>({default:e.ProjectDetailPage}))),Ewe=(0,Z.lazy)(()=>zP().then(e=>({default:e.WorkItemDetailPage}))),Dwe=(0,Z.lazy)(()=>BP().then(e=>({default:e.GoalsPage}))),Owe=(0,Z.lazy)(()=>VP().then(e=>({default:e.GoalDetailPage}))),q9=(0,Z.lazy)(()=>HP().then(e=>({default:e.NotesPage}))),kwe=(0,Z.lazy)(()=>UP().then(e=>({default:e.WorkflowsPage}))),Awe=(0,Z.lazy)(()=>WP().then(e=>({default:e.SkillsPage}))),jwe=(0,Z.lazy)(()=>GP().then(e=>({default:e.ConnectorsPage}))),Mwe=(0,Z.lazy)(()=>KP().then(e=>({default:e.LogsPage}))),Nwe=(0,Z.lazy)(()=>qP().then(e=>({default:e.SettingsPage}))),J9=(0,Z.lazy)(()=>JP().then(e=>({default:e.AgentsSettingsPanel}))),Pwe=(0,Z.lazy)(()=>YP().then(e=>({default:e.AgentBrowserSettingsPage}))),Y9=(0,Z.lazy)(()=>XP().then(e=>({default:e.ChannelsSettingsPanel}))),Fwe=(0,Z.lazy)(()=>ZP().then(e=>({default:e.ExtensionsPage}))),X9=(0,Z.lazy)(()=>QP().then(e=>({default:e.ExtensionPage}))),Z9=(0,Z.lazy)(()=>$P().then(e=>({default:e.ExtensionSettingsPage}))),Iwe=(0,Z.lazy)(()=>eF().then(e=>({default:e.ExtensionDebugPage}))),Lwe=(0,Z.lazy)(()=>tF().then(e=>({default:e.SharePreviewPage}))),Rwe=(0,Z.lazy)(()=>c(()=>import(`./desktop-pet-Jmdn6q47.js`).then(e=>({default:e.DesktopPetPage})),__vite__mapDeps([94,1,2,7,3,69,4,11])));function Q9(){let e=(0,Q.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,$.jsx)(uI,{className:`h-5 w-44`}),(0,$.jsx)(uI,{className:`h-3 w-64 max-w-full`})]}),(0,$.jsx)(uI,{className:`h-9 w-24 shrink-0 rounded-lg`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:Array.from({length:4}).map(Bwe)}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel`,"aria-busy":!0,children:(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[t,n,(0,$.jsx)(`div`,{className:`grid gap-3 lg:grid-cols-3`,children:Array.from({length:6}).map(zwe)})]})}),e[2]=r):r=e[2],r}function zwe(e,t){return(0,$.jsx)(uI,{className:`h-36 rounded-lg`},t)}function Bwe(e,t){return(0,$.jsx)(uI,{className:`h-20 rounded-lg`},t)}function $9(){let e=(0,Q.c)(4),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(uI,{className:`h-8 w-48 max-w-full`}),n=(0,$.jsx)(uI,{className:`mt-6 h-36 rounded-xl`}),r=(0,$.jsx)(uI,{className:`mt-4 h-24 rounded-xl`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"aria-busy":!0,children:(0,$.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,$.jsxs)(`div`,{className:`mt-6 grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(uI,{className:`h-20 rounded-xl`}),(0,$.jsx)(uI,{className:`h-20 rounded-xl`})]})]})}),e[3]=i):i=e[3],i}var Vwe=xee([{path:`/desktop-pet`,element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Rwe,{})})},{path:`/share/:token`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Lwe,{})})},{path:`/`,element:(0,$.jsx)(npe,{}),children:[{index:!0,element:(0,$.jsx)(ii,{to:`/chat`,replace:!0})},{path:`chat`,element:(0,$.jsx)(dwe,{}),children:[{index:!0,element:(0,$.jsx)(B9,{})},{path:`new`,element:(0,$.jsx)(B9,{})},{path:`:sessionKey`,element:(0,$.jsx)(B9,{})}]},{path:`automations`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(wwe,{})})},{path:`projects`,children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Twe,{})})},{path:`:projectId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(K9,{})})},{path:`:projectId/:tabId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(K9,{})})},{path:`:projectId/notes/:noteId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(K9,{})})}]},{path:`work-items/:workItemId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Ewe,{})})},{path:`goals`,children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Dwe,{})})},{path:`:goalId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Owe,{})})}]},{path:`notes`,children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(q9,{})})},{path:`:noteId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(q9,{})})}]},{path:`workflows`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(kwe,{})})},{path:`skills`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Awe,{})})},{path:`connectors`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(jwe,{})})},{path:`channels`,children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Y9,{})})},{path:`:channelId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Y9,{})})}]},{path:`agents`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(J9,{})})},{path:`agents/:agentId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(J9,{})})},{path:`extensions`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Fwe,{})})},{path:`extensions/:extensionId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(X9,{})})},{path:`extensions/:extensionId/:pageId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(X9,{})})},{path:`settings`,element:(0,$.jsx)(Ope,{children:(0,$.jsx)(Cpe,{})}),children:[{index:!0,element:(0,$.jsx)(ii,{to:`overview`,replace:!0})},{path:`sessions`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Cwe,{})})},{path:`logs`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(Q9,{}),children:(0,$.jsx)(Mwe,{})})},{path:`agent-browser`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)($9,{}),children:(0,$.jsx)(Pwe,{})})},{path:`extensions/debug`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)($9,{}),children:(0,$.jsx)(Iwe,{})})},{path:`ext/:extensionId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)($9,{}),children:(0,$.jsx)(Z9,{})})},{path:`ext/:extensionId/:panelId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)($9,{}),children:(0,$.jsx)(Z9,{})})},{path:`:section`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)($9,{}),children:(0,$.jsx)(Nwe,{})})}]}]}]);function Hwe(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(Uwe,t),null}function Uwe(){let e=x.persist.onFinishHydration(Gwe),t=jA.persist.onFinishHydration(Wwe),n=y(),r=S();return()=>{e?.(),t?.(),n(),r()}}function Wwe(){MA()}function Gwe(){C()}function Kwe(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Hwe,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Swe,{children:(0,$.jsx)(LF,{children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col *:min-h-0 *:flex-1`,children:[(0,$.jsx)(ywe,{}),(0,$.jsx)(Iee,{router:Vwe})]})]})})}),e[1]=n):n=e[1],n}document.documentElement.setAttribute(`lang`,v(g())),w(),AA(),ee(),(0,Vk.createRoot)(document.getElementById(`root`)).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(Kwe,{})}));export{S7 as $,Yj as $a,vd as $c,BR as $i,sue as $n,ew as $o,U$ as $r,Dv as $s,U3 as $t,Ibe as A,hF as Aa,sh as Ac,NK as Ai,Vue as An,bk as Ao,nle as Ar,ry as As,z6 as At,xbe as B,HN as Ba,np as Bc,sz as Bi,Bue as Bn,mD as Bo,b1 as Br,Hv as Bs,q3 as Bt,U7 as C,FF as Ca,p_ as Cc,PK as Ci,Hi as Cl,Hue as Cn,aA as Co,$ce as Cr,Iy as Cs,qme as Ct,Rbe as D,sF as Da,Eh as Dc,MK as Di,wr as Dl,nde as Dn,tA as Do,sle as Dr,Ey as Ds,Z6 as Dt,Gbe as E,gF as Ea,ag as Ec,CK as Ei,br as El,Jue as En,oA as Eo,ele as Er,Oy as Es,Fme as Et,Nbe as F,nF as Fa,Fp as Fc,nz as Fi,Yue as Fn,lO as Fo,z2 as Fr,Yv as Fs,Y3 as Ft,Cbe as G,FN as Ga,ef as Gc,qR as Gi,Y4 as Gn,rE as Go,m1 as Gr,Fv as Gs,W3 as Gt,E7 as H,VN as Ha,Sf as Hc,FR as Hi,r3 as Hn,EE as Ho,v1 as Hr,Bv as Hs,J3 as Ht,A7 as I,pF as Ia,jp as Ic,ez as Ii,Gue as In,ZD as Io,L2 as Ir,Jv as Is,X3 as It,Dbe as J,fM as Ja,Xd as Jc,OR as Ji,H4 as Jn,hT as Jo,i1 as Jr,Mv as Js,xfe as Jt,Tbe as K,BN as Ka,$d as Kc,KR as Ki,X4 as Kn,OT as Ko,u1 as Kr,Pv as Ks,Dfe as Kt,M7 as L,oF as La,lp as Lc,QR as Li,rde as Ln,HD as Lo,F2 as Lr,Kv as Ls,Z3 as Lt,zbe as M,iF as Ma,Bm as Mc,fz as Mi,a3 as Mn,HO as Mo,Pce as Mr,ey as Ms,t6 as Mt,Bbe as N,lF as Na,sm as Nc,dz as Ni,$ue as Nn,MO as No,Ice as Nr,Qv as Ns,Lfe as Nt,Mbe as O,mF as Oa,bh as Oc,DK as Oi,Ki as Ol,tde as On,wk as Oo,tle as Or,oy as Os,X6 as Ot,Ube as P,fF as Pa,Gp as Pc,rz as Pi,ede as Pn,uO as Po,R2 as Pr,Zv as Ps,Ife as Pt,w7 as Q,Zj as Qa,yd as Qc,kR as Qi,tue as Qn,Dw as Qo,W$ as Qr,Ov as Qs,Tfe as Qt,Vbe as R,aF as Ra,sp as Rc,oz as Ri,s3 as Rn,VD as Ro,B2 as Rr,Gv as Rs,Nfe as Rt,ESe as S,NF as Sa,__ as Sc,OK as Si,Zi as Sl,Wue as Sn,sA as So,ale as Sr,Ly as Ss,nhe as St,Wbe as T,rF as Ta,_g as Tc,TK as Ti,_r as Tl,o3 as Tn,rA as To,ile as Tr,Ny as Ts,Pme as Tt,Ebe as U,RN as Ua,uf as Uc,jR as Ui,i3 as Un,TE as Uo,p1 as Ur,Lv as Us,G3 as Ut,kbe as V,zN as Va,Ff as Vc,XR as Vi,Lue as Vn,aD as Vo,y1 as Vr,Vv as Vs,Afe as Vt,Obe as W,LN as Wa,sf as Wc,HR as Wi,Z4 as Wn,sE as Wo,d1 as Wr,Iv as Ws,K3 as Wt,bbe as X,Xj as Xa,Vd as Xc,WR as Xi,$le as Xn,oT as Xo,e1 as Xr,Av as Xs,H3 as Xt,Sbe as Y,uM as Ya,Gd as Yc,AR as Yi,V4 as Yn,lT as Yo,c1 as Yr,jv as Ys,V3 as Yt,gbe as Z,Jj as Za,Rd as Zc,UR as Zi,fue as Zn,Yw as Zo,J$ as Zr,kv as Zs,Sfe as Zt,T9 as _,uI as _a,iv as _c,Pq as _i,to as _l,M3 as _n,mA as _o,n4 as _r,jb as _s,Qme as _t,nwe as a,GR as aa,bv as ac,XQ as ai,gl as al,hfe as an,xj as ao,rue as ar,_S as as,F5 as at,S9 as b,zF as ba,O_ as bc,FK as bi,ka as bl,b3 as bn,uA as bo,cle as br,$y as bs,Yme as bt,F9 as c,GL as ca,_v as cc,Uq as ci,Wc as cl,B3 as cn,_j as co,cue as cr,cS as cs,k8 as ct,QCe as d,UI as da,mv as dc,Qq as di,bc as dl,ife as dn,oj as do,due as dr,Gx as ds,Xme as dt,DR as ea,Ev as ec,H$ as ei,ld as el,wfe as en,Pj as eo,oue as er,SC as es,$ye as et,twe as f,WI as fa,fv as fc,$q as fi,ec as fl,ofe as fn,cj as fo,s4 as fr,Px as fs,the as ft,jCe as g,mI as ga,ov as gc,Lq as gi,ao as gl,j3 as gn,xA as go,t4 as gr,Lb as gs,a8 as gt,M9 as h,hI as ha,lv as hc,Bq as hi,yo as hl,cfe as hn,wA as ho,ble as hr,ax as hs,rhe as ht,$Ce as i,VR as ia,xv as ic,JQ as ii,Iu as il,gfe as in,Dj as io,R4 as ir,yS as is,$5 as it,Abe as j,dF as ja,oh as jc,pz as ji,Kue as jn,ek as jo,rle as jr,ny as js,j6 as jt,jbe as k,uF as ka,gh as kc,jK as ki,que as kn,Sk as ko,ole as kr,ay as ks,Y6 as kt,ewe as l,NI as la,gv as lc,Hq as li,zc as ll,sfe as ln,uj as lo,z4 as lr,rS as ls,c8 as lt,N9 as m,pI as ma,uv as mc,Vq as mi,$o as ml,afe as mn,CA as mo,r4 as mr,cx as ms,Zme as mt,R9 as n,LR as na,wv as nc,B$ as ni,Ju as nl,Cfe as nn,Aj as no,L4 as nr,aC as ns,m7 as nt,rwe as o,RR as oa,yv as oc,UQ as oi,Qc as ol,z3 as on,gj as oo,iue as or,uS as os,E5 as ot,I9 as p,_I as pa,dv as pc,tJ as pi,Ns as pl,P3 as pn,SA as po,o4 as pr,Ex as ps,ehe as pt,wbe as q,YM as qa,Qd as qc,zR as qi,G4 as qn,ST as qo,f1 as qr,Nv as qs,Efe as qt,XCe as r,IR as ra,Cv as rc,V$ as ri,Gu as rl,mfe as rn,Oj as ro,aue as rr,kS as rs,a7 as rt,YCe as s,NR as sa,vv as sc,gQ as si,Jc as sl,R3 as sn,hj as so,nue as sr,lS as ss,Z8 as st,L9 as t,MR as ta,Tv as tc,z$ as ti,Yu as tl,_fe as tn,wj as to,Qle as tr,lC as ts,_7 as tt,ZCe as u,BI as ua,hv as uc,eJ as ui,Fc as ul,N3 as un,lj as uo,eue as ur,Qx as us,Jme as ut,ACe as v,lI as va,X_ as vc,Oq as vi,Za as vl,E3 as vn,gA as vo,yle as vr,nb as vs,ahe as vt,H7 as w,cF as wa,Eg as wc,EK as wi,ii as wl,Uue as wn,nA as wo,J2 as wr,Py as ws,e8 as wt,l9 as x,VF as xa,x_ as xc,AK as xi,Da as xl,d3 as xn,lA as xo,lle as xr,qy as xs,s8 as xt,w9 as y,HF as ya,V_ as yc,gq as yi,qa as yl,O3 as yn,dA as yo,Y2 as yr,tb as ys,ihe as yt,k7 as z,lP as za,op as zc,iz as zi,Que as zn,MD as zo,I2 as zr,Uv as zs,kfe as zt};