@hachej/boring-ui-cli 0.1.80 → 0.1.82

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 (70) hide show
  1. package/package.json +9 -9
  2. package/public/assets/{DebugDrawer-CmBNqdMZ.js → DebugDrawer-BXDxUqG6.js} +1 -1
  3. package/public/assets/{DiagramPane-DExG3C_B.js → DiagramPane-Vzg5nzB5.js} +4 -4
  4. package/public/assets/{abnfDiagram-VRR7QNED-BYIpnEWe.js → abnfDiagram-VRR7QNED-DIM4WdUu.js} +1 -1
  5. package/public/assets/{architectureDiagram-ZJ3FMSHR-CuXk1ExT.js → architectureDiagram-ZJ3FMSHR-CvlgW3i6.js} +1 -1
  6. package/public/assets/{blockDiagram-677ZJIJ3-BNuwFkOB.js → blockDiagram-677ZJIJ3-CAVw539c.js} +1 -1
  7. package/public/assets/{c4Diagram-LMCZKHZV-vOd-i6oU.js → c4Diagram-LMCZKHZV-CAS7VvIZ.js} +1 -1
  8. package/public/assets/channel-IP5ecgg3.js +1 -0
  9. package/public/assets/{chunk-32BRIVSS-D0LVvwRn.js → chunk-32BRIVSS-C8WNKZUy.js} +1 -1
  10. package/public/assets/{chunk-C7G6YPKG-WlrjvRPU.js → chunk-C7G6YPKG-JkY7BZ9Y.js} +1 -1
  11. package/public/assets/{chunk-EX3LRPZG-C1D9OQgx.js → chunk-EX3LRPZG-D1e6FeJf.js} +1 -1
  12. package/public/assets/{chunk-HOUHSVGY-DsnMzn8e.js → chunk-HOUHSVGY-b9ihJSE7.js} +1 -1
  13. package/public/assets/{chunk-ICXQ74PX-CyAvh-Bu.js → chunk-ICXQ74PX-CQKuUo-t.js} +1 -1
  14. package/public/assets/{chunk-MOJQB5TN-D8X4zTh2.js → chunk-MOJQB5TN-HUMNIDR1.js} +1 -1
  15. package/public/assets/{chunk-OGEWGWER-BShclaB5.js → chunk-OGEWGWER-eUOKygVq.js} +1 -1
  16. package/public/assets/{chunk-PUDLZKDR-xAlZkx_V.js → chunk-PUDLZKDR-ccT5LcXZ.js} +1 -1
  17. package/public/assets/{chunk-Q4XR5HBZ-DjBZZefu.js → chunk-Q4XR5HBZ-BmyKr7fn.js} +1 -1
  18. package/public/assets/{chunk-V7JOEXUC-BjWM_jnD.js → chunk-V7JOEXUC-XIIJkR7-.js} +1 -1
  19. package/public/assets/{chunk-VR4S4FIN-0xFZ77et.js → chunk-VR4S4FIN-CKIZWeQy.js} +1 -1
  20. package/public/assets/{chunk-WYO6CB5R-B5B5hVg0.js → chunk-WYO6CB5R-AwdhWuZo.js} +2 -2
  21. package/public/assets/{chunk-ZGVPDNZ5-ezDabbl-.js → chunk-ZGVPDNZ5-mGpw_02_.js} +1 -1
  22. package/public/assets/classDiagram-OUVF2IWQ-B9Etcp-t.js +1 -0
  23. package/public/assets/classDiagram-v2-EOCWNBFH-B9Etcp-t.js +1 -0
  24. package/public/assets/{cynefinDiagram-TSTJHNR4-DirqPxaJ.js → cynefinDiagram-TSTJHNR4-Ck5X3Pvz.js} +1 -1
  25. package/public/assets/{dagre-VKFMJZFB-CsWb9Wvi.js → dagre-VKFMJZFB-BRFoDSW8.js} +1 -1
  26. package/public/assets/{diagram-FQU43EPY-CWXXPDyf.js → diagram-FQU43EPY-DK1yLdyN.js} +1 -1
  27. package/public/assets/{diagram-G47NLZAW-CR6Vw1qI.js → diagram-G47NLZAW-CFK_ti2g.js} +1 -1
  28. package/public/assets/{diagram-NH7WQ7WH-C7egv5PI.js → diagram-NH7WQ7WH-D8afauUh.js} +1 -1
  29. package/public/assets/{diagram-OA4YK3LP-BDjGAN6E.js → diagram-OA4YK3LP-BcWPtrFs.js} +1 -1
  30. package/public/assets/{diagram-WEI45ONY-ByWPeJ3n.js → diagram-WEI45ONY-Cg4RvV8X.js} +1 -1
  31. package/public/assets/{dist-CnC30ANf.js → dist-C0T8yw3E.js} +1 -1
  32. package/public/assets/{ebnfDiagram-CCIWWBDH-DTE_Hi9u.js → ebnfDiagram-CCIWWBDH-CfduTGsM.js} +1 -1
  33. package/public/assets/{erDiagram-Q63AITRT-B6RMjkqo.js → erDiagram-Q63AITRT-ChOMFsyu.js} +1 -1
  34. package/public/assets/flowDiagram-23GEKE2U-CWVKIbSe.js +1 -0
  35. package/public/assets/{ganttDiagram-NO4QXBWP-C7VOoWID.js → ganttDiagram-NO4QXBWP-BJyI59N-.js} +1 -1
  36. package/public/assets/{gitGraphDiagram-IHSO6WYX-_Ujm6vip.js → gitGraphDiagram-IHSO6WYX-Dpw0EMH3.js} +1 -1
  37. package/public/assets/{highlighted-body-OFNGDK62-Cj3Ar0n3.js → highlighted-body-OFNGDK62-BoMwTwLt.js} +1 -1
  38. package/public/assets/{index-Lpwxmb5G.js → index-C18DGlO8.js} +9 -9
  39. package/public/assets/index-ClhTb6at.css +1 -0
  40. package/public/assets/{infoDiagram-FWYZ7A6U-BNFhgDLP.js → infoDiagram-FWYZ7A6U-CEuxB7IW.js} +1 -1
  41. package/public/assets/{ishikawaDiagram-FXEZZL3T-VJcgTL8W.js → ishikawaDiagram-FXEZZL3T-wk1u9NX7.js} +1 -1
  42. package/public/assets/{journeyDiagram-5HDEW3XC-BlcNNU8v.js → journeyDiagram-5HDEW3XC-D1ftt9ge.js} +1 -1
  43. package/public/assets/{kanban-definition-HUTT4EX6-DLdfqqIW.js → kanban-definition-HUTT4EX6-DCelZ2vh.js} +1 -1
  44. package/public/assets/{line-CrRWgAHs.js → line-A-4XUjwX.js} +1 -1
  45. package/public/assets/mermaid-GHXKKRXX-gnLaGsbP.js +1 -0
  46. package/public/assets/{mindmap-definition-LN4V7U3C-B3bwSTt2.js → mindmap-definition-LN4V7U3C-DuYnLQGd.js} +1 -1
  47. package/public/assets/{pegDiagram-2B236MQR-9LLuxSRX.js → pegDiagram-2B236MQR-D9Fg-G2c.js} +1 -1
  48. package/public/assets/{pieDiagram-ENE6RG2P-BgJCWQHt.js → pieDiagram-ENE6RG2P-DLkqng2U.js} +1 -1
  49. package/public/assets/{quadrantDiagram-ABIIQ3AL-CQYQ3GYO.js → quadrantDiagram-ABIIQ3AL-Dw0uY7MQ.js} +1 -1
  50. package/public/assets/{railroadDiagram-RFXS5EU6-C0cBUvf6.js → railroadDiagram-RFXS5EU6-BW70k7aB.js} +1 -1
  51. package/public/assets/{requirementDiagram-TGXJPOKE-C-oeLyY_.js → requirementDiagram-TGXJPOKE-BJtZwK-r.js} +1 -1
  52. package/public/assets/{sankeyDiagram-HTMAVEWB-COo7g9T1.js → sankeyDiagram-HTMAVEWB-DeZe-cA5.js} +1 -1
  53. package/public/assets/{sequenceDiagram-DBY2YBRQ-hsxNS03R.js → sequenceDiagram-DBY2YBRQ-DKCWWujI.js} +1 -1
  54. package/public/assets/{stateDiagram-2N3HPSRC-bIMnxqO8.js → stateDiagram-2N3HPSRC-DalzGktj.js} +1 -1
  55. package/public/assets/stateDiagram-v2-6OUMAXLB-CI1LWAFu.js +1 -0
  56. package/public/assets/{swimlanes-5IMT3BWC-D_RQIhid.js → swimlanes-5IMT3BWC-46Asc0jn.js} +1 -1
  57. package/public/assets/swimlanesDiagram-G3AALYLV-4tvcCzsT.js +8 -0
  58. package/public/assets/{timeline-definition-FHXFAJF6-C9JnE-9Z.js → timeline-definition-FHXFAJF6-CWFZnqYm.js} +1 -1
  59. package/public/assets/{vennDiagram-L72KCM5P-Bs58CXI0.js → vennDiagram-L72KCM5P-DMwzFRSk.js} +1 -1
  60. package/public/assets/{wardleyDiagram-EHGQE667-ngPnquAL.js → wardleyDiagram-EHGQE667-BWVEPVA9.js} +1 -1
  61. package/public/assets/{xychartDiagram-FW5EYKEG-oepIN_mI.js → xychartDiagram-FW5EYKEG-BXglxQCg.js} +1 -1
  62. package/public/index.html +10 -10
  63. package/public/assets/channel-UL65cgUu.js +0 -1
  64. package/public/assets/classDiagram-OUVF2IWQ-DD8BZuSm.js +0 -1
  65. package/public/assets/classDiagram-v2-EOCWNBFH-DD8BZuSm.js +0 -1
  66. package/public/assets/flowDiagram-23GEKE2U-CouB6ylb.js +0 -1
  67. package/public/assets/index-BlhPFh_2.css +0 -1
  68. package/public/assets/mermaid-GHXKKRXX-C4DsMfhs.js +0 -1
  69. package/public/assets/stateDiagram-v2-6OUMAXLB-nx3bC5I9.js +0 -1
  70. package/public/assets/swimlanesDiagram-G3AALYLV-CwYEB1yi.js +0 -8
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-r4nzjlvl.js","assets/rolldown-runtime-DAXXjFlN.js","assets/html-BwPosJq7.js","assets/javascript-C3H1hIQj.js","assets/css-BCANWTts.js","assets/angular-ts-BxqKd0Zc.js","assets/scss-CGgB8MuJ.js","assets/apl-C04b0OjT.js","assets/xml-D8dNscGz.js","assets/java-CO4kXx58.js","assets/json-GHnjY4eF.js","assets/astro-AQ_iZfq_.js","assets/typescript-QDgNEXlg.js","assets/postcss-BunjpCQr.js","assets/tsx--25XuaIh.js","assets/blade-DH22iKQU.js","assets/html-derivative-tMv-aKGZ.js","assets/sql-DvBUnkQP.js","assets/bsl-DJOyloKD.js","assets/sdbl-DzilZtvS.js","assets/c-CEbO_RKk.js","assets/cairo-CDc8os0h.js","assets/python-DkGugaUl.js","assets/cobol-j5M6C8cE.js","assets/coffee-BhrHAdFL.js","assets/cpp-dOwNr0lq.js","assets/regexp-BTmVwUGX.js","assets/glsl-D4M1jM50.js","assets/crystal-BQKjzQ6q.js","assets/shellscript-DDxwoqAb.js","assets/edge-D8ZvGBZ4.js","assets/elixir-8PeAFHYj.js","assets/elm-CYP47Cl5.js","assets/erb-e24MnpOC.js","assets/ruby-CuVu4KOG.js","assets/haml-BsIdCvCS.js","assets/graphql-B9wSVVyi.js","assets/jsx-SanyMke9.js","assets/lua-CMKXOhwQ.js","assets/yaml-xy6SaJYi.js","assets/erlang-Dej7b2OY.js","assets/markdown-Bk5jPFPK.js","assets/fortran-fixed-form-RVbzjQ2q.js","assets/fortran-free-form-EhmKDVgM.js","assets/fsharp-DKW21_Cq.js","assets/gdresource-b7MixKdf.js","assets/gdshader-C7BToOo8.js","assets/gdscript-DbNIuFFJ.js","assets/git-commit-BU_RZ1WH.js","assets/diff-COJGj3FI.js","assets/git-rebase-BA9-AyLM.js","assets/glimmer-js-BAhz69_J.js","assets/glimmer-ts-DceI_LA7.js","assets/hack-DxPgm4F4.js","assets/handlebars-DdTlUnCd.js","assets/http-CDkctGoQ.js","assets/hurl-BeYO3sUq.js","assets/csv-aQe9eWwB.js","assets/hxml-B_tSdhCX.js","assets/haxe-BZXihDV-.js","assets/jinja-DHXIPVIS.js","assets/jison-eQA0nxws.js","assets/julia-DjbOEOq7.js","assets/r-DhQeW39P.js","assets/just-e17iqfha.js","assets/perl-CZJdECIs.js","assets/latex-C_WFP2fs.js","assets/tex-BQuLuNB_.js","assets/liquid-9ZAw5ESd.js","assets/marko-BaTlCnew.js","assets/less-BGJv5CZz.js","assets/mdc-V7J1bLNm.js","assets/nextflow-BJtWHP5T.js","assets/nextflow-groovy-DJMQeKeT.js","assets/nginx-Cf6hnit0.js","assets/nim-BLaoQEWH.js","assets/php-DIy4CEY0.js","assets/pug-r52_xqX8.js","assets/qml-BZ3S9mpj.js","assets/razor-uUSeMB08.js","assets/csharp-oqKa8noW.js","assets/rst-DZtY-B3E.js","assets/cmake-CbIxKMg_.js","assets/sas-BRgKo67P.js","assets/shaderlab-QzRPXpa3.js","assets/hlsl-BxIm9IaD.js","assets/shellsession-BtkHDZw6.js","assets/soy-DWSlVwxw.js","assets/sparql-BQ8pLLZr.js","assets/turtle-CA3RhB-1.js","assets/stata-DK4xd-1U.js","assets/surrealql-WCIpV-w3.js","assets/svelte-COt-aqLJ.js","assets/templ-DUVqjRh3.js","assets/go-rLFTqkRN.js","assets/ts-tags-BBqvRvIx.js","assets/twig-BHAJLapx.js","assets/vue-CDP3wwGh.js","assets/vue-html-BlXIoEQI.js","assets/vue-vine-O34tJq4k.js","assets/stylus-BrO8Mu5X.js","assets/xsl-BKE2QB1H.js","assets/angular-html-Da2ImPYj.js","assets/html-2owMSsYc.js","assets/javascript-DC7Y13dy.js","assets/css-CgQmFL-t.js","assets/angular-ts-CfbQ_CSh.js","assets/scss-CKrqXKNz.js","assets/apl-Cg3VgmnT.js","assets/xml-DzUK0Pry.js","assets/java-DJul3uN_.js","assets/json-DaZn6kP4.js","assets/astro-D7LRhiig.js","assets/typescript-DToX5D_l.js","assets/postcss-BXeXVLqQ.js","assets/tsx-Db8p8m2t.js","assets/blade-DE2J2P4J.js","assets/html-derivative-DjY87ttd.js","assets/sql-DAk8t4E1.js","assets/bsl-BkkzgIyY.js","assets/sdbl-bTVj8UrX.js","assets/c-Bp9SPJXV.js","assets/cairo-DLTphjLi.js","assets/python-gzcpVVnB.js","assets/cobol-CSZIDYWx.js","assets/coffee-68oYHmZj.js","assets/cpp-qzvOo2yl.js","assets/regexp-D77ZphON.js","assets/glsl-fbNNN2Bp.js","assets/crystal-DHHDVHRy.js","assets/shellscript-xyv2Ai2R.js","assets/edge-Cdhi70bQ.js","assets/elixir-ZBegKj6G.js","assets/elm-Aa2ys7L1.js","assets/erb-CoYAxOCW.js","assets/ruby-DiTzTPD2.js","assets/haml-Dk5AgJFk.js","assets/graphql-BVCjFJgP.js","assets/jsx-C97fCUqH.js","assets/lua-BF4pD4PQ.js","assets/yaml-uB2nBBeV.js","assets/erlang-Cphh6RMH.js","assets/markdown-BYOwaDjH.js","assets/fortran-fixed-form-DEKoE2YW.js","assets/fortran-free-form-CYNrtFtB.js","assets/fsharp-D13ZGOAj.js","assets/gdresource-C0sCabJj.js","assets/gdshader-CBce3t8t.js","assets/gdscript-Cp2uCuqX.js","assets/git-commit-BSykSTBG.js","assets/diff-woXpYk--.js","assets/git-rebase-gx2II6xm.js","assets/glimmer-js-nibZcW0E.js","assets/glimmer-ts-CiNDKS9-.js","assets/hack-CX65dzJU.js","assets/handlebars-CUlggvE0.js","assets/http-B1LJ0uJF.js","assets/hurl-GKc7yueO.js","assets/csv-Dx-8-gkx.js","assets/hxml-B0Qn7Nwc.js","assets/haxe-OTjmBuCE.js","assets/jinja-DTtnHnMF.js","assets/jison-Bb-bjV_r.js","assets/julia-CWUaLFvh.js","assets/r-D9B56oy7.js","assets/just-CyyGdrCJ.js","assets/perl-L_VLWuBs.js","assets/latex-dDT3L_Pr.js","assets/tex-we3ORCro.js","assets/liquid-htIxSkY0.js","assets/marko-CYoducAR.js","assets/less-DVTAwKKz.js","assets/mdc-BwGL0Z9o.js","assets/nextflow-Bbiyy34d.js","assets/nextflow-groovy-Dc_ddanL.js","assets/nginx-YcT3QO7G.js","assets/nim-DmDMFNUJ.js","assets/php-DjG8FNj4.js","assets/pug-Dyx2Gc8f.js","assets/qml-Be35LeVE.js","assets/razor-DrbTumE-.js","assets/csharp-Ct8U2NOr.js","assets/rst-9_O48jfa.js","assets/cmake-Bj61d0ZC.js","assets/sas-DpB6gF-4.js","assets/shaderlab-TOUzSsQk.js","assets/hlsl-Cvrh5tZx.js","assets/shellsession-BEUInF7X.js","assets/soy-ChOzCMcc.js","assets/sparql-D_iOobhT.js","assets/turtle-ByJddavk.js","assets/stata-DWVk40Jf.js","assets/surrealql-BQstUV05.js","assets/svelte-Dj0As3Vu.js","assets/templ-BPUG9C8b.js","assets/go-BJwz_mda.js","assets/ts-tags-BnD1MIHb.js","assets/twig-Cj9Y_GTX.js","assets/vue-BTEOc_VE.js","assets/vue-html-Cj0ctcUy.js","assets/vue-vine-B0hpy35H.js","assets/stylus-B6D30XZt.js","assets/xsl-B-eulOKn.js","assets/dagre-VKFMJZFB-CsWb9Wvi.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-DgGH3qgX.js","assets/chunk-WYO6CB5R-B5B5hVg0.js","assets/preload-helper-CZgWQFsJ.js","assets/chunk-ICXQ74PX-CyAvh-Bu.js","assets/dist-CrdG7pnv.js","assets/chunk-C7G6YPKG-WlrjvRPU.js","assets/chunk-OGEWGWER-BShclaB5.js","assets/chunk-HOUHSVGY-DsnMzn8e.js","assets/chunk-Q4XR5HBZ-DjBZZefu.js","assets/chunk-ZGVPDNZ5-ezDabbl-.js","assets/rough.esm-CSKSodPl.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/graphlib-DS17s2tU.js","assets/dagre-dpRSp0QF.js","assets/map-BaFkSB1l.js","assets/chunk-RYQCIY6F-BZKWq7vX.js","assets/swimlanes-5IMT3BWC-D_RQIhid.js","assets/cose-bilkent-JH36ORCC-BPtyRiiY.js","assets/cytoscape.esm-CQFVGiJu.js","assets/c4Diagram-LMCZKHZV-vOd-i6oU.js","assets/chunk-32BRIVSS-D0LVvwRn.js","assets/flowDiagram-23GEKE2U-CouB6ylb.js","assets/chunk-XXDRQBXY-DoU4wU65.js","assets/chunk-VR4S4FIN-0xFZ77et.js","assets/chunk-PUDLZKDR-xAlZkx_V.js","assets/channel-UL65cgUu.js","assets/chunk-5VM5RSS4-ZNzvKenW.js","assets/swimlanesDiagram-G3AALYLV-CwYEB1yi.js","assets/erDiagram-Q63AITRT-B6RMjkqo.js","assets/gitGraphDiagram-IHSO6WYX-_Ujm6vip.js","assets/mermaid-parser.core-D7RD-ESl.js","assets/chunk-KEIR6QF5-Dj-OpFgW.js","assets/chunk-JWPE2WC7-DVXcaiue.js","assets/chunk-2Q5K7J3B-C1jixKkw.js","assets/ganttDiagram-NO4QXBWP-C7VOoWID.js","assets/linear-CVZQ2nPX.js","assets/defaultLocale-C8Fc0cco.js","assets/init-D6jRqBbL.js","assets/infoDiagram-FWYZ7A6U-BNFhgDLP.js","assets/pieDiagram-ENE6RG2P-BgJCWQHt.js","assets/ordinal-hYBb2elL.js","assets/path-BWPyau1x.js","assets/arc-DxS8QPrP.js","assets/array-BifhSqXX.js","assets/quadrantDiagram-ABIIQ3AL-CQYQ3GYO.js","assets/xychartDiagram-FW5EYKEG-oepIN_mI.js","assets/line-CrRWgAHs.js","assets/requirementDiagram-TGXJPOKE-C-oeLyY_.js","assets/sequenceDiagram-DBY2YBRQ-hsxNS03R.js","assets/classDiagram-OUVF2IWQ-DD8BZuSm.js","assets/chunk-V7JOEXUC-BjWM_jnD.js","assets/classDiagram-v2-EOCWNBFH-DD8BZuSm.js","assets/stateDiagram-2N3HPSRC-bIMnxqO8.js","assets/chunk-EX3LRPZG-C1D9OQgx.js","assets/stateDiagram-v2-6OUMAXLB-nx3bC5I9.js","assets/journeyDiagram-5HDEW3XC-BlcNNU8v.js","assets/timeline-definition-FHXFAJF6-C9JnE-9Z.js","assets/mindmap-definition-LN4V7U3C-B3bwSTt2.js","assets/kanban-definition-HUTT4EX6-DLdfqqIW.js","assets/sankeyDiagram-HTMAVEWB-COo7g9T1.js","assets/diagram-NH7WQ7WH-C7egv5PI.js","assets/diagram-WEI45ONY-ByWPeJ3n.js","assets/blockDiagram-677ZJIJ3-BNuwFkOB.js","assets/diagram-OA4YK3LP-BDjGAN6E.js","assets/architectureDiagram-ZJ3FMSHR-CuXk1ExT.js","assets/diagram-FQU43EPY-CWXXPDyf.js","assets/ishikawaDiagram-FXEZZL3T-VJcgTL8W.js","assets/vennDiagram-L72KCM5P-Bs58CXI0.js","assets/diagram-G47NLZAW-CR6Vw1qI.js","assets/wardleyDiagram-EHGQE667-ngPnquAL.js","assets/cynefinDiagram-TSTJHNR4-DirqPxaJ.js","assets/railroadDiagram-RFXS5EU6-C0cBUvf6.js","assets/chunk-MOJQB5TN-D8X4zTh2.js","assets/ebnfDiagram-CCIWWBDH-DTE_Hi9u.js","assets/abnfDiagram-VRR7QNED-BYIpnEWe.js","assets/pegDiagram-2B236MQR-9LLuxSRX.js","assets/highlighted-body-OFNGDK62-Cj3Ar0n3.js","assets/jsx-runtime-CBD9r_Rc.js","assets/DebugDrawer-CmBNqdMZ.js","assets/createLucideIcon-Wu4zuv2w.js","assets/bundle-mjs-C3wVjQ1B.js","assets/DiagramPane-DExG3C_B.js","assets/chunk-K2UTITRG-6LurgM_T.js","assets/chunk-SRAX5OIU-DZPQwvLc.js","assets/chunk-6U3AYISY-C6-Mtja1.js","assets/chunk-Z3N5DIM6-D9TMVU7m.js","assets/DiagramPane-DtRVLazd.css"])))=>i.map(i=>d[i]);
2
- import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-DAXXjFlN.js";import{n as a,t as o}from"./jsx-runtime-CBD9r_Rc.js";import{n as s,r as c,t as l}from"./bundle-mjs-C3wVjQ1B.js";import{$ as u,A as d,B as f,C as p,D as m,Dt as h,E as g,Et as _,F as v,Ft as y,G as b,H as x,I as S,It as C,J as w,K as T,L as E,Lt as D,M as O,Mt as k,N as A,Nt as ee,O as te,Ot as ne,P as j,Pt as M,Q as N,R as re,Rt as ie,S as ae,T as oe,U as se,V as ce,Vt as le,W as ue,X as de,Y as fe,Z as pe,_ as me,_t as he,a as ge,at as _e,b as ve,bt as ye,c as be,ct as xe,d as Se,dt as Ce,et as we,f as Te,ft as Ee,g as De,gt as Oe,h as ke,ht as Ae,i as je,it as Me,j as Ne,jt as Pe,k as Fe,kt as Ie,l as Le,lt as Re,m as ze,mt as Be,n as Ve,nt as He,o as Ue,ot as We,p as Ge,pt as Ke,q as qe,r as Je,rt as Ye,s as Xe,st as Ze,t as Qe,tt as $e,u as et,ut as tt,v as nt,vt as rt,w as it,x as at,xt as ot,y as st,yt as ct,z as lt}from"./createLucideIcon-Wu4zuv2w.js";import{t as P}from"./preload-helper-CZgWQFsJ.js";import{n as F}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{h as ut,m as dt,p as ft}from"./src-DgGH3qgX.js";import{$ as pt,C as mt,E as ht,I as gt,L as _t,N as vt,P as yt,Q as bt,S as xt,T as St,V as Ct,W as wt,X as Tt,Z as Et,_ as Dt,b as Ot,c as kt,g as At,l as jt,m as Mt,n as Nt,p as Pt,q as Ft,r as It,s as Lt,t as Rt,u as zt,x as Bt}from"./chunk-WYO6CB5R-B5B5hVg0.js";import{$ as Vt,J as Ht,K as Ut,Q as Wt,S as Gt,X as Kt,Y as qt,Z as Jt,a as Yt,d as Xt,et as Zt,f as Qt,g as $t,h as en,i as tn,nt as nn,o as rn,q as an,rt as on,tt as sn,u as cn,v as ln,x as un,y as dn}from"./chunk-ICXQ74PX-CyAvh-Bu.js";import{t as fn}from"./line-CrRWgAHs.js";import{i as pn,n as mn}from"./chunk-C7G6YPKG-WlrjvRPU.js";import{n as hn}from"./chunk-OGEWGWER-BShclaB5.js";import{r as gn}from"./chunk-HOUHSVGY-DsnMzn8e.js";import{n as _n,r as vn}from"./chunk-Q4XR5HBZ-DjBZZefu.js";import{t as yn}from"./rough.esm-CSKSodPl.js";import{a as bn,i as xn,r as Sn,s as Cn}from"./chunk-ZGVPDNZ5-ezDabbl-.js";import{i as wn,n as Tn,r as En,t as Dn}from"./chunk-7BUUIJ7U-Bb538aSH.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 On=i((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&ee(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ee(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function ee(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ee(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),kn=i(((e,t)=>{t.exports=On()})),An=i((e=>{var t=kn(),n=a(),r=c();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(s(e)!==e)throw Error(i(188))}function f(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return d(a),e;if(o===r)return d(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var c=!1,l=a.child;l;){if(l===n){c=!0,n=a,r=o;break}if(l===r){c=!0,r=a,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=a;break}if(l===r){c=!0,r=o,n=a;break}l=l.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),k=Symbol.for(`react.memo_cache_sentinel`),A=Symbol.iterator;function ee(e){return typeof e!=`object`||!e?null:(e=A&&e[A]||e[`@@iterator`],typeof e==`function`?e:null)}var te=Symbol.for(`react.client.reference`);function ne(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===te?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case E:return t=e.displayName||null,t===null?ne(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return ne(e(t))}catch{}}return null}var j=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,re={pending:!1,data:null,method:null,action:null},ie=[],ae=-1;function oe(e){return{current:e}}function se(e){0>ae||(e.current=ie[ae],ie[ae]=null,ae--)}function ce(e,t){ae++,ie[ae]=e.current,e.current=t}var le=oe(null),ue=oe(null),de=oe(null),fe=oe(null);function pe(e,t){switch(ce(de,t),ce(ue,e),ce(le,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Jd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Jd(t),e=Yd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}se(le),ce(le,e)}function me(){se(le),se(ue),se(de)}function he(e){e.memoizedState!==null&&ce(fe,e);var t=le.current,n=Yd(t,e.type);t!==n&&(ce(ue,e),ce(le,n))}function ge(e){ue.current===e&&(se(le),se(ue)),fe.current===e&&(se(fe),Yf._currentValue=re)}var _e,ve;function ye(e){if(_e===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);_e=t&&t[1]||``,ve=-1<e.stack.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-r4nzjlvl.js","assets/rolldown-runtime-DAXXjFlN.js","assets/html-BwPosJq7.js","assets/javascript-C3H1hIQj.js","assets/css-BCANWTts.js","assets/angular-ts-BxqKd0Zc.js","assets/scss-CGgB8MuJ.js","assets/apl-C04b0OjT.js","assets/xml-D8dNscGz.js","assets/java-CO4kXx58.js","assets/json-GHnjY4eF.js","assets/astro-AQ_iZfq_.js","assets/typescript-QDgNEXlg.js","assets/postcss-BunjpCQr.js","assets/tsx--25XuaIh.js","assets/blade-DH22iKQU.js","assets/html-derivative-tMv-aKGZ.js","assets/sql-DvBUnkQP.js","assets/bsl-DJOyloKD.js","assets/sdbl-DzilZtvS.js","assets/c-CEbO_RKk.js","assets/cairo-CDc8os0h.js","assets/python-DkGugaUl.js","assets/cobol-j5M6C8cE.js","assets/coffee-BhrHAdFL.js","assets/cpp-dOwNr0lq.js","assets/regexp-BTmVwUGX.js","assets/glsl-D4M1jM50.js","assets/crystal-BQKjzQ6q.js","assets/shellscript-DDxwoqAb.js","assets/edge-D8ZvGBZ4.js","assets/elixir-8PeAFHYj.js","assets/elm-CYP47Cl5.js","assets/erb-e24MnpOC.js","assets/ruby-CuVu4KOG.js","assets/haml-BsIdCvCS.js","assets/graphql-B9wSVVyi.js","assets/jsx-SanyMke9.js","assets/lua-CMKXOhwQ.js","assets/yaml-xy6SaJYi.js","assets/erlang-Dej7b2OY.js","assets/markdown-Bk5jPFPK.js","assets/fortran-fixed-form-RVbzjQ2q.js","assets/fortran-free-form-EhmKDVgM.js","assets/fsharp-DKW21_Cq.js","assets/gdresource-b7MixKdf.js","assets/gdshader-C7BToOo8.js","assets/gdscript-DbNIuFFJ.js","assets/git-commit-BU_RZ1WH.js","assets/diff-COJGj3FI.js","assets/git-rebase-BA9-AyLM.js","assets/glimmer-js-BAhz69_J.js","assets/glimmer-ts-DceI_LA7.js","assets/hack-DxPgm4F4.js","assets/handlebars-DdTlUnCd.js","assets/http-CDkctGoQ.js","assets/hurl-BeYO3sUq.js","assets/csv-aQe9eWwB.js","assets/hxml-B_tSdhCX.js","assets/haxe-BZXihDV-.js","assets/jinja-DHXIPVIS.js","assets/jison-eQA0nxws.js","assets/julia-DjbOEOq7.js","assets/r-DhQeW39P.js","assets/just-e17iqfha.js","assets/perl-CZJdECIs.js","assets/latex-C_WFP2fs.js","assets/tex-BQuLuNB_.js","assets/liquid-9ZAw5ESd.js","assets/marko-BaTlCnew.js","assets/less-BGJv5CZz.js","assets/mdc-V7J1bLNm.js","assets/nextflow-BJtWHP5T.js","assets/nextflow-groovy-DJMQeKeT.js","assets/nginx-Cf6hnit0.js","assets/nim-BLaoQEWH.js","assets/php-DIy4CEY0.js","assets/pug-r52_xqX8.js","assets/qml-BZ3S9mpj.js","assets/razor-uUSeMB08.js","assets/csharp-oqKa8noW.js","assets/rst-DZtY-B3E.js","assets/cmake-CbIxKMg_.js","assets/sas-BRgKo67P.js","assets/shaderlab-QzRPXpa3.js","assets/hlsl-BxIm9IaD.js","assets/shellsession-BtkHDZw6.js","assets/soy-DWSlVwxw.js","assets/sparql-BQ8pLLZr.js","assets/turtle-CA3RhB-1.js","assets/stata-DK4xd-1U.js","assets/surrealql-WCIpV-w3.js","assets/svelte-COt-aqLJ.js","assets/templ-DUVqjRh3.js","assets/go-rLFTqkRN.js","assets/ts-tags-BBqvRvIx.js","assets/twig-BHAJLapx.js","assets/vue-CDP3wwGh.js","assets/vue-html-BlXIoEQI.js","assets/vue-vine-O34tJq4k.js","assets/stylus-BrO8Mu5X.js","assets/xsl-BKE2QB1H.js","assets/angular-html-Da2ImPYj.js","assets/html-2owMSsYc.js","assets/javascript-DC7Y13dy.js","assets/css-CgQmFL-t.js","assets/angular-ts-CfbQ_CSh.js","assets/scss-CKrqXKNz.js","assets/apl-Cg3VgmnT.js","assets/xml-DzUK0Pry.js","assets/java-DJul3uN_.js","assets/json-DaZn6kP4.js","assets/astro-D7LRhiig.js","assets/typescript-DToX5D_l.js","assets/postcss-BXeXVLqQ.js","assets/tsx-Db8p8m2t.js","assets/blade-DE2J2P4J.js","assets/html-derivative-DjY87ttd.js","assets/sql-DAk8t4E1.js","assets/bsl-BkkzgIyY.js","assets/sdbl-bTVj8UrX.js","assets/c-Bp9SPJXV.js","assets/cairo-DLTphjLi.js","assets/python-gzcpVVnB.js","assets/cobol-CSZIDYWx.js","assets/coffee-68oYHmZj.js","assets/cpp-qzvOo2yl.js","assets/regexp-D77ZphON.js","assets/glsl-fbNNN2Bp.js","assets/crystal-DHHDVHRy.js","assets/shellscript-xyv2Ai2R.js","assets/edge-Cdhi70bQ.js","assets/elixir-ZBegKj6G.js","assets/elm-Aa2ys7L1.js","assets/erb-CoYAxOCW.js","assets/ruby-DiTzTPD2.js","assets/haml-Dk5AgJFk.js","assets/graphql-BVCjFJgP.js","assets/jsx-C97fCUqH.js","assets/lua-BF4pD4PQ.js","assets/yaml-uB2nBBeV.js","assets/erlang-Cphh6RMH.js","assets/markdown-BYOwaDjH.js","assets/fortran-fixed-form-DEKoE2YW.js","assets/fortran-free-form-CYNrtFtB.js","assets/fsharp-D13ZGOAj.js","assets/gdresource-C0sCabJj.js","assets/gdshader-CBce3t8t.js","assets/gdscript-Cp2uCuqX.js","assets/git-commit-BSykSTBG.js","assets/diff-woXpYk--.js","assets/git-rebase-gx2II6xm.js","assets/glimmer-js-nibZcW0E.js","assets/glimmer-ts-CiNDKS9-.js","assets/hack-CX65dzJU.js","assets/handlebars-CUlggvE0.js","assets/http-B1LJ0uJF.js","assets/hurl-GKc7yueO.js","assets/csv-Dx-8-gkx.js","assets/hxml-B0Qn7Nwc.js","assets/haxe-OTjmBuCE.js","assets/jinja-DTtnHnMF.js","assets/jison-Bb-bjV_r.js","assets/julia-CWUaLFvh.js","assets/r-D9B56oy7.js","assets/just-CyyGdrCJ.js","assets/perl-L_VLWuBs.js","assets/latex-dDT3L_Pr.js","assets/tex-we3ORCro.js","assets/liquid-htIxSkY0.js","assets/marko-CYoducAR.js","assets/less-DVTAwKKz.js","assets/mdc-BwGL0Z9o.js","assets/nextflow-Bbiyy34d.js","assets/nextflow-groovy-Dc_ddanL.js","assets/nginx-YcT3QO7G.js","assets/nim-DmDMFNUJ.js","assets/php-DjG8FNj4.js","assets/pug-Dyx2Gc8f.js","assets/qml-Be35LeVE.js","assets/razor-DrbTumE-.js","assets/csharp-Ct8U2NOr.js","assets/rst-9_O48jfa.js","assets/cmake-Bj61d0ZC.js","assets/sas-DpB6gF-4.js","assets/shaderlab-TOUzSsQk.js","assets/hlsl-Cvrh5tZx.js","assets/shellsession-BEUInF7X.js","assets/soy-ChOzCMcc.js","assets/sparql-D_iOobhT.js","assets/turtle-ByJddavk.js","assets/stata-DWVk40Jf.js","assets/surrealql-BQstUV05.js","assets/svelte-Dj0As3Vu.js","assets/templ-BPUG9C8b.js","assets/go-BJwz_mda.js","assets/ts-tags-BnD1MIHb.js","assets/twig-Cj9Y_GTX.js","assets/vue-BTEOc_VE.js","assets/vue-html-Cj0ctcUy.js","assets/vue-vine-B0hpy35H.js","assets/stylus-B6D30XZt.js","assets/xsl-B-eulOKn.js","assets/dagre-VKFMJZFB-BRFoDSW8.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-DgGH3qgX.js","assets/chunk-WYO6CB5R-AwdhWuZo.js","assets/preload-helper-CZgWQFsJ.js","assets/chunk-ICXQ74PX-CQKuUo-t.js","assets/dist-CrdG7pnv.js","assets/chunk-C7G6YPKG-JkY7BZ9Y.js","assets/chunk-OGEWGWER-eUOKygVq.js","assets/chunk-HOUHSVGY-b9ihJSE7.js","assets/chunk-Q4XR5HBZ-BmyKr7fn.js","assets/chunk-ZGVPDNZ5-mGpw_02_.js","assets/rough.esm-CSKSodPl.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/graphlib-DS17s2tU.js","assets/dagre-dpRSp0QF.js","assets/map-BaFkSB1l.js","assets/chunk-RYQCIY6F-BZKWq7vX.js","assets/swimlanes-5IMT3BWC-46Asc0jn.js","assets/cose-bilkent-JH36ORCC-BPtyRiiY.js","assets/cytoscape.esm-CQFVGiJu.js","assets/c4Diagram-LMCZKHZV-CAS7VvIZ.js","assets/chunk-32BRIVSS-C8WNKZUy.js","assets/flowDiagram-23GEKE2U-CWVKIbSe.js","assets/chunk-XXDRQBXY-DoU4wU65.js","assets/chunk-VR4S4FIN-CKIZWeQy.js","assets/chunk-PUDLZKDR-ccT5LcXZ.js","assets/channel-IP5ecgg3.js","assets/chunk-5VM5RSS4-ZNzvKenW.js","assets/swimlanesDiagram-G3AALYLV-4tvcCzsT.js","assets/erDiagram-Q63AITRT-ChOMFsyu.js","assets/gitGraphDiagram-IHSO6WYX-Dpw0EMH3.js","assets/mermaid-parser.core-D7RD-ESl.js","assets/chunk-KEIR6QF5-Dj-OpFgW.js","assets/chunk-JWPE2WC7-DVXcaiue.js","assets/chunk-2Q5K7J3B-C1jixKkw.js","assets/ganttDiagram-NO4QXBWP-BJyI59N-.js","assets/linear-CVZQ2nPX.js","assets/defaultLocale-C8Fc0cco.js","assets/init-D6jRqBbL.js","assets/infoDiagram-FWYZ7A6U-CEuxB7IW.js","assets/pieDiagram-ENE6RG2P-DLkqng2U.js","assets/ordinal-hYBb2elL.js","assets/path-BWPyau1x.js","assets/arc-DxS8QPrP.js","assets/array-BifhSqXX.js","assets/quadrantDiagram-ABIIQ3AL-Dw0uY7MQ.js","assets/xychartDiagram-FW5EYKEG-BXglxQCg.js","assets/line-A-4XUjwX.js","assets/requirementDiagram-TGXJPOKE-BJtZwK-r.js","assets/sequenceDiagram-DBY2YBRQ-DKCWWujI.js","assets/classDiagram-OUVF2IWQ-B9Etcp-t.js","assets/chunk-V7JOEXUC-XIIJkR7-.js","assets/classDiagram-v2-EOCWNBFH-B9Etcp-t.js","assets/stateDiagram-2N3HPSRC-DalzGktj.js","assets/chunk-EX3LRPZG-D1e6FeJf.js","assets/stateDiagram-v2-6OUMAXLB-CI1LWAFu.js","assets/journeyDiagram-5HDEW3XC-D1ftt9ge.js","assets/timeline-definition-FHXFAJF6-CWFZnqYm.js","assets/mindmap-definition-LN4V7U3C-DuYnLQGd.js","assets/kanban-definition-HUTT4EX6-DCelZ2vh.js","assets/sankeyDiagram-HTMAVEWB-DeZe-cA5.js","assets/diagram-NH7WQ7WH-D8afauUh.js","assets/diagram-WEI45ONY-Cg4RvV8X.js","assets/blockDiagram-677ZJIJ3-CAVw539c.js","assets/diagram-OA4YK3LP-BcWPtrFs.js","assets/architectureDiagram-ZJ3FMSHR-CvlgW3i6.js","assets/diagram-FQU43EPY-DK1yLdyN.js","assets/ishikawaDiagram-FXEZZL3T-wk1u9NX7.js","assets/vennDiagram-L72KCM5P-DMwzFRSk.js","assets/diagram-G47NLZAW-CFK_ti2g.js","assets/wardleyDiagram-EHGQE667-BWVEPVA9.js","assets/cynefinDiagram-TSTJHNR4-Ck5X3Pvz.js","assets/railroadDiagram-RFXS5EU6-BW70k7aB.js","assets/chunk-MOJQB5TN-HUMNIDR1.js","assets/ebnfDiagram-CCIWWBDH-CfduTGsM.js","assets/abnfDiagram-VRR7QNED-DIM4WdUu.js","assets/pegDiagram-2B236MQR-D9Fg-G2c.js","assets/highlighted-body-OFNGDK62-BoMwTwLt.js","assets/jsx-runtime-CBD9r_Rc.js","assets/DebugDrawer-BXDxUqG6.js","assets/createLucideIcon-Wu4zuv2w.js","assets/bundle-mjs-C3wVjQ1B.js","assets/DiagramPane-Vzg5nzB5.js","assets/chunk-K2UTITRG-6LurgM_T.js","assets/chunk-SRAX5OIU-DZPQwvLc.js","assets/chunk-6U3AYISY-C6-Mtja1.js","assets/chunk-Z3N5DIM6-D9TMVU7m.js","assets/DiagramPane-DtRVLazd.css"])))=>i.map(i=>d[i]);
2
+ import{a as e,n as t,o as n,r,t as i}from"./rolldown-runtime-DAXXjFlN.js";import{n as a,t as o}from"./jsx-runtime-CBD9r_Rc.js";import{n as s,r as c,t as l}from"./bundle-mjs-C3wVjQ1B.js";import{$ as u,A as d,B as f,C as p,D as m,Dt as h,E as g,Et as _,F as v,Ft as y,G as b,H as x,I as S,It as C,J as w,K as T,L as E,Lt as D,M as O,Mt as k,N as A,Nt as ee,O as te,Ot as ne,P as j,Pt as M,Q as N,R as re,Rt as ie,S as ae,T as oe,U as se,V as ce,Vt as le,W as ue,X as de,Y as fe,Z as pe,_ as me,_t as he,a as ge,at as _e,b as ve,bt as ye,c as be,ct as xe,d as Se,dt as Ce,et as we,f as Te,ft as Ee,g as De,gt as Oe,h as ke,ht as Ae,i as je,it as Me,j as Ne,jt as Pe,k as Fe,kt as Ie,l as Le,lt as Re,m as ze,mt as Be,n as Ve,nt as He,o as Ue,ot as We,p as Ge,pt as Ke,q as qe,r as Je,rt as Ye,s as Xe,st as Ze,t as Qe,tt as $e,u as et,ut as tt,v as nt,vt as rt,w as it,x as at,xt as ot,y as st,yt as ct,z as lt}from"./createLucideIcon-Wu4zuv2w.js";import{t as P}from"./preload-helper-CZgWQFsJ.js";import{n as F}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{h as ut,m as dt,p as ft}from"./src-DgGH3qgX.js";import{$ as pt,C as mt,E as ht,I as gt,L as _t,N as vt,P as yt,Q as bt,S as xt,T as St,V as Ct,W as wt,X as Tt,Z as Et,_ as Dt,b as Ot,c as kt,g as At,l as jt,m as Mt,n as Nt,p as Pt,q as Ft,r as It,s as Lt,t as Rt,u as zt,x as Bt}from"./chunk-WYO6CB5R-AwdhWuZo.js";import{$ as Vt,J as Ht,K as Ut,Q as Wt,S as Gt,X as Kt,Y as qt,Z as Jt,a as Yt,d as Xt,et as Zt,f as Qt,g as $t,h as en,i as tn,nt as nn,o as rn,q as an,rt as on,tt as sn,u as cn,v as ln,x as un,y as dn}from"./chunk-ICXQ74PX-CQKuUo-t.js";import{t as fn}from"./line-A-4XUjwX.js";import{i as pn,n as mn}from"./chunk-C7G6YPKG-JkY7BZ9Y.js";import{n as hn}from"./chunk-OGEWGWER-eUOKygVq.js";import{r as gn}from"./chunk-HOUHSVGY-b9ihJSE7.js";import{n as _n,r as vn}from"./chunk-Q4XR5HBZ-BmyKr7fn.js";import{t as yn}from"./rough.esm-CSKSodPl.js";import{a as bn,i as xn,r as Sn,s as Cn}from"./chunk-ZGVPDNZ5-mGpw_02_.js";import{i as wn,n as Tn,r as En,t as Dn}from"./chunk-7BUUIJ7U-Bb538aSH.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 On=i((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&ee(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ee(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function ee(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ee(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),kn=i(((e,t)=>{t.exports=On()})),An=i((e=>{var t=kn(),n=a(),r=c();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(s(e)!==e)throw Error(i(188))}function f(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return d(a),e;if(o===r)return d(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var c=!1,l=a.child;l;){if(l===n){c=!0,n=a,r=o;break}if(l===r){c=!0,r=a,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=a;break}if(l===r){c=!0,r=o,n=a;break}l=l.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),k=Symbol.for(`react.memo_cache_sentinel`),A=Symbol.iterator;function ee(e){return typeof e!=`object`||!e?null:(e=A&&e[A]||e[`@@iterator`],typeof e==`function`?e:null)}var te=Symbol.for(`react.client.reference`);function ne(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===te?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case E:return t=e.displayName||null,t===null?ne(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return ne(e(t))}catch{}}return null}var j=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,re={pending:!1,data:null,method:null,action:null},ie=[],ae=-1;function oe(e){return{current:e}}function se(e){0>ae||(e.current=ie[ae],ie[ae]=null,ae--)}function ce(e,t){ae++,ie[ae]=e.current,e.current=t}var le=oe(null),ue=oe(null),de=oe(null),fe=oe(null);function pe(e,t){switch(ce(de,t),ce(ue,e),ce(le,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Jd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Jd(t),e=Yd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}se(le),ce(le,e)}function me(){se(le),se(ue),se(de)}function he(e){e.memoizedState!==null&&ce(fe,e);var t=le.current,n=Yd(t,e.type);t!==n&&(ce(ue,e),ce(le,n))}function ge(e){ue.current===e&&(se(le),se(ue)),fe.current===e&&(se(fe),Yf._currentValue=re)}var _e,ve;function ye(e){if(_e===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);_e=t&&t[1]||``,ve=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+_e+e+ve}var be=!1;function xe(e,t){if(!e||be)return``;be=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
5
  `),l=s.split(`
@@ -177,7 +177,7 @@ XID_Start XIDS`.split(/\s/).map(e=>[Uh(e),e])),Dae=new Map([[`s`,ng(383)],[ng(38
177
177
  ?|[
178
178
  \v\f…\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${ng(e.codePointAt(0)-1)}${ng(e.codePointAt(2)+1)}-\u{10FFFF}`),n(vg(hg(`[${e}]`),t))}else n(vg(gg(hg(Aae.get(u)),l),t));else if(c===`property`)ug.has(Uh(u))||(e.key=`sc`);else if(c===`space`)n(_g(Vh(`space`,{negate:l}),t));else if(c===`word`)n(vg(gg(hg(lg),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=zh({flags:c});e.body[0].body=o(),i(vg(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&Die(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(rg`Uses "\K" in a way that's unsupported`);let o=Bh({behind:!0});o.body[0].body=a(),i(vg(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n(vg(Bh({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=zh();t.body[0].body.push(e.body),e.body=vg(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=Kae(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error(rg`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!mg(n)&&(n=pg(n,t),e.ref=n)}},Fae={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=_g(Vae(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&sg(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=sg(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=og(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&!(n.type===`CapturingGroup`&&(n.name===a||n.number===a)););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?Vae(0):Bae(o,r.groupOriginByCopy,null),l=c;if(!s){let e=Uae(Hae(o,e=>e.type===`Group`&&!!e.flags)),t=e?og(r.globalFlags,e):r.globalFlags;Rae(t,r.currentFlags)||(l=zh({flags:Wae(t)}),l.body[0].body.push(c))}n(vg(l,t),{traverse:!s})}},Iae={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>zae(t,e));i.length?i.length>1?n(vg(zh({atomic:!0,body:i.reverse().map(e=>Nh({body:[Fh(e.number)]}))}),t)):e.ref=i[0].number:n(vg(Bh({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=Bie();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function Lae(e){Wh(e,{"*"({node:e,parent:t}){e.parent=t}})}function Rae(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function zae(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=Gae(n.parent);for(let r of t){if(r===n)break;if(r===e||qae(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function Bae(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=Bae(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function Vae(e){let t=Jie(e);return t.isRecursive=!0,t}function Hae(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function pg(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function Uae(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Wae({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Gae(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function Kae(e){let t=e.find(e=>e.kind===`search_start`||Xae(e,{negate:!1})||!Jae(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=Kae(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function qae(e,t){let n=Gae(e)??[];for(let e of n)if(e===t||qae(e,t))return!0;return!1}function Jae({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function Yae(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function Xae(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&Die(e.body[0],{type:`Assertion`,kind:`search_start`})}function mg(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function hg(e,t){let n=Aie(e,{...t,unicodePropertyMap:ug}).body;return n.length>1||n[0].body.length>1?zh({body:n}):n[0].body[0]}function gg(e,t){return e.negate=t,e}function _g(e,t){return e.parent=t,e}function vg(e,t){return Lae(e),e.parent=t,e}function Zae(e,t){let n=Cae(t),r=cg(n.target,`ES2024`),i=cg(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];Wh(e,Qae,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,bae($ae[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&sg(f._captureTransfers,e.transferTo,[]).push(t)}),f}var Qae={"*":{enter({node:e},t){if(loe(e)){let n=t.getCurrentModI();t.pushModI(e.flags?og({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){loe(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){yg(ng(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),aoe(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&Mae.has(e.value)&&t.setHasCasedChar()}},$ae={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?rg`\B`:rg`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=ng(e),r=bg(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&yg(n)){let e=Eae(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);ig.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(doe)&&(o=[Ih(45),...o.filter(e=>!doe(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||ig.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=zh(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=Nh({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(ig.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=bg(n,i),o=bg(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&ooe(aoe(e)).forEach(e=>{s.add(Array.isArray(e)?`${bg(e[0],i)}-${bg(e[1],i)}`:bg(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:rg`[^\n]`;if(e===`digit`)return t?rg`\D`:rg`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&Mae.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?rg`\P`:rg`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?rg`\W`:rg`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=og(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${soe(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+coe(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:rg`\g<${t}&R=${r}>`}},eoe=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),toe=new Set([`-`,`\\`,`]`,`^`,`[`]),noe=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),roe=new Map([[9,rg`\t`],[10,rg`\n`],[11,rg`\v`],[12,rg`\f`],[13,rg`\r`],[8232,rg`\u2028`],[8233,rg`\u2029`],[65279,rg`\uFEFF`]]),ioe=/^\p{Cased}$/u;function yg(e){return ioe.test(e)}function aoe(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=ng(e);if(!yg(t))continue;let o=Eae(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function bg(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(roe.has(e))return roe.get(e);if(e<32||e>126&&e<160||e>262143||t&&uoe(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?noe:toe:eoe,a=ng(e);return(i.has(a)?`\\`:``)+a}function ooe(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function soe(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function coe({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function loe({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function uoe(e){return e>47&&e<58}function doe({type:e,value:t}){return e===`Character`&&t===45}var foe=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=moe(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(poe(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=hoe(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function poe(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function moe(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)sg(n,t,{}).transferTo=e;return n}function hoe(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function goe(e,t){let n=_oe(e,t);return n.options?new foe(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function _oe(e,t){let n=Cae(t),r=Nae(Aie(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:ug}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=Zae(r,n),a=mae(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=uae(fae(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}var voe=e=>e&&e&1,yoe=e=>e&&e&2,boe=e=>e&&e&4,xoe=e=>e.map((e,t)=>({key:`line-${t}`,tokens:e.map((e,n)=>({key:`line-${t}-${n}`,token:e}))})),Soe=({token:e})=>(0,L.jsx)(`span`,{className:`dark:!text-[var(--shiki-dark)]`,style:{backgroundColor:e.bgColor,color:e.color,fontStyle:voe(e.fontStyle)?`italic`:void 0,fontWeight:yoe(e.fontStyle)?`bold`:void 0,textDecoration:boe(e.fontStyle)?`underline`:void 0,...e.htmlStyle},children:e.content}),Coe=R(`block`,`before:content-[counter(line)]`,`before:inline-block`,`before:[counter-increment:line]`,`before:w-8`,`before:mr-4`,`before:text-right`,`before:text-muted-foreground/50`,`before:font-mono`,`before:select-none`),woe=({keyedLine:e,showLineNumbers:t})=>(0,L.jsx)(`span`,{className:t?Coe:`block`,children:e.tokens.length===0?`
179
179
  `:e.tokens.map(({token:e,key:t})=>(0,L.jsx)(Soe,{token:e},t))}),Toe=(0,I.createContext)({code:``}),Eoe=new Map,Doe=new Map,xg=new Map,Ooe=(e,t)=>{let n=e.slice(0,100),r=e.length>100?e.slice(-100):``;return`${t}:${e.length}:${n}:${r}`},koe=e=>{let t=Eoe.get(e);if(t)return t;let n=zre({langs:[e],themes:[`github-light`,`github-dark`]});return Eoe.set(e,n),n},Aoe=e=>({bg:`transparent`,fg:`inherit`,tokens:e.split(`
180
- `).map(e=>e===``?[]:[{color:`inherit`,content:e}])}),joe=(e,t,n)=>{let r=Ooe(e,t);return Doe.get(r)||(n&&(xg.has(r)||xg.set(r,new Set),xg.get(r)?.add(n)),koe(t).then(n=>{let i=n.getLoadedLanguages().includes(t)?t:`text`,a=n.codeToTokens(e,{lang:i,themes:{dark:`github-dark`,light:`github-light`}}),o={bg:a.bg??`transparent`,fg:a.fg??`inherit`,tokens:a.tokens};Doe.set(r,o);let s=xg.get(r);if(s){for(let e of s)e(o);xg.delete(r)}}).catch(e=>{console.error(`Failed to highlight code:`,e),xg.delete(r)}),null)},Moe=(0,I.memo)(({tokenized:e,showLineNumbers:t,className:n})=>{let r=(0,I.useMemo)(()=>({color:e.fg}),[e.fg]),i=(0,I.useMemo)(()=>xoe(e.tokens),[e.tokens]);return(0,L.jsx)(`pre`,{className:R(`!bg-transparent dark:!text-[var(--shiki-dark)] m-0 p-4 text-sm`,n),style:r,children:(0,L.jsx)(`code`,{className:R(`font-mono text-sm`,t&&`[counter-increment:line_0] [counter-reset:line]`),children:i.map(e=>(0,L.jsx)(woe,{keyedLine:e,showLineNumbers:t},e.key))})})},(e,t)=>e.tokenized===t.tokenized&&e.showLineNumbers===t.showLineNumbers&&e.className===t.className);Moe.displayName=`CodeBlockBody`;var Noe=({className:e,language:t,style:n,...r})=>(0,L.jsx)(`div`,{className:R(`group relative w-full overflow-hidden rounded-md border bg-background text-foreground`,e),"data-language":t,style:{containIntrinsicSize:`auto 200px`,contentVisibility:`auto`,...n},...r}),Poe=({children:e,className:t,...n})=>(0,L.jsx)(`div`,{className:R(`flex items-center justify-between border-b bg-muted/80 px-3 py-2 text-muted-foreground text-xs`,t),...n,children:e}),Foe=({children:e,className:t,...n})=>(0,L.jsx)(`div`,{className:R(`flex items-center gap-2`,t),...n,children:e}),Ioe=({children:e,className:t,...n})=>(0,L.jsx)(`span`,{className:R(`font-medium text-muted-foreground text-xs uppercase tracking-wider`,t),...n,children:e}),Loe=({code:e,language:t,showLineNumbers:n=!1})=>{let r=(0,I.useMemo)(()=>Aoe(e),[e]),i=t,a=(0,I.useMemo)(()=>joe(e,i)??r,[e,i,r]),[o,s]=(0,I.useState)(null),c=(0,I.useRef)({code:e,language:t});return(c.current.code!==e||c.current.language!==t)&&(c.current={code:e,language:t},s(null)),(0,I.useEffect)(()=>{let t=!1;return joe(e,i,e=>{t||s(e)}),()=>{t=!0}},[e,t]),(0,L.jsx)(`div`,{className:`relative overflow-auto`,children:(0,L.jsx)(Moe,{showLineNumbers:n,tokenized:o??a})})},Sg=({code:e,language:t,showLineNumbers:n=!1,className:r,children:i,...a})=>{let o=(0,I.useMemo)(()=>({code:e}),[e]);return(0,L.jsx)(Toe.Provider,{value:o,children:(0,L.jsxs)(Noe,{className:r,language:t,...a,children:[i,(0,L.jsx)(Loe,{code:e,language:t,showLineNumbers:n})]})})},Roe=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,...a})=>{let[o,s]=(0,I.useState)(!1),c=(0,I.useRef)(0),{code:l}=(0,I.useContext)(Toe),u=(0,I.useCallback)(async()=>{if(typeof window>`u`){t?.(Error(`Clipboard API not available`));return}if(!o){if(!await df(l)){t?.(Error(`Clipboard API not available`));return}s(!0),e?.(),c.current=window.setTimeout(()=>s(!1),n)}},[l,e,t,n,o]);(0,I.useEffect)(()=>()=>{window.clearTimeout(c.current)},[]);let d=o?br:Fr;return(0,L.jsx)(Se,{className:R(`shrink-0`,i),onClick:u,size:`icon`,variant:`ghost`,...a,children:r??(0,L.jsx)(d,{size:14})})},Cg=({className:e,...t})=>(0,L.jsx)(st,{"data-boring-agent-part":`tool-card`,className:R(`group not-prose my-3 w-full rounded-[var(--radius-lg)] bg-card/60`,`shadow-[0_1px_0_oklch(0_0_0/0.02),0_1px_2px_-1px_oklch(0_0_0/0.04),inset_0_0_0_1px_oklch(from_var(--border)_l_c_h/0.55)]`,`overflow-hidden`,e),...t}),zoe={"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"input-available":`Running`,"input-streaming":`Pending`,"output-available":`Completed`,"output-denied":`Denied`,"output-error":`Error`,aborted:`Aborted`},Boe={"approval-requested":(0,L.jsx)(jr,{className:`size-4 text-accent`}),"approval-responded":(0,L.jsx)(Er,{className:`size-4 text-accent`}),"input-available":(0,L.jsx)(jr,{className:`size-4 animate-pulse text-muted-foreground`}),"input-streaming":(0,L.jsx)(kr,{className:`size-4 text-muted-foreground`}),"output-available":(0,L.jsx)(Er,{className:`size-4 text-accent`}),"output-denied":(0,L.jsx)(Or,{className:`size-4 text-destructive`}),"output-error":(0,L.jsx)(Or,{className:`size-4 text-destructive`}),aborted:(0,L.jsx)(Or,{className:`size-4 text-muted-foreground`})},wg=e=>(0,L.jsxs)(et,{className:`shrink-0 gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[Boe[e],zoe[e]]}),Tg=({className:e,title:t,type:n,state:r,icon:i,toolName:a,...o})=>{let s=n===`dynamic-tool`||n===`tool-call`?a:n.split(`-`).slice(1).join(`-`);return(0,L.jsxs)(at,{"data-boring-agent-part":`tool-header`,className:R(`flex w-full min-w-0 items-center justify-between gap-3 p-3 text-left`,e),...o,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[i??(0,L.jsx)($i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{"data-boring-agent-part":`tool-title`,className:`min-w-0 flex-1 truncate text-sm font-medium`,children:t??s}),wg(r)]}),(0,L.jsx)(xr,{"data-boring-agent-part":`tool-chevron`,className:`size-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})},Eg=({className:e,...t})=>(0,L.jsx)(ve,{className:R(`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 space-y-4 p-4 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...t}),Dg=({className:e,input:t,...n})=>(0,L.jsxs)(`div`,{className:R(`space-y-2 overflow-hidden`,e),...n,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Parameters`}),(0,L.jsx)(`div`,{className:`rounded-md bg-muted/50`,children:(0,L.jsx)(Sg,{code:JSON.stringify(t,null,2),language:`json`})})]}),Og=({className:e,output:t,errorText:n,...r})=>{if(!(t||n))return null;let i=null;return n||(typeof t==`object`&&!(0,I.isValidElement)(t)?i=(0,L.jsx)(Sg,{code:JSON.stringify(t,null,2),language:`json`}):typeof t==`string`?i=(0,L.jsx)(Sg,{code:t,language:`text`}):t&&(i=(0,L.jsx)(`div`,{children:t}))),(0,L.jsxs)(`div`,{"data-boring-agent-part":`tool-result`,className:R(`space-y-2`,e),...r,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:n?`Error`:`Result`}),(0,L.jsxs)(`div`,{className:R(`rounded-md text-xs [&_table]:w-full`,n?`overflow-hidden border border-destructive/20 bg-destructive/10 text-destructive`:`overflow-x-auto bg-muted/30 text-foreground`),children:[n?(0,L.jsx)(`pre`,{className:`m-0 overflow-x-auto whitespace-pre-wrap break-words p-3 font-mono text-[12px] leading-5 [overflow-wrap:anywhere]`,children:n}):null,i]})]})},Voe=({className:e,...t})=>(0,L.jsx)(`div`,{className:R(`flex flex-col overflow-hidden rounded-lg border bg-background shadow-sm`,e),...t}),Hoe=({className:e,...t})=>(0,L.jsx)(`div`,{className:R(`flex items-center justify-between border-b bg-muted/50 px-4 py-3`,e),...t}),Uoe=({className:e,...t})=>(0,L.jsx)(`p`,{className:R(`font-medium text-foreground text-sm`,e),...t}),Woe=({className:e,...t})=>(0,L.jsx)(`p`,{className:R(`text-muted-foreground text-sm`,e),...t}),Goe=({className:e,...t})=>(0,L.jsx)(`div`,{className:R(`flex items-center gap-1`,e),...t}),kg=({tooltip:e,label:t,icon:n,children:r,className:i,size:a=`sm`,variant:o=`ghost`,...s})=>{let c=(0,L.jsxs)(Se,{className:R(`size-8 p-0 text-muted-foreground hover:text-foreground`,i),size:a,type:`button`,variant:o,...s,children:[n?(0,L.jsx)(n,{className:`size-4`}):r,(0,L.jsx)(`span`,{className:`sr-only`,children:t||e})]});return e?(0,L.jsx)(M,{children:(0,L.jsxs)(k,{children:[(0,L.jsx)(y,{asChild:!0,children:c}),(0,L.jsx)(ee,{children:(0,L.jsx)(`p`,{children:e})})]})}):c},Koe=({className:e,...t})=>(0,L.jsx)(`div`,{className:R(`flex-1 overflow-auto p-4`,e),...t}),Ag=vs(`UNAUTHORIZED.MISSING_API_KEY.INVALID_API_KEY.OIDC_REFRESH_FAILED.VERCEL_AUTH_FAILED.CONFIG_INVALID.PATH_ESCAPE.PATH_ABSOLUTE.PATH_NULL_BYTE.PATH_SYMLINK_ESCAPE.PATH_NOT_FOUND.PATH_NOT_WRITABLE.WORKSPACE_UNINITIALIZED.WORKSPACE_NOT_READY.AGENT_RUNTIME_NOT_READY.AGENT_BINDING_DISPOSED.AGENT_CONTROL_RECEIPT_INVALID.RUNTIME_PROVISIONING_FAILED.RUNTIME_PROVISIONING_LOCKED.BWRAP_UNAVAILABLE.BWRAP_TIMEOUT.OUTPUT_TRUNCATED.SANDBOX_NOT_READY.SANDBOX_EXPIRED.VERCEL_API_ERROR.REMOTE_WORKER_TIMEOUT.REMOTE_WORKER_STREAM_CLOSED.CIRCUIT_OPEN.ABORTED.PAYMENT_REQUIRED.MODEL_BUDGET_EXCEEDED.METERING_UNSUPPORTED_COMMAND.SESSION_NOT_FOUND.SESSION_LOCKED.STREAM_BUFFER_EVICTED.CURSOR_OUT_OF_RANGE.BRIDGE_COMMAND_INVALID.TOOL_NOT_FOUND.TOOL_INVALID_INPUT.TOOL_EXECUTION_ERROR.MCP_AGENT_ARTIFACT_INVALID.MCP_AGENT_ARTIFACT_TOO_LARGE.MCP_AGENT_ARTIFACT_UNAVAILABLE.PLUGIN_LOAD_FAILED.PLUGIN_NAME_COLLISION.PLUGIN_RUNTIME_REVISION_MISMATCH.PLUGIN_RUNTIME_PRIVATE_FILE.PLUGIN_RUNTIME_UNSAFE_IMPORT.PLUGIN_RUNTIME_TRANSFORM_FAILED.RUNTIME_PLUGIN_NOT_FOUND.RUNTIME_PLUGIN_ROUTE_NOT_FOUND.RUNTIME_PLUGIN_HANDLER_FAILED.RUNTIME_PLUGIN_LOAD_FAILED.RUNTIME_PLUGIN_RESPONSE_UNSUPPORTED.PROVISIONING_LAYOUT_FAILED.PROVISIONING_SKILLS_FAILED.PROVISIONING_TEMPLATES_FAILED.PROVISIONING_NODE_PREFLIGHT_FAILED.PROVISIONING_NPM_INSTALL_FAILED.PROVISIONING_UV_BOOTSTRAP_FAILED.PROVISIONING_UV_INSTALL_FAILED.PROVISIONING_ARTIFACT_FAILED.ERR_NOT_IMPLEMENTED_UNTIL_T1.INTERNAL_ERROR`.split(`.`));Ag.options,vs([`AGENT_DEFINITION_INVALID`,`AGENT_DEFINITION_UNSUPPORTED_FIELD`]),vs([`AGENT_DEPLOYMENT_INVALID`,`AGENT_DEPLOYMENT_UNSUPPORTED_FIELD`]),ps({error:ps({code:Ag,message:ss().min(1),details:gs(ds()).optional()})}),ps({level:vs([`warn`,`error`]),code:Ag,prefix:ss().min(1),msg:ss().min(1)}).catchall(ds());var qoe={"runtime-dependencies":`Runtime dependencies are still installing.`,"runtime:python":`Python runtime dependencies are still installing.`,"runtime:node":`Node runtime dependencies are still installing.`};function Joe(e){return e===`runtime-dependencies`||e.startsWith(`runtime:`)}function Yoe(e){if(!e||typeof e!=`object`)return null;let t=e;return t.details&&typeof t.details==`object`?t.details:t}function Xoe(e){let t=Yoe(e);if(!t||t.code!==Ag.enum.AGENT_RUNTIME_NOT_READY&&t.code!==Ag.enum.RUNTIME_PROVISIONING_FAILED)return null;let n=t.requirement;if(typeof n!=`string`||!Joe(n))return null;let r=t.code===Ag.enum.RUNTIME_PROVISIONING_FAILED||t.state===`failed`;return{code:t.code,retryable:t.retryable===!0,requirement:n,state:typeof t.state==`string`?t.state:void 0,message:r?`Runtime setup failed. Retry or reload the workspace.`:qoe[n]??`Runtime dependencies are still installing.`}}var Zoe={"workspace-fs":`Files are still loading.`,"sandbox-exec":`Sandbox is still waking.`,"ui-bridge":`Workspace UI is still connecting.`},Qoe=new Set([`workspace-fs`,`sandbox-exec`,`ui-bridge`]);function $oe(e){if(!e||typeof e!=`object`)return null;let t=e;return t.details&&typeof t.details==`object`?t.details:t}function jg(e){let t=$oe(e);if(!t||t.code!==Ag.enum.WORKSPACE_NOT_READY||t.retryable!==!0)return null;let n=t.requirement;return typeof n!=`string`||!Qoe.has(n)?null:{code:Ag.enum.WORKSPACE_NOT_READY,retryable:!0,requirement:n,message:Zoe[n]??`Workspace is still preparing.`}}function Mg(e){return typeof e==`object`&&e?e:{}}function Ng(e,t=`text`){let n=e[t];if(typeof n==`string`)return n;let r=e.content;return Array.isArray(r)?r.map(e=>typeof e?.text==`string`?e.text:``).join(``):typeof r==`string`?r:``}function Pg(e){return{type:`dynamic-tool`,state:e.state,toolName:e.toolName}}function ese({path:e,filesystem:t}){let n=dd();if(!n)return(0,L.jsx)(`span`,{className:`font-mono text-[12.5px] text-foreground/85`,children:e});let r=r=>{r.preventDefault(),r.stopPropagation(),t?n(e,{filesystem:t}):n(e)};return(0,L.jsxs)(`span`,{role:`button`,tabIndex:0,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&r(e)},title:`Open ${e} in workbench`,className:R(`group/path inline-flex min-w-0 items-center gap-1 rounded-sm px-1 py-0.5`,`cursor-pointer font-mono text-[12.5px] text-foreground/85`,`transition-colors duration-150`,`hover:bg-foreground/[0.05] hover:text-[color:var(--accent)]`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--accent)]/40`),children:[(0,L.jsx)(`span`,{className:`truncate`,children:e}),(0,L.jsx)(zr,{className:`h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover/path:opacity-100`,strokeWidth:1.75,"aria-hidden":`true`})]})}function tse(e){let t=jg(e.output);return t?(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{title:`${e.toolName} · ${t.message}`,...Pg(e)}),(0,L.jsx)(Eg,{children:(0,L.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-sm text-muted-foreground`,children:[t.message,` Try again in a moment.`]})})]}):null}function nse(e){let t=Xoe(e.output);if(!t)return null;let n=t.code===Ag.enum.RUNTIME_PROVISIONING_FAILED?`Retry or reload the workspace.`:`This is retryable; try again shortly.`;return(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{title:`${e.toolName} · ${t.message} ${n}`,...Pg(e)}),(0,L.jsx)(Eg,{children:(0,L.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-sm text-muted-foreground`,children:[t.message,` `,n]})})]})}function Fg(e){return tse(e)??nse(e)}function Ig(e,t,n){return(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,L.jsx)(`span`,{className:`text-muted-foreground/40`,"aria-hidden":`true`,children:`·`}),(0,L.jsx)(ese,{path:t,filesystem:n})]})}function rse(e){let t=Fg(e);if(t)return t;let n=Mg(e.input),r=Mg(e.output),i=typeof n.command==`string`?n.command:``,a=typeof n.description==`string`?n.description:``,o=Ng(r,`stdout`),s=typeof r.stderr==`string`?r.stderr:``,c=typeof r.exitCode==`number`?r.exitCode:null,l=a||(i.length>64?i.slice(0,64)+`…`:i)||`bash`,u=e.errorText||(s&&(c??0)!==0?s:void 0);return(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{icon:(0,L.jsx)(zi,{className:`size-4 text-muted-foreground`}),title:`bash · ${l}`,...Pg(e)}),(0,L.jsxs)(Eg,{children:[i&&(0,L.jsxs)(`section`,{className:`space-y-2`,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Command`}),(0,L.jsx)(Sg,{code:i,language:`bash`})]}),(0,L.jsx)(Og,{output:o&&!u?o:void 0,errorText:u}),c!==null&&c!==0&&!u&&(0,L.jsxs)(`div`,{className:`text-xs text-destructive`,children:[`exit `,c]})]})]})}function ise(e){let t=Fg(e);if(t)return t;let n=Mg(e.input),r=Mg(e.output),i=typeof n.path==`string`?n.path:``,a=typeof n.filesystem==`string`?n.filesystem:void 0,o=Ng(r),s=bf(i);return(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{icon:(0,L.jsx)(Gr,{className:`size-4 text-muted-foreground`}),title:Ig(`read`,i,a),...Pg(e)}),(0,L.jsxs)(Eg,{children:[(0,L.jsx)(Dg,{input:n}),o&&(0,L.jsxs)(`section`,{className:`space-y-2`,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Content`}),(0,L.jsx)(Sg,{code:o,language:s??`text`})]})]})]})}function ase(e){let t=Fg(e);if(t)return t;let n=Mg(e.input),r=typeof n.path==`string`?n.path:``,i=typeof n.filesystem==`string`?n.filesystem:void 0,a=typeof n.content==`string`?n.content:``,o=a.length,s=bf(r);return(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{icon:(0,L.jsx)(Ur,{className:`size-4 text-muted-foreground`}),title:Ig(`write`,r,i),...Pg(e)}),(0,L.jsx)(Eg,{children:(0,L.jsxs)(Voe,{className:`rounded-none border-0 bg-transparent shadow-none`,children:[(0,L.jsxs)(Hoe,{className:`border-0 px-0 pt-0 pb-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(Uoe,{children:r||`untitled`}),(0,L.jsxs)(Woe,{children:[o.toLocaleString(),` `,o===1?`byte`:`bytes`,s?` · ${s}`:``]})]}),(0,L.jsxs)(Goe,{children:[(0,L.jsx)(kg,{icon:Fr,tooltip:`Copy contents`,label:`Copy`,onClick:()=>{df(a)}}),(0,L.jsx)(kg,{icon:Lr,tooltip:`Download file`,label:`Download`,onClick:()=>{try{let e=new Blob([a],{type:`text/plain`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=r.split(`/`).pop()||`artifact.txt`,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(t)}catch{}}})]})]}),a&&(0,L.jsx)(Koe,{className:`p-0`,children:(0,L.jsx)(Sg,{code:a,language:s??`text`,showLineNumbers:!0})})]})})]})}function ose(e){let t=Fg(e);if(t)return t;let n=Mg(e.input),r=typeof n.path==`string`?n.path:``,i=typeof n.filesystem==`string`?n.filesystem:void 0,a=typeof n.oldString==`string`?n.oldString:``,o=typeof n.newString==`string`?n.newString:``;return(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{icon:(0,L.jsx)(Hr,{className:`size-4 text-muted-foreground`}),title:Ig(`edit`,r,i),...Pg(e)}),(0,L.jsxs)(Eg,{children:[(0,L.jsxs)(`section`,{className:`space-y-2`,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Diff`}),(0,L.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-input/60 bg-muted/30 font-mono text-[13px] leading-relaxed`,children:[a&&(0,L.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-2 border-b border-input/40 bg-destructive/5 px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`select-none text-destructive/70`,children:`-`}),(0,L.jsx)(`span`,{className:R(`whitespace-pre-wrap break-all text-destructive/90`),children:a})]}),o&&(0,L.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-2 bg-accent/5 px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`select-none text-accent/80`,children:`+`}),(0,L.jsx)(`span`,{className:`whitespace-pre-wrap break-all text-accent`,children:o})]})]})]}),(0,L.jsx)(Og,{output:e.output,errorText:e.errorText})]})]})}function Lg(e,t){let n=Fg(t);if(n)return n;let r=Mg(t.input),i=e===`find`||e===`grep`?Ii:Gr,a=[typeof r.pattern==`string`?r.pattern:``,typeof r.path==`string`?r.path:``,typeof r.glob==`string`?r.glob:``].filter(Boolean).join(` · `);return(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{icon:(0,L.jsx)(i,{className:`size-4 text-muted-foreground`}),title:a?`${e} · ${a}`:e,...Pg(t)}),(0,L.jsxs)(Eg,{children:[(0,L.jsx)(Dg,{input:r}),(0,L.jsx)(Og,{output:t.output,errorText:t.errorText})]})]})}function Rg(e,t=0){return e==null?[]:typeof e==`string`?[e]:typeof e==`number`||typeof e==`boolean`?[String(e)]:Array.isArray(e)?t>=2?[JSON.stringify(e)]:e.flatMap(e=>Rg(e,t+1)):typeof e==`object`?t>=2?[JSON.stringify(e)]:Object.values(e).flatMap(e=>Rg(e,t+1)):[String(e)]}function sse(e){let t=Fg(e);if(t)return t;let n=Mg(e.input),r=typeof n.kind==`string`?n.kind:`(empty)`,i=Rg(n.params),a=Pg(e);return(0,L.jsxs)(Cg,{children:[(0,L.jsxs)(at,{className:R(`group/exec-ui flex w-full items-center gap-3 px-3 py-2.5 text-left`,`hover:bg-muted/40 transition-colors`),children:[(0,L.jsx)(ta,{className:`size-3.5 shrink-0 text-muted-foreground/70`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`font-medium text-sm`,children:r}),i.length>0&&(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[(0,L.jsx)(`span`,{className:`text-muted-foreground/40`,"aria-hidden":`true`,children:`·`}),i.map((e,t)=>(0,L.jsx)(`span`,{className:R(`truncate rounded-sm bg-muted/60 px-1.5 py-0.5`,`font-mono text-[11px] text-muted-foreground`),title:e,children:e},t))]}),(0,L.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[wg(a.state),(0,L.jsx)(xr,{className:`size-4 text-muted-foreground/60 transition-transform group-data-[state=open]/exec-ui:rotate-180`,"aria-hidden":`true`})]})]}),(0,L.jsxs)(Eg,{children:[e.input!==void 0&&e.input!==null&&(0,L.jsx)(Dg,{input:e.input}),(0,L.jsx)(Og,{output:e.output,errorText:e.errorText})]})]})}function cse(e){let t=e.rendererResolution?.requestedRendererId;return t&&t!==e.toolName?`${e.toolName} · renderer ${t} unavailable`:e.toolName}function lse(e){return Fg(e)||(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{title:cse(e),...Pg(e)}),(0,L.jsxs)(Eg,{children:[e.input!==void 0&&e.input!==null&&(0,L.jsx)(Dg,{input:e.input}),(0,L.jsx)(Og,{output:e.output,errorText:e.errorText})]})]})}var zg={bash:rse,read:ise,write:ase,edit:ose,find:e=>Lg(`find`,e),grep:e=>Lg(`grep`,e),ls:e=>Lg(`ls`,e),exec_ui:sse,__fallback:lse};function use(e){if(!e)return{...zg};let t={...zg};for(let[n,r]of Object.entries(e))r&&(t[n]=r);return t}var dse=[`Shift`,`Meta`,`Control`,`Alt`,`CapsLock`];function Bg(e,t){(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function fse({userHistory:e,textareaRef:t,disabled:n}){let r=(0,I.useRef)(-1),i=(0,I.useRef)(``);return(0,I.useCallback)(a=>{let o=a.currentTarget;if(t.current=o,!n)if(a.key===`ArrowUp`){if(o.selectionStart!==0||o.selectionEnd!==0||e.length===0)return;a.preventDefault(),r.current===-1&&(i.current=o.value);let t=Math.min(r.current+1,e.length-1);r.current=t;let n=e[e.length-1-t];Bg(o,n),o.setSelectionRange(0,0)}else if(a.key===`ArrowDown`){if(r.current===-1)return;a.preventDefault();let t=r.current-1;r.current=t;let n=t===-1?i.current:e[e.length-1-t];Bg(o,n),o.setSelectionRange(n.length,n.length)}else dse.includes(a.key)||(r.current=-1)},[n,t,e])}function pse(e){let t=e.trim();return t?mse(/[*?\[\]{}]/.test(t)?t:`*${t}*`):`*`}function mse(e){let t=``,n=!1,r=!1;for(let i of e){if(r){t+=i,r=!1;continue}if(i===`\\`){t+=i,r=!0;continue}if(i===`[`&&!n){n=!0,t+=i;continue}if(i===`]`&&n){n=!1,t+=i;continue}if(!n&&/[a-z]/i.test(i)){let e=i.toLowerCase(),n=i.toUpperCase();t+=e===n?i:`[${n}${e}]`;continue}t+=i}return t}function Vg({count:e,activeIdx:t,setActiveIdx:n,listRef:r,onSelect:i,onDismiss:a}){let o=(0,I.useRef)(i),s=(0,I.useRef)(a);(0,I.useEffect)(()=>{o.current=i},[i]),(0,I.useEffect)(()=>{s.current=a},[a]),(0,I.useEffect)(()=>{let r=r=>{r.key===`ArrowDown`?(r.preventDefault(),n(t=>e===0?0:(t+1)%e)):r.key===`ArrowUp`?(r.preventDefault(),n(t=>e===0?0:(t-1+e)%e)):r.key===`Enter`||r.key===`Tab`?e>0?(r.preventDefault(),o.current(t)):s.current():r.key===`Escape`&&(r.preventDefault(),s.current())};return window.addEventListener(`keydown`,r,{capture:!0}),()=>window.removeEventListener(`keydown`,r,{capture:!0})},[e,t,n]),(0,I.useEffect)(()=>{(r.current?.children[t])?.scrollIntoView({block:`nearest`})},[t,r])}var hse=pse;function gse(e,t){if(!t)return null;let n=e.toLowerCase().indexOf(t.toLowerCase());return n===-1?null:{before:e.slice(0,n),match:e.slice(n,n+t.length),after:e.slice(n+t.length)}}function _se({mention:e,onSelect:t,onDismiss:n,apiBaseUrl:r=``,fetch:i,requestHeaders:a,storageScope:o}){let[s,c]=(0,I.useState)([]),[l,u]=(0,I.useState)(0),d=(0,I.useRef)(null);(0,I.useEffect)(()=>{u(0);let t=new AbortController,n=i??globalThis.fetch.bind(globalThis),s=yse(a,o),l=r.replace(/\/$/,``),d=setTimeout(()=>{n(`${l}/api/v1/files/search?q=${encodeURIComponent(hse(e.query))}&limit=8`,{signal:t.signal,...s?{headers:s}:{}}).then(e=>e.ok?e.json():null).then(e=>{e?.results&&c(e.results.slice(0,8))}).catch(()=>{})},120);return()=>{clearTimeout(d),t.abort()}},[e.query,r,i,a,o]);let f=(0,I.useCallback)(e=>{s[e]&&t(s[e])},[s,t]);return Vg({count:s.length,activeIdx:l,setActiveIdx:u,listRef:d,onSelect:f,onDismiss:n}),s.length===0?null:(0,L.jsx)(`div`,{className:`mb-1 w-full overflow-hidden rounded-lg border border-border/60 bg-popover shadow-lg`,children:(0,L.jsx)(`ul`,{ref:d,className:`max-h-48 overflow-y-auto py-1`,role:`listbox`,"aria-label":`File suggestions`,children:s.map((n,r)=>{let i=n.split(`/`).pop()??n,a=gse(i,e.query);return(0,L.jsxs)(`li`,{role:`option`,"aria-selected":r===l,className:R(`flex cursor-pointer flex-col gap-0.5 px-3 py-1.5 text-[12px]`,r===l?`bg-accent/10 text-foreground`:`text-muted-foreground hover:bg-muted/40`),onMouseEnter:()=>u(r),onMouseDown:e=>{e.preventDefault(),t(n)},children:[(0,L.jsx)(`span`,{className:`font-medium`,children:a?(0,L.jsxs)(L.Fragment,{children:[a.before,(0,L.jsx)(`mark`,{className:`bg-transparent text-[color:var(--accent)]`,children:a.match}),a.after]}):i}),(0,L.jsx)(`span`,{className:`truncate text-[11px] opacity-50`,children:n})]},n)})})})}function vse(e,t){let n=e.slice(0,t),r=n.match(/(^|[\s\n])@(\S*)$/);if(!r)return null;let i=n.lastIndexOf(`@`);return{query:r[2],anchorStart:i,anchorEnd:t}}function yse(e,t){let n={};for(let[t,r]of Object.entries(e??{}))r!==void 0&&(n[t]=r);let r=Object.keys(n).some(e=>e.toLowerCase()===`x-boring-storage-scope`);return t&&!r&&(n[`x-boring-storage-scope`]=t),Object.keys(n).length>0?n:void 0}function Hg(e,t){(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function bse(e){return`@${e.split(`/`).pop()??e}`}function xse(e){return`@${e.replace(/^\/+/,``)||e}`}function Sse(e,t){let n=bse(e);return t.some(t=>t.path!==e&&t.token===n)?xse(e):n}function Cse(e,t){let n=`[^A-Za-z0-9_./-]`;return RegExp(`(^|${n})${wse(t)}($|${n})`).test(e)}function wse(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Tse({textareaRef:e}){let[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(null),[a,o]=(0,I.useState)([]),s=(0,I.useCallback)(e=>{o(t=>t.filter(t=>Cse(e,t.token)))},[]),c=(0,I.useCallback)(t=>{let r=t.currentTarget;e.current=r;let a=r.selectionStart??r.value.length,o=r.value.slice(0,a).match(/^\/(\S*)$/);o?(i(o[1]),n(null)):(i(null),n(vse(r.value,a))),s(r.value)},[s,e]),l=(0,I.useCallback)(r=>{let i=e.current;if(!i||!t)return;let{anchorStart:s,anchorEnd:c}=t,l=Sse(r,a);Hg(i,i.value.slice(0,s)+l+i.value.slice(c));let u=s+l.length;i.setSelectionRange(u,u),i.focus(),n(null),o(e=>e.some(e=>e.path===r)?e:[...e,{path:r,token:l}])},[t,a,e]),u=(0,I.useCallback)(t=>{let n=e.current;if(!n)return;let r=`/${t} `;Hg(n,r),n.setSelectionRange(r.length,r.length),n.focus(),i(null)},[e]),d=(0,I.useCallback)(()=>{o([])},[]),f=(0,I.useCallback)(()=>{n(null)},[]),p=(0,I.useCallback)(()=>{i(null)},[]);return{mentionState:t,slashQuery:r,mentionedFiles:a.map(e=>e.path),clearMentionedFiles:d,dismissMention:f,dismissSlash:p,handleComposerChange:c,selectMention:l,selectSlashCommand:u}}var Ug=async e=>{try{let t=await(await fetch(e)).blob();return new Promise(e=>{let n=new FileReader;n.onloadend=()=>e(n.result),n.onerror=()=>e(null),n.readAsDataURL(t)})}catch{return null}},Ese=[`text/`,`application/json`,`application/xml`,`application/yaml`];async function Dse(e){return e?Promise.all(e.map(async e=>({filename:e.filename,mediaType:e.mediaType,url:e.url.startsWith(`blob:`)?await Ug(e.url)??e.url:e.url,...e.path?{path:e.path}:{}}))):[]}async function Ose(e){if(!(Ese.some(t=>e.mediaType?.startsWith(t))||/\.(md|txt|csv|json|yaml|yml|ts|tsx|js|jsx|py|rb|rs|go|sh|bash|css|html|sql|log)$/i.test(e.filename??``)))return null;try{let t=await fetch(e.url);return t.ok?await t.text():null}catch{return null}}function kse(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}async function Ase({text:e,files:t,mentionedFiles:n}){let r=[];for(let e of t??[]){let t=e.filename??`attachment`,n=e.mediaType??`application/octet-stream`,i=e.path,a=[[`data-boring-agent`,`composer-file`],[`filename`,t],[`mime`,n]];i&&a.push([`path`,i]);let o=a.map(([e,t])=>`${e}="${kse(t)}"`).join(` `),s=await Ose(e);s===null?r.push(`<attachment ${o} binary="true" />`):r.push(`<attachment ${o}>\n\`\`\`\n${s}\n\`\`\`\n</attachment>`)}let i=n.length>0?`@files: ${n.join(`, `)}`:null;return{serverMessage:[e.trim(),...r.length>0?[r.join(`
180
+ `).map(e=>e===``?[]:[{color:`inherit`,content:e}])}),joe=(e,t,n)=>{let r=Ooe(e,t);return Doe.get(r)||(n&&(xg.has(r)||xg.set(r,new Set),xg.get(r)?.add(n)),koe(t).then(n=>{let i=n.getLoadedLanguages().includes(t)?t:`text`,a=n.codeToTokens(e,{lang:i,themes:{dark:`github-dark`,light:`github-light`}}),o={bg:a.bg??`transparent`,fg:a.fg??`inherit`,tokens:a.tokens};Doe.set(r,o);let s=xg.get(r);if(s){for(let e of s)e(o);xg.delete(r)}}).catch(e=>{console.error(`Failed to highlight code:`,e),xg.delete(r)}),null)},Moe=(0,I.memo)(({tokenized:e,showLineNumbers:t,className:n})=>{let r=(0,I.useMemo)(()=>({color:e.fg}),[e.fg]),i=(0,I.useMemo)(()=>xoe(e.tokens),[e.tokens]);return(0,L.jsx)(`pre`,{className:R(`!bg-transparent dark:!text-[var(--shiki-dark)] m-0 p-4 text-sm`,n),style:r,children:(0,L.jsx)(`code`,{className:R(`font-mono text-sm`,t&&`[counter-increment:line_0] [counter-reset:line]`),children:i.map(e=>(0,L.jsx)(woe,{keyedLine:e,showLineNumbers:t},e.key))})})},(e,t)=>e.tokenized===t.tokenized&&e.showLineNumbers===t.showLineNumbers&&e.className===t.className);Moe.displayName=`CodeBlockBody`;var Noe=({className:e,language:t,style:n,...r})=>(0,L.jsx)(`div`,{className:R(`group relative w-full overflow-hidden rounded-md border bg-background text-foreground`,e),"data-language":t,style:{containIntrinsicSize:`auto 200px`,contentVisibility:`auto`,...n},...r}),Poe=({children:e,className:t,...n})=>(0,L.jsx)(`div`,{className:R(`flex items-center justify-between border-b bg-muted/80 px-3 py-2 text-muted-foreground text-xs`,t),...n,children:e}),Foe=({children:e,className:t,...n})=>(0,L.jsx)(`div`,{className:R(`flex items-center gap-2`,t),...n,children:e}),Ioe=({children:e,className:t,...n})=>(0,L.jsx)(`span`,{className:R(`font-medium text-muted-foreground text-xs uppercase tracking-wider`,t),...n,children:e}),Loe=({code:e,language:t,showLineNumbers:n=!1})=>{let r=(0,I.useMemo)(()=>Aoe(e),[e]),i=t,a=(0,I.useMemo)(()=>joe(e,i)??r,[e,i,r]),[o,s]=(0,I.useState)(null),c=(0,I.useRef)({code:e,language:t});return(c.current.code!==e||c.current.language!==t)&&(c.current={code:e,language:t},s(null)),(0,I.useEffect)(()=>{let t=!1;return joe(e,i,e=>{t||s(e)}),()=>{t=!0}},[e,t]),(0,L.jsx)(`div`,{className:`relative overflow-auto`,children:(0,L.jsx)(Moe,{showLineNumbers:n,tokenized:o??a})})},Sg=({code:e,language:t,showLineNumbers:n=!1,className:r,children:i,...a})=>{let o=(0,I.useMemo)(()=>({code:e}),[e]);return(0,L.jsx)(Toe.Provider,{value:o,children:(0,L.jsxs)(Noe,{className:r,language:t,...a,children:[i,(0,L.jsx)(Loe,{code:e,language:t,showLineNumbers:n})]})})},Roe=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,...a})=>{let[o,s]=(0,I.useState)(!1),c=(0,I.useRef)(0),{code:l}=(0,I.useContext)(Toe),u=(0,I.useCallback)(async()=>{if(typeof window>`u`){t?.(Error(`Clipboard API not available`));return}if(!o){if(!await df(l)){t?.(Error(`Clipboard API not available`));return}s(!0),e?.(),c.current=window.setTimeout(()=>s(!1),n)}},[l,e,t,n,o]);(0,I.useEffect)(()=>()=>{window.clearTimeout(c.current)},[]);let d=o?br:Fr;return(0,L.jsx)(Se,{className:R(`shrink-0`,i),onClick:u,size:`icon`,variant:`ghost`,...a,children:r??(0,L.jsx)(d,{size:14})})},Cg=({className:e,...t})=>(0,L.jsx)(st,{"data-boring-agent-part":`tool-card`,className:R(`group not-prose my-3 w-full rounded-[var(--radius-lg)] bg-card/60`,`shadow-[0_1px_0_oklch(0_0_0/0.02),0_1px_2px_-1px_oklch(0_0_0/0.04),inset_0_0_0_1px_oklch(from_var(--border)_l_c_h/0.55)]`,`overflow-hidden`,e),...t}),zoe={"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"input-available":`Running`,"input-streaming":`Pending`,"output-available":`Completed`,"output-denied":`Denied`,"output-error":`Error`,aborted:`Aborted`},Boe={"approval-requested":(0,L.jsx)(jr,{className:`size-4 text-accent`}),"approval-responded":(0,L.jsx)(Er,{className:`size-4 text-accent`}),"input-available":(0,L.jsx)(jr,{className:`size-4 animate-pulse text-muted-foreground`}),"input-streaming":(0,L.jsx)(kr,{className:`size-4 text-muted-foreground`}),"output-available":(0,L.jsx)(Er,{className:`size-4 text-accent`}),"output-denied":(0,L.jsx)(Or,{className:`size-4 text-destructive`}),"output-error":(0,L.jsx)(Or,{className:`size-4 text-destructive`}),aborted:(0,L.jsx)(Or,{className:`size-4 text-muted-foreground`})},wg=e=>(0,L.jsxs)(et,{className:`shrink-0 gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[Boe[e],zoe[e]]}),Tg=({className:e,title:t,type:n,state:r,icon:i,toolName:a,...o})=>{let s=n===`dynamic-tool`||n===`tool-call`?a:n.split(`-`).slice(1).join(`-`);return(0,L.jsxs)(at,{"data-boring-agent-part":`tool-header`,className:R(`flex w-full min-w-0 items-center justify-between gap-3 p-3 text-left`,e),...o,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[i??(0,L.jsx)($i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{"data-boring-agent-part":`tool-title`,className:`min-w-0 flex-1 truncate text-sm font-medium`,children:t??s}),wg(r)]}),(0,L.jsx)(xr,{"data-boring-agent-part":`tool-chevron`,className:`size-4 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})},Eg=({className:e,...t})=>(0,L.jsx)(ve,{className:R(`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 space-y-4 p-4 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...t}),Dg=({className:e,input:t,...n})=>(0,L.jsxs)(`div`,{className:R(`space-y-2 overflow-hidden`,e),...n,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Parameters`}),(0,L.jsx)(`div`,{className:`rounded-md bg-muted/50`,children:(0,L.jsx)(Sg,{code:JSON.stringify(t,null,2),language:`json`})})]}),Og=({className:e,output:t,errorText:n,...r})=>{if(!(t||n))return null;let i=null;return n||(typeof t==`object`&&!(0,I.isValidElement)(t)?i=(0,L.jsx)(Sg,{code:JSON.stringify(t,null,2),language:`json`}):typeof t==`string`?i=(0,L.jsx)(Sg,{code:t,language:`text`}):t&&(i=(0,L.jsx)(`div`,{children:t}))),(0,L.jsxs)(`div`,{"data-boring-agent-part":`tool-result`,className:R(`space-y-2`,e),...r,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:n?`Error`:`Result`}),(0,L.jsxs)(`div`,{className:R(`rounded-md text-xs [&_table]:w-full`,n?`overflow-hidden border border-destructive/20 bg-destructive/10 text-destructive`:`overflow-x-auto bg-muted/30 text-foreground`),children:[n?(0,L.jsx)(`pre`,{className:`m-0 overflow-x-auto whitespace-pre-wrap break-words p-3 font-mono text-[12px] leading-5 [overflow-wrap:anywhere]`,children:n}):null,i]})]})},Voe=({className:e,...t})=>(0,L.jsx)(`div`,{className:R(`flex flex-col overflow-hidden rounded-lg border bg-background shadow-sm`,e),...t}),Hoe=({className:e,...t})=>(0,L.jsx)(`div`,{className:R(`flex items-center justify-between border-b bg-muted/50 px-4 py-3`,e),...t}),Uoe=({className:e,...t})=>(0,L.jsx)(`p`,{className:R(`font-medium text-foreground text-sm`,e),...t}),Woe=({className:e,...t})=>(0,L.jsx)(`p`,{className:R(`text-muted-foreground text-sm`,e),...t}),Goe=({className:e,...t})=>(0,L.jsx)(`div`,{className:R(`flex items-center gap-1`,e),...t}),kg=({tooltip:e,label:t,icon:n,children:r,className:i,size:a=`sm`,variant:o=`ghost`,...s})=>{let c=(0,L.jsxs)(Se,{className:R(`size-8 p-0 text-muted-foreground hover:text-foreground`,i),size:a,type:`button`,variant:o,...s,children:[n?(0,L.jsx)(n,{className:`size-4`}):r,(0,L.jsx)(`span`,{className:`sr-only`,children:t||e})]});return e?(0,L.jsx)(M,{children:(0,L.jsxs)(k,{children:[(0,L.jsx)(y,{asChild:!0,children:c}),(0,L.jsx)(ee,{children:(0,L.jsx)(`p`,{children:e})})]})}):c},Koe=({className:e,...t})=>(0,L.jsx)(`div`,{className:R(`flex-1 overflow-auto p-4`,e),...t}),Ag=vs(`UNAUTHORIZED.MISSING_API_KEY.INVALID_API_KEY.OIDC_REFRESH_FAILED.VERCEL_AUTH_FAILED.CONFIG_INVALID.PATH_ESCAPE.PATH_ABSOLUTE.PATH_NULL_BYTE.PATH_SYMLINK_ESCAPE.PATH_NOT_FOUND.PATH_NOT_WRITABLE.WORKSPACE_UNINITIALIZED.WORKSPACE_NOT_READY.D1_HOST_SCOPE_VIOLATION.AGENT_RUNTIME_NOT_READY.AGENT_BINDING_DISPOSED.AGENT_CONTROL_RECEIPT_INVALID.RUNTIME_PROVISIONING_FAILED.RUNTIME_PROVISIONING_LOCKED.BWRAP_UNAVAILABLE.BWRAP_TIMEOUT.OUTPUT_TRUNCATED.SANDBOX_NOT_READY.SANDBOX_EXPIRED.VERCEL_API_ERROR.REMOTE_WORKER_TIMEOUT.REMOTE_WORKER_STREAM_CLOSED.CIRCUIT_OPEN.ABORTED.PAYMENT_REQUIRED.MODEL_BUDGET_EXCEEDED.METERING_UNSUPPORTED_COMMAND.SESSION_NOT_FOUND.SESSION_LOCKED.STREAM_BUFFER_EVICTED.CURSOR_OUT_OF_RANGE.BRIDGE_COMMAND_INVALID.TOOL_NOT_FOUND.TOOL_INVALID_INPUT.TOOL_EXECUTION_ERROR.MCP_AGENT_ARTIFACT_INVALID.MCP_AGENT_ARTIFACT_TOO_LARGE.MCP_AGENT_ARTIFACT_UNAVAILABLE.PLUGIN_LOAD_FAILED.PLUGIN_NAME_COLLISION.PLUGIN_RUNTIME_REVISION_MISMATCH.PLUGIN_RUNTIME_PRIVATE_FILE.PLUGIN_RUNTIME_UNSAFE_IMPORT.PLUGIN_RUNTIME_TRANSFORM_FAILED.RUNTIME_PLUGIN_NOT_FOUND.RUNTIME_PLUGIN_ROUTE_NOT_FOUND.RUNTIME_PLUGIN_HANDLER_FAILED.RUNTIME_PLUGIN_LOAD_FAILED.RUNTIME_PLUGIN_RESPONSE_UNSUPPORTED.PROVISIONING_LAYOUT_FAILED.PROVISIONING_SKILLS_FAILED.PROVISIONING_TEMPLATES_FAILED.PROVISIONING_NODE_PREFLIGHT_FAILED.PROVISIONING_NPM_INSTALL_FAILED.PROVISIONING_UV_BOOTSTRAP_FAILED.PROVISIONING_UV_INSTALL_FAILED.PROVISIONING_ARTIFACT_FAILED.ERR_NOT_IMPLEMENTED_UNTIL_T1.INTERNAL_ERROR`.split(`.`));Ag.options,vs([`AGENT_DEFINITION_INVALID`,`AGENT_DEFINITION_UNSUPPORTED_FIELD`]),vs([`AGENT_DEPLOYMENT_INVALID`,`AGENT_DEPLOYMENT_UNSUPPORTED_FIELD`]),vs([`AGENT_CONSUMPTION_INVALID_TRANSITION`,`AGENT_CONSUMPTION_CYCLE_DETECTED`,`AGENT_CONSUMPTION_DEPTH_EXCEEDED`,`AGENT_CONSUMPTION_SCHEMA_MISMATCH`]),ps({error:ps({code:Ag,message:ss().min(1),details:gs(ds()).optional()})}),ps({level:vs([`warn`,`error`]),code:Ag,prefix:ss().min(1),msg:ss().min(1)}).catchall(ds());var qoe={"runtime-dependencies":`Runtime dependencies are still installing.`,"runtime:python":`Python runtime dependencies are still installing.`,"runtime:node":`Node runtime dependencies are still installing.`};function Joe(e){return e===`runtime-dependencies`||e.startsWith(`runtime:`)}function Yoe(e){if(!e||typeof e!=`object`)return null;let t=e;return t.details&&typeof t.details==`object`?t.details:t}function Xoe(e){let t=Yoe(e);if(!t||t.code!==Ag.enum.AGENT_RUNTIME_NOT_READY&&t.code!==Ag.enum.RUNTIME_PROVISIONING_FAILED)return null;let n=t.requirement;if(typeof n!=`string`||!Joe(n))return null;let r=t.code===Ag.enum.RUNTIME_PROVISIONING_FAILED||t.state===`failed`;return{code:t.code,retryable:t.retryable===!0,requirement:n,state:typeof t.state==`string`?t.state:void 0,message:r?`Runtime setup failed. Retry or reload the workspace.`:qoe[n]??`Runtime dependencies are still installing.`}}var Zoe={"workspace-fs":`Files are still loading.`,"sandbox-exec":`Sandbox is still waking.`,"ui-bridge":`Workspace UI is still connecting.`},Qoe=new Set([`workspace-fs`,`sandbox-exec`,`ui-bridge`]);function $oe(e){if(!e||typeof e!=`object`)return null;let t=e;return t.details&&typeof t.details==`object`?t.details:t}function jg(e){let t=$oe(e);if(!t||t.code!==Ag.enum.WORKSPACE_NOT_READY||t.retryable!==!0)return null;let n=t.requirement;return typeof n!=`string`||!Qoe.has(n)?null:{code:Ag.enum.WORKSPACE_NOT_READY,retryable:!0,requirement:n,message:Zoe[n]??`Workspace is still preparing.`}}function Mg(e){return typeof e==`object`&&e?e:{}}function Ng(e,t=`text`){let n=e[t];if(typeof n==`string`)return n;let r=e.content;return Array.isArray(r)?r.map(e=>typeof e?.text==`string`?e.text:``).join(``):typeof r==`string`?r:``}function Pg(e){return{type:`dynamic-tool`,state:e.state,toolName:e.toolName}}function ese({path:e,filesystem:t}){let n=dd();if(!n)return(0,L.jsx)(`span`,{className:`font-mono text-[12.5px] text-foreground/85`,children:e});let r=r=>{r.preventDefault(),r.stopPropagation(),t?n(e,{filesystem:t}):n(e)};return(0,L.jsxs)(`span`,{role:`button`,tabIndex:0,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&r(e)},title:`Open ${e} in workbench`,className:R(`group/path inline-flex min-w-0 items-center gap-1 rounded-sm px-1 py-0.5`,`cursor-pointer font-mono text-[12.5px] text-foreground/85`,`transition-colors duration-150`,`hover:bg-foreground/[0.05] hover:text-[color:var(--accent)]`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--accent)]/40`),children:[(0,L.jsx)(`span`,{className:`truncate`,children:e}),(0,L.jsx)(zr,{className:`h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover/path:opacity-100`,strokeWidth:1.75,"aria-hidden":`true`})]})}function tse(e){let t=jg(e.output);return t?(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{title:`${e.toolName} · ${t.message}`,...Pg(e)}),(0,L.jsx)(Eg,{children:(0,L.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-sm text-muted-foreground`,children:[t.message,` Try again in a moment.`]})})]}):null}function nse(e){let t=Xoe(e.output);if(!t)return null;let n=t.code===Ag.enum.RUNTIME_PROVISIONING_FAILED?`Retry or reload the workspace.`:`This is retryable; try again shortly.`;return(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{title:`${e.toolName} · ${t.message} ${n}`,...Pg(e)}),(0,L.jsx)(Eg,{children:(0,L.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-muted/30 px-3 py-2 text-sm text-muted-foreground`,children:[t.message,` `,n]})})]})}function Fg(e){return tse(e)??nse(e)}function Ig(e,t,n){return(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,L.jsx)(`span`,{className:`text-muted-foreground/40`,"aria-hidden":`true`,children:`·`}),(0,L.jsx)(ese,{path:t,filesystem:n})]})}function rse(e){let t=Fg(e);if(t)return t;let n=Mg(e.input),r=Mg(e.output),i=typeof n.command==`string`?n.command:``,a=typeof n.description==`string`?n.description:``,o=Ng(r,`stdout`),s=typeof r.stderr==`string`?r.stderr:``,c=typeof r.exitCode==`number`?r.exitCode:null,l=a||(i.length>64?i.slice(0,64)+`…`:i)||`bash`,u=e.errorText||(s&&(c??0)!==0?s:void 0);return(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{icon:(0,L.jsx)(zi,{className:`size-4 text-muted-foreground`}),title:`bash · ${l}`,...Pg(e)}),(0,L.jsxs)(Eg,{children:[i&&(0,L.jsxs)(`section`,{className:`space-y-2`,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Command`}),(0,L.jsx)(Sg,{code:i,language:`bash`})]}),(0,L.jsx)(Og,{output:o&&!u?o:void 0,errorText:u}),c!==null&&c!==0&&!u&&(0,L.jsxs)(`div`,{className:`text-xs text-destructive`,children:[`exit `,c]})]})]})}function ise(e){let t=Fg(e);if(t)return t;let n=Mg(e.input),r=Mg(e.output),i=typeof n.path==`string`?n.path:``,a=typeof n.filesystem==`string`?n.filesystem:void 0,o=Ng(r),s=bf(i);return(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{icon:(0,L.jsx)(Gr,{className:`size-4 text-muted-foreground`}),title:Ig(`read`,i,a),...Pg(e)}),(0,L.jsxs)(Eg,{children:[(0,L.jsx)(Dg,{input:n}),o&&(0,L.jsxs)(`section`,{className:`space-y-2`,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Content`}),(0,L.jsx)(Sg,{code:o,language:s??`text`})]})]})]})}function ase(e){let t=Fg(e);if(t)return t;let n=Mg(e.input),r=typeof n.path==`string`?n.path:``,i=typeof n.filesystem==`string`?n.filesystem:void 0,a=typeof n.content==`string`?n.content:``,o=a.length,s=bf(r);return(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{icon:(0,L.jsx)(Ur,{className:`size-4 text-muted-foreground`}),title:Ig(`write`,r,i),...Pg(e)}),(0,L.jsx)(Eg,{children:(0,L.jsxs)(Voe,{className:`rounded-none border-0 bg-transparent shadow-none`,children:[(0,L.jsxs)(Hoe,{className:`border-0 px-0 pt-0 pb-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(Uoe,{children:r||`untitled`}),(0,L.jsxs)(Woe,{children:[o.toLocaleString(),` `,o===1?`byte`:`bytes`,s?` · ${s}`:``]})]}),(0,L.jsxs)(Goe,{children:[(0,L.jsx)(kg,{icon:Fr,tooltip:`Copy contents`,label:`Copy`,onClick:()=>{df(a)}}),(0,L.jsx)(kg,{icon:Lr,tooltip:`Download file`,label:`Download`,onClick:()=>{try{let e=new Blob([a],{type:`text/plain`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=r.split(`/`).pop()||`artifact.txt`,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(t)}catch{}}})]})]}),a&&(0,L.jsx)(Koe,{className:`p-0`,children:(0,L.jsx)(Sg,{code:a,language:s??`text`,showLineNumbers:!0})})]})})]})}function ose(e){let t=Fg(e);if(t)return t;let n=Mg(e.input),r=typeof n.path==`string`?n.path:``,i=typeof n.filesystem==`string`?n.filesystem:void 0,a=typeof n.oldString==`string`?n.oldString:``,o=typeof n.newString==`string`?n.newString:``;return(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{icon:(0,L.jsx)(Hr,{className:`size-4 text-muted-foreground`}),title:Ig(`edit`,r,i),...Pg(e)}),(0,L.jsxs)(Eg,{children:[(0,L.jsxs)(`section`,{className:`space-y-2`,children:[(0,L.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Diff`}),(0,L.jsxs)(`div`,{className:`overflow-hidden rounded-sm border border-input/60 bg-muted/30 font-mono text-[13px] leading-relaxed`,children:[a&&(0,L.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-2 border-b border-input/40 bg-destructive/5 px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`select-none text-destructive/70`,children:`-`}),(0,L.jsx)(`span`,{className:R(`whitespace-pre-wrap break-all text-destructive/90`),children:a})]}),o&&(0,L.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-2 bg-accent/5 px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`select-none text-accent/80`,children:`+`}),(0,L.jsx)(`span`,{className:`whitespace-pre-wrap break-all text-accent`,children:o})]})]})]}),(0,L.jsx)(Og,{output:e.output,errorText:e.errorText})]})]})}function Lg(e,t){let n=Fg(t);if(n)return n;let r=Mg(t.input),i=e===`find`||e===`grep`?Ii:Gr,a=[typeof r.pattern==`string`?r.pattern:``,typeof r.path==`string`?r.path:``,typeof r.glob==`string`?r.glob:``].filter(Boolean).join(` · `);return(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{icon:(0,L.jsx)(i,{className:`size-4 text-muted-foreground`}),title:a?`${e} · ${a}`:e,...Pg(t)}),(0,L.jsxs)(Eg,{children:[(0,L.jsx)(Dg,{input:r}),(0,L.jsx)(Og,{output:t.output,errorText:t.errorText})]})]})}function Rg(e,t=0){return e==null?[]:typeof e==`string`?[e]:typeof e==`number`||typeof e==`boolean`?[String(e)]:Array.isArray(e)?t>=2?[JSON.stringify(e)]:e.flatMap(e=>Rg(e,t+1)):typeof e==`object`?t>=2?[JSON.stringify(e)]:Object.values(e).flatMap(e=>Rg(e,t+1)):[String(e)]}function sse(e){let t=Fg(e);if(t)return t;let n=Mg(e.input),r=typeof n.kind==`string`?n.kind:`(empty)`,i=Rg(n.params),a=Pg(e);return(0,L.jsxs)(Cg,{children:[(0,L.jsxs)(at,{className:R(`group/exec-ui flex w-full items-center gap-3 px-3 py-2.5 text-left`,`hover:bg-muted/40 transition-colors`),children:[(0,L.jsx)(ta,{className:`size-3.5 shrink-0 text-muted-foreground/70`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`font-medium text-sm`,children:r}),i.length>0&&(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[(0,L.jsx)(`span`,{className:`text-muted-foreground/40`,"aria-hidden":`true`,children:`·`}),i.map((e,t)=>(0,L.jsx)(`span`,{className:R(`truncate rounded-sm bg-muted/60 px-1.5 py-0.5`,`font-mono text-[11px] text-muted-foreground`),title:e,children:e},t))]}),(0,L.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[wg(a.state),(0,L.jsx)(xr,{className:`size-4 text-muted-foreground/60 transition-transform group-data-[state=open]/exec-ui:rotate-180`,"aria-hidden":`true`})]})]}),(0,L.jsxs)(Eg,{children:[e.input!==void 0&&e.input!==null&&(0,L.jsx)(Dg,{input:e.input}),(0,L.jsx)(Og,{output:e.output,errorText:e.errorText})]})]})}function cse(e){let t=e.rendererResolution?.requestedRendererId;return t&&t!==e.toolName?`${e.toolName} · renderer ${t} unavailable`:e.toolName}function lse(e){return Fg(e)||(0,L.jsxs)(Cg,{children:[(0,L.jsx)(Tg,{title:cse(e),...Pg(e)}),(0,L.jsxs)(Eg,{children:[e.input!==void 0&&e.input!==null&&(0,L.jsx)(Dg,{input:e.input}),(0,L.jsx)(Og,{output:e.output,errorText:e.errorText})]})]})}var zg={bash:rse,read:ise,write:ase,edit:ose,find:e=>Lg(`find`,e),grep:e=>Lg(`grep`,e),ls:e=>Lg(`ls`,e),exec_ui:sse,__fallback:lse};function use(e){if(!e)return{...zg};let t={...zg};for(let[n,r]of Object.entries(e))r&&(t[n]=r);return t}var dse=[`Shift`,`Meta`,`Control`,`Alt`,`CapsLock`];function Bg(e,t){(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function fse({userHistory:e,textareaRef:t,disabled:n}){let r=(0,I.useRef)(-1),i=(0,I.useRef)(``);return(0,I.useCallback)(a=>{let o=a.currentTarget;if(t.current=o,!n)if(a.key===`ArrowUp`){if(o.selectionStart!==0||o.selectionEnd!==0||e.length===0)return;a.preventDefault(),r.current===-1&&(i.current=o.value);let t=Math.min(r.current+1,e.length-1);r.current=t;let n=e[e.length-1-t];Bg(o,n),o.setSelectionRange(0,0)}else if(a.key===`ArrowDown`){if(r.current===-1)return;a.preventDefault();let t=r.current-1;r.current=t;let n=t===-1?i.current:e[e.length-1-t];Bg(o,n),o.setSelectionRange(n.length,n.length)}else dse.includes(a.key)||(r.current=-1)},[n,t,e])}function pse(e){let t=e.trim();return t?mse(/[*?\[\]{}]/.test(t)?t:`*${t}*`):`*`}function mse(e){let t=``,n=!1,r=!1;for(let i of e){if(r){t+=i,r=!1;continue}if(i===`\\`){t+=i,r=!0;continue}if(i===`[`&&!n){n=!0,t+=i;continue}if(i===`]`&&n){n=!1,t+=i;continue}if(!n&&/[a-z]/i.test(i)){let e=i.toLowerCase(),n=i.toUpperCase();t+=e===n?i:`[${n}${e}]`;continue}t+=i}return t}function Vg({count:e,activeIdx:t,setActiveIdx:n,listRef:r,onSelect:i,onDismiss:a}){let o=(0,I.useRef)(i),s=(0,I.useRef)(a);(0,I.useEffect)(()=>{o.current=i},[i]),(0,I.useEffect)(()=>{s.current=a},[a]),(0,I.useEffect)(()=>{let r=r=>{r.key===`ArrowDown`?(r.preventDefault(),n(t=>e===0?0:(t+1)%e)):r.key===`ArrowUp`?(r.preventDefault(),n(t=>e===0?0:(t-1+e)%e)):r.key===`Enter`||r.key===`Tab`?e>0?(r.preventDefault(),o.current(t)):s.current():r.key===`Escape`&&(r.preventDefault(),s.current())};return window.addEventListener(`keydown`,r,{capture:!0}),()=>window.removeEventListener(`keydown`,r,{capture:!0})},[e,t,n]),(0,I.useEffect)(()=>{(r.current?.children[t])?.scrollIntoView({block:`nearest`})},[t,r])}var hse=pse;function gse(e,t){if(!t)return null;let n=e.toLowerCase().indexOf(t.toLowerCase());return n===-1?null:{before:e.slice(0,n),match:e.slice(n,n+t.length),after:e.slice(n+t.length)}}function _se({mention:e,onSelect:t,onDismiss:n,apiBaseUrl:r=``,fetch:i,requestHeaders:a,storageScope:o}){let[s,c]=(0,I.useState)([]),[l,u]=(0,I.useState)(0),d=(0,I.useRef)(null);(0,I.useEffect)(()=>{u(0);let t=new AbortController,n=i??globalThis.fetch.bind(globalThis),s=yse(a,o),l=r.replace(/\/$/,``),d=setTimeout(()=>{n(`${l}/api/v1/files/search?q=${encodeURIComponent(hse(e.query))}&limit=8`,{signal:t.signal,...s?{headers:s}:{}}).then(e=>e.ok?e.json():null).then(e=>{e?.results&&c(e.results.slice(0,8))}).catch(()=>{})},120);return()=>{clearTimeout(d),t.abort()}},[e.query,r,i,a,o]);let f=(0,I.useCallback)(e=>{s[e]&&t(s[e])},[s,t]);return Vg({count:s.length,activeIdx:l,setActiveIdx:u,listRef:d,onSelect:f,onDismiss:n}),s.length===0?null:(0,L.jsx)(`div`,{className:`mb-1 w-full overflow-hidden rounded-lg border border-border/60 bg-popover shadow-lg`,children:(0,L.jsx)(`ul`,{ref:d,className:`max-h-48 overflow-y-auto py-1`,role:`listbox`,"aria-label":`File suggestions`,children:s.map((n,r)=>{let i=n.split(`/`).pop()??n,a=gse(i,e.query);return(0,L.jsxs)(`li`,{role:`option`,"aria-selected":r===l,className:R(`flex cursor-pointer flex-col gap-0.5 px-3 py-1.5 text-[12px]`,r===l?`bg-accent/10 text-foreground`:`text-muted-foreground hover:bg-muted/40`),onMouseEnter:()=>u(r),onMouseDown:e=>{e.preventDefault(),t(n)},children:[(0,L.jsx)(`span`,{className:`font-medium`,children:a?(0,L.jsxs)(L.Fragment,{children:[a.before,(0,L.jsx)(`mark`,{className:`bg-transparent text-[color:var(--accent)]`,children:a.match}),a.after]}):i}),(0,L.jsx)(`span`,{className:`truncate text-[11px] opacity-50`,children:n})]},n)})})})}function vse(e,t){let n=e.slice(0,t),r=n.match(/(^|[\s\n])@(\S*)$/);if(!r)return null;let i=n.lastIndexOf(`@`);return{query:r[2],anchorStart:i,anchorEnd:t}}function yse(e,t){let n={};for(let[t,r]of Object.entries(e??{}))r!==void 0&&(n[t]=r);let r=Object.keys(n).some(e=>e.toLowerCase()===`x-boring-storage-scope`);return t&&!r&&(n[`x-boring-storage-scope`]=t),Object.keys(n).length>0?n:void 0}function Hg(e,t){(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function bse(e){return`@${e.split(`/`).pop()??e}`}function xse(e){return`@${e.replace(/^\/+/,``)||e}`}function Sse(e,t){let n=bse(e);return t.some(t=>t.path!==e&&t.token===n)?xse(e):n}function Cse(e,t){let n=`[^A-Za-z0-9_./-]`;return RegExp(`(^|${n})${wse(t)}($|${n})`).test(e)}function wse(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Tse({textareaRef:e}){let[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(null),[a,o]=(0,I.useState)([]),s=(0,I.useCallback)(e=>{o(t=>t.filter(t=>Cse(e,t.token)))},[]),c=(0,I.useCallback)(t=>{let r=t.currentTarget;e.current=r;let a=r.selectionStart??r.value.length,o=r.value.slice(0,a).match(/^\/(\S*)$/);o?(i(o[1]),n(null)):(i(null),n(vse(r.value,a))),s(r.value)},[s,e]),l=(0,I.useCallback)(r=>{let i=e.current;if(!i||!t)return;let{anchorStart:s,anchorEnd:c}=t,l=Sse(r,a);Hg(i,i.value.slice(0,s)+l+i.value.slice(c));let u=s+l.length;i.setSelectionRange(u,u),i.focus(),n(null),o(e=>e.some(e=>e.path===r)?e:[...e,{path:r,token:l}])},[t,a,e]),u=(0,I.useCallback)(t=>{let n=e.current;if(!n)return;let r=`/${t} `;Hg(n,r),n.setSelectionRange(r.length,r.length),n.focus(),i(null)},[e]),d=(0,I.useCallback)(()=>{o([])},[]),f=(0,I.useCallback)(()=>{n(null)},[]),p=(0,I.useCallback)(()=>{i(null)},[]);return{mentionState:t,slashQuery:r,mentionedFiles:a.map(e=>e.path),clearMentionedFiles:d,dismissMention:f,dismissSlash:p,handleComposerChange:c,selectMention:l,selectSlashCommand:u}}var Ug=async e=>{try{let t=await(await fetch(e)).blob();return new Promise(e=>{let n=new FileReader;n.onloadend=()=>e(n.result),n.onerror=()=>e(null),n.readAsDataURL(t)})}catch{return null}},Ese=[`text/`,`application/json`,`application/xml`,`application/yaml`];async function Dse(e){return e?Promise.all(e.map(async e=>({filename:e.filename,mediaType:e.mediaType,url:e.url.startsWith(`blob:`)?await Ug(e.url)??e.url:e.url,...e.path?{path:e.path}:{}}))):[]}async function Ose(e){if(!(Ese.some(t=>e.mediaType?.startsWith(t))||/\.(md|txt|csv|json|yaml|yml|ts|tsx|js|jsx|py|rb|rs|go|sh|bash|css|html|sql|log)$/i.test(e.filename??``)))return null;try{let t=await fetch(e.url);return t.ok?await t.text():null}catch{return null}}function kse(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}async function Ase({text:e,files:t,mentionedFiles:n}){let r=[];for(let e of t??[]){let t=e.filename??`attachment`,n=e.mediaType??`application/octet-stream`,i=e.path,a=[[`data-boring-agent`,`composer-file`],[`filename`,t],[`mime`,n]];i&&a.push([`path`,i]);let o=a.map(([e,t])=>`${e}="${kse(t)}"`).join(` `),s=await Ose(e);s===null?r.push(`<attachment ${o} binary="true" />`):r.push(`<attachment ${o}>\n\`\`\`\n${s}\n\`\`\`\n</attachment>`)}let i=n.length>0?`@files: ${n.join(`, `)}`:null;return{serverMessage:[e.trim(),...r.length>0?[r.join(`
181
181
 
182
182
  `)]:[],...i?[i]:[]].filter(Boolean).join(`
183
183
 
@@ -491,8 +491,8 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
491
491
  L0,20`)},`requirement_arrow`),requirement_contains:F((e,t,n)=>{let r=e.append(`defs`).append(`marker`).attr(`id`,n+`_`+t+`-requirement_containsStart`).attr(`refX`,0).attr(`refY`,10).attr(`markerWidth`,20).attr(`markerHeight`,20).attr(`orient`,`auto`).append(`g`);r.append(`circle`).attr(`cx`,10).attr(`cy`,10).attr(`r`,9).attr(`fill`,`none`),r.append(`line`).attr(`x1`,1).attr(`x2`,19).attr(`y1`,10).attr(`y2`,10),r.append(`line`).attr(`y1`,1).attr(`y2`,19).attr(`x1`,10).attr(`x2`,10)},`requirement_contains`),requirement_arrow_neo:F((e,t,n)=>{let{themeVariables:r}=Ot(),{strokeWidth:i}=r;e.append(`defs`).append(`marker`).attr(`id`,n+`_`+t+`-requirement_arrowEnd`).attr(`refX`,20).attr(`refY`,10).attr(`markerWidth`,20).attr(`markerHeight`,20).attr(`orient`,`auto`).attr(`markerUnits`,`userSpaceOnUse`).attr(`stroke-width`,`${i}`).attr(`viewBox`,`0 0 25 20`).append(`path`).attr(`d`,`M0,0
492
492
  L20,10
493
493
  M20,10
494
- L0,20`).attr(`stroke-linejoin`,`miter`)},`requirement_arrow_neo`),requirement_contains_neo:F((e,t,n)=>{let{themeVariables:r}=Ot(),{strokeWidth:i}=r,a=e.append(`defs`).append(`marker`).attr(`id`,n+`_`+t+`-requirement_containsStart`).attr(`refX`,0).attr(`refY`,10).attr(`markerWidth`,20).attr(`markerHeight`,20).attr(`orient`,`auto`).attr(`markerUnits`,`userSpaceOnUse`).append(`g`);a.append(`circle`).attr(`cx`,10).attr(`cy`,10).attr(`r`,9).attr(`fill`,`none`),a.append(`line`).attr(`x1`,1).attr(`x2`,19).attr(`y1`,10).attr(`y2`,10),a.append(`line`).attr(`y1`,1).attr(`y2`,19).attr(`x1`,10).attr(`x2`,10),a.selectAll(`*`).attr(`stroke-width`,`${i}`)},`requirement_contains_neo`)},OSe=ESe,kSe={common:Lt,getConfig:Ot,insertCluster:xn,insertEdge:CSe,insertEdgeLabel:pSe,insertMarkers:OSe,insertNode:bn,interpolateToCurve:Xt,labelHelper:Cn,log:dt,positionEdgeLabel:mSe},pT={},ASe=F(e=>{for(let t of e)pT[t.name]=t},`registerLayoutLoaders`);F(()=>{ASe([{name:`dagre`,loader:F(async()=>await P(()=>import(`./dagre-VKFMJZFB-CsWb9Wvi.js`),__vite__mapDeps([203,204,205,1,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220])),`loader`)},{name:`swimlane`,loader:F(async()=>await P(()=>import(`./swimlanes-5IMT3BWC-D_RQIhid.js`),__vite__mapDeps([221,207,204,205,1,206,208,209,210,211,212,213,214,215,216,217,220,219])),`loader`)},{name:`cose-bilkent`,loader:F(async()=>await P(()=>import(`./cose-bilkent-JH36ORCC-BPtyRiiY.js`),__vite__mapDeps([222,1,204,205,223])),`loader`)}])},`registerDefaultLayoutLoaders`)();var jSe=F(async(e,t,n)=>{if(!(e.layoutAlgorithm in pT))throw Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);if(e.diagramId)for(let t of e.nodes){let n=t.domId||t.id;t.domId=`${e.diagramId}-${n}`}let r=pT[e.layoutAlgorithm],i=await r.loader(),{theme:a,themeVariables:o}=e.config,{useGradient:s,gradientStart:c,gradientStop:l}=o,u=t.attr(`id`);if(t.append(`defs`).append(`filter`).attr(`id`,`${u}-drop-shadow`).attr(`height`,`130%`).attr(`width`,`130%`).append(`feDropShadow`).attr(`dx`,`4`).attr(`dy`,`4`).attr(`stdDeviation`,0).attr(`flood-opacity`,`0.06`).attr(`flood-color`,`${a?.includes(`dark`)?`#FFFFFF`:`#000000`}`),t.append(`defs`).append(`filter`).attr(`id`,`${u}-drop-shadow-small`).attr(`height`,`150%`).attr(`width`,`150%`).append(`feDropShadow`).attr(`dx`,`2`).attr(`dy`,`2`).attr(`stdDeviation`,0).attr(`flood-opacity`,`0.06`).attr(`flood-color`,`${a?.includes(`dark`)?`#FFFFFF`:`#000000`}`),s){let e=t.append(`linearGradient`).attr(`id`,t.attr(`id`)+`-gradient`).attr(`gradientUnits`,`objectBoundingBox`).attr(`x1`,`0%`).attr(`y1`,`0%`).attr(`x2`,`100%`).attr(`y2`,`0%`);e.append(`svg:stop`).attr(`offset`,`0%`).attr(`stop-color`,c).attr(`stop-opacity`,1),e.append(`svg:stop`).attr(`offset`,`100%`).attr(`stop-color`,l).attr(`stop-opacity`,1)}return i.render(e,t,kSe,{algorithm:r.algorithm},n)},`render`),MSe=F((e=``,{fallback:t=`dagre`}={})=>{if(e in pT)return e;if(t in pT)return dt.warn(`Layout algorithm ${e} is not registered. Using ${t} as fallback.`),t;throw Error(`Both layout algorithms ${e} and ${t} are not registered.`)},`getRegisteredLayoutAlgorithm`),mT=`comm`,NSe=`rule`,PSe=`decl`,FSe=`@import`,ISe=`@namespace`,LSe=`@keyframes`,RSe=`@layer`,zSe=Math.abs,hT=String.fromCharCode;function BSe(e){return e.trim()}function gT(e,t,n){return e.replace(t,n)}function _T(e,t){return e.charCodeAt(t)|0}function vT(e,t,n){return e.slice(t,n)}function yT(e){return e.length}function VSe(e){return e.length}function bT(e,t){return t.push(e),e}var xT=1,ST=1,HSe=0,CT=0,wT=0,TT=``;function ET(e,t,n,r,i,a,o,s){return{value:e,root:t,parent:n,type:r,props:i,children:a,line:xT,column:ST,length:o,return:``,siblings:s}}function USe(){return wT}function WSe(){return wT=CT>0?_T(TT,--CT):0,ST--,wT===10&&(ST=1,xT--),wT}function DT(){return wT=CT<HSe?_T(TT,CT++):0,ST++,wT===10&&(ST=1,xT++),wT}function OT(){return _T(TT,CT)}function kT(){return CT}function AT(e,t){return vT(TT,e,t)}function jT(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function GSe(e){return xT=ST=1,HSe=yT(TT=e),CT=0,[]}function KSe(e){return TT=``,e}function MT(e){return BSe(AT(CT-1,NT(e===91?e+2:e===40?e+1:e)))}function qSe(e){for(;(wT=OT())&&wT<33;)DT();return jT(e)>2||jT(wT)>3?``:` `}function JSe(e,t){for(;--t&&DT()&&!(wT<48||wT>102||wT>57&&wT<65||wT>70&&wT<97););return AT(e,kT()+(t<6&&OT()==32&&DT()==32))}function NT(e){for(;DT();)switch(wT){case e:return CT;case 34:case 39:e!==34&&e!==39&&NT(wT);break;case 40:e===41&&NT(e);break;case 92:DT();break}return CT}function YSe(e,t){for(;DT()&&e+wT!==57&&!(e+wT===84&&OT()===47););return`/*`+AT(t,CT-1)+`*`+hT(e===47?e:DT())}function XSe(e){for(;!jT(OT());)DT();return AT(e,CT)}function ZSe(e){return KSe(PT(``,null,null,null,[``],e=GSe(e),0,[0],e))}function PT(e,t,n,r,i,a,o,s,c){for(var l=0,u=0,d=o,f=0,p=0,m=0,h=1,g=1,_=1,v=0,y=0,b=``,x=i,S=a,C=r,w=b;g;)switch(m=y,y=DT()){case 40:m!=108&&_T(w,d-1)==58?(v++,w+=`(`):w+=MT(y);break;case 41:v--,w+=`)`;break;case 34:case 39:case 91:w+=MT(y);break;case 9:case 10:case 13:case 32:if(v>0){w+=hT(y);break}w+=qSe(m);break;case 92:w+=JSe(kT()-1,7);continue;case 47:switch(OT()){case 42:case 47:bT($Se(YSe(DT(),kT()),t,n,c),c),(jT(m||1)==5||jT(OT()||1)==5)&&yT(w)&&vT(w,-1,void 0)!==` `&&(w+=` `);break;default:w+=`/`}break;case 123*h:s[l++]=yT(w)*_;case 125*h:case 59:case 0:if(v>0&&y){w+=hT(y);break}switch(y){case 0:case 125:g=0;case 59+u:_==-1&&(w=gT(w,/\f/g,``)),p>0&&(yT(w)-d||h===0)&&bT(p>32?eCe(w+`;`,r,n,d-1,c):eCe(gT(w,` `,``)+`;`,r,n,d-2,c),c);break;case 59:w+=`;`;default:if(bT(C=QSe(w,t,n,l,u,i,s,b,x=[],S=[],d,a),a),y===123)if(u===0)PT(w,t,C,C,x,a,d,s,S);else{switch(f){case 99:if(_T(w,3)===110)break;case 108:if(_T(w,2)===97)break;default:u=0;case 100:case 109:case 115:}u?PT(e,C,C,r&&bT(QSe(e,C,C,0,0,i,s,b,i,x=[],d,S),S),i,S,d,s,r?x:S):PT(w,C,C,C,[``],S,0,s,S)}}l=u=p=0,h=_=1,b=w=``,d=o;break;case 58:d=1+yT(w),p=m;default:if(h<1){if(y==123)--h;else if(y==125&&h++==0&&WSe()==125)continue}switch(w+=hT(y),y*h){case 38:_=u>0?1:(w+=`\f`,-1);break;case 44:if(v>0)break;s[l++]=(yT(w)-1)*_,_=1;break;case 64:OT()===45&&(w+=MT(DT())),f=OT(),u=d=yT(b=w+=XSe(kT())),y++;break;case 45:m===45&&yT(w)==2&&(h=0)}}return a}function QSe(e,t,n,r,i,a,o,s,c,l,u,d){for(var f=i-1,p=i===0?a:[``],m=VSe(p),h=0,g=0,_=0;h<r;++h)for(var v=0,y=vT(e,f+1,f=zSe(g=o[h])),b=e;v<m;++v)(b=BSe(g>0?p[v]+` `+y:gT(y,/&\f/g,p[v])))&&(c[_++]=b);return ET(e,t,n,i===0?NSe:s,c,l,u,d)}function $Se(e,t,n,r){return ET(e,t,n,mT,hT(USe()),vT(e,2,-2),0,r)}function eCe(e,t,n,r,i){return ET(e,t,n,PSe,vT(e,0,r),vT(e,r+1,-1),r,i)}function FT(e,t){for(var n=``,r=0;r<e.length;r++)n+=t(e[r],r,e,t)||``;return n}function tCe(e,t,n,r){switch(e.type){case RSe:if(e.children.length)break;case FSe:case ISe:case PSe:return e.return=e.return||e.value;case mT:return``;case LSe:return e.return=e.value+`{`+FT(e.children,r)+`}`;case NSe:if(!yT(e.value=e.props.join(`,`)))return``}return yT(n=FT(e.children,r))?e.return=e.value+`{`+n+`}`:``}function nCe(e){var t=VSe(e);return function(n,r,i,a){for(var o=``,s=0;s<t;s++)o+=e[s](n,r,i,a)||``;return o}}var rCe=`c4`,iCe={id:rCe,detector:F(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./c4Diagram-LMCZKHZV-vOd-i6oU.js`);return{diagram:e}},__vite__mapDeps([224,204,205,1,206,207,209,208,225]));return{id:rCe,diagram:e}},`loader`)},aCe=`flowchart`,oCe={id:aCe,detector:F((e,t)=>t?.flowchart?.defaultRenderer===`dagre-wrapper`||t?.flowchart?.defaultRenderer===`elk`?!1:/^\s*graph/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./flowDiagram-23GEKE2U-CouB6ylb.js`);return{diagram:e}},__vite__mapDeps([226,205,1,204,206,207,208,209,210,211,212,213,214,215,216,225,227,228,229,230,231]));return{id:aCe,diagram:e}},`loader`)},sCe=`flowchart-v2`,cCe={id:sCe,detector:F((e,t)=>t?.flowchart?.defaultRenderer===`dagre-d3`?!1:(t?.flowchart?.defaultRenderer===`elk`&&(t.layout=`elk`),/^\s*graph/.test(e)&&t?.flowchart?.defaultRenderer===`dagre-wrapper`?!0:/^\s*flowchart/.test(e)),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./flowDiagram-23GEKE2U-CouB6ylb.js`);return{diagram:e}},__vite__mapDeps([226,205,1,204,206,207,208,209,210,211,212,213,214,215,216,225,227,228,229,230,231]));return{id:sCe,diagram:e}},`loader`)},lCe=`swimlane`,uCe={id:lCe,detector:F(e=>/^\s*swimlane-beta\b/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./swimlanesDiagram-G3AALYLV-CwYEB1yi.js`);return{diagram:e}},__vite__mapDeps([232,204,205,1,206,207,208,209,210,211,212,213,214,215,216,225,227,228,229,230,231]));return{id:lCe,diagram:e}},`loader`)},dCe=`er`,fCe={id:dCe,detector:F(e=>/^\s*erDiagram/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./erDiagram-Q63AITRT-B6RMjkqo.js`);return{diagram:e}},__vite__mapDeps([233,204,205,1,206,207,230,208,209,210,211,212,213,214,215,216,227,228]));return{id:dCe,diagram:e}},`loader`)},pCe=`gitGraph`,mCe={id:pCe,detector:F(e=>/^\s*gitGraph/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./gitGraphDiagram-IHSO6WYX-_Ujm6vip.js`);return{diagram:e}},__vite__mapDeps([234,204,205,1,206,207,208,209,235,236,237,238]));return{id:pCe,diagram:e}},`loader`)},hCe=`gantt`,gCe={id:hCe,detector:F(e=>/^\s*gantt/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./ganttDiagram-NO4QXBWP-C7VOoWID.js`);return{diagram:e}},__vite__mapDeps([239,1,204,205,206,207,240,241,242,209,208]));return{id:hCe,diagram:e}},`loader`)},_Ce=`info`,vCe={id:_Ce,detector:F(e=>/^\s*info/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./infoDiagram-FWYZ7A6U-BNFhgDLP.js`);return{diagram:e}},__vite__mapDeps([243,204,205,1,206,207,235,236]));return{id:_Ce,diagram:e}},`loader`)},yCe=`pie`,bCe={id:yCe,detector:F(e=>/^\s*pie/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./pieDiagram-ENE6RG2P-BgJCWQHt.js`);return{diagram:e}},__vite__mapDeps([244,204,205,1,206,207,245,242,246,209,247,248,208,235,236,237]));return{id:yCe,diagram:e}},`loader`)},xCe=`quadrantChart`,SCe={id:xCe,detector:F(e=>/^\s*quadrantChart/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./quadrantDiagram-ABIIQ3AL-CQYQ3GYO.js`);return{diagram:e}},__vite__mapDeps([249,204,205,1,206,207,240,241,242]));return{id:xCe,diagram:e}},`loader`)},CCe=`xychart`,wCe={id:CCe,detector:F(e=>/^\s*xychart(-beta)?/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./xychartDiagram-FW5EYKEG-oepIN_mI.js`);return{diagram:e}},__vite__mapDeps([250,204,205,1,206,207,240,241,242,245,208,209,251,246,248,212,213]));return{id:CCe,diagram:e}},`loader`)},TCe=`requirement`,ECe={id:TCe,detector:F(e=>/^\s*requirement(Diagram)?/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./requirementDiagram-TGXJPOKE-C-oeLyY_.js`);return{diagram:e}},__vite__mapDeps([252,204,205,1,206,207,208,209,210,211,212,213,214,215,216,227,228]));return{id:TCe,diagram:e}},`loader`)},DCe=`sequence`,OCe={id:DCe,detector:F(e=>/^\s*sequenceDiagram/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./sequenceDiagram-DBY2YBRQ-hsxNS03R.js`);return{diagram:e}},__vite__mapDeps([253,204,205,1,206,207,209,208,225,238]));return{id:DCe,diagram:e}},`loader`)},kCe=`class`,ACe={id:kCe,detector:F((e,t)=>t?.class?.defaultRenderer!==`dagre-wrapper`&&/^\s*classDiagram/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./classDiagram-OUVF2IWQ-DD8BZuSm.js`);return{diagram:e}},__vite__mapDeps([254,204,205,1,206,207,208,209,210,211,212,213,214,215,216,225,227,228,255,231]));return{id:kCe,diagram:e}},`loader`)},jCe=`classDiagram`,MCe={id:jCe,detector:F((e,t)=>/^\s*classDiagram/.test(e)&&t?.class?.defaultRenderer===`dagre-wrapper`?!0:/^\s*classDiagram-v2/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./classDiagram-v2-EOCWNBFH-DD8BZuSm.js`);return{diagram:e}},__vite__mapDeps([256,204,205,1,206,207,208,209,210,211,212,213,214,215,216,225,227,228,255,231]));return{id:jCe,diagram:e}},`loader`)},NCe=`state`,PCe={id:NCe,detector:F((e,t)=>t?.state?.defaultRenderer!==`dagre-wrapper`&&/^\s*stateDiagram/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./stateDiagram-2N3HPSRC-bIMnxqO8.js`);return{diagram:e}},__vite__mapDeps([257,204,205,1,206,207,208,209,251,246,248,210,211,212,213,214,215,216,217,218,219,225,227,228,258]));return{id:NCe,diagram:e}},`loader`)},FCe=`stateDiagram`,ICe={id:FCe,detector:F((e,t)=>!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&t?.state?.defaultRenderer===`dagre-wrapper`),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./stateDiagram-v2-6OUMAXLB-nx3bC5I9.js`);return{diagram:e}},__vite__mapDeps([259,204,205,1,206,207,208,209,210,211,212,213,214,215,216,225,227,228,258]));return{id:FCe,diagram:e}},`loader`)},LCe=`journey`,RCe={id:LCe,detector:F(e=>/^\s*journey/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./journeyDiagram-5HDEW3XC-BlcNNU8v.js`);return{diagram:e}},__vite__mapDeps([260,204,205,1,206,207,247,246,209,231,225]));return{id:LCe,diagram:e}},`loader`)},zCe={draw:F((e,t,n)=>{dt.debug(`rendering svg for syntax error
495
- `);let r=wye(t),i=r.append(`g`);r.attr(`viewBox`,`0 0 2412 512`),kt(r,100,512,!0),i.append(`path`).attr(`class`,`error-icon`).attr(`d`,`m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z`),i.append(`path`).attr(`class`,`error-icon`).attr(`d`,`m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z`),i.append(`path`).attr(`class`,`error-icon`).attr(`d`,`m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z`),i.append(`path`).attr(`class`,`error-icon`).attr(`d`,`m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z`),i.append(`path`).attr(`class`,`error-icon`).attr(`d`,`m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z`),i.append(`path`).attr(`class`,`error-icon`).attr(`d`,`m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z`),i.append(`text`).attr(`class`,`error-text`).attr(`x`,1440).attr(`y`,250).attr(`font-size`,`150px`).style(`text-anchor`,`middle`).text(`Syntax error in text`),i.append(`text`).attr(`class`,`error-text`).attr(`x`,1250).attr(`y`,400).attr(`font-size`,`100px`).style(`text-anchor`,`middle`).text(`mermaid version ${n}`)},`draw`)},BCe=zCe,VCe={db:{},renderer:zCe,parser:{parse:F(()=>{},`parse`)}},HCe=`flowchart-elk`,UCe={id:HCe,detector:F((e,t={})=>/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&t?.flowchart?.defaultRenderer===`elk`?(t.layout=`elk`,!0):!1,`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./flowDiagram-23GEKE2U-CouB6ylb.js`);return{diagram:e}},__vite__mapDeps([226,205,1,204,206,207,208,209,210,211,212,213,214,215,216,225,227,228,229,230,231]));return{id:HCe,diagram:e}},`loader`)},WCe=`timeline`,GCe={id:WCe,detector:F(e=>/^\s*timeline/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./timeline-definition-FHXFAJF6-C9JnE-9Z.js`);return{diagram:e}},__vite__mapDeps([261,204,205,1,206,207,247,246,209,208]));return{id:WCe,diagram:e}},`loader`)},KCe=`mindmap`,qCe={id:KCe,detector:F(e=>/^\s*mindmap/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./mindmap-definition-LN4V7U3C-B3bwSTt2.js`);return{diagram:e}},__vite__mapDeps([262,204,205,1,206,207,208,209,210,211,212,213,214,215,216,227,228]));return{id:KCe,diagram:e}},`loader`)},JCe=`kanban`,YCe={id:JCe,detector:F(e=>/^\s*kanban/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./kanban-definition-HUTT4EX6-DLdfqqIW.js`);return{diagram:e}},__vite__mapDeps([263,204,205,1,206,207,208,209,210,211,212,213,214,215,231]));return{id:JCe,diagram:e}},`loader`)},XCe=`sankey`,ZCe={id:XCe,detector:F(e=>/^\s*sankey(-beta)?/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./sankeyDiagram-HTMAVEWB-COo7g9T1.js`);return{diagram:e}},__vite__mapDeps([264,204,205,1,206,207,245,242]));return{id:XCe,diagram:e}},`loader`)},QCe=`packet`,$Ce={id:QCe,detector:F(e=>/^\s*packet(-beta)?/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./diagram-NH7WQ7WH-C7egv5PI.js`);return{diagram:e}},__vite__mapDeps([265,204,205,1,206,207,208,209,235,236,237]));return{id:QCe,diagram:e}},`loader`)},ewe=`radar`,twe={id:ewe,detector:F(e=>/^\s*radar-beta/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./diagram-WEI45ONY-ByWPeJ3n.js`);return{diagram:e}},__vite__mapDeps([266,204,205,1,206,207,208,209,235,236,237]));return{id:ewe,diagram:e}},`loader`)},nwe=`block`,rwe={id:nwe,detector:F(e=>/^\s*block(-beta)?/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./blockDiagram-677ZJIJ3-BNuwFkOB.js`);return{diagram:e}},__vite__mapDeps([267,204,205,1,206,207,230,208,209,251,246,248,211,212,213,216,231,217]));return{id:nwe,diagram:e}},`loader`)},iwe=`treeView`,awe={id:iwe,detector:F(e=>/^\s*treeView-beta/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./diagram-OA4YK3LP-BDjGAN6E.js`);return{diagram:e}},__vite__mapDeps([268,204,205,1,206,207,208,209,212,235,236,237,238]));return{id:iwe,diagram:e}},`loader`)},owe=`architecture`,swe={id:owe,detector:F(e=>/^\s*architecture/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./architectureDiagram-ZJ3FMSHR-CuXk1ExT.js`);return{diagram:e}},__vite__mapDeps([269,1,204,205,206,207,208,209,212,213,235,236,237,223]));return{id:owe,diagram:e}},`loader`)},cwe=`eventmodeling`,lwe={id:cwe,detector:F(e=>/^\s*eventmodeling/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./diagram-FQU43EPY-CWXXPDyf.js`);return{diagram:e}},__vite__mapDeps([270,204,205,1,206,207,208,209,236,235,237]));return{id:cwe,diagram:e}},`loader`)},uwe=`ishikawa`,dwe={id:uwe,detector:F(e=>/^\s*ishikawa(-beta)?\b/i.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./ishikawaDiagram-FXEZZL3T-VJcgTL8W.js`);return{diagram:e}},__vite__mapDeps([271,204,205,1,206,207,208,209,215]));return{id:uwe,diagram:e}},`loader`)},fwe=`venn`,pwe={id:fwe,detector:F(e=>/^\s*venn-beta/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./vennDiagram-L72KCM5P-Bs58CXI0.js`);return{diagram:e}},__vite__mapDeps([272,204,205,1,206,207,208,209,215]));return{id:fwe,diagram:e}},`loader`)},mwe=`treemap`,hwe={id:mwe,detector:F(e=>/^\s*treemap/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./diagram-G47NLZAW-CR6Vw1qI.js`);return{diagram:e}},__vite__mapDeps([273,204,205,1,206,207,245,242,241,208,209,210,235,236,237,228]));return{id:mwe,diagram:e}},`loader`)},gwe=`wardley`,_we={id:gwe,detector:F(e=>/^\s*wardley-beta/i.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./wardleyDiagram-EHGQE667-ngPnquAL.js`);return{diagram:e}},__vite__mapDeps([274,204,205,1,206,207,208,209,235,236,237]));return{id:gwe,diagram:e}},`loader`)},vwe=`cynefin`,ywe={id:vwe,detector:F(e=>/^\s*cynefin-beta(?:[\s:]|$)/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./cynefinDiagram-TSTJHNR4-DirqPxaJ.js`);return{diagram:e}},__vite__mapDeps([275,204,205,1,206,207,208,209,235,236,237]));return{id:vwe,diagram:e}},`loader`)},bwe=`railroad`,xwe={id:bwe,detector:F(e=>/^\s*railroad-beta/i.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./railroadDiagram-RFXS5EU6-C0cBUvf6.js`);return{diagram:e}},__vite__mapDeps([276,204,205,1,206,207,235,236,277,237]));return{id:bwe,diagram:e}},`loader`)},Swe=`railroadEbnf`,Cwe={id:Swe,detector:F(e=>/^\s*railroad-ebnf-beta/i.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./ebnfDiagram-CCIWWBDH-DTE_Hi9u.js`);return{diagram:e}},__vite__mapDeps([278,204,205,1,206,207,235,236,277,237]));return{id:Swe,diagram:e}},`loader`)},wwe=`railroadAbnf`,Twe={id:wwe,detector:F(e=>/^\s*railroad-abnf-beta/i.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./abnfDiagram-VRR7QNED-BYIpnEWe.js`);return{diagram:e}},__vite__mapDeps([279,204,205,1,206,207,235,236,277,237]));return{id:wwe,diagram:e}},`loader`)},Ewe=`railroadPeg`,Dwe={id:Ewe,detector:F(e=>/^\s*railroad-peg-beta/i.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./pegDiagram-2B236MQR-9LLuxSRX.js`);return{diagram:e}},__vite__mapDeps([280,204,205,1,206,207,235,236,277,237]));return{id:Ewe,diagram:e}},`loader`)},Owe=!1,IT=F(()=>{Owe||(Owe=!0,vt(`error`,VCe,e=>e.toLowerCase().trim()===`error`),vt(`---`,{db:{clear:F(()=>{},`clear`)},styles:{},renderer:{draw:F(()=>{},`draw`)},parser:{parse:F(()=>{throw Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},`parse`)},init:F(()=>null,`init`)},e=>e.toLowerCase().trimStart().startsWith(`---`)),yt(UCe,qCe,swe),yt(iCe,YCe,MCe,ACe,fCe,gCe,vCe,bCe,ECe,OCe,uCe,cCe,oCe,GCe,mCe,ICe,PCe,RCe,SCe,ZCe,$Ce,wCe,rwe,lwe,awe,twe,dwe,hwe,xwe,Cwe,Twe,Dwe,pwe,_we,ywe))},`addDiagrams`),kwe=F(async()=>{dt.debug(`Loading registered diagrams`);let e=(await Promise.allSettled(Object.entries(Mt).map(async([e,{detector:t,loader:n}])=>{if(n)try{xt(e)}catch{try{let{diagram:e,id:r}=await n();vt(r,e,t)}catch(t){throw dt.error(`Failed to load external diagram with key ${e}. Removing from detectors.`),delete Mt[e],t}}}))).filter(e=>e.status===`rejected`);if(e.length>0){dt.error(`Failed to load ${e.length} external diagrams`);for(let t of e)dt.error(t);throw Error(`Failed to load ${e.length} external diagrams`)}},`loadRegisteredDiagrams`),Awe=`graphics-document document`;function jwe(e,t){e.attr(`role`,Awe),t!==``&&e.attr(`aria-roledescription`,t)}F(jwe,`setA11yDiagramInfo`);function Mwe(e,t,n,r){if(e.insert!==void 0){if(n){let t=`chart-desc-${r}`;e.attr(`aria-describedby`,t),e.insert(`desc`,`:first-child`).attr(`id`,t).text(n)}if(t){let n=`chart-title-${r}`;e.attr(`aria-labelledby`,n),e.insert(`title`,`:first-child`).attr(`id`,n).text(t)}}}F(Mwe,`addSVGa11yTitleDescription`);var LT=class e{constructor(e,t,n,r,i){this.type=e,this.text=t,this.db=n,this.parser=r,this.renderer=i}static{F(this,`Diagram`)}static async fromText(t,n={}){let r=Ot(),i=Pt(t,r);t=rn(t)+`
494
+ L0,20`).attr(`stroke-linejoin`,`miter`)},`requirement_arrow_neo`),requirement_contains_neo:F((e,t,n)=>{let{themeVariables:r}=Ot(),{strokeWidth:i}=r,a=e.append(`defs`).append(`marker`).attr(`id`,n+`_`+t+`-requirement_containsStart`).attr(`refX`,0).attr(`refY`,10).attr(`markerWidth`,20).attr(`markerHeight`,20).attr(`orient`,`auto`).attr(`markerUnits`,`userSpaceOnUse`).append(`g`);a.append(`circle`).attr(`cx`,10).attr(`cy`,10).attr(`r`,9).attr(`fill`,`none`),a.append(`line`).attr(`x1`,1).attr(`x2`,19).attr(`y1`,10).attr(`y2`,10),a.append(`line`).attr(`y1`,1).attr(`y2`,19).attr(`x1`,10).attr(`x2`,10),a.selectAll(`*`).attr(`stroke-width`,`${i}`)},`requirement_contains_neo`)},OSe=ESe,kSe={common:Lt,getConfig:Ot,insertCluster:xn,insertEdge:CSe,insertEdgeLabel:pSe,insertMarkers:OSe,insertNode:bn,interpolateToCurve:Xt,labelHelper:Cn,log:dt,positionEdgeLabel:mSe},pT={},ASe=F(e=>{for(let t of e)pT[t.name]=t},`registerLayoutLoaders`);F(()=>{ASe([{name:`dagre`,loader:F(async()=>await P(()=>import(`./dagre-VKFMJZFB-BRFoDSW8.js`),__vite__mapDeps([203,204,205,1,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220])),`loader`)},{name:`swimlane`,loader:F(async()=>await P(()=>import(`./swimlanes-5IMT3BWC-46Asc0jn.js`),__vite__mapDeps([221,207,204,205,1,206,208,209,210,211,212,213,214,215,216,217,220,219])),`loader`)},{name:`cose-bilkent`,loader:F(async()=>await P(()=>import(`./cose-bilkent-JH36ORCC-BPtyRiiY.js`),__vite__mapDeps([222,1,204,205,223])),`loader`)}])},`registerDefaultLayoutLoaders`)();var jSe=F(async(e,t,n)=>{if(!(e.layoutAlgorithm in pT))throw Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);if(e.diagramId)for(let t of e.nodes){let n=t.domId||t.id;t.domId=`${e.diagramId}-${n}`}let r=pT[e.layoutAlgorithm],i=await r.loader(),{theme:a,themeVariables:o}=e.config,{useGradient:s,gradientStart:c,gradientStop:l}=o,u=t.attr(`id`);if(t.append(`defs`).append(`filter`).attr(`id`,`${u}-drop-shadow`).attr(`height`,`130%`).attr(`width`,`130%`).append(`feDropShadow`).attr(`dx`,`4`).attr(`dy`,`4`).attr(`stdDeviation`,0).attr(`flood-opacity`,`0.06`).attr(`flood-color`,`${a?.includes(`dark`)?`#FFFFFF`:`#000000`}`),t.append(`defs`).append(`filter`).attr(`id`,`${u}-drop-shadow-small`).attr(`height`,`150%`).attr(`width`,`150%`).append(`feDropShadow`).attr(`dx`,`2`).attr(`dy`,`2`).attr(`stdDeviation`,0).attr(`flood-opacity`,`0.06`).attr(`flood-color`,`${a?.includes(`dark`)?`#FFFFFF`:`#000000`}`),s){let e=t.append(`linearGradient`).attr(`id`,t.attr(`id`)+`-gradient`).attr(`gradientUnits`,`objectBoundingBox`).attr(`x1`,`0%`).attr(`y1`,`0%`).attr(`x2`,`100%`).attr(`y2`,`0%`);e.append(`svg:stop`).attr(`offset`,`0%`).attr(`stop-color`,c).attr(`stop-opacity`,1),e.append(`svg:stop`).attr(`offset`,`100%`).attr(`stop-color`,l).attr(`stop-opacity`,1)}return i.render(e,t,kSe,{algorithm:r.algorithm},n)},`render`),MSe=F((e=``,{fallback:t=`dagre`}={})=>{if(e in pT)return e;if(t in pT)return dt.warn(`Layout algorithm ${e} is not registered. Using ${t} as fallback.`),t;throw Error(`Both layout algorithms ${e} and ${t} are not registered.`)},`getRegisteredLayoutAlgorithm`),mT=`comm`,NSe=`rule`,PSe=`decl`,FSe=`@import`,ISe=`@namespace`,LSe=`@keyframes`,RSe=`@layer`,zSe=Math.abs,hT=String.fromCharCode;function BSe(e){return e.trim()}function gT(e,t,n){return e.replace(t,n)}function _T(e,t){return e.charCodeAt(t)|0}function vT(e,t,n){return e.slice(t,n)}function yT(e){return e.length}function VSe(e){return e.length}function bT(e,t){return t.push(e),e}var xT=1,ST=1,HSe=0,CT=0,wT=0,TT=``;function ET(e,t,n,r,i,a,o,s){return{value:e,root:t,parent:n,type:r,props:i,children:a,line:xT,column:ST,length:o,return:``,siblings:s}}function USe(){return wT}function WSe(){return wT=CT>0?_T(TT,--CT):0,ST--,wT===10&&(ST=1,xT--),wT}function DT(){return wT=CT<HSe?_T(TT,CT++):0,ST++,wT===10&&(ST=1,xT++),wT}function OT(){return _T(TT,CT)}function kT(){return CT}function AT(e,t){return vT(TT,e,t)}function jT(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function GSe(e){return xT=ST=1,HSe=yT(TT=e),CT=0,[]}function KSe(e){return TT=``,e}function MT(e){return BSe(AT(CT-1,NT(e===91?e+2:e===40?e+1:e)))}function qSe(e){for(;(wT=OT())&&wT<33;)DT();return jT(e)>2||jT(wT)>3?``:` `}function JSe(e,t){for(;--t&&DT()&&!(wT<48||wT>102||wT>57&&wT<65||wT>70&&wT<97););return AT(e,kT()+(t<6&&OT()==32&&DT()==32))}function NT(e){for(;DT();)switch(wT){case e:return CT;case 34:case 39:e!==34&&e!==39&&NT(wT);break;case 40:e===41&&NT(e);break;case 92:DT();break}return CT}function YSe(e,t){for(;DT()&&e+wT!==57&&!(e+wT===84&&OT()===47););return`/*`+AT(t,CT-1)+`*`+hT(e===47?e:DT())}function XSe(e){for(;!jT(OT());)DT();return AT(e,CT)}function ZSe(e){return KSe(PT(``,null,null,null,[``],e=GSe(e),0,[0],e))}function PT(e,t,n,r,i,a,o,s,c){for(var l=0,u=0,d=o,f=0,p=0,m=0,h=1,g=1,_=1,v=0,y=0,b=``,x=i,S=a,C=r,w=b;g;)switch(m=y,y=DT()){case 40:m!=108&&_T(w,d-1)==58?(v++,w+=`(`):w+=MT(y);break;case 41:v--,w+=`)`;break;case 34:case 39:case 91:w+=MT(y);break;case 9:case 10:case 13:case 32:if(v>0){w+=hT(y);break}w+=qSe(m);break;case 92:w+=JSe(kT()-1,7);continue;case 47:switch(OT()){case 42:case 47:bT($Se(YSe(DT(),kT()),t,n,c),c),(jT(m||1)==5||jT(OT()||1)==5)&&yT(w)&&vT(w,-1,void 0)!==` `&&(w+=` `);break;default:w+=`/`}break;case 123*h:s[l++]=yT(w)*_;case 125*h:case 59:case 0:if(v>0&&y){w+=hT(y);break}switch(y){case 0:case 125:g=0;case 59+u:_==-1&&(w=gT(w,/\f/g,``)),p>0&&(yT(w)-d||h===0)&&bT(p>32?eCe(w+`;`,r,n,d-1,c):eCe(gT(w,` `,``)+`;`,r,n,d-2,c),c);break;case 59:w+=`;`;default:if(bT(C=QSe(w,t,n,l,u,i,s,b,x=[],S=[],d,a),a),y===123)if(u===0)PT(w,t,C,C,x,a,d,s,S);else{switch(f){case 99:if(_T(w,3)===110)break;case 108:if(_T(w,2)===97)break;default:u=0;case 100:case 109:case 115:}u?PT(e,C,C,r&&bT(QSe(e,C,C,0,0,i,s,b,i,x=[],d,S),S),i,S,d,s,r?x:S):PT(w,C,C,C,[``],S,0,s,S)}}l=u=p=0,h=_=1,b=w=``,d=o;break;case 58:d=1+yT(w),p=m;default:if(h<1){if(y==123)--h;else if(y==125&&h++==0&&WSe()==125)continue}switch(w+=hT(y),y*h){case 38:_=u>0?1:(w+=`\f`,-1);break;case 44:if(v>0)break;s[l++]=(yT(w)-1)*_,_=1;break;case 64:OT()===45&&(w+=MT(DT())),f=OT(),u=d=yT(b=w+=XSe(kT())),y++;break;case 45:m===45&&yT(w)==2&&(h=0)}}return a}function QSe(e,t,n,r,i,a,o,s,c,l,u,d){for(var f=i-1,p=i===0?a:[``],m=VSe(p),h=0,g=0,_=0;h<r;++h)for(var v=0,y=vT(e,f+1,f=zSe(g=o[h])),b=e;v<m;++v)(b=BSe(g>0?p[v]+` `+y:gT(y,/&\f/g,p[v])))&&(c[_++]=b);return ET(e,t,n,i===0?NSe:s,c,l,u,d)}function $Se(e,t,n,r){return ET(e,t,n,mT,hT(USe()),vT(e,2,-2),0,r)}function eCe(e,t,n,r,i){return ET(e,t,n,PSe,vT(e,0,r),vT(e,r+1,-1),r,i)}function FT(e,t){for(var n=``,r=0;r<e.length;r++)n+=t(e[r],r,e,t)||``;return n}function tCe(e,t,n,r){switch(e.type){case RSe:if(e.children.length)break;case FSe:case ISe:case PSe:return e.return=e.return||e.value;case mT:return``;case LSe:return e.return=e.value+`{`+FT(e.children,r)+`}`;case NSe:if(!yT(e.value=e.props.join(`,`)))return``}return yT(n=FT(e.children,r))?e.return=e.value+`{`+n+`}`:``}function nCe(e){var t=VSe(e);return function(n,r,i,a){for(var o=``,s=0;s<t;s++)o+=e[s](n,r,i,a)||``;return o}}var rCe=`c4`,iCe={id:rCe,detector:F(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./c4Diagram-LMCZKHZV-CAS7VvIZ.js`);return{diagram:e}},__vite__mapDeps([224,204,205,1,206,207,209,208,225]));return{id:rCe,diagram:e}},`loader`)},aCe=`flowchart`,oCe={id:aCe,detector:F((e,t)=>t?.flowchart?.defaultRenderer===`dagre-wrapper`||t?.flowchart?.defaultRenderer===`elk`?!1:/^\s*graph/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./flowDiagram-23GEKE2U-CWVKIbSe.js`);return{diagram:e}},__vite__mapDeps([226,205,1,204,206,207,208,209,210,211,212,213,214,215,216,225,227,228,229,230,231]));return{id:aCe,diagram:e}},`loader`)},sCe=`flowchart-v2`,cCe={id:sCe,detector:F((e,t)=>t?.flowchart?.defaultRenderer===`dagre-d3`?!1:(t?.flowchart?.defaultRenderer===`elk`&&(t.layout=`elk`),/^\s*graph/.test(e)&&t?.flowchart?.defaultRenderer===`dagre-wrapper`?!0:/^\s*flowchart/.test(e)),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./flowDiagram-23GEKE2U-CWVKIbSe.js`);return{diagram:e}},__vite__mapDeps([226,205,1,204,206,207,208,209,210,211,212,213,214,215,216,225,227,228,229,230,231]));return{id:sCe,diagram:e}},`loader`)},lCe=`swimlane`,uCe={id:lCe,detector:F(e=>/^\s*swimlane-beta\b/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./swimlanesDiagram-G3AALYLV-4tvcCzsT.js`);return{diagram:e}},__vite__mapDeps([232,204,205,1,206,207,208,209,210,211,212,213,214,215,216,225,227,228,229,230,231]));return{id:lCe,diagram:e}},`loader`)},dCe=`er`,fCe={id:dCe,detector:F(e=>/^\s*erDiagram/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./erDiagram-Q63AITRT-ChOMFsyu.js`);return{diagram:e}},__vite__mapDeps([233,204,205,1,206,207,230,208,209,210,211,212,213,214,215,216,227,228]));return{id:dCe,diagram:e}},`loader`)},pCe=`gitGraph`,mCe={id:pCe,detector:F(e=>/^\s*gitGraph/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./gitGraphDiagram-IHSO6WYX-Dpw0EMH3.js`);return{diagram:e}},__vite__mapDeps([234,204,205,1,206,207,208,209,235,236,237,238]));return{id:pCe,diagram:e}},`loader`)},hCe=`gantt`,gCe={id:hCe,detector:F(e=>/^\s*gantt/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./ganttDiagram-NO4QXBWP-BJyI59N-.js`);return{diagram:e}},__vite__mapDeps([239,1,204,205,206,207,240,241,242,209,208]));return{id:hCe,diagram:e}},`loader`)},_Ce=`info`,vCe={id:_Ce,detector:F(e=>/^\s*info/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./infoDiagram-FWYZ7A6U-CEuxB7IW.js`);return{diagram:e}},__vite__mapDeps([243,204,205,1,206,207,235,236]));return{id:_Ce,diagram:e}},`loader`)},yCe=`pie`,bCe={id:yCe,detector:F(e=>/^\s*pie/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./pieDiagram-ENE6RG2P-DLkqng2U.js`);return{diagram:e}},__vite__mapDeps([244,204,205,1,206,207,245,242,246,209,247,248,208,235,236,237]));return{id:yCe,diagram:e}},`loader`)},xCe=`quadrantChart`,SCe={id:xCe,detector:F(e=>/^\s*quadrantChart/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./quadrantDiagram-ABIIQ3AL-Dw0uY7MQ.js`);return{diagram:e}},__vite__mapDeps([249,204,205,1,206,207,240,241,242]));return{id:xCe,diagram:e}},`loader`)},CCe=`xychart`,wCe={id:CCe,detector:F(e=>/^\s*xychart(-beta)?/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./xychartDiagram-FW5EYKEG-BXglxQCg.js`);return{diagram:e}},__vite__mapDeps([250,204,205,1,206,207,240,241,242,245,208,209,251,246,248,212,213]));return{id:CCe,diagram:e}},`loader`)},TCe=`requirement`,ECe={id:TCe,detector:F(e=>/^\s*requirement(Diagram)?/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./requirementDiagram-TGXJPOKE-BJtZwK-r.js`);return{diagram:e}},__vite__mapDeps([252,204,205,1,206,207,208,209,210,211,212,213,214,215,216,227,228]));return{id:TCe,diagram:e}},`loader`)},DCe=`sequence`,OCe={id:DCe,detector:F(e=>/^\s*sequenceDiagram/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./sequenceDiagram-DBY2YBRQ-DKCWWujI.js`);return{diagram:e}},__vite__mapDeps([253,204,205,1,206,207,209,208,225,238]));return{id:DCe,diagram:e}},`loader`)},kCe=`class`,ACe={id:kCe,detector:F((e,t)=>t?.class?.defaultRenderer!==`dagre-wrapper`&&/^\s*classDiagram/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./classDiagram-OUVF2IWQ-B9Etcp-t.js`);return{diagram:e}},__vite__mapDeps([254,204,205,1,206,207,208,209,210,211,212,213,214,215,216,225,227,228,255,231]));return{id:kCe,diagram:e}},`loader`)},jCe=`classDiagram`,MCe={id:jCe,detector:F((e,t)=>/^\s*classDiagram/.test(e)&&t?.class?.defaultRenderer===`dagre-wrapper`?!0:/^\s*classDiagram-v2/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./classDiagram-v2-EOCWNBFH-B9Etcp-t.js`);return{diagram:e}},__vite__mapDeps([256,204,205,1,206,207,208,209,210,211,212,213,214,215,216,225,227,228,255,231]));return{id:jCe,diagram:e}},`loader`)},NCe=`state`,PCe={id:NCe,detector:F((e,t)=>t?.state?.defaultRenderer!==`dagre-wrapper`&&/^\s*stateDiagram/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./stateDiagram-2N3HPSRC-DalzGktj.js`);return{diagram:e}},__vite__mapDeps([257,204,205,1,206,207,208,209,251,246,248,210,211,212,213,214,215,216,217,218,219,225,227,228,258]));return{id:NCe,diagram:e}},`loader`)},FCe=`stateDiagram`,ICe={id:FCe,detector:F((e,t)=>!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&t?.state?.defaultRenderer===`dagre-wrapper`),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./stateDiagram-v2-6OUMAXLB-CI1LWAFu.js`);return{diagram:e}},__vite__mapDeps([259,204,205,1,206,207,208,209,210,211,212,213,214,215,216,225,227,228,258]));return{id:FCe,diagram:e}},`loader`)},LCe=`journey`,RCe={id:LCe,detector:F(e=>/^\s*journey/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./journeyDiagram-5HDEW3XC-D1ftt9ge.js`);return{diagram:e}},__vite__mapDeps([260,204,205,1,206,207,247,246,209,231,225]));return{id:LCe,diagram:e}},`loader`)},zCe={draw:F((e,t,n)=>{dt.debug(`rendering svg for syntax error
495
+ `);let r=wye(t),i=r.append(`g`);r.attr(`viewBox`,`0 0 2412 512`),kt(r,100,512,!0),i.append(`path`).attr(`class`,`error-icon`).attr(`d`,`m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z`),i.append(`path`).attr(`class`,`error-icon`).attr(`d`,`m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z`),i.append(`path`).attr(`class`,`error-icon`).attr(`d`,`m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z`),i.append(`path`).attr(`class`,`error-icon`).attr(`d`,`m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z`),i.append(`path`).attr(`class`,`error-icon`).attr(`d`,`m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z`),i.append(`path`).attr(`class`,`error-icon`).attr(`d`,`m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z`),i.append(`text`).attr(`class`,`error-text`).attr(`x`,1440).attr(`y`,250).attr(`font-size`,`150px`).style(`text-anchor`,`middle`).text(`Syntax error in text`),i.append(`text`).attr(`class`,`error-text`).attr(`x`,1250).attr(`y`,400).attr(`font-size`,`100px`).style(`text-anchor`,`middle`).text(`mermaid version ${n}`)},`draw`)},BCe=zCe,VCe={db:{},renderer:zCe,parser:{parse:F(()=>{},`parse`)}},HCe=`flowchart-elk`,UCe={id:HCe,detector:F((e,t={})=>/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&t?.flowchart?.defaultRenderer===`elk`?(t.layout=`elk`,!0):!1,`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./flowDiagram-23GEKE2U-CWVKIbSe.js`);return{diagram:e}},__vite__mapDeps([226,205,1,204,206,207,208,209,210,211,212,213,214,215,216,225,227,228,229,230,231]));return{id:HCe,diagram:e}},`loader`)},WCe=`timeline`,GCe={id:WCe,detector:F(e=>/^\s*timeline/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./timeline-definition-FHXFAJF6-CWFZnqYm.js`);return{diagram:e}},__vite__mapDeps([261,204,205,1,206,207,247,246,209,208]));return{id:WCe,diagram:e}},`loader`)},KCe=`mindmap`,qCe={id:KCe,detector:F(e=>/^\s*mindmap/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./mindmap-definition-LN4V7U3C-DuYnLQGd.js`);return{diagram:e}},__vite__mapDeps([262,204,205,1,206,207,208,209,210,211,212,213,214,215,216,227,228]));return{id:KCe,diagram:e}},`loader`)},JCe=`kanban`,YCe={id:JCe,detector:F(e=>/^\s*kanban/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./kanban-definition-HUTT4EX6-DCelZ2vh.js`);return{diagram:e}},__vite__mapDeps([263,204,205,1,206,207,208,209,210,211,212,213,214,215,231]));return{id:JCe,diagram:e}},`loader`)},XCe=`sankey`,ZCe={id:XCe,detector:F(e=>/^\s*sankey(-beta)?/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./sankeyDiagram-HTMAVEWB-DeZe-cA5.js`);return{diagram:e}},__vite__mapDeps([264,204,205,1,206,207,245,242]));return{id:XCe,diagram:e}},`loader`)},QCe=`packet`,$Ce={id:QCe,detector:F(e=>/^\s*packet(-beta)?/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./diagram-NH7WQ7WH-D8afauUh.js`);return{diagram:e}},__vite__mapDeps([265,204,205,1,206,207,208,209,235,236,237]));return{id:QCe,diagram:e}},`loader`)},ewe=`radar`,twe={id:ewe,detector:F(e=>/^\s*radar-beta/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./diagram-WEI45ONY-Cg4RvV8X.js`);return{diagram:e}},__vite__mapDeps([266,204,205,1,206,207,208,209,235,236,237]));return{id:ewe,diagram:e}},`loader`)},nwe=`block`,rwe={id:nwe,detector:F(e=>/^\s*block(-beta)?/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./blockDiagram-677ZJIJ3-CAVw539c.js`);return{diagram:e}},__vite__mapDeps([267,204,205,1,206,207,230,208,209,251,246,248,211,212,213,216,231,217]));return{id:nwe,diagram:e}},`loader`)},iwe=`treeView`,awe={id:iwe,detector:F(e=>/^\s*treeView-beta/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./diagram-OA4YK3LP-BcWPtrFs.js`);return{diagram:e}},__vite__mapDeps([268,204,205,1,206,207,208,209,212,235,236,237,238]));return{id:iwe,diagram:e}},`loader`)},owe=`architecture`,swe={id:owe,detector:F(e=>/^\s*architecture/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./architectureDiagram-ZJ3FMSHR-CvlgW3i6.js`);return{diagram:e}},__vite__mapDeps([269,1,204,205,206,207,208,209,212,213,235,236,237,223]));return{id:owe,diagram:e}},`loader`)},cwe=`eventmodeling`,lwe={id:cwe,detector:F(e=>/^\s*eventmodeling/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./diagram-FQU43EPY-DK1yLdyN.js`);return{diagram:e}},__vite__mapDeps([270,204,205,1,206,207,208,209,236,235,237]));return{id:cwe,diagram:e}},`loader`)},uwe=`ishikawa`,dwe={id:uwe,detector:F(e=>/^\s*ishikawa(-beta)?\b/i.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./ishikawaDiagram-FXEZZL3T-wk1u9NX7.js`);return{diagram:e}},__vite__mapDeps([271,204,205,1,206,207,208,209,215]));return{id:uwe,diagram:e}},`loader`)},fwe=`venn`,pwe={id:fwe,detector:F(e=>/^\s*venn-beta/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./vennDiagram-L72KCM5P-DMwzFRSk.js`);return{diagram:e}},__vite__mapDeps([272,204,205,1,206,207,208,209,215]));return{id:fwe,diagram:e}},`loader`)},mwe=`treemap`,hwe={id:mwe,detector:F(e=>/^\s*treemap/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./diagram-G47NLZAW-CFK_ti2g.js`);return{diagram:e}},__vite__mapDeps([273,204,205,1,206,207,245,242,241,208,209,210,235,236,237,228]));return{id:mwe,diagram:e}},`loader`)},gwe=`wardley`,_we={id:gwe,detector:F(e=>/^\s*wardley-beta/i.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./wardleyDiagram-EHGQE667-BWVEPVA9.js`);return{diagram:e}},__vite__mapDeps([274,204,205,1,206,207,208,209,235,236,237]));return{id:gwe,diagram:e}},`loader`)},vwe=`cynefin`,ywe={id:vwe,detector:F(e=>/^\s*cynefin-beta(?:[\s:]|$)/.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./cynefinDiagram-TSTJHNR4-Ck5X3Pvz.js`);return{diagram:e}},__vite__mapDeps([275,204,205,1,206,207,208,209,235,236,237]));return{id:vwe,diagram:e}},`loader`)},bwe=`railroad`,xwe={id:bwe,detector:F(e=>/^\s*railroad-beta/i.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./railroadDiagram-RFXS5EU6-BW70k7aB.js`);return{diagram:e}},__vite__mapDeps([276,204,205,1,206,207,235,236,277,237]));return{id:bwe,diagram:e}},`loader`)},Swe=`railroadEbnf`,Cwe={id:Swe,detector:F(e=>/^\s*railroad-ebnf-beta/i.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./ebnfDiagram-CCIWWBDH-CfduTGsM.js`);return{diagram:e}},__vite__mapDeps([278,204,205,1,206,207,235,236,277,237]));return{id:Swe,diagram:e}},`loader`)},wwe=`railroadAbnf`,Twe={id:wwe,detector:F(e=>/^\s*railroad-abnf-beta/i.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./abnfDiagram-VRR7QNED-DIM4WdUu.js`);return{diagram:e}},__vite__mapDeps([279,204,205,1,206,207,235,236,277,237]));return{id:wwe,diagram:e}},`loader`)},Ewe=`railroadPeg`,Dwe={id:Ewe,detector:F(e=>/^\s*railroad-peg-beta/i.test(e),`detector`),loader:F(async()=>{let{diagram:e}=await P(async()=>{let{diagram:e}=await import(`./pegDiagram-2B236MQR-D9Fg-G2c.js`);return{diagram:e}},__vite__mapDeps([280,204,205,1,206,207,235,236,277,237]));return{id:Ewe,diagram:e}},`loader`)},Owe=!1,IT=F(()=>{Owe||(Owe=!0,vt(`error`,VCe,e=>e.toLowerCase().trim()===`error`),vt(`---`,{db:{clear:F(()=>{},`clear`)},styles:{},renderer:{draw:F(()=>{},`draw`)},parser:{parse:F(()=>{throw Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},`parse`)},init:F(()=>null,`init`)},e=>e.toLowerCase().trimStart().startsWith(`---`)),yt(UCe,qCe,swe),yt(iCe,YCe,MCe,ACe,fCe,gCe,vCe,bCe,ECe,OCe,uCe,cCe,oCe,GCe,mCe,ICe,PCe,RCe,SCe,ZCe,$Ce,wCe,rwe,lwe,awe,twe,dwe,hwe,xwe,Cwe,Twe,Dwe,pwe,_we,ywe))},`addDiagrams`),kwe=F(async()=>{dt.debug(`Loading registered diagrams`);let e=(await Promise.allSettled(Object.entries(Mt).map(async([e,{detector:t,loader:n}])=>{if(n)try{xt(e)}catch{try{let{diagram:e,id:r}=await n();vt(r,e,t)}catch(t){throw dt.error(`Failed to load external diagram with key ${e}. Removing from detectors.`),delete Mt[e],t}}}))).filter(e=>e.status===`rejected`);if(e.length>0){dt.error(`Failed to load ${e.length} external diagrams`);for(let t of e)dt.error(t);throw Error(`Failed to load ${e.length} external diagrams`)}},`loadRegisteredDiagrams`),Awe=`graphics-document document`;function jwe(e,t){e.attr(`role`,Awe),t!==``&&e.attr(`aria-roledescription`,t)}F(jwe,`setA11yDiagramInfo`);function Mwe(e,t,n,r){if(e.insert!==void 0){if(n){let t=`chart-desc-${r}`;e.attr(`aria-describedby`,t),e.insert(`desc`,`:first-child`).attr(`id`,t).text(n)}if(t){let n=`chart-title-${r}`;e.attr(`aria-labelledby`,n),e.insert(`title`,`:first-child`).attr(`id`,n).text(t)}}}F(Mwe,`addSVGa11yTitleDescription`);var LT=class e{constructor(e,t,n,r,i){this.type=e,this.text=t,this.db=n,this.parser=r,this.renderer=i}static{F(this,`Diagram`)}static async fromText(t,n={}){let r=Ot(),i=Pt(t,r);t=rn(t)+`
496
496
  `;try{xt(i)}catch{let e=mt(i);if(!e)throw new Rt(`Diagram ${i} not found.`);let{id:t,diagram:n}=await e();vt(t,n)}let{db:a,parser:o,renderer:s,init:c}=xt(i);return o.parser&&(o.parser.yy=a),a.clear?.(),c?.(r),n.title&&a.setDiagramTitle?.(n.title),await o.parse(t),new e(i,t,a,o,s)}async render(e,t){await this.renderer.draw(this.text,e,t,this)}getParser(){return this.parser}getType(){return this.type}},Nwe=[],Pwe=F(()=>{Nwe.forEach(e=>{e()}),Nwe=[]},`attachFunctions`),Fwe=F(e=>e.replace(/^\s*%%(?!{)[^\n]+\n?/gm,``).trimStart(),`cleanupComments`);function Iwe(e){let t=e.match(Dt);if(!t)return{text:e,metadata:{}};let n=t[1],r=iSe(n?t[2].split(`
497
497
  `).map(e=>e.startsWith(n)?e.slice(n.length):e).join(`
498
498
  `):t[2],{schema:rSe})??{};r=typeof r==`object`&&!Array.isArray(r)?r:{};let i={};return r.displayMode&&(i.displayMode=r.displayMode.toString()),r.title&&(i.title=r.title.toString()),r.config&&(i.config=r.config),{text:e.slice(t[0].length),metadata:i}}F(Iwe,`extractFrontMatter`);var Lwe=F(e=>e.replace(/\r\n?/g,`
@@ -610,14 +610,14 @@ ${e}</tr>
610
610
  `}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>${Lj(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=Rj(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Lj(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=Rj(e);if(i===null)return Lj(n);e=i;let a=`<img src="${e}" alt="${Lj(n)}"`;return t&&(a+=` title="${Lj(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Lj(e.text)}},Gj=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}},Kj=class e{options;renderer;textRenderer;constructor(e){this.options=e||aj,this.options.renderer=this.options.renderer||new Wj,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Gj}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}},qj=class{options;block;constructor(e){this.options=e||aj}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?Uj.lex:Uj.lexInline}provideParser(e=this.block){return e?Kj.parse:Kj.parseInline}},Jj=new class{defaults=ij();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Kj;Renderer=Wj;TextRenderer=Gj;Lexer=Uj;Tokenizer=Hj;Hooks=qj;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 Wj(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 Hj(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 qj;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];qj.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&qj.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 Uj.lex(e,t??this.defaults)}parser(e,t){return Kj.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?Uj.lex:Uj.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?Kj.parse:Kj.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?Uj.lex:Uj.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?Kj.parse:Kj.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+=`
611
611
  Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Lj(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Yj(e,t){return Jj.parse(e,t)}Yj.options=Yj.setOptions=function(e){return Jj.setOptions(e),Yj.defaults=Jj.defaults,oj(Yj.defaults),Yj},Yj.getDefaults=ij,Yj.defaults=aj,Yj.use=function(...e){return Jj.use(...e),Yj.defaults=Jj.defaults,oj(Yj.defaults),Yj},Yj.walkTokens=function(e,t){return Jj.walkTokens(e,t)},Yj.parseInline=Jj.parseInline,Yj.Parser=Kj,Yj.parser=Kj.parse,Yj.Renderer=Wj,Yj.TextRenderer=Gj,Yj.Lexer=Uj,Yj.lexer=Uj.lex,Yj.Tokenizer=Hj,Yj.Hooks=qj,Yj.parse=Yj,Yj.options,Yj.setOptions,Yj.use,Yj.walkTokens,Yj.parseInline,Kj.parse,Uj.lex;var TIe=300,EIe=`300px`,DIe=500;function OIe(e={}){let{immediate:t=!1,debounceDelay:n=TIe,rootMargin:r=EIe,idleTimeout:i=DIe}=e,[a,o]=(0,I.useState)(!1),s=(0,I.useRef)(null),c=(0,I.useRef)(null),l=(0,I.useRef)(null),u=(0,I.useMemo)(()=>e=>{let t=Date.now();return window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})},1)},[]),d=(0,I.useMemo)(()=>typeof window<`u`&&window.requestIdleCallback?(e,t)=>window.requestIdleCallback(e,t):u,[u]),f=(0,I.useMemo)(()=>typeof window<`u`&&window.cancelIdleCallback?e=>window.cancelIdleCallback(e):e=>{clearTimeout(e)},[]);return(0,I.useEffect)(()=>{if(t){o(!0);return}let e=s.current;if(!e)return;c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null);let a=()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null)},u=e=>{l.current=d(t=>{t.timeRemaining()>0||t.didTimeout?(o(!0),e.disconnect()):l.current=d(()=>{o(!0),e.disconnect()},{timeout:i/2})},{timeout:i})},p=e=>{a(),c.current=window.setTimeout(()=>{var t;let n=e.takeRecords();(n.length===0||(t=n.at(-1)?.isIntersecting)!=null&&t)&&u(e)},n)},m=(e,t)=>{e.isIntersecting?p(t):a()},h=new IntersectionObserver(e=>{for(let t of e)m(t,h)},{rootMargin:r,threshold:0});return h.observe(e),()=>{c.current&&clearTimeout(c.current),l.current&&f(l.current),h.disconnect()}},[t,n,r,i,f,d]),{shouldRender:a,containerRef:s}}var Xj=/\s/,kIe=/^\s+$/,AIe=new Set([`code`,`pre`,`svg`,`math`,`annotation`]),jIe=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`element`,MIe=e=>e.some(e=>jIe(e)&&AIe.has(e.tagName)),NIe=e=>{let t=[],n=``,r=!1;for(let i of e){let e=Xj.test(i);e!==r&&n&&(t.push(n),n=``),n+=i,r=e}return n&&t.push(n),t},PIe=e=>{let t=[],n=``;for(let r of e)Xj.test(r)?n+=r:(n&&=(t.push(n),``),t.push(r));return n&&t.push(n),t},FIe=(e,t,n,r,i,a)=>{let o=`--sd-animation:sd-${t};--sd-duration:${i?0:n}ms;--sd-easing:${r}`;return a&&(o+=`;--sd-delay:${a}ms`),{type:`element`,tagName:`span`,properties:{"data-sd-animate":!0,style:o},children:[{type:`text`,value:e}]}},IIe=(e,t,n,r,i)=>{let a=t.at(-1);if(!(a&&`children`in a))return;if(MIe(t))return Sb;let o=a,s=o.children.indexOf(e);if(s===-1)return;let c=e.value;if(!c.trim()){i.count+=c.length;return}let l=n.sep===`char`?PIe(c):NIe(c),u=r.prevContentLength,d=l.map(e=>{let t=i.count;if(i.count+=e.length,kIe.test(e))return{type:`text`,value:e};let r=u>0&&t<u,a=r?0:i.newIndex++*n.stagger;return FIe(e,n.animation,n.duration,n.easing,r,a)});return o.children.splice(s,1,...d),s+d.length},LIe=0;function Zj(e){let t={animation:e?.animation??`fadeIn`,duration:e?.duration??150,easing:e?.easing??`ease`,sep:e?.sep??`word`,stagger:e?.stagger??40},n={prevContentLength:0,lastRenderCharCount:0},r=LIe++,i=()=>e=>{let r={count:0,newIndex:0};Cb(e,`text`,(e,i)=>IIe(e,i,t,n,r)),n.lastRenderCharCount=r.count,n.prevContentLength=0};return Object.defineProperty(i,"name",{value:`rehypeAnimate$${r}`}),{name:`animate`,type:`animate`,rehypePlugin:i,setPrevContentLength(e){n.prevContentLength=e},getLastRenderCharCount(){let e=n.lastRenderCharCount;return n.lastRenderCharCount=0,e}}}Zj();var Qj=(0,I.createContext)(!1),RIe=()=>(0,I.useContext)(Qj),$j=(...e)=>l(s(e)),zIe=(e,t)=>{if(!e||!t)return t;let n=`${e}:`;return t.split(/\s+/).filter(Boolean).map(t=>t.startsWith(n)?t:`${e}:${t}`).join(` `)},BIe=e=>e?(...t)=>zIe(e,l(s(t))):$j,eM=(e,t,n)=>{let r=typeof t==`string`&&n.startsWith(`text/csv`)?``:``,i=typeof t==`string`?new Blob([r+t],{type:n}):t,a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},tM=(0,I.createContext)($j),nM=()=>(0,I.useContext)(tM),VIe=$j(`block`,`before:content-[counter(line)]`,`before:inline-block`,`before:[counter-increment:line]`,`before:w-6`,`before:mr-4`,`before:text-[13px]`,`before:text-right`,`before:text-muted-foreground/50`,`before:font-mono`,`before:select-none`),HIe=e=>{let t={};for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e>0){let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}}return t},rM=(0,I.memo)(({children:e,result:t,language:n,className:r,startLine:i,lineNumbers:a=!0,...o})=>{let s=nM(),c=(0,I.useMemo)(()=>s(VIe),[s]),l=(0,I.useMemo)(()=>{let e={};return t.bg&&(e[`--sdm-bg`]=t.bg),t.fg&&(e[`--sdm-fg`]=t.fg),t.rootStyle&&Object.assign(e,HIe(t.rootStyle)),e},[t.bg,t.fg,t.rootStyle]);return(0,L.jsx)(`div`,{className:s(r,`overflow-x-auto rounded-md border border-border bg-background p-4 text-sm`),"data-language":n,"data-streamdown":`code-block-body`,...o,children:(0,L.jsx)(`pre`,{className:s(r,`bg-[var(--sdm-bg,inherit]`,`dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]`),style:l,children:(0,L.jsx)(`code`,{className:a?s(`[counter-increment:line_0] [counter-reset:line]`):void 0,style:a&&i&&i>1?{counterReset:`line ${i-1}`}:void 0,children:t.tokens.map((e,t)=>(0,L.jsx)(`span`,{className:a?c:void 0,children:e.length===0||e.length===1&&e[0].content===``?`
612
612
  `:e.map((e,t)=>{let n={},r=!!e.bgColor;if(e.color&&(n[`--sdm-c`]=e.color),e.bgColor&&(n[`--sdm-tbg`]=e.bgColor),e.htmlStyle)for(let[t,i]of Object.entries(e.htmlStyle))t===`color`?n[`--sdm-c`]=i:t===`background-color`?(n[`--sdm-tbg`]=i,r=!0):n[t]=i;return(0,L.jsx)(`span`,{className:s(`text-[var(--sdm-c,inherit)]`,`dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]`,r&&`bg-[var(--sdm-tbg)]`,r&&`dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]`),style:n,...e.htmlAttrs,children:e.content},t)})},t))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),UIe=({className:e,language:t,style:n,isIncomplete:r,...i})=>(0,L.jsx)(`div`,{className:nM()(`my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,e),"data-incomplete":r||void 0,"data-language":t,"data-streamdown":`code-block`,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 200px`,...n},...i}),iM=(0,I.createContext)({code:``}),aM=()=>(0,I.useContext)(iM),WIe=({language:e})=>{let t=nM();return(0,L.jsx)(`div`,{className:t(`flex h-8 items-center text-muted-foreground text-xs`),"data-language":e,"data-streamdown":`code-block-header`,children:(0,L.jsx)(`span`,{className:t(`ml-1 font-mono lowercase`),children:e})})},GIe=e=>{let t=e.length;for(;t>0&&e[t-1]===`
613
- `;)t--;return e.slice(0,t)},KIe=(0,I.lazy)(()=>P(()=>import(`./highlighted-body-OFNGDK62-Cj3Ar0n3.js`).then(e=>({default:e.HighlightedCodeBlockBody})),__vite__mapDeps([281,1,282]))),qIe=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=nM(),l=(0,I.useMemo)(()=>GIe(e),[e]),u=(0,I.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:l.split(`
613
+ `;)t--;return e.slice(0,t)},KIe=(0,I.lazy)(()=>P(()=>import(`./highlighted-body-OFNGDK62-BoMwTwLt.js`).then(e=>({default:e.HighlightedCodeBlockBody})),__vite__mapDeps([281,1,282]))),qIe=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=nM(),l=(0,I.useMemo)(()=>GIe(e),[e]),u=(0,I.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:l.split(`
614
614
  `).map(e=>[{content:e,color:`inherit`,bgColor:`transparent`,htmlStyle:{},offset:0}])}),[l]);return(0,L.jsx)(iM.Provider,{value:{code:e},children:(0,L.jsxs)(UIe,{isIncomplete:i,language:t,children:[(0,L.jsx)(WIe,{language:t}),r?(0,L.jsx)(`div`,{className:c(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,L.jsx)(`div`,{className:c(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`code-block-actions`,children:r})}):null,(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(rM,{className:n,language:t,lineNumbers:o,result:u,startLine:a,...s}),children:(0,L.jsx)(KIe,{className:n,code:l,language:t,lineNumbers:o,raw:u,startLine:a,...s})})]})})},oM={CheckIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z`,fill:`currentColor`,fillRule:`evenodd`})}),CopyIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),DownloadIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),ExternalLinkIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z`,fill:`currentColor`,fillRule:`evenodd`})}),Loader2Icon:e=>(0,L.jsxs)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:[(0,L.jsx)(`path`,{d:`M8 0V4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M8 16V12`,opacity:`0.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M3.29773 1.52783L5.64887 4.7639`,opacity:`0.9`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M12.7023 1.52783L10.3511 4.7639`,opacity:`0.1`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M12.7023 14.472L10.3511 11.236`,opacity:`0.4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M3.29773 14.472L5.64887 11.236`,opacity:`0.6`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M15.6085 5.52783L11.8043 6.7639`,opacity:`0.2`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M0.391602 10.472L4.19583 9.23598`,opacity:`0.7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M15.6085 10.4722L11.8043 9.2361`,opacity:`0.3`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,L.jsx)(`path`,{d:`M0.391602 5.52783L4.19583 6.7639`,opacity:`0.8`,stroke:`currentColor`,strokeWidth:`1.5`})]}),Maximize2Icon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z`,fill:`currentColor`,fillRule:`evenodd`})}),RotateCcwIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z`,fill:`currentColor`,fillRule:`evenodd`})}),XIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomInIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomOutIcon:e=>(0,L.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,L.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})})},sM=(0,I.createContext)(oM),JIe=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])},cM=({icons:e,children:t})=>{let n=(0,I.useRef)(e),r=(0,I.useRef)(e?{...oM,...e}:oM);JIe(n.current,e)||(n.current=e,r.current=e?{...oM,...e}:oM);let i=r.current;return(0,L.jsx)(sM.Provider,{value:i,children:t})},lM=()=>(0,I.useContext)(sM),uM={copyCode:`Copy Code`,downloadFile:`Download file`,downloadDiagram:`Download diagram`,downloadDiagramAsSvg:`Download diagram as SVG`,downloadDiagramAsPng:`Download diagram as PNG`,downloadDiagramAsMmd:`Download diagram as MMD`,viewFullscreen:`View fullscreen`,exitFullscreen:`Exit fullscreen`,mermaidFormatSvg:`SVG`,mermaidFormatPng:`PNG`,mermaidFormatMmd:`MMD`,copyTable:`Copy table`,copyTableAsMarkdown:`Copy table as Markdown`,copyTableAsCsv:`Copy table as CSV`,copyTableAsTsv:`Copy table as TSV`,downloadTable:`Download table`,downloadTableAsCsv:`Download table as CSV`,downloadTableAsMarkdown:`Download table as Markdown`,tableFormatMarkdown:`Markdown`,tableFormatCsv:`CSV`,tableFormatTsv:`TSV`,imageNotAvailable:`Image not available`,downloadImage:`Download image`,openExternalLink:`Open external link?`,externalLinkWarning:`You're about to visit an external website.`,close:`Close`,copyLink:`Copy link`,copied:`Copied`,openLink:`Open link`},dM=(0,I.createContext)(uM),fM=()=>(0,I.useContext)(dM),pM=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,code:a,...o})=>{let s=nM(),[c,l]=(0,I.useState)(!1),u=(0,I.useRef)(0),{code:d}=aM(),{isAnimating:f}=(0,I.useContext)(SN),p=fM(),m=a??d,h=async()=>{var r;if(typeof window>`u`||!((r=navigator==null?void 0:navigator.clipboard)!=null&&r.writeText)){t?.(Error(`Clipboard API not available`));return}try{c||(await navigator.clipboard.writeText(m),l(!0),e?.(),u.current=window.setTimeout(()=>l(!1),n))}catch(e){t?.(e)}};(0,I.useEffect)(()=>()=>{window.clearTimeout(u.current)},[]);let g=lM(),_=c?g.CheckIcon:g.CopyIcon;return(0,L.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-copy-button`,disabled:f,onClick:h,title:p.copyCode,type:`button`,...o,children:r??(0,L.jsx)(_,{size:14})})},mM={"1c":`1c`,"1c-query":`1cq`,abap:`abap`,"actionscript-3":`as`,ada:`ada`,adoc:`adoc`,"angular-html":`html`,"angular-ts":`ts`,apache:`conf`,apex:`cls`,apl:`apl`,applescript:`applescript`,ara:`ara`,asciidoc:`adoc`,asm:`asm`,astro:`astro`,awk:`awk`,ballerina:`bal`,bash:`sh`,bat:`bat`,batch:`bat`,be:`be`,beancount:`beancount`,berry:`berry`,bibtex:`bib`,bicep:`bicep`,blade:`blade.php`,bsl:`bsl`,c:`c`,"c#":`cs`,"c++":`cpp`,cadence:`cdc`,cairo:`cairo`,cdc:`cdc`,clarity:`clar`,clj:`clj`,clojure:`clj`,"closure-templates":`soy`,cmake:`cmake`,cmd:`cmd`,cobol:`cob`,codeowners:`CODEOWNERS`,codeql:`ql`,coffee:`coffee`,coffeescript:`coffee`,"common-lisp":`lisp`,console:`sh`,coq:`v`,cpp:`cpp`,cql:`cql`,crystal:`cr`,cs:`cs`,csharp:`cs`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cql`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,docker:`dockerfile`,dockerfile:`dockerfile`,dotenv:`env`,"dream-maker":`dm`,edge:`edge`,elisp:`el`,elixir:`ex`,elm:`elm`,"emacs-lisp":`el`,erb:`erb`,erl:`erl`,erlang:`erl`,f:`f`,"f#":`fs`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`f90`,f95:`f95`,fennel:`fnl`,fish:`fish`,fluent:`ftl`,for:`for`,"fortran-fixed-form":`f`,"fortran-free-form":`f90`,fs:`fs`,fsharp:`fs`,fsl:`fsl`,ftl:`ftl`,gdresource:`tres`,gdscript:`gd`,gdshader:`gdshader`,genie:`gs`,gherkin:`feature`,"git-commit":`gitcommit`,"git-rebase":`gitrebase`,gjs:`js`,gleam:`gleam`,"glimmer-js":`js`,"glimmer-ts":`ts`,glsl:`glsl`,gnuplot:`plt`,go:`go`,gql:`gql`,graphql:`graphql`,groovy:`groovy`,gts:`gts`,hack:`hack`,haml:`haml`,handlebars:`hbs`,haskell:`hs`,haxe:`hx`,hbs:`hbs`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,hs:`hs`,html:`html`,"html-derivative":`html`,http:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,jade:`jade`,java:`java`,javascript:`js`,jinja:`jinja`,jison:`jison`,jl:`jl`,js:`js`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,julia:`jl`,kotlin:`kt`,kql:`kql`,kt:`kt`,kts:`kts`,kusto:`kql`,latex:`tex`,lean:`lean`,lean4:`lean`,less:`less`,liquid:`liquid`,lisp:`lisp`,lit:`lit`,llvm:`ll`,log:`log`,logo:`logo`,lua:`lua`,luau:`luau`,make:`mak`,makefile:`mak`,markdown:`md`,marko:`marko`,matlab:`m`,md:`md`,mdc:`mdc`,mdx:`mdx`,mediawiki:`wiki`,mermaid:`mmd`,mips:`s`,mipsasm:`s`,mmd:`mmd`,mojo:`mojo`,move:`move`,nar:`nar`,narrat:`narrat`,nextflow:`nf`,nf:`nf`,nginx:`conf`,nim:`nim`,nix:`nix`,nu:`nu`,nushell:`nu`,objc:`m`,"objective-c":`m`,"objective-cpp":`mm`,ocaml:`ml`,pascal:`pas`,perl:`pl`,perl6:`p6`,php:`php`,plsql:`pls`,po:`po`,polar:`polar`,postcss:`pcss`,pot:`pot`,potx:`potx`,powerquery:`pq`,powershell:`ps1`,prisma:`prisma`,prolog:`pl`,properties:`properties`,proto:`proto`,protobuf:`proto`,ps:`ps`,ps1:`ps1`,pug:`pug`,puppet:`pp`,purescript:`purs`,py:`py`,python:`py`,ql:`ql`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,racket:`rkt`,raku:`raku`,razor:`cshtml`,rb:`rb`,reg:`reg`,regex:`regex`,regexp:`regexp`,rel:`rel`,riscv:`s`,rs:`rs`,rst:`rst`,ruby:`rb`,rust:`rs`,sas:`sas`,sass:`sass`,scala:`scala`,scheme:`scm`,scss:`scss`,sdbl:`sdbl`,sh:`sh`,shader:`shader`,shaderlab:`shader`,shell:`sh`,shellscript:`sh`,shellsession:`sh`,smalltalk:`st`,solidity:`sol`,soy:`soy`,sparql:`rq`,spl:`spl`,splunk:`spl`,sql:`sql`,"ssh-config":`config`,stata:`do`,styl:`styl`,stylus:`styl`,svelte:`svelte`,swift:`swift`,"system-verilog":`sv`,systemd:`service`,talon:`talon`,talonscript:`talon`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,terraform:`tf`,tex:`tex`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`ts`,"ts-tags":`ts`,tsp:`tsp`,tsv:`tsv`,tsx:`tsx`,turtle:`ttl`,twig:`twig`,typ:`typ`,typescript:`ts`,typespec:`tsp`,typst:`typ`,v:`v`,vala:`vala`,vb:`vb`,verilog:`v`,vhdl:`vhdl`,vim:`vim`,viml:`vim`,vimscript:`vim`,vue:`vue`,"vue-html":`html`,"vue-vine":`vine`,vy:`vy`,vyper:`vy`,wasm:`wasm`,wenyan:`wy`,wgsl:`wgsl`,wiki:`wiki`,wikitext:`wiki`,wit:`wit`,wl:`wl`,wolfram:`wl`,xml:`xml`,xsl:`xsl`,yaml:`yaml`,yml:`yml`,zenscript:`zs`,zig:`zig`,zsh:`zsh`,文言:`wy`},YIe=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let s=nM(),{code:c}=aM(),{isAnimating:l}=(0,I.useContext)(SN),u=fM(),d=lM(),f=a??c,p=`file.${n&&n in mM?mM[n]:`txt`}`;return(0,L.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-download-button`,disabled:l,onClick:()=>{try{eM(p,f,`text/plain`),e?.()}catch(e){t?.(e)}},title:u.downloadFile,type:`button`,...o,children:r??(0,L.jsx)(d.DownloadIcon,{size:14})})},hM=()=>{let{Loader2Icon:e}=lM(),t=nM();return(0,L.jsxs)(`div`,{className:t(`w-full divide-y divide-border overflow-hidden rounded-xl border border-border`),children:[(0,L.jsx)(`div`,{className:t(`h-[46px] w-full bg-muted/80`)}),(0,L.jsx)(`div`,{className:t(`flex w-full items-center justify-center p-4`),children:(0,L.jsx)(e,{className:t(`size-4 animate-spin`)})})]})},XIe=/\.[^/.]+$/,ZIe=({node:e,className:t,src:n,alt:r,onLoad:i,onError:a,...o})=>{let{DownloadIcon:s}=lM(),c=nM(),l=(0,I.useRef)(null),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(!1),m=fM(),h=o.width!=null||o.height!=null,g=(u||h)&&!f,_=f&&!h;(0,I.useEffect)(()=>{let e=l.current;if(e!=null&&e.complete){let t=e.naturalWidth>0;d(t),p(!t)}},[]);let v=(0,I.useCallback)(e=>{d(!0),p(!1),i?.(e)},[i]),y=(0,I.useCallback)(e=>{d(!1),p(!0),a?.(e)},[a]),b=async()=>{if(n)try{let e=await(await fetch(n)).blob(),t=new URL(n,window.location.origin).pathname.split(`/`).pop()||``,i=t.split(`.`).pop(),a=t.includes(`.`)&&i!==void 0&&i.length<=4,o=``;if(a)o=t;else{let n=e.type,i=`png`;n.includes(`jpeg`)||n.includes(`jpg`)?i=`jpg`:n.includes(`png`)?i=`png`:n.includes(`svg`)?i=`svg`:n.includes(`gif`)?i=`gif`:n.includes(`webp`)&&(i=`webp`),o=`${(r||t||`image`).replace(XIe,``)}.${i}`}eM(o,e,e.type)}catch{window.open(n,`_blank`)}};return n?(0,L.jsxs)(`div`,{className:c(`group relative my-4 inline-block`),"data-streamdown":`image-wrapper`,children:[(0,L.jsx)(`img`,{alt:r,className:c(`max-w-full rounded-lg`,_&&`hidden`,t),"data-streamdown":`image`,onError:y,onLoad:v,ref:l,src:n,...o}),_&&(0,L.jsx)(`span`,{className:c(`text-muted-foreground text-xs italic`),"data-streamdown":`image-fallback`,children:m.imageNotAvailable}),(0,L.jsx)(`div`,{className:c(`pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block`)}),g&&(0,L.jsx)(`button`,{className:c(`absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background`,`opacity-0 group-hover:opacity-100`),onClick:b,title:m.downloadImage,type:`button`,children:(0,L.jsx)(s,{size:14})})]}):null},gM=0,_M=()=>{gM+=1,gM===1&&(document.body.style.overflow=`hidden`)},vM=()=>{gM=Math.max(0,gM-1),gM===0&&(document.body.style.overflow=``)},QIe=({url:e,isOpen:t,onClose:n,onConfirm:r})=>{let{CheckIcon:i,CopyIcon:a,ExternalLinkIcon:o,XIcon:s}=lM(),c=nM(),[l,u]=(0,I.useState)(!1),d=fM(),f=(0,I.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[e]),p=(0,I.useCallback)(()=>{r(),n()},[r,n]);return(0,I.useEffect)(()=>{if(t){_M();let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),vM()}}},[t,n]),t?(0,L.jsx)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm`),"data-streamdown":`link-safety-modal`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`button`,tabIndex:0,children:(0,L.jsxs)(`div`,{className:c(`relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,L.jsx)(`button`,{className:c(`absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:n,title:d.close,type:`button`,children:(0,L.jsx)(s,{size:16})}),(0,L.jsxs)(`div`,{className:c(`flex flex-col gap-2`),children:[(0,L.jsxs)(`div`,{className:c(`flex items-center gap-2 font-semibold text-lg`),children:[(0,L.jsx)(o,{size:20}),(0,L.jsx)(`span`,{children:d.openExternalLink})]}),(0,L.jsx)(`p`,{className:c(`text-muted-foreground text-sm`),children:d.externalLinkWarning})]}),(0,L.jsx)(`div`,{className:c(`break-all rounded-md bg-muted p-3 font-mono text-sm`,e.length>100&&`max-h-32 overflow-y-auto`),children:e}),(0,L.jsxs)(`div`,{className:c(`flex gap-2`),children:[(0,L.jsx)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted`),onClick:f,type:`button`,children:l?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(i,{size:14}),(0,L.jsx)(`span`,{children:d.copied})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(a,{size:14}),(0,L.jsx)(`span`,{children:d.copyLink})]})}),(0,L.jsxs)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90`),onClick:p,type:`button`,children:[(0,L.jsx)(o,{size:14}),(0,L.jsx)(`span`,{children:d.openLink})]})]})]})}):null},yM=(0,I.createContext)(null),bM=()=>(0,I.useContext)(yM),$Ie=()=>bM()?.code??null,xM=()=>bM()?.mermaid??null,eLe=e=>{var t;let n=bM();return n!=null&&n.renderers&&e&&(t=n.renderers.find(t=>Array.isArray(t.language)?t.language.includes(e):t.language===e))!=null?t:null},tLe=(e,t)=>new Promise((t,n)=>{let r=`data:image/svg+xml;base64,`+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin=`anonymous`,i.onload=()=>{let e=document.createElement(`canvas`),r=i.width*5,a=i.height*5;e.width=r,e.height=a;let o=e.getContext(`2d`);if(!o){n(Error(`Failed to create 2D canvas context for PNG export`));return}o.drawImage(i,0,0,r,a),e.toBlob(e=>{if(!e){n(Error(`Failed to create PNG blob`));return}t(e)},`image/png`)},i.onerror=()=>n(Error(`Failed to load SVG image`)),i.src=r}),nLe=({chart:e,children:t,className:n,onDownload:r,config:i,onError:a})=>{let o=nM(),[s,c]=(0,I.useState)(!1),l=(0,I.useRef)(null),{isAnimating:u}=(0,I.useContext)(SN),d=lM(),f=xM(),p=fM(),m=async t=>{try{if(t===`mmd`){eM(`diagram.mmd`,e,`text/plain`),c(!1),r?.(t);return}if(!f){a?.(Error(`Mermaid plugin not available`));return}let n=f.getMermaid(i),o=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),s=`mermaid-${Math.abs(o)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:l}=await n.render(s,e);if(!l){a?.(Error(`SVG not found. Please wait for the diagram to render.`));return}if(t===`svg`){eM(`diagram.svg`,l,`image/svg+xml`),c(!1),r?.(t);return}if(t===`png`){eM(`diagram.png`,await tLe(l),`image/png`),r?.(t),c(!1);return}}catch(e){a?.(e)}};return(0,I.useEffect)(()=>{let e=e=>{let t=e.composedPath();l.current&&!t.includes(l.current)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,L.jsxs)(`div`,{className:o(`relative`),ref:l,children:[(0,L.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),disabled:u,onClick:()=>c(!s),title:p.downloadDiagram,type:`button`,children:t??(0,L.jsx)(d.DownloadIcon,{size:14})}),s?(0,L.jsxs)(`div`,{className:o(`absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,L.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`svg`),title:p.downloadDiagramAsSvg,type:`button`,children:p.mermaidFormatSvg}),(0,L.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`png`),title:p.downloadDiagramAsPng,type:`button`,children:p.mermaidFormatPng}),(0,L.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`mmd`),title:p.downloadDiagramAsMmd,type:`button`,children:p.mermaidFormatMmd})]}):null]})},rLe=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let{Maximize2Icon:o,XIcon:s}=lM(),c=nM(),[l,u]=(0,I.useState)(!1),{isAnimating:d,controls:f}=(0,I.useContext)(SN),p=fM(),m=(()=>{if(typeof f==`boolean`)return f;let e=f.mermaid;return e===!1?!1:e===!0||e===void 0||e.panZoom!==!1})(),h=()=>{u(!l)};return(0,I.useEffect)(()=>{if(l){_M();let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),vM()}}},[l]),(0,I.useEffect)(()=>{l?n?.():r&&r()},[l,n,r]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:c(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),disabled:d,onClick:h,title:p.viewFullscreen,type:`button`,...a,children:(0,L.jsx)(o,{size:14})}),l?(0,Pn.createPortal)((0,L.jsxs)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm`),onClick:h,onKeyDown:e=>{e.key===`Escape`&&h()},role:`button`,tabIndex:0,children:[(0,L.jsx)(`button`,{className:c(`absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:h,title:p.exitFullscreen,type:`button`,children:(0,L.jsx)(s,{size:20})}),(0,L.jsx)(`div`,{className:c(`flex size-full items-center justify-center p-4`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:(0,L.jsx)(TN,{chart:e,className:c(`size-full [&_svg]:h-auto [&_svg]:w-auto`),config:t,fullscreen:!0,showControls:m})})]}),document.body):null]})},SM=e=>{let t=[],n=[],r=e.querySelectorAll(`thead th`);for(let e of r)t.push(e.textContent?.trim()||``);let i=e.querySelectorAll(`tbody tr`);for(let e of i){let t=[],r=e.querySelectorAll(`td`);for(let e of r)t.push(e.textContent?.trim()||``);n.push(t)}return{headers:t,rows:n}},CM=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1,n=!1;for(let r of e){if(r===`"`){t=!0,n=!0;break}(r===`,`||r===`
615
615
  `)&&(t=!0)}return t?n?`"${e.replace(/"/g,`""`)}"`:`"${e}"`:e},i=t.length>0?n.length+1:n.length,a=Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(`,`),o+=1);for(let e of n)a[o]=e.map(r).join(`,`),o+=1;return a.join(`
616
616
  `)},iLe=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1;for(let n of e)if(n===` `||n===`
617
617
  `||n===`\r`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===` `?n.push(`\\t`):t===`
618
618
  `?n.push(`\\n`):t===`\r`?n.push(`\\r`):n.push(t);return n.join(``)},i=t.length>0?n.length+1:n.length,a=Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(` `),o+=1);for(let e of n)a[o]=e.map(r).join(` `),o+=1;return a.join(`
619
619
  `)},wM=e=>{let t=!1;for(let n of e)if(n===`\\`||n===`|`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===`\\`?n.push(`\\\\`):t===`|`?n.push(`\\|`):n.push(t);return n.join(``)},TM=e=>{let{headers:t,rows:n}=e;if(t.length===0)return``;let r=Array(n.length+2),i=0;r[i]=`| ${t.map(e=>wM(e)).join(` | `)} |`,i+=1;let a=Array(t.length);for(let e=0;e<t.length;e+=1)a[e]=`---`;r[i]=`| ${a.join(` | `)} |`,i+=1;for(let e of n)if(e.length<t.length){let n=Array(t.length);for(let r=0;r<t.length;r+=1)n[r]=r<e.length?wM(e[r]):``;r[i]=`| ${n.join(` | `)} |`,i+=1}else r[i]=`| ${e.map(e=>wM(e)).join(` | `)} |`,i+=1;return r.join(`
620
- `)},EM=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=nM(),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(!1),u=(0,I.useRef)(null),d=(0,I.useRef)(0),{isAnimating:f}=(0,I.useContext)(SN),p=fM(),m=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=SM(t),o=({csv:CM,tsv:iLe,md:TM}[e]||TM)(a),c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),d.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,I.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(d.current)}},[]);let h=lM(),g=c?h.CheckIcon:h.CopyIcon;return(0,L.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,L.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:f,onClick:()=>s(!o),title:p.copyTable,type:`button`,children:e??(0,L.jsx)(g,{height:14,width:14})}),o?(0,L.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,L.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`md`),title:p.copyTableAsMarkdown,type:`button`,children:p.tableFormatMarkdown}),(0,L.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`csv`),title:p.copyTableAsCsv,type:`button`,children:p.tableFormatCsv}),(0,L.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`tsv`),title:p.copyTableAsTsv,type:`button`,children:p.tableFormatTsv})]}):null]})},DM=({children:e,className:t,onDownload:n,onError:r})=>{let i=nM(),[a,o]=(0,I.useState)(!1),s=(0,I.useRef)(null),{isAnimating:c}=(0,I.useContext)(SN),l=fM(),u=lM(),d=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=SM(t),a=e===`csv`?CM(i):TM(i);eM(`table.${e===`csv`?`csv`:`md`}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,I.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,L.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,L.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:l.downloadTable,type:`button`,children:e??(0,L.jsx)(u.DownloadIcon,{size:14})}),a?(0,L.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,L.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`csv`),title:l.downloadTableAsCsv,type:`button`,children:l.tableFormatCsv}),(0,L.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`markdown`),title:l.downloadTableAsMarkdown,type:`button`,children:l.tableFormatMarkdown})]}):null]})},aLe=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=lM(),o=nM(),[s,c]=(0,I.useState)(!1),{isAnimating:l}=(0,I.useContext)(SN),u=fM(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,I.useEffect)(()=>{if(s){_M();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),vM()}}},[s]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:d,title:u.viewFullscreen,type:`button`,children:(0,L.jsx)(i,{size:14})}),s?(0,Pn.createPortal)((0,L.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:f,onKeyDown:e=>{e.key===`Escape`&&f()},role:`dialog`,children:(0,L.jsxs)(`div`,{className:o(`flex h-full flex-col`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,L.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,L.jsx)(EM,{}):null,r?(0,L.jsx)(DM,{}):null,(0,L.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:f,title:u.exitFullscreen,type:`button`,children:(0,L.jsx)(a,{size:20})})]}),(0,L.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,L.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},oLe=({children:e,className:t,showControls:n,showCopy:r=!0,showDownload:i=!0,showFullscreen:a=!0,...o})=>{let s=nM(),c=n&&r,l=n&&i,u=n&&a,d=c||l||u;return(0,L.jsxs)(`div`,{className:s(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[d?(0,L.jsxs)(`div`,{className:s(`flex items-center justify-end gap-1`),children:[c?(0,L.jsx)(EM,{}):null,l?(0,L.jsx)(DM,{}):null,u?(0,L.jsx)(aLe,{showCopy:c,showDownload:l,children:e}):null]}):null,(0,L.jsx)(`div`,{className:s(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),children:(0,L.jsx)(`table`,{className:s(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...o,children:e})})]})},sLe=/startLine=(\d+)/,cLe=/\bnoLineNumbers\b/,lLe=(0,I.lazy)(()=>P(()=>import(`./mermaid-GHXKKRXX-C4DsMfhs.js`).then(e=>({default:e.Mermaid})),[])),uLe=/language-([^\s]+)/;function OM(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function kM(e,t){return e.className===t.className&&OM(e.node,t.node)}var AM=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,jM=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},MM=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},NM=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},PM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`ol`,{className:nM()(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e}),(e,t)=>kM(e,t));PM.displayName=`MarkdownOl`;var FM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`li`,{className:nM()(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e}),(e,t)=>e.className===t.className&&OM(e.node,t.node));FM.displayName=`MarkdownLi`;var IM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`ul`,{className:nM()(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e}),(e,t)=>kM(e,t));IM.displayName=`MarkdownUl`;var LM=(0,I.memo)(({className:e,node:t,...n})=>(0,L.jsx)(`hr`,{className:nM()(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n}),(e,t)=>kM(e,t));LM.displayName=`MarkdownHr`;var RM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`span`,{className:nM()(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e}),(e,t)=>kM(e,t));RM.displayName=`MarkdownStrong`;var zM=(0,I.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=nM(),{linkSafety:o}=(0,I.useContext)(SN),[s,c]=(0,I.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,I.useCallback)(async e=>{if(!(!(o!=null&&o.enabled&&n)||l)){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),d=(0,I.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),f=(0,I.useCallback)(()=>{c(!1)},[]),p={url:n??``,isOpen:s,onClose:f,onConfirm:d};return o!=null&&o.enabled&&n?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(p):(0,L.jsx)(QIe,{...p})]}):(0,L.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>kM(e,t)&&e.href===t.href);zM.displayName=`MarkdownA`;var BM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h1`,{className:nM()(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e}),(e,t)=>kM(e,t));BM.displayName=`MarkdownH1`;var VM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h2`,{className:nM()(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e}),(e,t)=>kM(e,t));VM.displayName=`MarkdownH2`;var HM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h3`,{className:nM()(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e}),(e,t)=>kM(e,t));HM.displayName=`MarkdownH3`;var UM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h4`,{className:nM()(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e}),(e,t)=>kM(e,t));UM.displayName=`MarkdownH4`;var WM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h5`,{className:nM()(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e}),(e,t)=>kM(e,t));WM.displayName=`MarkdownH5`;var GM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h6`,{className:nM()(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e}),(e,t)=>kM(e,t));GM.displayName=`MarkdownH6`;var KM=(0,I.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,I.useContext)(SN);return(0,L.jsx)(oLe,{className:t,showControls:AM(i,`table`),showCopy:jM(i,`copy`),showDownload:jM(i,`download`),showFullscreen:jM(i,`fullscreen`),...r,children:e})},(e,t)=>kM(e,t));KM.displayName=`MarkdownTable`;var qM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`thead`,{className:nM()(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e}),(e,t)=>kM(e,t));qM.displayName=`MarkdownThead`;var JM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`tbody`,{className:nM()(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e}),(e,t)=>kM(e,t));JM.displayName=`MarkdownTbody`;var YM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`tr`,{className:nM()(`border-border`,t),"data-streamdown":`table-row`,...r,children:e}),(e,t)=>kM(e,t));YM.displayName=`MarkdownTr`;var XM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`th`,{className:nM()(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e}),(e,t)=>kM(e,t));XM.displayName=`MarkdownTh`;var ZM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`td`,{className:nM()(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e}),(e,t)=>kM(e,t));ZM.displayName=`MarkdownTd`;var QM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`blockquote`,{className:nM()(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e}),(e,t)=>kM(e,t));QM.displayName=`MarkdownBlockquote`;var $M=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`sup`,{className:nM()(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e}),(e,t)=>kM(e,t));$M.displayName=`MarkdownSup`;var eN=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`sub`,{className:nM()(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e}),(e,t)=>kM(e,t));eN.displayName=`MarkdownSub`;var tN=(0,I.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,I.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,I.isValidElement)(e))if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,I.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,I.isValidElement)(e))return e;if(e.type===PM){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,L.jsx)(`section`,{className:t,...r,children:i}):null}return(0,L.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>kM(e,t));tN.displayName=`MarkdownSection`;var nN=(0,I.memo)(({node:e,className:t,children:n,...r})=>{let i=nM(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,I.useContext)(SN),l=xM(),u=RIe(),d=(t?.match(uLe))?.at(1)??``,f=eLe(d);if(a)return(0,L.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let p=e?.properties?.metastring,m=p?.match(sLe),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&cLe.test(p))&&c!==!1,v=``;if((0,I.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?v=n.props.children:typeof n==`string`&&(v=n),f){let e=f.component;return(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(hM,{}),children:(0,L.jsx)(e,{code:v,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=AM(s,`mermaid`),n=NM(s,`download`),r=NM(s,`copy`),a=NM(s,`fullscreen`),c=NM(s,`panZoom`),l=e&&(n||r||a);return(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(hM,{}),children:(0,L.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,L.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,L.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,L.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,L.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,L.jsx)(nLe,{chart:v,config:o?.config}):null,r?(0,L.jsx)(pM,{code:v}):null,a?(0,L.jsx)(rLe,{chart:v,config:o?.config}):null]})}):null,(0,L.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,L.jsx)(lLe,{chart:v,config:o?.config,showControls:c})})]})})}let y=AM(s,`code`),b=MM(s,`download`),x=MM(s,`copy`);return(0,L.jsx)(qIe,{className:t,code:v,isIncomplete:u,language:d,lineNumbers:_,startLine:g,children:y?(0,L.jsxs)(L.Fragment,{children:[b?(0,L.jsx)(YIe,{code:v,language:d}):null,x?(0,L.jsx)(pM,{}):null]}):null})},(e,t)=>e.className===t.className&&OM(e.node,t.node));nN.displayName=`MarkdownCode`;var rN=(0,I.memo)(ZIe,(e,t)=>e.className===t.className&&OM(e.node,t.node));rN.displayName=`MarkdownImg`;var iN=(0,I.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,I.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,L.jsx)(L.Fragment,{children:e})}return(0,L.jsx)(`p`,{...n,children:e})},(e,t)=>kM(e,t));iN.displayName=`MarkdownParagraph`;var dLe={ol:PM,li:FM,ul:IM,hr:LM,strong:RM,a:zM,h1:BM,h2:VM,h3:HM,h4:UM,h5:WM,h6:GM,table:KM,thead:qM,tbody:JM,tr:YM,th:XM,td:ZM,blockquote:QM,code:nN,img:rN,pre:({children:e})=>(0,I.isValidElement)(e)?(0,I.cloneElement)(e,{"data-block":`true`}):e,sup:$M,sub:eN,p:iN,section:tN},fLe=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,pLe=/\p{L}/u;function aN(e){let t=e.replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``);for(let e of t){if(fLe.test(e))return`rtl`;if(pLe.test(e))return`ltr`}return`ltr`}var mLe=/^[ \t]{0,3}(`{3,}|~{3,})/,hLe=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,oN=e=>{let t=e.split(`
620
+ `)},EM=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=nM(),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(!1),u=(0,I.useRef)(null),d=(0,I.useRef)(0),{isAnimating:f}=(0,I.useContext)(SN),p=fM(),m=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=SM(t),o=({csv:CM,tsv:iLe,md:TM}[e]||TM)(a),c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),d.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,I.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(d.current)}},[]);let h=lM(),g=c?h.CheckIcon:h.CopyIcon;return(0,L.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,L.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:f,onClick:()=>s(!o),title:p.copyTable,type:`button`,children:e??(0,L.jsx)(g,{height:14,width:14})}),o?(0,L.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,L.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`md`),title:p.copyTableAsMarkdown,type:`button`,children:p.tableFormatMarkdown}),(0,L.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`csv`),title:p.copyTableAsCsv,type:`button`,children:p.tableFormatCsv}),(0,L.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`tsv`),title:p.copyTableAsTsv,type:`button`,children:p.tableFormatTsv})]}):null]})},DM=({children:e,className:t,onDownload:n,onError:r})=>{let i=nM(),[a,o]=(0,I.useState)(!1),s=(0,I.useRef)(null),{isAnimating:c}=(0,I.useContext)(SN),l=fM(),u=lM(),d=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=SM(t),a=e===`csv`?CM(i):TM(i);eM(`table.${e===`csv`?`csv`:`md`}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,I.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,L.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,L.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:l.downloadTable,type:`button`,children:e??(0,L.jsx)(u.DownloadIcon,{size:14})}),a?(0,L.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,L.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`csv`),title:l.downloadTableAsCsv,type:`button`,children:l.tableFormatCsv}),(0,L.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`markdown`),title:l.downloadTableAsMarkdown,type:`button`,children:l.tableFormatMarkdown})]}):null]})},aLe=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=lM(),o=nM(),[s,c]=(0,I.useState)(!1),{isAnimating:l}=(0,I.useContext)(SN),u=fM(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,I.useEffect)(()=>{if(s){_M();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),vM()}}},[s]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:d,title:u.viewFullscreen,type:`button`,children:(0,L.jsx)(i,{size:14})}),s?(0,Pn.createPortal)((0,L.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:f,onKeyDown:e=>{e.key===`Escape`&&f()},role:`dialog`,children:(0,L.jsxs)(`div`,{className:o(`flex h-full flex-col`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,L.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,L.jsx)(EM,{}):null,r?(0,L.jsx)(DM,{}):null,(0,L.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:f,title:u.exitFullscreen,type:`button`,children:(0,L.jsx)(a,{size:20})})]}),(0,L.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,L.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},oLe=({children:e,className:t,showControls:n,showCopy:r=!0,showDownload:i=!0,showFullscreen:a=!0,...o})=>{let s=nM(),c=n&&r,l=n&&i,u=n&&a,d=c||l||u;return(0,L.jsxs)(`div`,{className:s(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[d?(0,L.jsxs)(`div`,{className:s(`flex items-center justify-end gap-1`),children:[c?(0,L.jsx)(EM,{}):null,l?(0,L.jsx)(DM,{}):null,u?(0,L.jsx)(aLe,{showCopy:c,showDownload:l,children:e}):null]}):null,(0,L.jsx)(`div`,{className:s(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),children:(0,L.jsx)(`table`,{className:s(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...o,children:e})})]})},sLe=/startLine=(\d+)/,cLe=/\bnoLineNumbers\b/,lLe=(0,I.lazy)(()=>P(()=>import(`./mermaid-GHXKKRXX-gnLaGsbP.js`).then(e=>({default:e.Mermaid})),[])),uLe=/language-([^\s]+)/;function OM(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function kM(e,t){return e.className===t.className&&OM(e.node,t.node)}var AM=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,jM=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},MM=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},NM=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0||n[t]!==!1},PM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`ol`,{className:nM()(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e}),(e,t)=>kM(e,t));PM.displayName=`MarkdownOl`;var FM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`li`,{className:nM()(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e}),(e,t)=>e.className===t.className&&OM(e.node,t.node));FM.displayName=`MarkdownLi`;var IM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`ul`,{className:nM()(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e}),(e,t)=>kM(e,t));IM.displayName=`MarkdownUl`;var LM=(0,I.memo)(({className:e,node:t,...n})=>(0,L.jsx)(`hr`,{className:nM()(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n}),(e,t)=>kM(e,t));LM.displayName=`MarkdownHr`;var RM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`span`,{className:nM()(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e}),(e,t)=>kM(e,t));RM.displayName=`MarkdownStrong`;var zM=(0,I.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=nM(),{linkSafety:o}=(0,I.useContext)(SN),[s,c]=(0,I.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,I.useCallback)(async e=>{if(!(!(o!=null&&o.enabled&&n)||l)){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),d=(0,I.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),f=(0,I.useCallback)(()=>{c(!1)},[]),p={url:n??``,isOpen:s,onClose:f,onConfirm:d};return o!=null&&o.enabled&&n?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(p):(0,L.jsx)(QIe,{...p})]}):(0,L.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>kM(e,t)&&e.href===t.href);zM.displayName=`MarkdownA`;var BM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h1`,{className:nM()(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e}),(e,t)=>kM(e,t));BM.displayName=`MarkdownH1`;var VM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h2`,{className:nM()(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e}),(e,t)=>kM(e,t));VM.displayName=`MarkdownH2`;var HM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h3`,{className:nM()(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e}),(e,t)=>kM(e,t));HM.displayName=`MarkdownH3`;var UM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h4`,{className:nM()(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e}),(e,t)=>kM(e,t));UM.displayName=`MarkdownH4`;var WM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h5`,{className:nM()(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e}),(e,t)=>kM(e,t));WM.displayName=`MarkdownH5`;var GM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`h6`,{className:nM()(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e}),(e,t)=>kM(e,t));GM.displayName=`MarkdownH6`;var KM=(0,I.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,I.useContext)(SN);return(0,L.jsx)(oLe,{className:t,showControls:AM(i,`table`),showCopy:jM(i,`copy`),showDownload:jM(i,`download`),showFullscreen:jM(i,`fullscreen`),...r,children:e})},(e,t)=>kM(e,t));KM.displayName=`MarkdownTable`;var qM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`thead`,{className:nM()(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e}),(e,t)=>kM(e,t));qM.displayName=`MarkdownThead`;var JM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`tbody`,{className:nM()(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e}),(e,t)=>kM(e,t));JM.displayName=`MarkdownTbody`;var YM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`tr`,{className:nM()(`border-border`,t),"data-streamdown":`table-row`,...r,children:e}),(e,t)=>kM(e,t));YM.displayName=`MarkdownTr`;var XM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`th`,{className:nM()(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e}),(e,t)=>kM(e,t));XM.displayName=`MarkdownTh`;var ZM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`td`,{className:nM()(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e}),(e,t)=>kM(e,t));ZM.displayName=`MarkdownTd`;var QM=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`blockquote`,{className:nM()(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e}),(e,t)=>kM(e,t));QM.displayName=`MarkdownBlockquote`;var $M=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`sup`,{className:nM()(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e}),(e,t)=>kM(e,t));$M.displayName=`MarkdownSup`;var eN=(0,I.memo)(({children:e,className:t,node:n,...r})=>(0,L.jsx)(`sub`,{className:nM()(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e}),(e,t)=>kM(e,t));eN.displayName=`MarkdownSub`;var tN=(0,I.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,I.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,I.isValidElement)(e))if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,I.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,I.isValidElement)(e))return e;if(e.type===PM){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,L.jsx)(`section`,{className:t,...r,children:i}):null}return(0,L.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>kM(e,t));tN.displayName=`MarkdownSection`;var nN=(0,I.memo)(({node:e,className:t,children:n,...r})=>{let i=nM(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,I.useContext)(SN),l=xM(),u=RIe(),d=(t?.match(uLe))?.at(1)??``,f=eLe(d);if(a)return(0,L.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let p=e?.properties?.metastring,m=p?.match(sLe),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&cLe.test(p))&&c!==!1,v=``;if((0,I.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?v=n.props.children:typeof n==`string`&&(v=n),f){let e=f.component;return(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(hM,{}),children:(0,L.jsx)(e,{code:v,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=AM(s,`mermaid`),n=NM(s,`download`),r=NM(s,`copy`),a=NM(s,`fullscreen`),c=NM(s,`panZoom`),l=e&&(n||r||a);return(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(hM,{}),children:(0,L.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,L.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,L.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,L.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,L.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,L.jsx)(nLe,{chart:v,config:o?.config}):null,r?(0,L.jsx)(pM,{code:v}):null,a?(0,L.jsx)(rLe,{chart:v,config:o?.config}):null]})}):null,(0,L.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,L.jsx)(lLe,{chart:v,config:o?.config,showControls:c})})]})})}let y=AM(s,`code`),b=MM(s,`download`),x=MM(s,`copy`);return(0,L.jsx)(qIe,{className:t,code:v,isIncomplete:u,language:d,lineNumbers:_,startLine:g,children:y?(0,L.jsxs)(L.Fragment,{children:[b?(0,L.jsx)(YIe,{code:v,language:d}):null,x?(0,L.jsx)(pM,{}):null]}):null})},(e,t)=>e.className===t.className&&OM(e.node,t.node));nN.displayName=`MarkdownCode`;var rN=(0,I.memo)(ZIe,(e,t)=>e.className===t.className&&OM(e.node,t.node));rN.displayName=`MarkdownImg`;var iN=(0,I.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,I.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,L.jsx)(L.Fragment,{children:e})}return(0,L.jsx)(`p`,{...n,children:e})},(e,t)=>kM(e,t));iN.displayName=`MarkdownParagraph`;var dLe={ol:PM,li:FM,ul:IM,hr:LM,strong:RM,a:zM,h1:BM,h2:VM,h3:HM,h4:UM,h5:WM,h6:GM,table:KM,thead:qM,tbody:JM,tr:YM,th:XM,td:ZM,blockquote:QM,code:nN,img:rN,pre:({children:e})=>(0,I.isValidElement)(e)?(0,I.cloneElement)(e,{"data-block":`true`}):e,sup:$M,sub:eN,p:iN,section:tN},fLe=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,pLe=/\p{L}/u;function aN(e){let t=e.replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``);for(let e of t){if(fLe.test(e))return`rtl`;if(pLe.test(e))return`ltr`}return`ltr`}var mLe=/^[ \t]{0,3}(`{3,}|~{3,})/,hLe=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,oN=e=>{let t=e.split(`
621
621
  `),n=null,r=0;for(let e of t){let t=mLe.exec(e);if(n===null){if(t){let e=t[1];n=e[0],r=e.length}}else if(t){let e=t[1],i=e[0],a=e.length;i===n&&a>=r&&(n=null,r=0)}}return n!==null},gLe=e=>{let t=e.split(`
622
622
  `);for(let e of t){let t=e.trim();if(t.length>0&&t.includes(`|`)&&hLe.test(t))return!0}return!1},_Le=()=>e=>{wb(e,`html`,(e,t,n)=>{!n||typeof t!=`number`||(n.children[t]={type:`text`,value:e.value})})},sN=[],cN={allowDangerousHtml:!0},lN=new WeakMap,uN=new class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(e){let t=this.keyCache.get(e);if(t)return t;let n=e.rehypePlugins,r=e.remarkPlugins,i=e.remarkRehypeOptions;if(!(n||r||i)){let t=`default`;return this.keyCache.set(e,t),t}let a=e=>{if(!e||e.length===0)return``;let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(n>0&&(t+=`,`),Array.isArray(r)){let[e,n]=r;if(typeof e==`function`){let n=lN.get(e);n||(n=e.name,lN.set(e,n)),t+=n}else t+=String(e);t+=`:`,t+=JSON.stringify(n)}else if(typeof r==`function`){let e=lN.get(r);e||(e=r.name,lN.set(r,e)),t+=e}else t+=String(r)}return t},o=a(n),s=`${a(r)}::${o}::${i?JSON.stringify(i):``}`;return this.keyCache.set(e,s),s}get(e){let t=this.generateCacheKey(e),n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(e,t){let n=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let e=this.cache.keys().next().value;e&&this.cache.delete(e)}this.cache.set(n,t)}clear(){this.cache.clear()}},dN=e=>{let t=vLe(e),n=e.children||``;return TLe(t.runSync(t.parse(n),n),e)},vLe=e=>{let t=uN.get(e);if(t)return t;let n=bLe(e);return uN.set(e,n),n},yLe=e=>e.some(e=>Array.isArray(e)?e[0]===lO:e===lO),bLe=e=>{let t=e.rehypePlugins||sN,n=e.remarkPlugins||sN,r=yLe(t)?n:[...n,_Le],i=e.remarkRehypeOptions?{...cN,...e.remarkRehypeOptions}:cN;return LFe().use(LPe).use(r).use(yFe,i).use(t)},xLe=e=>e,SLe=(e,t,n,r)=>{n?e.children.splice(t,1):e.children[t]={type:`text`,value:r}},CLe=(e,t)=>{for(let n in wA)if(Object.hasOwn(wA,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],i=wA[n];(i===null||i.includes(e.tagName))&&(e.properties[n]=t(String(r||``),n,e)??void 0)}},wLe=(e,t,n,r,i,a)=>{let o=!1;return r?o=!r.includes(e.tagName):i&&(o=i.includes(e.tagName)),!o&&a&&typeof t==`number`&&(o=!a(e,t,n)),o},TLe=(e,t)=>{let{allowElement:n,allowedElements:r,disallowedElements:i,skipHtml:a,unwrapDisallowed:o,urlTransform:s}=t;if(n||r||i||a||s){let t=s||xLe;wb(e,(e,s,c)=>{if(e.type===`raw`&&c&&typeof s==`number`)return SLe(c,s,a,e.value),s;if(e.type===`element`&&(CLe(e,t),wLe(e,s,c,r,i,n)&&c&&typeof s==`number`))return o&&e.children?c.children.splice(s,1,...e.children):c.children.splice(s,1),s})}return GNe(e,{Fragment:L.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:L.jsx,jsxs:L.jsxs,passKeys:!0,passNode:!0})},ELe=/\[\^[\w-]{1,200}\](?!:)/,DLe=/\[\^[\w-]{1,200}\]:/,OLe=/<(\w+)[\s>]/,kLe=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),fN=new Map,pN=new Map,ALe=e=>{let t=e.toLowerCase(),n=fN.get(t);if(n)return n;let r=RegExp(`<${t}(?=[\\s>/])[^>]*>`,`gi`);return fN.set(t,r),r},jLe=e=>{let t=e.toLowerCase(),n=pN.get(t);if(n)return n;let r=RegExp(`</${t}(?=[\\s>])[^>]*>`,`gi`);return pN.set(t,r),r},mN=(e,t)=>{if(kLe.has(t.toLowerCase()))return 0;let n=e.match(ALe(t));if(!n)return 0;let r=0;for(let e of n)e.trimEnd().endsWith(`/>`)||(r+=1);return r},hN=(e,t)=>{let n=e.match(jLe(t));return n?n.length:0},MLe=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]===`$`&&e[n+1]===`$`&&(t+=1,n+=1);return t},NLe=e=>{let t=ELe.test(e),n=DLe.test(e);if(t||n)return[e];let r=Uj.lex(e,{gfm:!0}),i=[],a=[],o=!1;for(let e of r){let t=e.raw,n=i.length;if(a.length>0){i[n-1]+=t;let e=a.at(-1),r=mN(t,e),o=hN(t,e);for(let t=0;t<r;t+=1)a.push(e);for(let t=0;t<o;t+=1)a.length>0&&a.at(-1)===e&&a.pop();continue}if(e.type===`html`&&e.block){let e=t.match(OLe);if(e){let n=e[1];mN(t,n)>hN(t,n)&&a.push(n)}}if(n>0&&!o){let e=i[n-1];if(MLe(e)%2==1){i[n-1]=e+t;continue}}i.push(t),e.type!==`space`&&(o=e.type===`code`)}return i},PLe=(e,t)=>{if(!t.length)return e;let n=e;for(let e of t){let t=RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`,`gi`);n=n.replace(t,(e,t,n,r)=>{if(!n.includes(`
623
623
 
@@ -636,7 +636,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
636
636
  `).trim()}function mUe(e){let t=e.trim();return t.startsWith(`[attached: `)||t.startsWith(`<attachment `)&&t.includes(`data-boring-agent="composer-file"`)}function hUe(e){return e.flatMap(e=>e.text.split(`
637
637
  `).flatMap(e=>{let t=e.trim(),n=gUe(t,`path`);if(n)return[n];let r=t.match(/^\[attached: .+ Saved in workspace at: (.+?) Use the workspace file\/read tools/);if(r?.[1])return[r[1]];let i=t.match(/^Saved in workspace at: (.+)$/);return i?.[1]?[i[1]]:[]}))}function gUe(e,t){if(!e.startsWith(`<attachment `)||!e.includes(`data-boring-agent="composer-file"`))return;let n=e.match(RegExp(`\\b${t}="([^"]*)"`));return n?.[1]?_Ue(n[1]):void 0}function _Ue(e){return e.replace(/&quot;/g,`"`).replace(/&gt;/g,`>`).replace(/&lt;/g,`<`).replace(/&amp;/g,`&`)}function vUe({text:e,visible:t=!0}){let[n,r]=(0,I.useState)(!1),i=()=>{r(!0),setTimeout(()=>r(!1),1500)},a=async()=>{if(!t)return;if(typeof navigator<`u`&&navigator.clipboard&&window.isSecureContext)try{await navigator.clipboard.writeText(e),i();return}catch{}if(typeof document>`u`)return;let n=document.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,``),n.style.position=`fixed`,n.style.opacity=`0`,n.style.pointerEvents=`none`,document.body.appendChild(n),n.select();try{document.execCommand(`copy`)&&i()}catch{}finally{document.body.removeChild(n)}},o=R(`inline-flex h-6 w-6 items-center justify-center rounded-[var(--radius-sm)]`,`text-muted-foreground/35 transition-colors`,`hover:bg-foreground/[0.04] hover:text-muted-foreground/80`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--accent)]/40`),s=t?{}:{tabIndex:-1};return(0,L.jsx)(`div`,{"aria-hidden":!t,className:R(`flex min-h-6 items-center gap-0.5 -mt-1 transition-opacity duration-200`,t?`opacity-100`:`pointer-events-none opacity-0`),children:(0,L.jsx)(Se,{type:`button`,variant:`ghost`,size:`xs`,onClick:a,className:o,"aria-label":n?`Copied`:`Copy message`,title:n?`Copied`:`Copy`,...s,children:n?(0,L.jsx)(br,{className:`h-3.5 w-3.5 text-[color:var(--accent)]`}):(0,L.jsx)(Fr,{className:`h-3.5 w-3.5`})})})}function yUe(e,t){return{type:`file`,id:e.id??e.url??e.filename??t,filename:e.filename,mediaType:e.mediaType??`application/octet-stream`,url:e.url??``}}function bUe(e,t,n){return`id`in t&&t.id?`${e}:${t.type}:${t.id}`:`${e}:${t.type}:${n}`}var Cz=60,xUe=40,wz=320;function SUe({chrome:e,emptyHero:t,messages:n,emptyStateHydrating:r,emptyState:i,suggestions:a,isStreaming:o,showThoughts:s,toolRenderers:c,runtimeNotices:l,onDismissNotice:u,renderNoticeAction:d,onScrollToBottomReady:f,onSuggestionSubmit:p,onRestoreDraft:m,windowResetKey:h}){let g=wUe(n),_=g.length,[v,y]=(0,I.useState)(Cz);(0,I.useEffect)(()=>{y(Cz)},[h]);let b=_>v,x=b?g.slice(_-v):g,S=b?_-v:0,C=(0,I.useCallback)(()=>{y(e=>e+xUe)},[]);return(0,L.jsxs)(que,{className:t?`max-h-[45vh] flex-none`:`flex-1`,"aria-label":`Agent conversation`,"aria-live":`polite`,onScrollToBottomReady:f,children:[(0,L.jsxs)(Jue,{className:R(`mx-auto flex w-full flex-col gap-6`,e?`max-w-3xl px-6 py-8`:`max-w-[680px] px-4 py-4`,t&&`py-4 text-center`),children:[n.length===0&&r?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl border border-border bg-card/70 px-4 py-3 text-sm text-muted-foreground`,children:[(0,L.jsx)(di,{className:`h-4 w-4 animate-spin`}),`Loading chat history…`]}):null,n.length===0&&!r?(0,L.jsx)(cee,{eyebrow:i?.eyebrow,title:i?.title,description:i?.description,footer:i?.footer,suggestions:a,className:t?`items-center text-center [&>p]:mx-auto`:void 0,onSelect:e=>{let t=e.prompt??e.label;t.trim()&&p({text:t,files:[],source:`suggestion`}).then(e=>{e===!1&&m(t)})}}):null,b?(0,L.jsx)(CUe,{olderCount:S,onLoadOlder:C}):null,x.map(({message:e,key:t},n)=>(0,L.jsx)(sUe,{message:e,isLast:n===x.length-1,isStreaming:o,showThoughts:s,toolRenderers:c},t)),(0,L.jsx)(tde,{notices:l,onDismiss:u,renderAction:d})]}),(0,L.jsx)(Yue,{})]})}function CUe({olderCount:e,onLoadOlder:t}){let{scrollRef:n}=Kv(),r=(0,I.useRef)(null),i=(0,I.useRef)(!0);return(0,I.useEffect)(()=>{let e=n.current;if(!e)return;let a=()=>{i.current&&e.scrollTop<=wz&&(i.current=!1,r.current=e.scrollHeight-e.scrollTop,t())};return e.addEventListener(`scroll`,a,{passive:!0}),()=>e.removeEventListener(`scroll`,a)},[n,t]),(0,I.useLayoutEffect)(()=>{let e=n.current;e&&(r.current!=null&&(e.scrollTop=e.scrollHeight-r.current,r.current=null),e.scrollTop>wz&&(i.current=!0))}),(0,L.jsx)(`div`,{className:`flex justify-center`,"data-boring-agent-part":`transcript-load-older`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:t,className:`rounded-full border border-border/60 px-3 py-1 text-[11px] text-muted-foreground transition-colors hover:text-foreground`,children:[`Load `,e,` older message`,e===1?``:`s`]})})}function wUe(e){let t=new Map;for(let n of e)n.role===`assistant`&&n.turnId&&t.set(n.turnId,(t.get(n.turnId)??0)+1);let n=new Map;return e.map(e=>{if(e.role!==`assistant`||!e.turnId)return{message:e,key:`message:${e.role}:${e.id}`};if((t.get(e.turnId)??0)<=1)return{message:e,key:`assistant-turn:${e.turnId}`};let r=n.get(e.turnId)??0;return n.set(e.turnId,r+1),{message:e,key:r===0?`assistant-turn:${e.turnId}`:`assistant-turn:${e.turnId}:message:${e.id}`}})}function Tz({tone:e,dataAttribute:t,runningContent:n,title:r,detail:i,message:a,children:o,onDismiss:s,onRetry:c,retryLabel:l=`Try again`,dismissAriaLabel:u=`Dismiss status`,maxWidthClassName:d=`max-w-3xl`}){let f={[t]:e};return e===`running`?(0,L.jsxs)(`div`,{...f,role:`status`,"aria-live":`polite`,className:R(`mx-auto mb-2 w-full rounded-[var(--radius-md)] border border-accent/30 bg-[color:var(--accent-soft)]`,`px-3 py-2 text-xs text-foreground flex items-center gap-2`,d),children:[(0,L.jsx)(`span`,{className:`inline-block h-2 w-2 animate-pulse rounded-full bg-accent`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{children:n})]}):e===`success`?(0,L.jsxs)(`div`,{...f,role:`status`,"aria-live":`polite`,className:R(`mx-auto mb-2 w-full rounded-[var(--radius-md)] border border-[oklch(0.78_0.13_148)]/35 bg-[oklch(0.95_0.05_148/0.28)]`,`px-3 py-2 text-xs text-foreground shadow-sm`,d),children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(`span`,{className:`mt-0.5 text-[oklch(0.45_0.13_148)]`,"aria-hidden":`true`,children:`✓`}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block font-medium leading-5`,children:r}),i?(0,L.jsx)(`span`,{className:`block leading-4 text-muted-foreground`,children:i}):null]}),s?(0,L.jsx)(`button`,{type:`button`,onClick:s,className:`-mr-1 rounded border border-transparent px-1.5 py-0.5 text-[13px] leading-none text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":u,children:`×`}):null]}),o]}):(0,L.jsxs)(`div`,{...f,role:`status`,"aria-live":`polite`,className:R(`mx-auto mb-2 w-full rounded-[var(--radius-md)] border border-destructive/40 bg-destructive/10`,`px-3 py-2 text-xs text-foreground`,d),children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-destructive`,"aria-hidden":`true`,children:`⚠`}),(0,L.jsx)(`span`,{className:`flex-1 font-medium`,children:r}),c?(0,L.jsx)(`button`,{type:`button`,onClick:c,className:`rounded border border-destructive/40 px-2 py-0.5 text-[11px] font-medium hover:bg-destructive/10`,children:l}):null,s?(0,L.jsx)(`button`,{type:`button`,onClick:s,className:`rounded border border-transparent px-2 py-0.5 text-[11px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":u,children:`Dismiss`}):null]}),a?(0,L.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words text-[11px] text-destructive/90`,children:a}):null]})}function TUe({state:e,onDismiss:t,onRetry:n,successAutoDismissMs:r=1400,maxWidthClassName:i=`max-w-3xl`}){let a=(0,I.useRef)(t);(0,I.useEffect)(()=>{a.current=t},[t]);let o=e?.kind===`success`?`${e.reloaded}:${(e.restartWarnings?.length??0)>0||(e.diagnostics?.length??0)>0}`:null;if((0,I.useEffect)(()=>{if(!e||e.kind!==`success`||r<=0||(e.restartWarnings?.length??0)>0||(e.diagnostics?.length??0)>0)return;let t=window.setTimeout(()=>a.current(),r);return()=>window.clearTimeout(t)},[e?.kind,o,r]),!e)return null;if(e.kind===`running`)return(0,L.jsx)(Tz,{tone:`running`,dataAttribute:`data-boring-plugin-update`,maxWidthClassName:i,runningContent:`Updating extensions…`});if(e.kind===`success`){let n=e.restartWarnings??[],r=e.diagnostics??[],a=e.frontEvents??[],o=n.length>0||r.length>0;return(0,L.jsxs)(Tz,{tone:`success`,dataAttribute:`data-boring-plugin-update`,maxWidthClassName:i,title:e.reloaded?o?`Reload finished with warnings`:`Reload complete`:`Reload queued`,detail:e.reloaded?o?`Some extension changes need attention.`:a.length>0?`${a.length} extension module${a.length===1?``:`s`} refreshed. Changes are live.`:`Changes are live.`:void 0,onDismiss:t,dismissAriaLabel:`Dismiss plugin update status`,children:[r.length>0?(0,L.jsxs)(`div`,{"data-boring-plugin-update-diagnostics":``,className:R(`mt-2 rounded border border-[oklch(0.78_0.15_85)]/40 bg-[oklch(0.95_0.06_85/0.4)]`,`px-2 py-1.5 text-[11px] text-foreground`),children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-[oklch(0.48_0.15_60)]`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),(0,L.jsxs)(`span`,{children:[`Reload diagnostics for `,r.length,` extension`,r.length===1?``:`s`]})]}),(0,L.jsx)(`ul`,{className:`mt-1 ml-4 list-disc text-foreground/85`,children:r.map((e,t)=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`code`,{className:`font-mono text-[10.5px]`,children:e.pluginId??e.source??`plugin`}),` — `,e.message??`reload diagnostic`]},`${e.pluginId??e.source??`plugin`}-${t}`))})]}):null,n.length>0?(0,L.jsxs)(`div`,{"data-boring-plugin-update-restart-warning":``,className:R(`mt-2 rounded border border-[oklch(0.78_0.15_85)]/40 bg-[oklch(0.95_0.06_85/0.4)]`,`px-2 py-1.5 text-[11px] text-foreground`),children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-[oklch(0.48_0.15_60)]`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),(0,L.jsxs)(`span`,{children:[`Restart needed for `,n.length,` extension`,n.length===1?``:`s`]})]}),(0,L.jsx)(`ul`,{className:`mt-1 ml-4 list-disc text-foreground/85`,children:n.map(e=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`code`,{className:`font-mono text-[10.5px]`,children:e.id}),` — `,e.surfaces.join(` + `)]},e.id))}),(0,L.jsx)(`p`,{className:`mt-1 text-foreground/70`,children:`The interface reloaded successfully, but routes and tools were wired at boot. Restart the workspace process to pick up the new code.`})]}):null]})}return(0,L.jsx)(Tz,{tone:`error`,dataAttribute:`data-boring-plugin-update`,maxWidthClassName:i,title:`Extension update failed.`,message:e.message,onRetry:n,onDismiss:t,retryLabel:`Try again`,dismissAriaLabel:`Dismiss plugin update status`})}function EUe({state:e,onDismiss:t,successAutoDismissMs:n=1400,maxWidthClassName:r=`max-w-3xl`}){let i=(0,I.useRef)(t);(0,I.useEffect)(()=>{i.current=t},[t]);let a=e?.kind===`success`?`${e.runId}:${e.command}:${e.detail??``}`:null;return(0,I.useEffect)(()=>{if(!e||e.kind!==`success`||n<=0)return;let t=window.setTimeout(()=>i.current(),n);return()=>window.clearTimeout(t)},[e?.kind,a,n]),e?e.kind===`running`?(0,L.jsx)(Tz,{tone:`running`,dataAttribute:`data-boring-command-run`,maxWidthClassName:r,runningContent:e.command?(0,L.jsxs)(L.Fragment,{children:[` Running `,(0,L.jsxs)(`code`,{className:`font-mono`,children:[`/`,e.command]}),`… `]}):`Running command…`}):e.kind===`success`?(0,L.jsx)(Tz,{tone:`success`,dataAttribute:`data-boring-command-run`,maxWidthClassName:r,title:e.command?(0,L.jsxs)(L.Fragment,{children:[` Ran `,(0,L.jsxs)(`code`,{className:`font-mono`,children:[`/`,e.command]}),` `]}):`Command ran`,detail:e.detail,onDismiss:t,dismissAriaLabel:`Dismiss command status`}):(0,L.jsx)(Tz,{tone:`error`,dataAttribute:`data-boring-command-run`,maxWidthClassName:r,title:e.command?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsxs)(`code`,{className:`font-mono`,children:[`/`,e.command]}),` failed. `]}):`Command failed.`,message:e.message,onDismiss:t,dismissAriaLabel:`Dismiss command status`}):null}function Ez(e){return(e.split(`/`).pop()??e).replace(/[-_]/g,` `).replace(/\s(\d+)\s(\d+)/g,` $1.$2`).replace(/\bgpt\b/g,`GPT`).replace(/\b(qwen|grok|glm|claude|sonnet|haiku|opus|codex|mini|max|spark|flash|turbo|pro|omni|mimo|deepseek|euryale)\b/g,e=>e.charAt(0).toUpperCase()+e.slice(1))}function Dz(e){let t={anthropic:`Anthropic`,openai:`OpenAI`,"openai-codex":`OpenAI Codex`,infomaniak:`Infomaniak`};return t[e]?t[e]:e.split(/[-_]/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var Oz=R(`inline-flex h-8 items-center justify-center gap-1.5 rounded-[var(--radius-md)] border-0 bg-transparent`,`text-muted-foreground shadow-none transition`,`hover:bg-muted/60 hover:text-foreground`,`focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,`disabled:pointer-events-none disabled:opacity-50`),kz={off:`Off`,low:`Low`,medium:`Med`,high:`High`},DUe={off:`off`,low:`low`,medium:`medium`,high:`high`},Az={off:`No extra reasoning`,low:`Light reasoning`,medium:`Balanced reasoning`,high:`Deep reasoning`},jz=R(Oz,`h-7 rounded-lg border border-border/60 bg-transparent px-2 text-[12px] font-medium text-muted-foreground`,`hover:border-border/80 hover:bg-muted/55 hover:text-foreground`),OUe=R(`rounded-xl border border-[color:var(--border)]`,`bg-[color:var(--popover)] p-1 text-[color:var(--popover-foreground)] shadow-xl`),Mz=R(`mb-1 w-full overflow-hidden rounded-lg border border-border/60`,`bg-[color:var(--popover)] text-[color:var(--popover-foreground)] shadow-lg`);function Nz(e){return R(`flex items-center gap-2 rounded-md px-2 py-1.5 text-[13px]`,`data-[selected=true]:bg-[color:oklch(from_var(--accent)_l_c_h/0.15)] data-[selected=true]:text-foreground`,e&&`bg-foreground/[0.06] text-foreground`)}function Pz(e){return e instanceof HTMLInputElement}function Fz(e,t){(0,I.useEffect)(()=>{if(!t)return;let n=n=>{let r=n.target;r instanceof Node&&e.current?.contains(r)||r instanceof Element&&r.closest(`[data-boring-agent-part="model-select"], [data-boring-agent-part="thinking-select"]`)||t()};return window.addEventListener(`pointerdown`,n,{capture:!0}),window.addEventListener(`mousedown`,n,{capture:!0}),()=>{window.removeEventListener(`pointerdown`,n,{capture:!0}),window.removeEventListener(`mousedown`,n,{capture:!0})}},[t,e])}function Iz({level:e}){let t=e===`off`?0:e===`low`?1:e===`medium`?2:3;return(0,L.jsx)(`svg`,{"aria-hidden":`true`,width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,className:`shrink-0`,children:[0,1,2].map(e=>(0,L.jsx)(`rect`,{x:2+e*4,y:10-e*2,width:`2`,height:3+e*2,rx:`0.5`,fill:`currentColor`,opacity:e<t?1:.25},e))})}function kUe(e,t){let n=e?t.find(t=>t.provider===e.provider&&t.id===e.id):void 0,r=n?.label??e?.id;return e?r&&n?.label&&n.label!==e.id&&/[A-Z]/.test(n.label)?n.label:Ez(r??e.id):`Default model`}function AUe(e,t){return t.filter(e=>e.available)}function jUe(e){let t=new Map;for(let n of e){let e=t.get(n.provider)??[];e.push(n),t.set(n.provider,e)}return t}var Lz=(0,I.forwardRef)(function({value:e,options:t,disabled:n,trigger:r=`button`,open:i=!1,onClick:a,className:o,...s},c){let l=kUe(e,t),u=e?`${l} (${Dz(e.provider)})`:l;return(0,L.jsx)(`button`,{ref:c,type:`button`,"data-boring-agent-part":`model-select`,"data-boring-state":n?`disabled`:void 0,disabled:n,"aria-label":r===`slash`?`Open model picker. Current model: ${u}`:`Model`,title:r===`slash`?`Open model picker. Current model: ${u}`:void 0,onClick:a,className:R(r===`slash`?`max-w-[min(52vw,260px)] cursor-pointer overflow-hidden text-ellipsis whitespace-nowrap rounded-[var(--radius-md)] px-1.5 py-0.5 transition-colors hover:bg-foreground/[0.045] hover:text-foreground/80 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground/20 disabled:pointer-events-none disabled:opacity-50`:jz,r===`slash`?`w-auto`:`w-auto max-w-[min(52vw,260px)] gap-1`,i&&(r===`slash`?`bg-muted/45`:`border-border/80 bg-muted/55 text-foreground`),o),...s,children:r===`slash`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`/model: `}),(0,L.jsx)(`span`,{className:`text-foreground`,children:u})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:u}),(0,L.jsx)(xr,{className:`h-3 w-3 shrink-0 text-muted-foreground/50`,"aria-hidden":`true`})]})})});function Rz({value:e,onChange:t,options:n,disabled:r,hideDefaultOption:i=!1,onClose:a,className:o}){let s=e?vd(e):null,c=AUe(e,n),l=jUe(c),u=[...l.values()].flat(),d=i?u:[null,...u],f=s?Math.max(0,d.findIndex(e=>e&&vd(e)===s)):0,[h,_]=(0,I.useState)(f),v=(0,I.useRef)(f),y=(0,I.useRef)(null);Fz(y,a);let b=e=>{let t=typeof e==`function`?e(v.current):e;v.current=t,_(t)};(0,I.useEffect)(()=>{b(f)},[f]),(0,I.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),a?.();return}r||Pz(e.target)||(e.key===`ArrowDown`?(e.preventDefault(),b(e=>Math.min(e+1,d.length-1))):e.key===`ArrowUp`?(e.preventDefault(),b(e=>Math.max(e-1,0))):(e.key===`Enter`||e.key===`Tab`)&&(e.preventDefault(),t(d[v.current]??null),a?.()))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[h,r,d,t,a]);let x=+!i,S=new Map(u.map((e,t)=>[vd(e),t+x]));return(0,L.jsx)(`div`,{ref:y,"data-boring-agent":``,"data-boring-agent-part":`model-picker-menu`,className:R(Mz,o),children:(0,L.jsxs)(ae,{className:`bg-transparent text-[color:var(--popover-foreground)]`,children:[c.length>8&&(0,L.jsx)(`div`,{className:`border-b border-border/60 px-2`,children:(0,L.jsx)(oe,{placeholder:`Search models…`,autoFocus:!0,className:`h-8 w-full border-0 bg-transparent text-[13px] outline-none focus:ring-0`})}),(0,L.jsxs)(m,{className:`max-h-[300px] p-0.5`,children:[(0,L.jsx)(p,{className:`py-4 text-center text-[13px] text-muted-foreground`,children:`No models found`}),i?null:(0,L.jsx)(it,{children:(0,L.jsxs)(g,{value:`Default model automatic auto`,onSelect:()=>{r||(t(null),a?.())},className:Nz(!e||h===0),children:[(0,L.jsx)(br,{className:R(`h-3.5 w-3.5 shrink-0`,e?`opacity-0`:`text-[color:var(--accent)] opacity-100`)}),(0,L.jsx)(`span`,{className:`truncate`,children:`Default model`}),(0,L.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-muted-foreground/60`,children:`auto`})]})}),[...l.entries()].map(([e,n])=>(0,L.jsx)(it,{heading:Dz(e),className:`[&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-[10px] [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-[0.08em] [&_[cmdk-group-heading]]:text-muted-foreground/60`,children:n.map(e=>{let n=vd(e),i=e.label||Ez(e.id),o=S.get(n)??0;return(0,L.jsxs)(g,{value:`${i} ${e.id} ${Dz(e.provider)}`,onSelect:()=>{r||(t(e),a?.())},className:R(Nz(n===s||h===o)),children:[(0,L.jsx)(br,{className:R(`h-3.5 w-3.5 shrink-0`,n===s?`text-[color:var(--accent)] opacity-100`:`opacity-0`)}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate whitespace-nowrap`,children:i}),(0,L.jsx)(`span`,{className:`ml-auto max-w-[45%] shrink-0 truncate whitespace-nowrap text-right text-[10px] text-muted-foreground/60`,children:e.id})]},n)})},e))]})]})})}function MUe({value:e,onChange:t,options:n,disabled:r,trigger:i=`button`,openSignal:a}){let[o,s]=(0,I.useState)(!1),c=(0,I.useRef)(a);return(0,I.useEffect)(()=>{r&&s(!1)},[r]),(0,I.useEffect)(()=>{if(r||a===void 0){c.current=a;return}c.current!==a&&s(!0),c.current=a},[r,a]),(0,L.jsxs)(_e,{open:o,onOpenChange:r?void 0:s,children:[(0,L.jsx)(Ze,{asChild:!0,children:(0,L.jsx)(Lz,{value:e,options:n,disabled:r,trigger:i,open:o})}),(0,L.jsx)(We,{align:i===`slash`?`center`:`start`,side:`top`,sideOffset:i===`slash`?54:6,collisionPadding:12,"data-boring-agent":``,className:R(`w-[min(92vw,340px)]`,OUe),children:(0,L.jsx)(Rz,{value:e,onChange:t,options:n,disabled:r,onClose:()=>s(!1),className:`mb-0 rounded-none border-0 bg-transparent shadow-none`})})]})}var NUe=(0,I.forwardRef)(function({value:e,disabled:t,trigger:n=`button`,open:r=!1,onClick:i,className:a,...o},s){return(0,L.jsxs)(`button`,{ref:s,type:`button`,"data-boring-agent-part":`thinking-select`,"data-boring-state":t?`disabled`:void 0,disabled:t,className:R(n===`slash`?`cursor-pointer rounded-[var(--radius-md)] px-1.5 py-0.5 transition-colors hover:bg-foreground/[0.045] hover:text-foreground/80 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground/20 disabled:pointer-events-none disabled:opacity-50`:jz,n===`button`&&`gap-1.5`,n===`button`&&e!==`off`&&!r&&`border-[color:oklch(from_var(--accent)_l_c_h/0.35)] bg-[color:oklch(from_var(--accent)_l_c_h/0.08)] text-foreground`,r&&(n===`slash`?`bg-muted/45`:`border-border/80 bg-muted/55 text-foreground`),a),"aria-label":`Thinking level: ${kz[e]}`,title:`Thinking: ${kz[e]}`,"data-testid":`thinking-select`,onClick:i,...o,children:[n===`button`?(0,L.jsx)(Iz,{level:e}):null,n===`slash`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`/thinking: `}),(0,L.jsx)(`span`,{className:`text-foreground`,children:DUe[e]})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{children:kz[e]}),(0,L.jsx)(xr,{className:`h-3 w-3 shrink-0 text-muted-foreground/50`,"aria-hidden":`true`})]})]})});function PUe({value:e,onChange:t,disabled:n,onClose:r,className:i}){let a=Math.max(0,hd.indexOf(e)),[o,s]=(0,I.useState)(a),c=(0,I.useRef)(a),l=(0,I.useRef)(null);Fz(l,r);let u=e=>{let t=typeof e==`function`?e(c.current):e;c.current=t,s(t)};return(0,I.useEffect)(()=>{u(a)},[a]),(0,I.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),r?.();return}n||Pz(e.target)||(e.key===`ArrowDown`?(e.preventDefault(),u(e=>Math.min(e+1,hd.length-1))):e.key===`ArrowUp`?(e.preventDefault(),u(e=>Math.max(e-1,0))):(e.key===`Enter`||e.key===`Tab`)&&(e.preventDefault(),t(hd[c.current]),r?.()))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[o,n,t,r]),(0,L.jsx)(`div`,{ref:l,"data-boring-agent":``,"data-boring-agent-part":`thinking-picker-menu`,className:R(Mz,i),children:(0,L.jsx)(ae,{className:`bg-transparent text-[color:var(--popover-foreground)]`,children:(0,L.jsx)(m,{className:`max-h-[300px] p-0.5`,children:hd.map((i,a)=>(0,L.jsxs)(g,{value:`Thinking ${kz[i]} ${Az[i]}`,onSelect:()=>{n||(t(i),r?.())},className:Nz(i===e||a===o),children:[(0,L.jsx)(br,{className:R(`h-3.5 w-3.5 shrink-0`,i===e?`text-[color:var(--accent)] opacity-100`:`opacity-0`)}),(0,L.jsx)(Iz,{level:i}),(0,L.jsx)(`span`,{className:`font-medium`,children:kz[i]}),(0,L.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground/65`,children:Az[i]})]},i))})})})}var FUe=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,zz=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=FUe[n[e]&63];return t},IUe=(0,I.createContext)(null),LUe=(0,I.createContext)(null),Bz=()=>(0,I.useContext)(IUe),RUe=()=>(0,I.useContext)(LUe),Vz=(0,I.createContext)(null),Hz=()=>{let e=RUe(),t=(0,I.useContext)(Vz)??e;if(!t)throw Error(`usePromptInputAttachments must be used within a PromptInput or PromptInputProvider`);return t},zUe=(0,I.createContext)(null),BUe=({align:e=`block-end`,className:t,...n})=>(0,L.jsx)(w,{align:e,className:R(`justify-between gap-1`,t),...n}),VUe=({className:e,accept:t,multiple:n,globalDrop:r,syncHiddenInput:i,maxFiles:a,maxFileSize:o,onError:s,onSubmit:c,onUploadFile:l,children:u,...d})=>{let f=Bz(),p=!!f,m=(0,I.useRef)(``);p&&(m.current=f.textInput.value);let h=(0,I.useRef)(null),g=(0,I.useRef)(null),[_,v]=(0,I.useState)([]),y=(0,I.useCallback)((e,t,n,r)=>{v(i=>i.map(i=>i.id===e?(i.url!==t&&i.url.startsWith(`blob:`)&&URL.revokeObjectURL(i.url),{...i,url:t,status:n,...r?{path:r}:{}}):i))},[]),b=p?f.attachments.files:_,[x,S]=(0,I.useState)([]),C=(0,I.useRef)(b);(0,I.useEffect)(()=>{C.current=b},[b]);let w=(0,I.useCallback)(()=>{h.current?.click()},[]),E=(0,I.useCallback)(e=>!t||t.trim()===``||t.split(`,`).map(e=>e.trim()).filter(Boolean).some(t=>{if(t.endsWith(`/*`)){let n=t.slice(0,-1);return e.type.startsWith(n)}return e.type===t}),[t]),D=(0,I.useCallback)(e=>{let t=[...e],n=t.filter(e=>E(e));if(t.length&&n.length===0){s?.({code:`accept`,message:`No files match the accepted types.`});return}let r=n.filter(e=>!o||e.size<=o);if(n.length>0&&r.length===0){s?.({code:`max_file_size`,message:`All files exceed the maximum size.`});return}let i=typeof a==`number`?Math.max(0,a-_.length):void 0,c=typeof i==`number`?r.slice(0,i):r;typeof i==`number`&&r.length>i&&s?.({code:`max_files`,message:`Too many files. Some were not added.`});let u=c.map(e=>({filename:e.name,id:zz(),mediaType:e.type,type:`file`,url:URL.createObjectURL(e),status:l?`uploading`:`ready`}));if(v(e=>[...e,...u]),l)for(let e=0;e<u.length;e++){let t=u[e],n=c[e];l(n).then(({url:e,path:n})=>y(t.id,e,`ready`,n)).catch(()=>y(t.id,t.url,`error`))}},[E,a,o,s,_.length,l,y]),O=(0,I.useCallback)(e=>v(t=>{let n=t.find(t=>t.id===e);return n?.url.startsWith(`blob:`)&&URL.revokeObjectURL(n.url),t.filter(t=>t.id!==e)}),[]),k=(0,I.useCallback)(e=>{let t=[...e],n=t.filter(e=>E(e));if(t.length&&n.length===0){s?.({code:`accept`,message:`No files match the accepted types.`});return}let r=n.filter(e=>!o||e.size<=o);if(n.length>0&&r.length===0){s?.({code:`max_file_size`,message:`All files exceed the maximum size.`});return}let i=b.length,c=typeof a==`number`?Math.max(0,a-i):void 0,l=typeof c==`number`?r.slice(0,c):r;typeof c==`number`&&r.length>c&&s?.({code:`max_files`,message:`Too many files. Some were not added.`}),l.length>0&&f?.attachments.add(l)},[E,o,a,s,b.length,f]),A=(0,I.useCallback)(()=>p?f?.attachments.clear():v(e=>{for(let t of e)t.url.startsWith(`blob:`)&&URL.revokeObjectURL(t.url);return[]}),[p,f]),ee=(0,I.useCallback)(()=>S([]),[]),te=p?k:D,ne=p?f.attachments.remove:O,j=p?f.attachments.openFileDialog:w,M=(0,I.useCallback)(()=>{A(),ee()},[A,ee]);(0,I.useEffect)(()=>{p&&f.__registerFileInput(h,()=>h.current?.click())},[p,f]),(0,I.useEffect)(()=>{i&&h.current&&b.length===0&&(h.current.value=``)},[b,i]),(0,I.useEffect)(()=>{let e=g.current;if(!e||r)return;let t=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},n=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&te(e.dataTransfer.files)};return e.addEventListener(`dragover`,t),e.addEventListener(`drop`,n),()=>{e.removeEventListener(`dragover`,t),e.removeEventListener(`drop`,n)}},[te,r]),(0,I.useEffect)(()=>{if(!r)return;let e=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},t=e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&te(e.dataTransfer.files)};return document.addEventListener(`dragover`,e),document.addEventListener(`drop`,t),()=>{document.removeEventListener(`dragover`,e),document.removeEventListener(`drop`,t)}},[te,r]),(0,I.useEffect)(()=>()=>{if(!p)for(let e of C.current)e.url&&URL.revokeObjectURL(e.url)},[p]);let N=(0,I.useCallback)(e=>{e.currentTarget.files&&te(e.currentTarget.files),e.currentTarget.value=``},[te]),re=p?f.attachments.setFileUrl:y,ie=(0,I.useMemo)(()=>({add:te,clear:A,fileInputRef:h,files:b.map(e=>({...e,id:e.id})),openFileDialog:j,remove:ne,setFileUrl:re}),[b,te,ne,A,j,re]),ae=(0,I.useMemo)(()=>({add:e=>{let t=Array.isArray(e)?e:[e];S(e=>[...e,...t.map(e=>({...e,id:zz()}))])},clear:ee,remove:e=>{S(t=>t.filter(t=>t.id!==e))},sources:x}),[x,ee]),oe=(0,I.useCallback)(async e=>{e.preventDefault();let t=e.currentTarget,n=p?f.textInput.value:new FormData(t).get(`message`)||``;if(!b.some(e=>e.status===`uploading`)){p?(f.textInput.clear(),m.current=``):t.reset();try{if(await c({files:await Promise.all(b.map(async({id:e,status:t,...n})=>{if(n.url?.startsWith(`blob:`)){let e=await Ug(n.url);return{...n,url:e??n.url}}return n})),text:n},e)===!1){if(p)m.current===``&&(f.textInput.setInput(n),m.current=n);else{let e=t.elements.namedItem(`message`);e&&e.value===``&&(e.value=n)}return}M(),p&&(m.current===``||m.current===n)&&(f.textInput.clear(),m.current=``)}catch{if(p)m.current===``&&(f.textInput.setInput(n),m.current=n);else{let e=t.elements.namedItem(`message`);e&&e.value===``&&(e.value=n)}}}},[p,f,b,c,M]),se=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(T,{accept:t,"aria-label":`Upload files`,className:`hidden`,multiple:n,onChange:N,ref:h,title:`Upload files`,type:`file`}),(0,L.jsx)(`form`,{"data-boring-agent-part":`composer`,className:R(`w-full`,e),onSubmit:oe,ref:g,...d,children:(0,L.jsx)(qe,{className:`overflow-hidden`,children:u})})]}),ce=(0,L.jsx)(zUe.Provider,{value:ae,children:se});return(0,L.jsx)(Vz.Provider,{value:ie,children:ce})},HUe=({onChange:e,onKeyDown:t,className:n,placeholder:r=`What would you like to know?`,...i})=>{let a=Bz(),o=Hz(),[s,c]=(0,I.useState)(!1),l=(0,I.useCallback)(e=>{if(t?.(e),!e.defaultPrevented){if(e.key===`Enter`){if(s||e.nativeEvent.isComposing||e.shiftKey)return;e.preventDefault();let{form:t}=e.currentTarget;if(t?.querySelector(`button[type="submit"]`)?.disabled)return;t?.requestSubmit()}if(e.key===`Backspace`&&e.currentTarget.value===``&&o.files.length>0){e.preventDefault();let t=o.files.at(-1);t&&o.remove(t.id)}}},[t,s,o]),u=(0,I.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`){let t=e.getAsFile();t&&n.push(t)}n.length>0&&(e.preventDefault(),o.add(n))},[o]),d=(0,I.useCallback)(()=>c(!1),[]),f=(0,I.useCallback)(()=>c(!0),[]),p=a?{onChange:t=>{a.textInput.setInput(t.currentTarget.value),e?.(t)},value:a.textInput.value}:{onChange:e};return(0,L.jsx)(de,{"data-boring-agent-part":`composer-input`,className:R(`field-sizing-content max-h-48 min-h-16`,n),name:`message`,onCompositionEnd:d,onCompositionStart:f,onKeyDown:l,onPaste:u,placeholder:r,...i,...p})},UUe=({className:e,variant:t=`default`,size:n=`icon-sm`,status:r,onStop:i,onClick:a,children:o,...s})=>{let c=r===`submitted`||r===`streaming`,l=(0,L.jsx)(Ir,{className:`size-4`});r===`submitted`?l=(0,L.jsx)(ot,{}):r===`streaming`?l=(0,L.jsx)(Bi,{className:`size-4`}):r===`error`&&(l=(0,L.jsx)(ea,{className:`size-4`}));let u=(0,I.useCallback)(e=>{if(c&&i){e.preventDefault(),i();return}a?.(e)},[c,i,a]);return(0,L.jsx)(fe,{"aria-label":c?`Stop`:`Submit`,className:R(e),"data-boring-agent-submit-status":r??`ready`,onClick:u,size:n,type:c&&i?`button`:`submit`,variant:t,...s,children:o??l})},Uz=`__all__`;function Wz(e){return e.source===`skill`?`skills`:e.sourcePlugin?e.sourcePlugin:`built-in`}function WUe({query:e,commands:t,onSelect:n,onDismiss:r}){let[i,a]=(0,I.useState)(Uz),[o,s]=(0,I.useState)(e),[c,l]=(0,I.useState)(0),u=(0,I.useRef)(null),d=(0,I.useRef)(null),f=(0,I.useRef)(null);(0,I.useEffect)(()=>{s(e)},[e]);let p=(0,I.useMemo)(()=>{let e=new Set(t.map(Wz));return Array.from(e).sort((e,t)=>e.localeCompare(t))},[t]),m=(0,I.useMemo)(()=>{let e=o.trim().toLowerCase();return t.filter(t=>i!==Uz&&Wz(t)!==i?!1:!e||t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e))},[t,o,i]);return(0,I.useEffect)(()=>{l(e=>m.length===0?0:Math.min(e,m.length-1))},[m.length]),(0,I.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&r()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]),Vg({count:m.length,activeIdx:c,setActiveIdx:l,listRef:d,onSelect:e=>{m[e]&&n(m[e].name)},onDismiss:r}),(0,L.jsxs)(`div`,{ref:u,className:`mb-1 w-full overflow-hidden rounded-lg border border-border/60 bg-popover shadow-lg`,children:[(0,L.jsx)(`input`,{ref:f,"aria-label":`Search commands`,type:`text`,value:o,onChange:e=>{s(e.target.value),l(0)},className:`w-full border-b border-border/50 bg-transparent px-3 py-1.5 text-[12px] outline-none`,autoComplete:`off`}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1 border-b border-border/50 px-2 py-1.5`,role:`tablist`,"aria-label":`Filter by plugin`,children:[Uz,...p].map(e=>{let t=i===e;return(0,L.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,onMouseDown:t=>{t.preventDefault(),a(e),l(0)},className:R(`rounded-full px-2 py-px text-[10px] font-medium transition-colors`,t?`bg-accent/15 text-accent-foreground`:`bg-muted/60 text-muted-foreground hover:bg-muted`),children:e===Uz?`All`:e},e)})}),m.length===0?(0,L.jsx)(`div`,{className:`px-3 py-2 text-[11px] text-muted-foreground`,children:`No matching commands.`}):(0,L.jsx)(`ul`,{ref:d,className:`max-h-80 overflow-y-auto py-1`,role:`listbox`,"aria-label":`Commands`,children:m.map((e,t)=>(0,L.jsxs)(`li`,{role:`option`,"aria-selected":t===c,title:e.description||void 0,className:R(`flex cursor-pointer flex-col gap-0.5 px-3 py-1.5 text-[12px]`,t===c?`bg-accent/10 text-foreground`:`text-muted-foreground`),onMouseEnter:()=>l(t),onMouseDown:t=>{t.preventDefault(),n(e.name)},children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,L.jsxs)(`span`,{className:`font-medium text-foreground/80`,children:[`/`,e.name]}),e.source===`skill`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`rounded-sm bg-accent/15 px-1 py-px text-[9px] font-medium uppercase tracking-wide text-accent-foreground`,children:`skill`}),e.sourcePlugin?(0,L.jsx)(`span`,{className:`rounded-sm bg-muted px-1 py-px text-[9px] font-medium text-muted-foreground`,children:e.sourcePlugin}):null]}):e.sourcePlugin?(0,L.jsx)(`span`,{className:`rounded-sm bg-muted px-1 py-px text-[9px] font-medium text-muted-foreground`,children:e.sourcePlugin}):null]}),(0,L.jsx)(`span`,{className:`truncate text-[11px] opacity-50`,children:e.description})]},e.name))})]})}function GUe({disabled:e,className:t}){let n=Hz();return(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e,onClick:()=>{e||n.openFileDialog()},className:R(Oz,`w-8`,t),"aria-label":`Attach files`,title:e?`Attachments are available when the composer is ready.`:`Attach files`,children:(0,L.jsx)(Ei,{className:`h-3.5 w-3.5`,strokeWidth:1.75})})}function KUe(){let e=Hz();return e.files.length===0?null:(0,L.jsx)(ey,{"data-boring-agent-part":`composer-attachment-row`,"data-align":`block-start`,variant:`inline`,className:`w-full flex-wrap items-center justify-start gap-2 px-5 pb-0 pt-3`,children:e.files.map(t=>(0,L.jsxs)(ty,{data:t,onRemove:()=>e.remove(t.id),className:R(`!h-9 !gap-2 !rounded-full !border-input/80 !bg-muted/40 !pl-1 !pr-2`,`transition-colors hover:!bg-muted/70 hover:!text-foreground`,t.status===`error`&&`!border-destructive/50 !bg-destructive/10`),children:[(0,L.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,L.jsx)(ny,{className:`!size-7 overflow-hidden !rounded-full bg-background/60`}),t.status===`uploading`?(0,L.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-full bg-background/70`,children:(0,L.jsx)(di,{className:`size-3.5 animate-spin text-muted-foreground`})}):null,t.status===`error`?(0,L.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-full bg-destructive/20`,children:(0,L.jsx)(Tr,{className:`size-3.5 text-destructive`})}):null]}),(0,L.jsx)(ry,{className:`min-w-0 !max-w-[180px] truncate text-[13px] font-medium`}),(0,L.jsx)(dde,{className:`!size-5 !rounded-full !opacity-100 text-muted-foreground/80 hover:text-foreground`})]},t.id))})}var Gz=2,qUe=4*1024*1024,Kz=56,qz=160,JUe=8,YUe=16;function XUe(e,t){let n=Number.parseFloat(t.paddingLeft)||0,r=Number.parseFloat(t.paddingRight)||0,i=e.clientWidth-n-r;if(i<=0)return!1;let a=document.createElement(`canvas`).getContext(`2d`);if(!a)return!1;a.font=t.font;let o=Number.parseFloat(t.letterSpacing)||0;return e.value.split(`
638
638
  `).some(e=>a.measureText(e||` `).width+Math.max(0,e.length-1)*o>i+1)}function ZUe({chrome:e,isStreaming:t,status:n,disabled:r,submitStatus:i,submitDisabled:a,composerBlocked:o,composerBlockerLabel:s,composerPlaceholder:c,composerStatusNotice:l,workspaceWarmupBlocked:u,primaryComposerBlocker:d,onComposerBlockerAction:f,queuePreview:p,onEditQueued:m,hotReloadEnabled:h,pluginUpdateState:g,onDismissPluginUpdate:_,onRunPluginUpdate:v,commandNotifyState:y,onDismissCommandNotify:b,attachmentNotice:x,onAttachmentNotice:S,mentionState:C,slashQuery:w,apiBaseUrl:T,fetch:E,requestHeaders:D,storageScope:O,onSelectMention:k,onDismissMention:A,commands:ee,onSelectSlashCommand:te,onDismissSlash:ne,modelPickerOpen:j,selectedModel:M,modelOptions:N,modelControlled:re,hideDefaultModelOption:ie=!1,hideComposerSettings:ae=!1,onModelChange:oe,onSetModelPickerOpen:se,onOpenModelPicker:ce,thinkingPickerOpen:le,selectedThinking:ue,thinkingControl:de,thinkingControlled:fe,onThinkingChange:pe,onSetThinkingPickerOpen:me,onOpenThinkingPicker:he,draft:ge,textareaRef:_e,onTextareaChange:ve,onTextareaKeyDown:ye,onSubmitMessage:be,onStop:xe}){let Se=QUe(D,`x-boring-workspace-id`),Ce=(0,I.useCallback)(e=>sd(e,{apiBaseUrl:T,workspaceRequestId:Se,responseUrl:`raw`,fetch:E}),[T,E,Se]),we=(0,I.useCallback)(e=>{if(!e)return;e.style.height=`auto`;let t=window.getComputedStyle(e),n=Number.parseFloat(t.lineHeight)||24,r=Number.parseFloat(t.paddingTop)||0,i=Number.parseFloat(t.paddingBottom)||0,a=n+r+i,o=e.value.includes(`
639
- `),s=e.value.length>0&&XUe(e,t),c=o||s,l=c?JUe:0,u=c?e.scrollHeight+l:a,d=Math.min(u,qz);e.style.height=`${d}px`,e.style.overflowY=u>qz?`auto`:`hidden`;let f=e.closest(`[data-boring-agent-part="composer-rail"]`),p=c?Math.max(Kz,d+YUe):Kz;f?.style.setProperty(`--composer-input-group-height`,`${p}px`),f?.setAttribute(`data-composer-multiline`,p>Kz?`true`:`false`)},[]);return(0,I.useLayoutEffect)(()=>{we(_e.current)},[ge,we,_e]),(0,L.jsxs)(`div`,{className:R(`relative z-20`,e?`px-4 pb-4 pt-2 sm:px-6 sm:pb-5`:`px-3 pb-2 pt-1`),children:[(0,L.jsx)(`div`,{"data-boring-agent-part":`chat-working-slot`,className:R(`mx-auto w-full overflow-hidden transition-[margin,max-height,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]`,e?`max-w-3xl`:`max-w-[680px]`,t?`mb-2 max-h-8 opacity-100`:`mb-0 max-h-0 opacity-0`),"aria-hidden":!t,children:(0,L.jsxs)(`div`,{"data-testid":t?`chat-working`:void 0,role:t?`status`:void 0,"aria-live":t?`polite`:void 0,className:`inline-flex items-center gap-2 rounded-full border border-border/50 bg-background/85 px-2.5 py-1 text-[12px] text-muted-foreground/75 shadow-sm backdrop-blur`,children:[(0,L.jsx)(pz.span,{"aria-hidden":`true`,className:`inline-block size-1.5 rounded-full bg-[color:var(--accent)]`,animate:{opacity:[.35,1,.35]},transition:{duration:1.2,repeat:1/0,ease:`easeInOut`}}),(0,L.jsx)(`span`,{children:`Working…`})]})}),l?(0,L.jsx)(nde,{notice:l}):null,o&&!u?(0,L.jsx)(ide,{blocker:d,label:s,onAction:f}):null,p.length>0?(0,L.jsx)(ode,{followUps:p,onEdit:m}):null,h?(0,L.jsx)(TUe,{state:g,onDismiss:_,onRetry:v}):null,(0,L.jsx)(EUe,{state:y,onDismiss:b}),x?(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:qv(`info`,`mx-auto mb-2 w-full max-w-3xl text-xs`),children:x}):null,(0,L.jsxs)(`div`,{className:R(`mx-auto w-full`,e?`max-w-3xl`:`max-w-[680px]`),children:[C?(0,L.jsx)(_se,{mention:C,apiBaseUrl:T,fetch:E,requestHeaders:D,storageScope:O,onSelect:k,onDismiss:A}):null,w===null?null:(0,L.jsx)(WUe,{query:w,commands:ee,onSelect:te,onDismiss:ne}),C===null&&w===null&&j?(0,L.jsx)(Rz,{value:M,onChange:oe,options:N,disabled:t||re,hideDefaultOption:ie,onClose:()=>se(!1)}):null,C===null&&w===null&&le?(0,L.jsx)(PUe,{value:ue,onChange:pe,disabled:t||fe,onClose:()=>me(!1)}):null]}),(0,L.jsx)(`div`,{"data-boring-agent-part":`composer-rail`,"data-composer-multiline":`false`,style:{"--composer-input-group-height":`${Kz}px`},className:R(`relative mx-auto w-full overflow-visible rounded-[28px]`,e?`max-w-3xl bg-transparent shadow-[0_1px_2px_-1px_oklch(0_0_0/0.06),0_6px_18px_-12px_oklch(0_0_0/0.12),inset_0_0_0_1px_oklch(from_var(--border)_l_c_h/0.7)] focus-within:shadow-[0_1px_3px_-1px_oklch(0_0_0/0.08),0_10px_28px_-14px_oklch(0_0_0/0.16),inset_0_0_0_1px_oklch(from_var(--accent)_l_c_h/0.45)]`:`max-w-[680px] bg-transparent shadow-[inset_0_0_0_1px_oklch(from_var(--border)_l_c_h/0.7)] focus-within:shadow-[inset_0_0_0_1px_oklch(from_var(--accent)_l_c_h/0.45)]`,`transition-shadow duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]`,`[&_[data-slot=input-group]]:!h-auto [&_[data-slot=input-group]]:!min-h-[var(--composer-input-group-height)]`,`[&_[data-slot=input-group]]:!flex-col [&_[data-slot=input-group]]:!items-stretch [&_[data-slot=input-group]]:!overflow-hidden`,`[&_[data-slot=input-group]]:!border-0 [&_[data-slot=input-group]]:!rounded-[28px]`,`[&_[data-slot=input-group]]:!bg-transparent [&_[data-slot=input-group]]:!shadow-none`,`[&_[data-slot=input-group]]:dark:!bg-transparent [&_[data-slot=input-group]]:!ring-0`,`[&_[data-slot=input-group]]:has-[:focus]:!ring-0`,`[&[data-composer-multiline=true]_[data-boring-agent-part=composer-submit-addon]]:self-end`,`[&[data-composer-multiline=true]_[data-boring-agent-part=composer-submit-addon]]:mb-2`),children:(0,L.jsxs)(VUe,{"data-boring-state":n,onSubmit:e=>be({text:e.text,files:e.files}),onUploadFile:Ce,multiple:!0,maxFiles:r||t?0:Gz,maxFileSize:qUe,onError:e=>{e.code===`max_files`?S(`Up to ${Gz} attachments per message.`):e.code===`max_file_size`?S(`Files must be under 4 MB each.`):e.code===`accept`?S(`That file type isn't supported here.`):S(e.message||`Attachment rejected.`)},children:[(0,L.jsx)(KUe,{}),(0,L.jsxs)(`div`,{"data-boring-agent-part":`composer-input-row`,className:`flex min-h-[var(--composer-input-group-height)] w-full items-center`,children:[(0,L.jsx)(`div`,{className:`flex h-14 shrink-0 items-center pl-2`,children:(0,L.jsx)(GUe,{disabled:r||t})}),(0,L.jsx)(HUe,{value:ge,placeholder:o?u?s:``:c??`Ask anything…`,disabled:r,readOnly:o,"aria-label":`Agent prompt`,ref:e=>{_e.current=e,we(e)},onChange:ve,onKeyDown:ye,style:{fieldSizing:`fixed`},className:R(`min-w-0 flex-1 !min-h-10 !max-h-40 resize-none overflow-hidden border-0 bg-transparent shadow-none`,`[field-sizing:fixed]`,`px-2 py-2 text-[13px] leading-6`,`placeholder:text-muted-foreground/45`,`focus-visible:ring-0 focus-visible:ring-offset-0`)}),(0,L.jsx)(BUe,{align:`inline-end`,"data-boring-agent-part":`composer-submit-addon`,className:`!order-none !w-auto shrink-0 self-center justify-between border-0 bg-transparent !px-2 !py-0`,children:(0,L.jsx)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:(0,L.jsx)(UUe,{"data-boring-agent-part":`composer-submit`,status:i,onStop:xe,disabled:a,className:R(`h-8 w-8 shrink-0 rounded-full`,`bg-foreground`,`text-background`,`transition-all duration-150 ease-[cubic-bezier(0.22,1,0.36,1)]`,`hover:bg-foreground/90 hover:shadow-[0_0_0_3px_oklch(from_var(--foreground)_l_c_h/0.12)] hover:scale-[1.04]`,`active:scale-[0.93] active:brightness-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/20`,`disabled:pointer-events-none disabled:opacity-40`,`[&>svg]:size-3.5`)})})})]})]})}),ae?null:(0,L.jsxs)(`div`,{"data-boring-agent-part":`composer-settings-row`,className:R(`mx-auto mt-1.5 flex w-full items-center justify-center gap-1.5 text-[10.5px] text-muted-foreground/45`,e?`max-w-3xl`:`max-w-[680px]`),children:[(0,L.jsx)(Lz,{value:M,options:N,disabled:t||re,trigger:`slash`,open:j,onClick:()=>{if(j){se(!1);return}ce()}}),de?(0,L.jsx)(NUe,{value:ue,disabled:t||fe,trigger:`slash`,open:le,onClick:()=>{if(le){me(!1);return}he()}}):null]})]})}function QUe(e,t){if(e)return e[t]??Object.entries(e).find(([e])=>e.toLowerCase()===t.toLowerCase())?.[1]}function $Ue({sessionId:e,workspaceId:t,storageScope:n,apiBaseUrl:r,requestHeaders:i,fetch:a,createRemoteSession:o,remoteSessionOptions:s}){let[c,l]=(0,I.useState)(),u=(0,I.useRef)(s);return u.current=s,(0,I.useEffect)(()=>{if(!e){l(void 0);return}let s=(o??lv)({...u.current,sessionId:e,workspaceId:t,storageScope:n,apiBaseUrl:r,headers:i,fetch:a});return l(s),()=>s.dispose()},[r,o,a,(0,I.useMemo)(()=>tWe(s),[s]),i,e,n,t]),c}var Jz=new WeakMap,eWe=0;function Yz(e){if(typeof e!=`object`&&typeof e!=`function`||e===null)return;let t=e,n=Jz.get(t);return n||(n=++eWe,Jz.set(t,n)),String(n)}function tWe(e){return e?JSON.stringify({autoStart:e.autoStart,requestTimeoutMs:e.requestTimeoutMs,onEvent:Yz(e.onEvent),storeOptions:Yz(e.storeOptions),setTimeoutFn:Yz(e.setTimeoutFn),clearTimeoutFn:Yz(e.clearTimeoutFn),reconnect:e.reconnect?{baseMs:e.reconnect.baseMs,maxMs:e.reconnect.maxMs,jitterRatio:e.reconnect.jitterRatio,random:Yz(e.reconnect.random)}:void 0,debug:e.debug?{largeStateWarningBytes:e.debug.largeStateWarningBytes,largeStateWarningMessages:e.debug.largeStateWarningMessages,onWarning:Yz(e.debug.onWarning)}:void 0}):`{}`}function nWe(e){return(0,I.useSyncExternalStore)((0,I.useCallback)(t=>e?.subscribe(t)??(()=>{}),[e]),(0,I.useCallback)(()=>e?.getState(),[e]),(0,I.useCallback)(()=>e?.getState(),[e]))}function rWe(e){return JSON.stringify(aWe(e).sort(([e],[t])=>e.localeCompare(t)))}function iWe(e){let t=JSON.parse(e);return t.length>0?Object.fromEntries(t):void 0}function aWe(e){return Object.entries(e??{}).filter(e=>typeof e[1]==`string`)}function oWe(e,t){return e?.status??(t?`hydrating`:`idle`)}function Xz(e,t){if(!e)return!0;let n=e.getState();return n.status===`idle`?t===void 0||n.lastSeq<t:!1}function Zz(e){return e===`submitted`||e===`streaming`||e===`aborting`}function sWe(e){return e===`submitted`||e===`hydrating`?`submitted`:e===`streaming`||e===`aborting`?`streaming`:e===`error`?`error`:`ready`}function cWe(e,t){let n=t.filter(e=>e.available),r=e.trim(),i=Number.parseInt(r,10);if(Number.isInteger(i)&&String(i)===r&&i>=1&&i<=n.length)return n[i-1]??null;let a=n.find(e=>`${e.provider}:${e.id}`===r||e.id===r);if(a)return a;let o=r.toLowerCase();return n.find(e=>{let t=e.label?.toLowerCase()??``,n=e.id.toLowerCase(),r=e.provider.toLowerCase();return t.includes(o)||n.includes(o)||`${r}:${n}`.includes(o)})??null}function lWe(e){let t=e.trim().toLowerCase();return t===`med`?`medium`:hd.find(e=>e===t)??null}function uWe(e){return e===`off`?`Off`:e===`low`?`Low`:e===`medium`?`Med`:`High`}function dWe(e){return{id:e.id,role:e.role===`system`?`assistant`:e.role,parts:e.parts.map(t=>t.type===`text`?{type:`text`,text:e.role===`user`?`[redacted user message]`:t.text}:t.type===`file`?{type:`file`,mediaType:t.mediaType??`application/octet-stream`,filename:t.filename?`[redacted attachment filename]`:void 0,url:t.url?`[redacted attachment url]`:``}:t.type===`reasoning`?{type:`reasoning`,text:`[redacted reasoning]`}:{type:`text`,text:t.type===`notice`?t.text:`[tool] ${t.toolName}`})}}function fWe(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.type!=`string`)return null;let n=typeof t.id==`string`?t.id:void 0,r=typeof t.revision==`number`?`revision ${t.revision}`:`updated`;switch(t.type){case`boring.plugin.load`:return{kind:`success`,diagnostic:{source:`browser front reload`,...n?{pluginId:n}:{},message:`front module loaded (${r})`}};case`boring.plugin.unload`:return{kind:`success`,diagnostic:{source:`browser front reload`,...n?{pluginId:n}:{},message:`front module unloaded (${r})`}};case`boring.plugin.error`:case`boring.plugin.front-error`:{let e=typeof t.message==`string`&&t.message.length>0?t.message:`browser front module failed to load`;return{kind:`error`,message:`Plugin front failed${n?` (${n})`:``}: ${e}. Previous live version was kept.`}}default:return null}}function pWe(e){let t=e.trim().split(/\r?\n/).find(e=>e.trim().length>0)?.trim()??``;return/^agent plugins reloaded\.?$/i.test(t)||/^agent plugins will reload on the next message\.?$/i.test(t)?null:e}function mWe(e){return e.type===`agent-end`}function Qz(e,t){return e instanceof Error&&e.message?e.message:t}var hWe=(0,I.lazy)(()=>P(()=>import(`./DebugDrawer-CmBNqdMZ.js`).then(e=>({default:e.DebugDrawer})),__vite__mapDeps([283,1,282,284,285]))),gWe=[],_We=[],vWe=[],$z=`run-rejected`;function yWe({sessionId:e,extraCommands:t,apiBaseUrl:n,workspaceId:r,storageScope:i=`default`,requestHeaders:a,storage:o,fetch:s,className:c,chrome:l=!0,debug:u=!1,showSessions:d,hotReloadEnabled:f=!0,suggestions:p=yd,emptyState:m,emptyPlacement:h=`default`,composerPlaceholder:g,initialDraft:_,autoSubmitInitialDraft:v=!1,onDraftRestored:y,onAutoSubmitInitialDraftAccepted:b,onAutoSubmitInitialDraftSettled:x,model:S,defaultModel:C,availableModels:w,hideDefaultModelOption:T=!1,hideComposerSettings:E=!1,suppressPreSubmitCancelledWarning:D=!1,thinkingLevel:O,thinkingControl:k=!0,serverResourcesEnabled:A=!0,mentionedFiles:ee,commands:te=gWe,excludeBuiltinCommands:ne=_We,toolRenderers:j,createRemoteSession:M,remoteSessionOptions:N,hydrateMessages:re=!0,allowPromptDuringInitialHydration:ie=!1,workspaceWarmupStatus:ae,onSessionReset:oe,onBeforeSubmit:se,onReloadAgentPlugins:ce,onCommandResult:le,onComposerWarning:ue,onMentionedFilesConsumed:de,onPromptSubmitStarted:fe,onData:pe,onOpenArtifact:me,composerBlockers:he=vWe,onComposerStop:ge,onComposerBlockerAction:_e,onTurnComplete:ve,renderNoticeAction:ye}){let be=e?.trim()||void 0,xe=d??be===void 0,Se=(0,I.useRef)(pe);Se.current=pe;let Ce=(0,I.useRef)(ve);Ce.current=ve;let we=(0,I.useRef)(void 0),Te=(0,I.useMemo)(()=>rWe(a),[a]),Ee=(0,I.useMemo)(()=>iWe(Te),[Te]),De=(0,I.useMemo)(()=>({...N,...re?{}:{autoStart:!1},onEvent:e=>{N?.onEvent?.(e),Se.current?.(e),e.type===`agent-end`&&!e.willRetry&&Ce.current?.(),mWe(e)&&we.current?.()}}),[re,N]),Oe=Ev({apiBaseUrl:n,workspaceId:r,storageScope:i,requestHeaders:a,storage:o,fetch:s,createRemoteSession:M,remoteSessionOptions:De,enabled:be===void 0});(0,I.useEffect)(()=>{if(be){we.current=void 0;return}let e=()=>{Oe.refresh({background:!0})};return we.current=e,()=>{we.current===e&&(we.current=void 0)}},[be,Oe.refresh]);let ke=$Ue({sessionId:be,workspaceId:r,storageScope:i,apiBaseUrl:n,requestHeaders:Ee,fetch:s,createRemoteSession:M,remoteSessionOptions:De}),Ae=be?ke:Oe.activePiSession,je=nWe(Ae),Me=be??Oe.activeSessionId,Ne=be?[]:Oe.sessions,Pe=!be&&Oe.loading,Fe=be?void 0:Oe.error,Ie=Me&&je?.sessionId!==Me?void 0:je,Le=Ie?Ae:void 0,Re=!!(Me&&je&&je.sessionId!==Me),ze=!!(Me&&!Ie),Be=A&&w===void 0,Ve=Zse({apiBaseUrl:n,defaultModel:C,fetch:s,requestHeaders:Ee,storage:o,storageScope:i,enabled:Be}),He=S===void 0?Ve.model:S,Ue=(0,I.useMemo)(()=>Jse(w??Ve.availableModels,He),[w,Ve.availableModels,He]),We=!Be||!!(He&&Ve.availableModels.some(e=>e.available&&e.provider===He.provider&&e.id===He.id)),Ge=Be&&!Ve.loaded,Ke=Be&&Ve.loaded&&!We,qe=!Ge&&!Ke,[Je,Ye]=(0,I.useState)(()=>k?Kg({storageScope:i,storage:o}).thinkingLevel:md),[Xe,Ze]=(0,I.useState)(()=>Kg({storageScope:i,storage:o}).showThoughts),[Qe,$e]=(0,I.useState)(()=>({storageScope:i,storage:o}));(0,I.useEffect)(()=>{let e=Kg({storageScope:i,storage:o});Ye(k?e.thinkingLevel:md),Ze(e.showThoughts),$e({storageScope:i,storage:o})},[o,i,k]);let et=Qe.storageScope===i&&Qe.storage===o;(0,I.useEffect)(()=>{k&&et&&Kse(Je,{storageScope:i,storage:o})},[et,o,i,Je,k]),(0,I.useEffect)(()=>{et&&qse(Xe,{storageScope:i,storage:o})},[et,Xe,o,i]);let tt=O??Je,nt=k||O!==void 0,[rt,it]=(0,I.useState)(!1),[at,ot]=(0,I.useState)(!1),[st,ct]=(0,I.useState)(()=>_??``),lt=(0,I.useRef)(st);lt.current=st;let P=(0,I.useRef)(new Gse),F=(0,I.useRef)(void 0),ut=(0,I.useRef)(void 0),dt=(0,I.useRef)(!1),ft=(0,I.useRef)(!1),pt=(0,I.useCallback)(e=>{let t=F.current;return!t||e&&t!==e?!1:(F.current=void 0,ut.current===t&&(ut.current=void 0),x?.(),!0)},[x]),mt=(0,I.useRef)(`idle`),ht=(0,I.useRef)(`idle`),gt=(0,I.useRef)(()=>{}),_t=(0,I.useRef)(null),[vt,yt]=(0,I.useState)([]),[bt,xt]=(0,I.useState)(()=>new Set),[St,Ct]=(0,I.useState)(null),[wt,Tt]=(0,I.useState)(null),Et=(0,I.useRef)(0),[Dt,Ot]=(0,I.useState)(0),[kt,At]=(0,I.useState)(),jt=(0,I.useRef)(void 0),{attachmentNotice:Mt,setAttachmentNotice:Nt}=ice(),Pt=(0,I.useCallback)(e=>{jt.current=e,At(e)},[]),Ft=(0,I.useCallback)(e=>{e&&jt.current!==e||(jt.current=void 0,At(void 0))},[]),It=(0,I.useMemo)(()=>{let e=new Set(ne),n=xd(Sd.filter(t=>!f&&t.name===`reload`?!1:!e.has(t.name)));for(let e of t??[])n.register(e);for(let e of te)n.register(e);return n},[n,te,ne,t,f,Ee,A,Dt,i]),Lt=(0,I.useMemo)(()=>It.list(),[It,nce({registry:It,requestHeaders:Ee,sessionId:Me??`default`,apiBaseUrl:n,fetch:s,storageScope:i,refreshKey:Dt,enabled:A})]),Rt=Ie?.sessionId,zt=ace(ae),Bt=oce(ae),Vt=!!zt,Ht=(0,I.useMemo)(()=>he.filter(e=>!e.sessionId||!Me||e.sessionId===Me),[Me,he]),Ut=Ie?xce(Ie):[],Wt=Ie?Sce(Ie):[],Gt=Ut,Kt=(0,I.useMemo)(()=>Wse(Ut),[Ut]),qt=oWe(Ie,Pe||Re||ze)===`hydrating`,Jt=h===`hero`&&Gt.length===0&&Wt.length===0&&!qt,Yt=Le?.getDebugState(),Xt=Vt||Ht.length>0,Zt=Ht[0],Qt=Vt?zt?.title??`Preparing workspace...`:Zt?.label??Zt?.reason??`Complete the pending workspace action to continue.`,$t=zt??Bt,en=(0,I.useMemo)(()=>{let e=Ie?Cce(Ie):[],t=Fe?[{id:`session-navigation-error`,level:`error`,text:Fe.message,dismissible:!0}]:[],n=u&&Yt?.largeStateWarning?[{id:`large-state-warning`,level:`warning`,text:`Large chat state: ${Yt.largeStateWarning.messageCount} messages, approximately ${Yt.largeStateWarning.approxBytes} bytes.`,dismissible:!0}]:[];return[...e,...t,...n,...vt].filter(e=>!bt.has(e.id))},[u,Yt?.largeStateWarning,bt,vt,Ie,Fe]),tn=(0,I.useCallback)(e=>{yt(t=>[...t.filter(t=>t.id!==e.id),e])},[]),nn=(0,I.useCallback)(e=>{xt(t=>new Set(t).add(e)),yt(t=>t.filter(t=>t.id!==e))},[]),rn=(0,I.useCallback)(e=>{xt(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),yt(t=>t.filter(t=>t.id!==e))},[]),an=(0,I.useCallback)(()=>{be||Oe.create().catch(e=>{tn({id:`session-create-error`,level:`error`,text:Qz(e,`Could not create a chat session.`),dismissible:!0})})},[tn,be,Oe.create]);(0,I.useEffect)(()=>{be||Pe||Fe||Me||Ne.length>0||dt.current||ft.current||(ft.current=!0,Oe.create().catch(e=>{ft.current=!1,tn({id:`session-auto-create-error`,level:`error`,text:Qz(e,`Could not create a chat session.`),dismissible:!0})}))},[Me,tn,be,Ne.length,Oe.create,Fe,Pe]),(0,I.useEffect)(()=>{(be||Fe||Me||Ne.length>0)&&(ft.current=!1)},[Me,be,Ne.length,Fe]);let on=(0,I.useCallback)(e=>{be||Oe.delete(e).catch(t=>{tn({id:`session-delete-error:${e}`,level:`error`,text:Qz(t,`Could not delete the chat session.`),dismissible:!0})})},[tn,be,Oe.delete]),sn=(0,I.useCallback)(()=>{let e=Me;if(be){oe?.();return}e&&(async()=>{dt.current=!0,await Oe.delete(e),await Oe.create(),await oe?.()})().catch(e=>{tn({id:`session-reset-error`,level:`error`,text:Qz(e,`Could not reset the chat session.`),dismissible:!0})}).finally(()=>{dt.current=!1})},[Me,tn,be,oe,Oe.create,Oe.delete]),cn=(0,I.useCallback)(async()=>{if(!ce)throw Error(`Agent plugin reload is not configured.`);return await ce()},[ce]),ln=(0,I.useCallback)(async()=>{Ct({kind:`running`});try{let e=await cn(),t=pWe(e);return t?(Ct({kind:`error`,message:t}),`Extension update failed: ${t}`):(Ct({kind:`success`,reloaded:!/will reload on the next message/i.test(e)}),Ot(e=>e+1),e)}catch(e){let t=Qz(e,`Extension reload failed.`);return Ct({kind:`error`,message:t}),`Extension update failed: ${t}`}},[cn]),un=(0,I.useCallback)(()=>Ct(null),[]),dn=(0,I.useCallback)(()=>Tt(null),[]);(0,I.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;if(!t||typeof t.message!=`string`)return;let n=t.tone,r=t.command??``;if(n===`error`)Tt({kind:`error`,command:r,message:t.message});else{let e=++Et.current;Tt({kind:`success`,command:r,detail:t.message,runId:e})}};return window.addEventListener(pd,e),()=>window.removeEventListener(pd,e)},[]),(0,I.useEffect)(()=>{if(!f||typeof window>`u`)return;let e=e=>{let t=fWe(e.detail);t&&(t.kind===`success`&&Ot(e=>e+1),Ct(e=>{if(!e)return e;if(t.kind===`error`)return{kind:`error`,message:t.message};if(e.kind===`error`)return e;let n=e.kind===`success`?e:{kind:`success`,reloaded:!0},r=n.frontEvents??[];return r.some(e=>e.pluginId===t.diagnostic.pluginId&&e.message===t.diagnostic.message)?n:{...n,frontEvents:[...r,t.diagnostic]}}))};return window.addEventListener(fd,e),()=>window.removeEventListener(fd,e)},[f]);let{mentionState:fn,slashQuery:pn,mentionedFiles:mn,clearMentionedFiles:hn,dismissMention:gn,dismissSlash:_n,handleComposerChange:vn,selectMention:yn,selectSlashCommand:bn}=Tse({textareaRef:_t}),xn=ee??mn,Sn=fse({userHistory:Kt,textareaRef:_t,disabled:fn!==null||pn!==null||rt||at}),Cn=(0,I.useCallback)((e,t=!0)=>{lt.current=e,ct(e),_t.current&&(_t.current.value=e,t&&_t.current.focus())},[]),wn=(0,I.useCallback)(e=>{ue?.(e),tn({id:`composer-warning:${Date.now()}`,level:`warning`,text:e,dismissible:!0})},[tn,ue]),Tn=(0,I.useCallback)(()=>Zz(ht.current)?(wn(`Model picker is unavailable while the agent is running.`),!1):S===void 0?(ot(!1),it(!0),!0):(wn(`Model selection is controlled by the host.`),!1),[S,wn]),En=(0,I.useCallback)(()=>Zz(ht.current)?(wn(`Thinking picker is unavailable while the agent is running.`),!1):!k||O!==void 0?(wn(`Thinking level is controlled by the host.`),!1):(it(!1),ot(!0),!0),[k,O,wn]),Dn=(0,I.useCallback)(e=>{if(S!==void 0)return`Model selection is controlled by the host.`;let t=cWe(e,Ue);return t?(Ve.setModel(t),`Model set to ${t.label??t.id}.`):`No model matched "${e}".`},[S,Ve,Ue]),On=(0,I.useCallback)(e=>{if(!k||O!==void 0)return`Thinking level is controlled by the host.`;let t=lWe(e);return t?(Ye(t),`Thinking set to ${uWe(t)}.`):`No thinking level matched "${e}".`},[k,O]),kn=(0,I.useCallback)(e=>{if(e===`model`){_n(),Tn()&&Cn(``);return}if(e===`thinking`||e===`think`){_n(),En()&&Cn(``);return}bn(e)},[_n,bn,Tn,En,Cn]),An=(0,I.useMemo)(()=>{if(!(!Le||!Rt||!qe))return Hse({session:{getState:()=>{let e=Le.getState();return jt.current===Rt&&e.status===`idle`?{...e,status:`submitted`}:e},prompt:Le.prompt.bind(Le),followUp:Le.followUp.bind(Le),clearQueue:Le.clearQueue.bind(Le),interrupt:Le.interrupt.bind(Le),stop:Le.stop.bind(Le)},registry:It,slashContext:{sessionId:Rt,clearMessages:()=>tn({id:`clear-not-supported`,level:`info`,text:`/clear is not available in this chat panel.`,dismissible:!0}),resetSession:sn,listCommands:()=>It.list(),reloadAgentPlugins:cn,pluginUpdate:{run:ln},openModelPicker:Tn,selectComposerModel:Dn,openThinkingPicker:En,selectComposerThinking:On},model:He,thinkingLevel:tt,thinkingControl:nt,composerBlocked:Xt,blockerMessage:Qt,mentionedFiles:xn,getDraft:()=>lt.current,onDraftChange:Cn,allowPromptDuringInitialHydration:ie,onPromptSubmitStarted:()=>{Pt(Rt)},onBeforeSubmit:se?async(e,t)=>await se(e,{...t,sessionId:Rt,source:t.source??`composer`})!==!1:void 0,onCommandResult:e=>{le?.(e),tn({id:`command:${Date.now()}`,level:`info`,text:e,dismissible:!0})},onWarning:e=>{D&&e===`Submit was cancelled before sending.`||(ue?.(e),tn({id:`composer-warning:${Date.now()}`,level:`warning`,text:e,dismissible:!0}))},onMentionedFilesConsumed:()=>{hn(),de?.()}})},[Rt,tn,ie,hn,Xt,Qt,xn,Pt,se,le,ue,de,fe,Tn,En,It,cn,sn,ln,Dn,On,He,Le,tt,qe,Cn,nt,D]),jn=(0,I.useCallback)(e=>{let t=sue(e);rn($z),tn({id:$z,level:`error`,text:Qz(e,`Could not send your message.`),dismissible:!0,...t?{errorCode:t}:{}})},[tn,rn]),Mn=(0,I.useCallback)(async({text:e,files:t,source:n=`composer`})=>{if(!An)return tn({id:`composer-no-session`,level:`warning`,text:`Create or select a chat session before sending.`,dismissible:!0}),!1;let r=e,i=()=>{lt.current===``&&Cn(r)};Cn(``,!1),gt.current();try{let r=await An.submit({text:e,files:t,source:n});if(r.preserveDraft)return i(),!1;(r.type===`prompt`||r.type===`followup`)&&rn($z),r.type===`prompt`&&Rt&&(fe?.({sessionId:Rt,clientNonce:r.clientNonce}),Xz(Le,r.cursor)?Pt(Rt):Ft(Rt));return}catch(e){return Ft(Rt),i(),jn(e),!1}},[Rt,Ft,rn,Pt,fe,An,Le,Cn,jn]),Nn=(0,I.useCallback)(()=>{An&&An.editQueued().then(e=>{e.type===`clear-failed`&&tn({id:`edit-queued-clear-failed`,level:`warning`,text:e.message,dismissible:!0})})},[tn,An]),Pn=(0,I.useCallback)(()=>{ge?.(),Ft(Rt),An?.stop().catch(e=>{tn({id:`stop-error`,level:`error`,text:Qz(e,`Could not stop the chat session.`),dismissible:!0})})},[Rt,tn,Ft,ge,An]),Fn=(0,I.useCallback)(()=>{An?.interrupt().catch(e=>{tn({id:`interrupt-error`,level:`error`,text:Qz(e,`Could not interrupt the chat session.`),dismissible:!0})})},[tn,An]);(0,I.useEffect)(()=>{Ct(null),Tt(null),yt([]),xt(new Set)},[Me]),(0,I.useEffect)(()=>{let e=Me??`__none__`;P.current.shouldRestore(e,_)&&_!==void 0&&(Cn(_,_.length>0),y?.())},[Me,_,y,Cn]);let In=Ie?.status??(Pe||Re||ze?`hydrating`:`idle`),Ln=kt===Me&&In===`idle`?`submitted`:In;(0,I.useEffect)(()=>{if(kt){if(kt!==Me){Ft();return}In!==`idle`&&Ft(kt)}},[Me,Ft,kt,In]),(0,I.useEffect)(()=>{let e=mt.current;ht.current=Ln,mt.current=Ln,F.current&&ut.current===F.current&&(Zz(Ln)||!Zz(e)&&e!==`submitted`||pt())},[pt,Ln]),(0,I.useEffect)(()=>{if(!v||!An||!Me||Xt||!P.current.claimAutoSubmit(Me,_))return;F.current=Me,ut.current=void 0;let e=_??``,t=()=>{lt.current===``&&Cn(e,e.length>0)};Cn(``,!1),An.submit({text:e,files:[],source:`auto-submit`}).then(e=>{if(e.preserveDraft){t(),pt(Me),e.type===`blocked`&&e.reason===`composer-blocked`&&P.current.releaseAutoSubmit(Me);return}(e.type===`prompt`||e.type===`followup`)&&rn($z),e.type===`prompt`&&(fe?.({sessionId:Me,clientNonce:e.clientNonce}),Xz(Le,e.cursor)?Pt(Me):Ft(Me)),ut.current=Me,b?.(),!Zz(ht.current)&&F.current===Me&&pt(Me)}).catch(e=>{Ft(Me),t(),pt(Me),jn(e)})},[Me,v,Ft,Xt,rn,_,Pt,b,fe,An,Le,Cn,pt,jn]),(0,I.useEffect)(()=>{ae?.status===`ready`&&nn(`workspace-warmup`)},[nn,ae?.status]);let Rn=!!(ie&&Ie&&Ie.status===`hydrating`&&!Ie.hydrated&&Ie.history.messageCount===0&&Ie.committedMessages.length===0&&Ie.queue.followUps.length===0&&Object.keys(Ie.optimisticOutbox).length===0&&!Ie.streamingMessage),zn=Be&&Ve.loaded&&Ve.availableModels.every(e=>!e.available),Bn=Ge||Ke||zn,Vn=!An||Pe||Xt,Hn=Zz(Ln),Un=Rn?`ready`:sWe(Ln),Wn=!An||Pe||Bn||Xt&&!Hn,Gn=(0,I.useMemo)(()=>use(j),[j]),Kn=(0,I.useMemo)(()=>Gt.map(dWe),[Gt]),qn=(0,I.useCallback)(e=>{it(!1),ot(!1),ct(e.currentTarget.value),vn(e)},[vn]);(0,I.useEffect)(()=>{Hn&&(it(!1),ot(!1))},[Hn]),(0,I.useEffect)(()=>{typeof window>`u`||!Rt||window.dispatchEvent(new CustomEvent(`boring:chat-session-status`,{detail:{sessionId:Rt,working:Hn}}))},[Rt,Hn]);let Jn=(0,I.useCallback)(e=>{if(e.key===`Escape`&&Hn){if(e.defaultPrevented||fn!==null||pn!==null){Sn(e);return}e.preventDefault(),Fn();return}Sn(e)},[Sn,Fn,Hn,fn,pn]);return(0,L.jsx)(ud,{onOpenArtifact:me,children:(0,L.jsxs)(`div`,{"data-boring-agent":``,"data-boring-agent-part":`chat`,"data-pi-chat-session-id":Me,"data-pi-chat-connection":Yt?.connection??`disconnected`,"data-pi-chat-last-seq":Yt?.lastSeq??0,className:R(`flex h-full min-h-0 overflow-hidden text-foreground antialiased`,u||xe?`flex-row`:`flex-col`,l?`bg-[color:var(--canvas)] text-[13px]`:`bg-transparent text-[13px]`,c),role:`region`,"aria-label":`Agent assistant`,children:[xe?(0,L.jsx)(`aside`,{"data-boring-agent-part":`pi-chat-session-sidebar`,className:`min-h-0 w-64 shrink-0 border-r border-border/60`,children:(0,L.jsx)(jue,{sessions:Ne,activeId:Me,loading:Pe,onCreate:an,onSwitch:Oe.switch,onDelete:on,onLoadMore:Oe.loadMore,hasMore:Oe.hasMore,loadingMore:Oe.loadingMore})}):null,(0,L.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,L.jsxs)(`div`,{className:R(`flex h-full min-h-0 flex-col overflow-hidden`,Jt&&`justify-center`,l&&`mx-3 my-3 rounded-xl bg-[color:var(--surface-chat)] shadow-[0_1px_0_oklch(0_0_0/0.02),0_1px_2px_-1px_oklch(0_0_0/0.04),inset_0_0_0_1px_oklch(from_var(--border)_l_c_h/0.6)]`),children:[(0,L.jsx)(SUe,{chrome:l,emptyHero:Jt,messages:Gt,emptyStateHydrating:qt,emptyState:m,suggestions:p,isStreaming:Hn,showThoughts:Xe,toolRenderers:Gn,runtimeNotices:en,onDismissNotice:nn,renderNoticeAction:ye,onScrollToBottomReady:e=>{gt.current=e},onSuggestionSubmit:({text:e,files:t,source:n})=>Mn({text:e,files:t,source:n}),onRestoreDraft:Cn,windowResetKey:Me}),(0,L.jsx)(ZUe,{chrome:l,isStreaming:Hn,status:Ln,disabled:Vn,submitStatus:Un,submitDisabled:Wn,composerBlocked:Xt,composerBlockerLabel:Qt,composerPlaceholder:g,composerStatusNotice:$t,workspaceWarmupBlocked:Vt,primaryComposerBlocker:Zt,onComposerBlockerAction:_e,queuePreview:Wt,onEditQueued:Nn,hotReloadEnabled:f,pluginUpdateState:St,onDismissPluginUpdate:un,onRunPluginUpdate:ln,commandNotifyState:wt,onDismissCommandNotify:dn,attachmentNotice:Mt,onAttachmentNotice:Nt,mentionState:fn,slashQuery:pn,apiBaseUrl:n,fetch:s,requestHeaders:Ee,storageScope:i,onSelectMention:yn,onDismissMention:gn,commands:Lt,onSelectSlashCommand:kn,onDismissSlash:_n,modelPickerOpen:rt,selectedModel:He,modelOptions:Ue,modelControlled:S!==void 0,hideDefaultModelOption:T,hideComposerSettings:E,onModelChange:Ve.setModel,onSetModelPickerOpen:it,onOpenModelPicker:Tn,thinkingPickerOpen:at,selectedThinking:tt,thinkingControl:k,thinkingControlled:O!==void 0,onThinkingChange:Ye,onSetThinkingPickerOpen:ot,onOpenThinkingPicker:En,draft:st,textareaRef:_t,onTextareaChange:qn,onTextareaKeyDown:Jn,onSubmitMessage:({text:e,files:t})=>Mn({text:e,files:t}),onStop:Pn})]})}),u?(0,L.jsx)(I.Suspense,{fallback:null,children:(0,L.jsx)(`div`,{"aria-label":`Chat debug metadata`,className:`contents`,role:`region`,children:(0,L.jsx)(hWe,{apiBaseUrl:n,fetch:s,sessionId:Me??Rt??`unknown`,messages:Kn,requestHeaders:Ee,storageScope:i,width:440,onWidthChange:()=>{}})})}):null]})})}function bWe(e){let t=Bu(),n=Vu(),[r,i]=(0,I.useState)(0);return{upload:(0,I.useCallback)(async(r,a)=>{i(e=>e+1);try{return await sd(r,{apiBaseUrl:t,workspaceRequestId:n,directory:a?.directory??e?.directory,sourcePath:a?.sourcePath})}finally{i(e=>e-1)}},[t,n,e?.directory]),uploading:r>0}}var eB=(0,I.createContext)({report:()=>void 0});function xWe(e,t){return e?`${e.replace(/\/$/,``)}${t}`:t}function SWe(e){return{"content-type":`application/json`,...e??{}}}function CWe(e){let t=(0,I.useCallback)(t=>{if(!t.panelInstanceId)return;let n=t;fetch(xWe(e.apiBaseUrl,`/api/v1/ui/panels/status`),{method:`PUT`,headers:SWe(e.authHeaders),body:JSON.stringify(n)}).catch(()=>{})},[e.apiBaseUrl,e.authHeaders]);return(0,I.createElement)(eB.Provider,{value:{report:t}},e.children)}function wWe(e){return(0,I.useEffect)(()=>{e.onReady()},[e.onReady]),(0,I.createElement)(I.Fragment,null,e.children)}function TWe(e){return(0,I.useEffect)(()=>{e.onLoading()},[e.onLoading]),(0,I.createElement)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,"data-boring-plugin-suspense-fallback":`true`},`Loading…`)}function EWe(e){let t=(0,I.useContext)(eB),n=e.panelInstanceId,r=(0,I.useCallback)((r,i)=>{n?.startsWith(`self-test:`)&&t.report({pluginId:e.pluginId,panelId:e.panelId,panelInstanceId:n,...e.revision===void 0?{}:{revision:e.revision},state:r,...i?{error:i}:{}})},[n,e.panelId,e.pluginId,e.revision,t]);(0,I.useEffect)(()=>()=>r(`missing`),[r]);let i=(0,I.useCallback)(e=>{r(`error`,{code:`PLUGIN_PANEL_RENDER_ERROR`,message:e.message})},[r]);return(0,I.createElement)(`div`,{className:`h-full min-h-0`,"data-boring-plugin-id":e.pluginId,"data-boring-panel-component-id":e.panelId,...n?{"data-boring-panel-instance-id":n}:{},...e.revision===void 0?{}:{"data-boring-plugin-revision":String(e.revision)}},(0,I.createElement)(oa,{pluginId:e.pluginId,contributionKind:`panel`,contributionId:e.panelId,onError:i,children:(0,I.createElement)(I.Suspense,{fallback:(0,I.createElement)(TWe,{onLoading:()=>r(`loading`)}),children:(0,I.createElement)(wWe,{onReady:()=>r(`ready`),children:e.children})})}))}var tB=class{panels=new Map;registrationOrder=[];capabilities;listeners=new Set;snapshotCache=null;lazyComponentCache=new Map;wrapperComponentCache=new Map;generation=0;constructor(e={}){this.capabilities=new Set(Object.entries(e).filter(([,e])=>e).map(([e])=>e))}register(e,t){let n=this.panels.has(e);this.panels.set(e,{...t,id:e}),n||this.registrationOrder.push(e),this.emit()}unregister(e){this.panels.delete(e)&&(this.lazyComponentCache.delete(e),this.wrapperComponentCache.delete(e),this.registrationOrder=this.registrationOrder.filter(t=>t!==e),this.emit())}replaceByPluginId(e,t){let n=new Set;for(let[t,r]of this.panels)r.pluginId===e&&n.add(t);if(n.size===0&&t.length===0)return;let r=n.size>0;for(let e of n)this.panels.delete(e),this.lazyComponentCache.delete(e),this.wrapperComponentCache.delete(e);n.size>0&&(this.registrationOrder=this.registrationOrder.filter(e=>this.panels.has(e)));for(let n of t){let t=n.id;if(!t)continue;let i=this.panels.get(t);if(i&&i.pluginId!==e){console.warn(`[PanelRegistry] plugin "${e}" tried to register panel "${t}" already owned by "${i.pluginId??`system`}" — skipped`);continue}this.panels.set(t,{...n,id:t,pluginId:e}),this.registrationOrder.includes(t)||this.registrationOrder.push(t),r=!0}r&&(this.generation+=1,this.emit())}get(e){return this.panels.get(e)}has(e){return this.panels.has(e)}list(){return this.filteredPanels()}listAll(){return this.registrationOrder.map(e=>this.panels.get(e))}getComponents(){let e={};for(let t of this.filteredPanels())e[t.id]=this.getWrappedComponent(t.id);return e}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>(this.snapshotCache||=this.filteredPanels(),this.snapshotCache);getWrappedComponent(e){let t=this.wrapperComponentCache.get(e);if(t)return t;let n=this,r=function(t){(0,I.useSyncExternalStore)(n.subscribe,n.getSnapshot,n.getSnapshot);let r=n.get(e),i=n.generation,a=!!(r&&n.satisfiesCapabilities(r)),o=(0,I.useMemo)(()=>!r||!n.satisfiesCapabilities(r)?()=>null:r.lazy?n.getLazyComponent(e,r.component):r.component,[r?.component,r?.lazy,r?.requiresCapabilities,i]);return a?(0,I.createElement)(EWe,{pluginId:r?.pluginId??r?.id??e,panelId:e,panelInstanceId:typeof t?.api?.id==`string`?t.api.id:void 0,revision:r?.pluginRevision,children:(0,I.createElement)(o,t)}):null};return this.wrapperComponentCache.set(e,r),r}getLazyComponent(e,t){let n=this.lazyComponentCache.get(e);if(n?.importer===t)return n.component;let r=(0,I.lazy)(t);return this.lazyComponentCache.set(e,{importer:t,component:r}),r}emit(){this.snapshotCache=null;for(let e of[...this.listeners])e()}filteredPanels(){return this.registrationOrder.map(e=>this.panels.get(e)).filter(e=>this.satisfiesCapabilities(e))}satisfiesCapabilities(e){return!e.requiresCapabilities?.length||e.requiresCapabilities.every(e=>this.capabilities.has(e))}},nB={ts:Vr,tsx:Vr,js:Vr,jsx:Vr,mjs:Vr,cjs:Vr,py:Vr,rb:Vr,go:Vr,rs:Vr,java:Vr,c:Vr,cpp:Vr,h:Vr,cs:Vr,swift:Vr,kt:Vr,sh:Vr,bash:Vr,zsh:Vr,json:Br,jsonl:Br,md:Gr,mdx:Gr,txt:Gr,csv:Gr,tsv:Gr,yaml:Gr,yml:Gr,toml:Gr,ini:Gr,cfg:Gr,conf:Gr,env:Gr,png:ni,jpg:ni,jpeg:ni,gif:ni,svg:ni,webp:ni,ico:ni,bmp:ni};function rB(e){let t=e.split(`.`).pop()?.toLowerCase();return t&&t in nB?nB[t]:Kr}var iB=`workspace.open.path`;function DWe(e){return typeof e.kind!=`string`||e.kind.length===0?null:{id:e.id,kind:e.kind,...e.title===void 0?{}:{title:e.title},...e.description===void 0?{}:{description:e.description},...e.targetHint===void 0?{}:{targetHint:e.targetHint},...e.examples===void 0?{}:{examples:e.examples},...e.metaSchema===void 0?{}:{metaSchema:e.metaSchema},...e.source===void 0?{}:{source:e.source},...e.pluginId===void 0?{}:{pluginId:e.pluginId}}}var aB=class{},oB=class extends aB{constructor(e,t,n,r){super(),this.viewId=e,this.groupId=t,this.panelId=n,this.tabGroupId=r}},sB=class extends aB{constructor(e,t){super(),this.viewId=e,this.paneId=t}},cB=class e{constructor(){}static getInstance(){return e.INSTANCE}hasData(e){return e&&e===this.proto}clearData(e){this.hasData(e)&&(this.proto=void 0,this.data=void 0)}getData(e){if(this.hasData(e))return this.data}setData(e,t){t&&(this.data=e,this.proto=t)}};cB.INSTANCE=new cB;function lB(){let e=cB.getInstance();if(e.hasData(oB.prototype))return e.getData(oB.prototype)[0]}function uB(){let e=cB.getInstance();if(e.hasData(sB.prototype))return e.getData(sB.prototype)[0]}var dB;(function(e){e.NONE={dispose:()=>{}};function t(e){return{dispose:()=>{e()}}}e.from=t})(dB||={});var fB=class{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=new Set(e)}addDisposables(...e){e.forEach(e=>this._disposables.add(e))}removeDisposable(e){this._disposables.delete(e)}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposables.forEach(e=>e.dispose()),this._disposables.clear())}},pB=class{constructor(){this._disposable=dB.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&=(this._disposable.dispose(),dB.NONE)}},mB;(function(e){e.any=(...e)=>t=>{let n=e.map(e=>e(t));return{dispose:()=>{n.forEach(e=>{e.dispose()})}}}})(mB||={});var hB=class{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}},gB=class{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}},OWe=class{constructor(){this.events=new Map}get size(){return this.events.size}add(e,t){this.events.set(e,t)}delete(e){this.events.delete(e)}clear(){this.events.clear()}},_B=class e{static create(){return new e(Error().stack??``)}constructor(e){this.value=e}print(){console.warn(`dockview: stacktrace`,this.value)}},kWe=class{constructor(e,t){this.callback=e,this.stacktrace=t}},Q=class e{static setLeakageMonitorEnabled(t){t!==e.ENABLE_TRACKING&&e.MEMORY_LEAK_WATCHER.clear(),e.ENABLE_TRACKING=t}get value(){return this._last}constructor(e){this.options=e,this._listeners=[],this._disposed=!1,this._pauseTokens=new Set}get event(){return this._event||(this._event=t=>{this.options?.replay&&this._last!==void 0&&t(this._last);let n=new kWe(t,e.ENABLE_TRACKING?_B.create():void 0);return this._listeners.push(n),{dispose:()=>{let t=this._listeners.indexOf(n);t>-1?this._listeners.splice(t,1):e.ENABLE_TRACKING}}},e.ENABLE_TRACKING&&e.MEMORY_LEAK_WATCHER.add(this._event,_B.create())),this._event}fire(e){if(!(this._pauseTokens.size>0)){this.options?.replay&&(this._last=e);for(let t of this._listeners)t.callback(e)}}pause(){let e={};return this._pauseTokens.add(e),dB.from(()=>this._pauseTokens.delete(e))}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(e.ENABLE_TRACKING&&queueMicrotask(()=>{for(let e of this._listeners)console.warn(`dockview: stacktrace`,e.stacktrace?.print())}),this._listeners=[]),e.ENABLE_TRACKING&&this._event&&e.MEMORY_LEAK_WATCHER.delete(this._event))}};Q.ENABLE_TRACKING=!1,Q.MEMORY_LEAK_WATCHER=new OWe;function vB(e,t,n,r){return e.addEventListener(t,n,r),{dispose:()=>{e.removeEventListener(t,n,r)}}}var yB=class{constructor(){this._onFired=new Q,this._currentFireCount=0,this._queued=!1,this.onEvent=e=>{let t=this._currentFireCount;return this._onFired.event(()=>{this._currentFireCount>t&&e()})}}fire(){this._currentFireCount++,!this._queued&&(this._queued=!0,queueMicrotask(()=>{this._queued=!1,this._onFired.fire()}))}dispose(){this._onFired.dispose()}},AWe=class extends fB{constructor(e){super(),this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,bB(e,e=>{let t=e.target.scrollWidth>e.target.clientWidth,n=e.target.scrollHeight>e.target.clientHeight;this._value={hasScrollX:t,hasScrollY:n},this._onDidChange.fire(this._value)}))}};function bB(e,t){let n=new ResizeObserver(e=>{requestAnimationFrame(()=>{let n=e[0];t(n)})});return n.observe(e),{dispose:()=>{n.unobserve(e),n.disconnect()}}}var xB=(e,...t)=>{for(let n of t)e.classList.contains(n)&&e.classList.remove(n)},SB=(e,...t)=>{for(let n of t)e.classList.contains(n)||e.classList.add(n)},CB=(e,t,n)=>{let r=e.classList.contains(t);n&&!r&&e.classList.add(t),!n&&r&&e.classList.remove(t)};function wB(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function TB(e){return new jWe(e)}var jWe=class extends fB{constructor(e){super(),this._onDidFocus=new Q,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new Q,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=wB(document.activeElement,e),n=!1,r=()=>{n=!1,t||(t=!0,this._onDidFocus.fire())},i=()=>{t&&(n=!0,window.setTimeout(()=>{n&&(n=!1,t=!1,this._onDidBlur.fire())},0))};this._refreshStateHandler=()=>{wB(document.activeElement,e)!==t&&(t?i():r())},this.addDisposables(vB(e,`focus`,r,!0)),this.addDisposables(vB(e,`blur`,i,!0))}refreshState(){this._refreshStateHandler()}},EB=`dv-quasiPreventDefault`;function DB(e){e[EB]=!0}function OB(e){return e[EB]}function MWe(e,t,n={}){let r=Array.from(t),{nonce:i}=n,a=typeof i==`function`?i(e):i;for(let t of r){if(t.href){let n=e.createElement(`link`);n.href=t.href,n.type=t.type,n.rel=`stylesheet`,e.head.appendChild(n);continue}let n=[];try{t.cssRules&&(n=Array.from(t.cssRules).map(e=>e.cssText))}catch(e){console.warn(`dockview: failed to access stylesheet rules due to security restrictions`,e)}let r=e.createDocumentFragment();for(let t of n){let n=e.createElement(`style`);a&&n.setAttribute(`nonce`,a),n.appendChild(e.createTextNode(t)),r.appendChild(n)}e.head.appendChild(r)}}function kB(e){let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t+window.scrollX,top:n+window.scrollY,width:r,height:i}}function NWe(e){let t=e;for(;t?.parentNode;)if(t.parentNode===document)return!0;else t=t.parentNode instanceof DocumentFragment?t.parentNode.host:t.parentNode;return!1}function PWe(e,t){e.setAttribute(`data-testid`,t)}function FWe(e,t){let n=[];function r(t){if(t.nodeType===Node.ELEMENT_NODE){e.includes(t.tagName)&&n.push(t),t.shadowRoot&&r(t.shadowRoot);for(let e of t.children)r(e)}}return r(t instanceof Document?t.documentElement:t),n}function AB(e=document){let t=FWe([`IFRAME`,`WEBVIEW`],e),n=new WeakMap;for(let e of t)n.set(e,e.style.pointerEvents),e.style.pointerEvents=`none`;return{release:()=>{for(let e of t)e.style.pointerEvents=n.get(e)??`auto`;t.splice(0,t.length)}}}function IWe(e){function t(e){let t=[];for(let n=0;n<e.classList.length;n++)t.push(e.classList.item(n));return t}let n,r=e;for(;r!==null&&(n=t(r).find(e=>e.startsWith(`dockview-theme-`)),typeof n!=`string`);)r=r.parentElement;return n}var jB=class{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(let e of this._classNames)CB(this.element,e,!1);this._classNames=e.split(` `).filter(e=>e.trim().length>0);for(let e of this._classNames)CB(this.element,e,!0)}},MB=100;function NB(e,t){let n=kB(e),r=kB(t);return!(n.left<r.left||n.left+n.width>r.left+r.width||n.top<r.top||n.top+n.height>r.top+r.height)}function LWe(e){let t=new Q,n=e.screenX,r=e.screenY,i,a=()=>{if(e.closed)return;let o=e.screenX,s=e.screenY;(o!==n||s!==r)&&(clearTimeout(i),i=setTimeout(()=>{t.fire()},MB),n=o,r=s),requestAnimationFrame(a)};return a(),t}function RWe(e,t){let n;return new fB(vB(e,`resize`,()=>{clearTimeout(n),n=setTimeout(()=>{t()},MB)}))}function zWe(e,t,n={buffer:10}){let r=n.buffer,i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=0,s=0,c=i.left-a.left,l=i.top-a.top,u=i.bottom-a.bottom,d=i.right-a.right;c<r?o=r-c:d>r&&(o=-r-d),l<r?s=r-l:u>r&&(s=-u-r),(o!==0||s!==0)&&(e.style.transform=`translate(${o}px, ${s}px)`)}function PB(e){let t=e;for(;t&&(t.style.zIndex===`auto`||t.style.zIndex===``);)t=t.parentElement;return t}function FB(e){if(e.length===0)throw Error(`Invalid tail call`);return[e.slice(0,e.length-1),e[e.length-1]]}function IB(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function LB(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.unshift(t))}function RB(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.push(t))}function BWe(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(t(r))return n}return-1}function zB(e,t){let n=e.findIndex(e=>e===t);return n>-1?(e.splice(n,1),!0):!1}var BB=(e,t,n)=>t>n?t:Math.min(n,Math.max(e,t)),VB=()=>{let e=1;return{next:()=>(e++).toString()}},HB=(e,t)=>{let n=[];if(typeof t!=`number`&&(t=e,e=0),e<=t)for(let r=e;r<t;r++)n.push(r);else for(let r=e;r>t;r--)n.push(r);return n},VWe=class{set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return this._cachedVisibleSize===void 0}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?``:`none`}constructor(e,t,n,r){this.container=e,this.view=t,this.disposable=r,this._cachedVisibleSize=void 0,typeof n==`number`?(this._size=n,this._cachedVisibleSize=void 0,e.classList.add(`visible`)):(this._size=0,this._cachedVisibleSize=n.cachedVisibleSize)}setVisible(e,t){e!==this.visible&&(e?(this.size=BB(this._cachedVisibleSize??0,this.viewMinimumSize,this.viewMaximumSize),this._cachedVisibleSize=void 0):(this._cachedVisibleSize=typeof t==`number`?t:this.size,this.size=0),this.container.classList.toggle(`visible`,e),this.view.setVisible&&this.view.setVisible(e))}dispose(){return this.disposable.dispose(),this.view}},UB;(function(e){e.HORIZONTAL=`HORIZONTAL`,e.VERTICAL=`VERTICAL`})(UB||={});var WB;(function(e){e[e.MAXIMUM=0]=`MAXIMUM`,e[e.MINIMUM=1]=`MINIMUM`,e[e.DISABLED=2]=`DISABLED`,e[e.ENABLED=3]=`ENABLED`})(WB||={});var GB;(function(e){e.Low=`low`,e.High=`high`,e.Normal=`normal`})(GB||={});var KB;(function(e){e.Distribute={type:`distribute`};function t(e){return{type:`split`,index:e}}e.Split=t;function n(e){return{type:`invisible`,cachedVisibleSize:e}}e.Invisible=n})(KB||={});var qB=class{get contentSize(){return this._contentSize}get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;let t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,xB(this.element,`dv-horizontal`,`dv-vertical`),this.element.classList.add(this.orientation==UB.HORIZONTAL?`dv-horizontal`:`dv-vertical`)}get minimumSize(){return this.viewItems.reduce((e,t)=>e+t.minimumSize,0)}get maximumSize(){return this.length===0?1/0:this.viewItems.reduce((e,t)=>e+t.maximumSize,0)}get startSnappingEnabled(){return this._startSnappingEnabled}set startSnappingEnabled(e){this._startSnappingEnabled!==e&&(this._startSnappingEnabled=e,this.updateSashEnablement())}get endSnappingEnabled(){return this._endSnappingEnabled}set endSnappingEnabled(e){this._endSnappingEnabled!==e&&(this._endSnappingEnabled=e,this.updateSashEnablement())}get disabled(){return this._disabled}set disabled(e){this._disabled=e,CB(this.element,`dv-splitview-disabled`,e)}get margin(){return this._margin}set margin(e){this._margin=e,CB(this.element,`dv-splitview-has-margin`,e!==0)}constructor(e,t){this.container=e,this.viewItems=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this._contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._disabled=!1,this._margin=0,this._onDidSashEnd=new Q,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new Q,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new Q,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(e,t,n=this.viewItems.map(e=>e.size),r,i,a=-1/0,o=1/0,s,c)=>{if(e<0||e>this.viewItems.length)return 0;let l=HB(e,-1),u=HB(e+1,this.viewItems.length);if(i)for(let e of i)LB(l,e),LB(u,e);if(r)for(let e of r)RB(l,e),RB(u,e);let d=l.map(e=>this.viewItems[e]),f=l.map(e=>n[e]),p=u.map(e=>this.viewItems[e]),m=u.map(e=>n[e]),h=l.reduce((e,t)=>e+this.viewItems[t].minimumSize-n[t],0),g=l.reduce((e,t)=>e+this.viewItems[t].maximumSize-n[t],0),_=u.length===0?1/0:u.reduce((e,t)=>e+n[t]-this.viewItems[t].minimumSize,0),v=u.length===0?-1/0:u.reduce((e,t)=>e+n[t]-this.viewItems[t].maximumSize,0),y=Math.max(h,v),b=Math.min(_,g),x=!1;if(s){let e=this.viewItems[s.index],n=t>=s.limitDelta;x=n!==e.visible,e.setVisible(n,s.size)}if(!x&&c){let e=this.viewItems[c.index],n=t<c.limitDelta;x=n!==e.visible,e.setVisible(n,c.size)}if(x)return this.resize(e,t,n,r,i,a,o);let S=BB(t,y,b),C=0,w=S;for(let e=0;e<d.length;e++){let t=d[e],n=BB(f[e]+w,t.minimumSize,t.maximumSize),r=n-f[e];C+=r,w-=r,t.size=n}let T=C;for(let e=0;e<p.length;e++){let t=p[e],n=BB(m[e]-T,t.minimumSize,t.maximumSize),r=n-m[e];T+=r,t.size=n}return t},this._orientation=t.orientation??UB.VERTICAL,this.element=this.createContainer(),this.margin=t.margin??0,this.proportionalLayout=t.proportionalLayout===void 0||!!t.proportionalLayout,this.viewContainer=this.createViewContainer(),this.sashContainer=this.createSashContainer(),this.element.appendChild(this.sashContainer),this.element.appendChild(this.viewContainer),this.container.appendChild(this.element),this.style(t.styles),t.descriptor&&(this._size=t.descriptor.size,t.descriptor.views.forEach((e,t)=>{let n=e.visible===void 0||e.visible?e.size:{type:`invisible`,cachedVisibleSize:e.size},r=e.view;this.addView(r,n,t,!0)}),this._contentSize=this.viewItems.reduce((e,t)=>e+t.size,0),this.saveProportions())}style(e){e?.separatorBorder===`transparent`?(xB(this.element,`dv-separator-border`),this.element.style.removeProperty(`--dv-separator-border`)):(SB(this.element,`dv-separator-border`),e?.separatorBorder&&this.element.style.setProperty(`--dv-separator-border`,e.separatorBorder))}isViewVisible(e){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);return this.viewItems[e].visible}setViewVisible(e,t){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);let n=this.viewItems[e];n.setVisible(t,n.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.viewItems.length?-1:this.viewItems[e].size}resizeView(e,t){if(e<0||e>=this.viewItems.length)return;let n=HB(this.viewItems.length).filter(t=>t!==e),r=[...n.filter(e=>this.viewItems[e].priority===GB.Low),e],i=n.filter(e=>this.viewItems[e].priority===GB.High),a=this.viewItems[e];t=Math.round(t),t=BB(t,a.minimumSize,Math.min(a.maximumSize,this._size)),a.size=t,this.relayout(r,i)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(e,t){let n=this.viewItems.indexOf(e);if(n<0||n>=this.viewItems.length)return;t=typeof t==`number`?t:e.size,t=BB(t,e.minimumSize,e.maximumSize),e.size=t;let r=HB(this.viewItems.length).filter(e=>e!==n),i=[...r.filter(e=>this.viewItems[e].priority===GB.Low),n],a=r.filter(e=>this.viewItems[e].priority===GB.High);this.relayout([...i,n],a)}addView(e,t={type:`distribute`},n=this.viewItems.length,r){let i=document.createElement(`div`);i.className=`dv-view`,i.appendChild(e.element);let a;a=typeof t==`number`?t:t.type===`split`?this.getViewSize(t.index)/2:t.type===`invisible`?{cachedVisibleSize:t.cachedVisibleSize}:e.minimumSize;let o=e.onDidChange(e=>this.onDidChange(s,e.size)),s=new VWe(i,e,a,{dispose:()=>{o.dispose(),this.viewContainer.removeChild(i)}});if(n===this.viewItems.length?this.viewContainer.appendChild(i):this.viewContainer.insertBefore(i,this.viewContainer.children.item(n)),this.viewItems.splice(n,0,s),this.viewItems.length>1){let e=document.createElement(`div`);e.className=`dv-sash`;let t=t=>{for(let e of this.viewItems)e.enabled=!1;let n=AB(),r=this._orientation===UB.HORIZONTAL?t.clientX:t.clientY,i=BWe(this.sashes,t=>t.container===e),a=this.viewItems.map(e=>e.size),o,s,c=HB(i,-1),l=HB(i+1,this.viewItems.length),u=c.reduce((e,t)=>e+(this.viewItems[t].minimumSize-a[t]),0),d=c.reduce((e,t)=>e+(this.viewItems[t].viewMaximumSize-a[t]),0),f=l.length===0?1/0:l.reduce((e,t)=>e+(a[t]-this.viewItems[t].minimumSize),0),p=l.length===0?-1/0:l.reduce((e,t)=>e+(a[t]-this.viewItems[t].viewMaximumSize),0),m=Math.max(u,p),h=Math.min(f,d),g=this.findFirstSnapIndex(c),_=this.findFirstSnapIndex(l);if(typeof g==`number`){let e=this.viewItems[g],t=Math.floor(e.viewMinimumSize/2);o={index:g,limitDelta:e.visible?m-t:m+t,size:e.size}}if(typeof _==`number`){let e=this.viewItems[_],t=Math.floor(e.viewMinimumSize/2);s={index:_,limitDelta:e.visible?h+t:h-t,size:e.size}}let v=e=>{let t=(this._orientation===UB.HORIZONTAL?e.clientX:e.clientY)-r;this.resize(i,t,a,void 0,void 0,m,h,o,s),this.distributeEmptySpace(),this.layoutViews()},y=()=>{for(let e of this.viewItems)e.enabled=!0;n.release(),this.saveProportions(),document.removeEventListener(`pointermove`,v),document.removeEventListener(`pointerup`,y),document.removeEventListener(`pointercancel`,y),document.removeEventListener(`contextmenu`,y),this._onDidSashEnd.fire(void 0)};document.addEventListener(`pointermove`,v),document.addEventListener(`pointerup`,y),document.addEventListener(`pointercancel`,y),document.addEventListener(`contextmenu`,y)};e.addEventListener(`pointerdown`,t);let n={container:e,disposable:()=>{e.removeEventListener(`pointerdown`,t),this.sashContainer.removeChild(e)}};this.sashContainer.appendChild(e),this.sashes.push(n)}r||this.relayout([n]),!r&&typeof t!=`number`&&t.type===`distribute`&&this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){let e=[],t=0;for(let n of this.viewItems)n.maximumSize-n.minimumSize>0&&(e.push(n),t+=n.size);let n=Math.floor(t/e.length);for(let t of e)t.size=BB(n,t.minimumSize,t.maximumSize);let r=HB(this.viewItems.length),i=r.filter(e=>this.viewItems[e].priority===GB.Low),a=r.filter(e=>this.viewItems[e].priority===GB.High);this.relayout(i,a)}removeView(e,t,n=!1){let r=this.viewItems.splice(e,1)[0];if(r.dispose(),this.viewItems.length>=1){let t=Math.max(e-1,0);this.sashes.splice(t,1)[0].disposable()}return n||this.relayout(),t&&t.type===`distribute`&&this.distributeViewSizes(),this._onDidRemoveView.fire(r.view),r.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);return this.viewItems[e].cachedVisibleSize}moveView(e,t){let n=this.getViewCachedVisibleSize(e),r=n===void 0?this.getViewSize(e):KB.Invisible(n),i=this.removeView(e,void 0,!0);this.addView(i,r,t)}layout(e,t){let n=Math.max(this.size,this._contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions){let t=0;for(let n=0;n<this.viewItems.length;n++){let r=this.viewItems[n],i=this.proportions[n];typeof i==`number`?t+=i:e-=r.size}for(let n=0;n<this.viewItems.length;n++){let r=this.viewItems[n],i=this.proportions[n];typeof i==`number`&&t>0&&(r.size=BB(Math.round(i*e/t),r.minimumSize,r.maximumSize))}}else{let t=HB(this.viewItems.length),r=t.filter(e=>this.viewItems[e].priority===GB.Low),i=t.filter(e=>this.viewItems[e].priority===GB.High);this.resize(this.viewItems.length-1,e-n,void 0,r,i)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){let n=this.viewItems.reduce((e,t)=>e+t.size,0);this.resize(this.viewItems.length-1,this._size-n,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(e){let t=this.viewItems.reduce((e,t)=>e+t.size,0),n=this.size-t,r=HB(this.viewItems.length-1,-1),i=r.filter(e=>this.viewItems[e].priority===GB.Low),a=r.filter(e=>this.viewItems[e].priority===GB.High);for(let e of a)LB(r,e);for(let e of i)RB(r,e);typeof e==`number`&&RB(r,e);for(let e=0;n!==0&&e<r.length;e++){let t=this.viewItems[r[e]],i=BB(t.size+n,t.minimumSize,t.maximumSize),a=i-t.size;n-=a,t.size=i}}saveProportions(){this.proportionalLayout&&this._contentSize>0&&(this._proportions=this.viewItems.map(e=>e.visible?e.size/this._contentSize:void 0))}layoutViews(){if(this._contentSize=this.viewItems.reduce((e,t)=>e+t.size,0),this.updateSashEnablement(),this.viewItems.length===0)return;let e=this.viewItems.filter(e=>e.visible),t=Math.max(0,e.length-1),n=this.margin*t/Math.max(1,e.length),r=0,i=[],a=this.viewItems.reduce((e,t,n)=>{let r=+!!t.visible;return n===0?e.push(r):e.push(e[n-1]+r),e},[]);this.viewItems.forEach((e,o)=>{r+=this.viewItems[o].size,i.push(r);let s=e.visible?e.size-n:0,c=Math.max(0,a[o]-1),l=o===0||c===0?0:i[o-1]+c/t*n;if(o<this.viewItems.length-1){let t=e.visible?l+s-4/2+this.margin/2:l;this._orientation===UB.HORIZONTAL&&(this.sashes[o].container.style.left=`${t}px`,this.sashes[o].container.style.top=`0px`),this._orientation===UB.VERTICAL&&(this.sashes[o].container.style.left=`0px`,this.sashes[o].container.style.top=`${t}px`)}this._orientation===UB.HORIZONTAL&&(e.container.style.width=`${s}px`,e.container.style.left=`${l}px`,e.container.style.top=``,e.container.style.height=``),this._orientation===UB.VERTICAL&&(e.container.style.height=`${s}px`,e.container.style.top=`${l}px`,e.container.style.width=``,e.container.style.left=``),e.view.layout(e.size-n,this._orthogonalSize)})}findFirstSnapIndex(e){for(let t of e){let e=this.viewItems[t];if(e.visible&&e.snap)return t}for(let t of e){let e=this.viewItems[t];if(e.visible&&e.maximumSize-e.minimumSize>0)return;if(!e.visible&&e.snap)return t}}updateSashEnablement(){let e=!1,t=this.viewItems.map(t=>e=t.size-t.minimumSize>0||e);e=!1;let n=this.viewItems.map(t=>e=t.maximumSize-t.size>0||e),r=[...this.viewItems].reverse();e=!1;let i=r.map(t=>e=t.size-t.minimumSize>0||e).reverse();e=!1;let a=r.map(t=>e=t.maximumSize-t.size>0||e).reverse(),o=0;for(let e=0;e<this.sashes.length;e++){let r=this.sashes[e],s=this.viewItems[e];o+=s.size;let c=!(t[e]&&a[e+1]),l=!(n[e]&&i[e+1]);if(c&&l){let n=HB(e,-1),a=HB(e+1,this.viewItems.length),s=this.findFirstSnapIndex(n),c=this.findFirstSnapIndex(a),l=typeof s==`number`&&!this.viewItems[s].visible,u=typeof c==`number`&&!this.viewItems[c].visible;l&&i[e]&&(o>0||this.startSnappingEnabled)?this.updateSash(r,WB.MINIMUM):u&&t[e]&&(o<this._contentSize||this.endSnappingEnabled)?this.updateSash(r,WB.MAXIMUM):this.updateSash(r,WB.DISABLED)}else c&&!l?this.updateSash(r,WB.MINIMUM):!c&&l?this.updateSash(r,WB.MAXIMUM):this.updateSash(r,WB.ENABLED)}}updateSash(e,t){CB(e.container,`dv-disabled`,t===WB.DISABLED),CB(e.container,`dv-enabled`,t===WB.ENABLED),CB(e.container,`dv-maximum`,t===WB.MAXIMUM),CB(e.container,`dv-minimum`,t===WB.MINIMUM)}createViewContainer(){let e=document.createElement(`div`);return e.className=`dv-view-container`,e}createSashContainer(){let e=document.createElement(`div`);return e.className=`dv-sash-container`,e}createContainer(){let e=document.createElement(`div`);return e.className=`dv-split-view-container ${this._orientation===UB.HORIZONTAL?`dv-horizontal`:`dv-vertical`}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}for(let e of this.viewItems)e.dispose();this.element.remove()}},JB=Object.keys({orientation:void 0,descriptor:void 0,proportionalLayout:void 0,styles:void 0,margin:void 0,disableAutoResizing:void 0,className:void 0}),YB=class extends fB{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._orientation=t.orientation??UB.VERTICAL,this.element=document.createElement(`div`),this.element.className=`dv-pane-container`,e.appendChild(this.element),this.splitview=new qB(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach(e=>{let t=new fB(e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),n={pane:e,disposable:{dispose:()=>{t.dispose()}}};this.paneItems.push(n),e.orthogonalSize=this.splitview.orthogonalSize}),this.addDisposables(this._onDidChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire(void 0)}),this.splitview.onDidAddView(()=>{this._onDidChange.fire()}),this.splitview.onDidRemoveView(()=>{this._onDidChange.fire()}))}setViewVisible(e,t){this.splitview.setViewVisible(e,t)}addPane(e,t,n=this.splitview.length,r=!1){let i=e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}),a={pane:e,disposable:{dispose:()=>{i.dispose()}}};this.paneItems.splice(n,0,a),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,n,r)}getViewSize(e){return this.splitview.getViewSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t={skipDispose:!1}){let n=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t.skipDispose||(n.disposable.dispose(),n.pane.dispose()),n}moveView(e,t){if(e===t)return;let n=this.removePane(e,{skipDispose:!0});this.skipAnimation=!0;try{this.addPane(n.pane,n.pane.size,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&=(clearTimeout(this.animationTimer),void 0),SB(this.element,`dv-animated`),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,xB(this.element,`dv-animated`)},200))}dispose(){super.dispose(),this.animationTimer&&=(clearTimeout(this.animationTimer),void 0),this.paneItems.forEach(e=>{e.disposable.dispose(),e.pane.dispose()}),this.paneItems=[],this.splitview.dispose(),this.element.remove()}},XB=class{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation===UB.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===UB.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===UB.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===UB.HORIZONTAL?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation===UB.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===UB.HORIZONTAL?this.size:this.orthogonalSize}constructor(e,t,n,r=0){this.view=e,this.orientation=t,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._orthogonalSize=n,this._size=r,this._disposable=this.view.onDidChange(e=>{e?this._onDidChange.fire({size:this.orientation===UB.VERTICAL?e.width:e.height,orthogonalSize:this.orientation===UB.VERTICAL?e.height:e.width}):this._onDidChange.fire({})})}setVisible(e){this.view.setVisible&&this.view.setVisible(e)}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}},ZB=class e extends fB{get width(){return this.orientation===UB.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===UB.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return this.children.length===0?0:Math.max(...this.children.map((e,t)=>this.splitview.isViewVisible(t)?e.minimumOrthogonalSize:0))}get maximumSize(){return Math.min(...this.children.map((e,t)=>this.splitview.isViewVisible(t)?e.maximumOrthogonalSize:1/0))}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation===UB.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===UB.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===UB.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===UB.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(this.children.length===0)return GB.Normal;let e=this.children.map(e=>e.priority===void 0?GB.Normal:e.priority);return e.some(e=>e===GB.High)?GB.High:e.some(e=>e===GB.Low)?GB.Low:GB.Normal}get disabled(){return this.splitview.disabled}set disabled(e){this.splitview.disabled=e}get margin(){return this.splitview.margin}set margin(t){this.splitview.margin=t,this.children.forEach(n=>{n instanceof e&&(n.margin=t)})}constructor(e,t,n,r,i,a,o,s){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=n,this._childrenDisposable=dB.NONE,this.children=[],this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new Q,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=i,this._size=r,this.element=document.createElement(`div`),this.element.className=`dv-branch-node`,!s)this.splitview=new qB(this.element,{orientation:this.orientation,proportionalLayout:t,styles:n,margin:o}),this.splitview.layout(this.size,this.orthogonalSize);else{let e={views:s.map(e=>({view:e.node,size:e.node.size,visible:e.node instanceof XB&&e.visible!==void 0?e.visible:!0})),size:this.orthogonalSize};this.children=s.map(e=>e.node),this.splitview=new qB(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t,styles:n,margin:o})}this.disabled=a,this.addDisposables(this._onDidChange,this._onDidVisibilityChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire({})})),this.setupChildrenEvents()}setVisible(e){}isChildVisible(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.isViewVisible(e)}setChildVisible(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);if(this.splitview.isViewVisible(e)===t)return;let n=this.splitview.contentSize===0;this.splitview.setViewVisible(e,t);let r=this.splitview.contentSize===0;(t&&n||!t&&r)&&this._onDidVisibilityChange.fire({visible:t})}moveChild(e,t){if(e===t)return;if(e<0||e>=this.children.length)throw Error(`Invalid from index`);e<t&&t--,this.splitview.moveView(e,t);let n=this._removeChild(e);this._addChild(n,t)}getChildSize(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.getViewSize(e)}resizeChild(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);this.splitview.resizeView(e,t)}layout(e,t){this._size=t,this._orthogonalSize=e,this.splitview.layout(t,e)}addChild(e,t,n,r){if(n<0||n>this.children.length)throw Error(`Invalid index`);this.splitview.addView(e,t,n,r),this._addChild(e,n)}getChildCachedVisibleSize(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.getViewCachedVisibleSize(e)}removeChild(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.removeView(e,t),this._removeChild(e)}_addChild(e,t){this.children.splice(t,0,e),this.setupChildrenEvents()}_removeChild(e){let[t]=this.children.splice(e,1);return this.setupChildrenEvents(),t}setupChildrenEvents(){this._childrenDisposable.dispose(),this._childrenDisposable=new fB(mB.any(...this.children.map(e=>e.onDidChange))(e=>{this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((t,n)=>t instanceof e?t.onDidVisibilityChange(({visible:e})=>{this.setChildVisible(n,e)}):dB.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}};function QB(e,t){if(e instanceof XB)return e;if(e instanceof ZB)return QB(e.children[t?e.children.length-1:0],t);throw Error(`invalid node`)}function $B(e,t,n){if(e instanceof ZB){let r=new ZB(e.orientation,e.proportionalLayout,e.styles,t,n,e.disabled,e.margin);for(let t=e.children.length-1;t>=0;t--){let n=e.children[t];r.addChild($B(n,n.size,n.orthogonalSize),n.size,0,!0)}return r}else return new XB(e.view,e.orientation,n)}function eV(e,t,n){if(e instanceof ZB){let r=new ZB(rV(e.orientation),e.proportionalLayout,e.styles,t,n,e.disabled,e.margin),i=0;for(let a=e.children.length-1;a>=0;a--){let o=e.children[a],s=o instanceof ZB?o.orthogonalSize:o.size,c=e.size===0?0:Math.round(t*s/e.size);i+=c,a===0&&(c+=t-i),r.addChild(eV(o,n,c),c,0,!0)}return r}else return new XB(e.view,rV(e.orientation),n)}function HWe(e){let t=e.parentElement;if(!t)throw Error(`Invalid grid element`);let n=t.firstElementChild,r=0;for(;n!==e&&n!==t.lastElementChild&&n;)n=n.nextElementSibling,r++;return r}function tV(e){let t=e.parentElement;if(!t)throw Error(`Invalid grid element`);if(/\bdv-grid-view\b/.test(t.className))return[];let n=HWe(t),r=t.parentElement.parentElement.parentElement;return[...tV(r),n]}function nV(e,t,n){if(WWe(e,t)===UWe(n)){let[e,r]=FB(t),i=r;return(n===`right`||n===`bottom`)&&(i+=1),[...e,i]}else{let e=+(n===`right`||n===`bottom`);return[...t,e]}}function UWe(e){return e===`top`||e===`bottom`?UB.VERTICAL:UB.HORIZONTAL}function WWe(e,t){return t.length%2==0?rV(e):e}var rV=e=>e===UB.HORIZONTAL?UB.VERTICAL:UB.HORIZONTAL;function GWe(e){return!!e.children}var iV=(e,t)=>{let n=t===UB.VERTICAL?e.box.width:e.box.height;return GWe(e)?{type:`branch`,data:e.children.map(e=>iV(e,rV(t))),size:n}:typeof e.cachedVisibleSize==`number`?{type:`leaf`,data:e.view.toJSON(),size:e.cachedVisibleSize,visible:!1}:{type:`leaf`,data:e.view.toJSON(),size:n}},aV=class{get length(){return this._root?this._root.children.length:0}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;let{size:t,orthogonalSize:n}=this.root;this.root=eV(this.root,n,t),this.root.layout(t,n)}get width(){return this.root.width}get height(){return this.root.height}get minimumWidth(){return this.root.minimumWidth}get minimumHeight(){return this.root.minimumHeight}get maximumWidth(){return this.root.maximumHeight}get maximumHeight(){return this.root.maximumHeight}get locked(){return this._locked}set locked(e){this._locked=e;let t=[this.root];for(;t.length>0;){let n=t.pop();n instanceof ZB&&(n.disabled=e,t.push(...n.children))}}get margin(){return this._margin}set margin(e){this._margin=e,this.root.margin=e}maximizedView(){return this._maximizedNode?.leaf.view}hasMaximizedView(){return this._maximizedNode!==void 0}maximizeView(e){let t=tV(e.element),[n,r]=this.getNode(t);if(!(r instanceof XB)||this._maximizedNode?.leaf===r)return;this.hasMaximizedView()&&this.exitMaximizedView(),iV(this.getView(),this.orientation);let i=[];function a(e,t){for(let n=0;n<e.children.length;n++){let r=e.children[n];r instanceof XB?r!==t&&(e.isChildVisible(n)?e.setChildVisible(n,!1):i.push(r)):a(r,t)}}a(this.root,r),this._maximizedNode={leaf:r,hiddenOnMaximize:i},this._onDidMaximizedNodeChange.fire({view:r.view,isMaximized:!0})}exitMaximizedView(){if(!this._maximizedNode)return;let e=this._maximizedNode.hiddenOnMaximize;function t(n){for(let r=n.children.length-1;r>=0;r--){let i=n.children[r];i instanceof XB?e.includes(i)||n.setChildVisible(r,!0):t(i)}}t(this.root);let n=this._maximizedNode.leaf;this._maximizedNode=void 0,this._onDidMaximizedNodeChange.fire({view:n.view,isMaximized:!1})}serialize(){let e=this.maximizedView(),t;e&&(t=tV(e.element));let n=this._onDidMaximizedNodeChange.pause();try{this.hasMaximizedView()&&this.exitMaximizedView();let n={root:iV(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(n.maximizedNode={location:t}),e&&this.maximizeView(e),n}finally{n.dispose()}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this._onDidMaximizedNodeChange.dispose(),this._onDidViewVisibilityChange.dispose(),this.root.dispose(),this._maximizedNode=void 0,this.element.remove()}clear(){let e=this.root.orientation;this.root=new ZB(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(e,t){let n=e.orientation,r=n===UB.VERTICAL?e.height:e.width;if(this._deserialize(e.root,n,t,r),this.layout(e.width,e.height),e.maximizedNode){let t=e.maximizedNode.location,[n,r]=this.getNode(t);if(!(r instanceof XB))return;this.maximizeView(r.view)}}_deserialize(e,t,n,r){this.root=this._deserializeNode(e,t,n,r)}_deserializeNode(e,t,n,r){var i;let a;if(e.type===`branch`){let i=e.data.map(r=>({node:this._deserializeNode(r,rV(t),n,e.size),visible:r.visible}));a=new ZB(t,this.proportionalLayout,this.styles,e.size,r,this.locked,this.margin,i)}else{let o=n.fromJSON(e);typeof e.visible==`boolean`&&((i=o.setVisible)==null||i.call(o,e.visible)),a=new XB(o,t,r,e.size)}return a}get root(){return this._root}set root(e){let t=this._root;t&&(t.dispose(),this._maximizedNode=void 0,this.element.removeChild(t.element)),this._root=e,this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}normalize(){if(!this._root||this._root.children.length!==1)return;let e=this.root,t=e.children[0];if(t instanceof XB)return;e.element.remove();let n=e.removeChild(0);e.dispose(),n.dispose(),this._root=$B(t,t.size,t.orthogonalSize),this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;let e=this.root;if(e.element.remove(),this._root=new ZB(rV(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),e.children.length!==0)if(e.children.length===1){let t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(eV(t,t.orthogonalSize,t.size),KB.Distribute,0)}else this._root.addChild(e,KB.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){let t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,n){let r={height:e.height,width:e.width};if(e instanceof XB)return{box:r,view:e.view,cachedVisibleSize:n};let i=[];for(let n=0;n<e.children.length;n++){let r=e.children[n],a=e.getChildCachedVisibleSize(n);i.push(this._getViews(r,rV(t),a))}return{box:r,children:i}}progmaticSelect(e,t=!1){let[n,r]=this.getNode(e);if(!(r instanceof XB))throw Error(`invalid location`);for(let r=n.length-1;r>-1;r--){let i=n[r],a=e[r]||0;if(t?a-1>-1:a+1<i.children.length)return QB(i.children[t?a-1:a+1],t)}return QB(this.root,t)}constructor(e,t,n,r,i){this.proportionalLayout=e,this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new pB,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new Q,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new Q,this.onDidMaximizedNodeChange=this._onDidMaximizedNodeChange.event,this.element=document.createElement(`div`),this.element.className=`dv-grid-view`,this._locked=r??!1,this._margin=i??0,this.root=new ZB(n,e,t,0,0,this.locked,this.margin)}isViewVisible(e){let[t,n]=FB(e),[,r]=this.getNode(t);if(!(r instanceof ZB))throw Error(`Invalid from location`);return r.isChildVisible(n)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();let[n,r]=FB(e),[,i]=this.getNode(n);if(!(i instanceof ZB))throw Error(`Invalid from location`);this._onDidViewVisibilityChange.fire(),i.setChildVisible(r,t)}moveView(e,t,n){this.hasMaximizedView()&&this.exitMaximizedView();let[,r]=this.getNode(e);if(!(r instanceof ZB))throw Error(`Invalid location`);r.moveChild(t,n)}addView(e,t,n){this.hasMaximizedView()&&this.exitMaximizedView();let[r,i]=FB(n),[a,o]=this.getNode(r);if(o instanceof ZB){let n=new XB(e,rV(o.orientation),o.orthogonalSize);o.addChild(n,t,i)}else{let[n,...s]=[...a].reverse(),[c,...l]=[...r].reverse(),u=0,d=n.getChildCachedVisibleSize(c);typeof d==`number`&&(u=KB.Invisible(d)),n.removeChild(c).dispose();let f=new ZB(o.orientation,this.proportionalLayout,this.styles,o.size,o.orthogonalSize,this.locked,this.margin);n.addChild(f,o.size,c);let p=new XB(o.view,n.orientation,o.size);f.addChild(p,u,0),typeof t!=`number`&&t.type===`split`&&(t={type:`split`,index:0});let m=new XB(e,n.orientation,o.size);f.addChild(m,t,i)}}remove(e,t){let n=tV(e.element);return this.removeView(n,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();let[n,r]=FB(e),[i,a]=this.getNode(n);if(!(a instanceof ZB))throw Error(`Invalid location`);let o=a.children[r];if(!(o instanceof XB))throw Error(`Invalid location`);if(a.removeChild(r,t),o.dispose(),a.children.length!==1)return o.view;let s=a.children[0];if(i.length===0)return s instanceof XB?o.view:(a.removeChild(0,t),this.root=s,o.view);let[c,...l]=[...i].reverse(),[u,...d]=[...n].reverse(),f=a.isChildVisible(0);a.removeChild(0,t);let p=c.children.map((e,t)=>c.getChildSize(t));if(c.removeChild(u,t).dispose(),s instanceof ZB){p.splice(u,1,...s.children.map(e=>e.size));for(let e=0;e<s.children.length;e++){let t=s.children[e];c.addChild(t,t.size,u+e)}for(;s.children.length>0;)s.removeChild(0)}else{let e=new XB(s.view,rV(s.orientation),s.size),t=f?s.orthogonalSize:KB.Invisible(s.orthogonalSize);c.addChild(e,t,u)}s.dispose();for(let e=0;e<p.length;e++)c.resizeChild(e,p[e]);return o.view}layout(e,t){let[n,r]=this.root.orientation===UB.HORIZONTAL?[t,e]:[e,t];this.root.layout(n,r)}getNode(e,t=this.root,n=[]){if(e.length===0)return[n,t];if(!(t instanceof ZB))throw Error(`Invalid location`);let[r,...i]=e;if(r<0||r>=t.children.length)throw Error(`Invalid location`);let a=t.children[r];return n.push(t),this.getNode(i,a,n)}},oV=Object.keys({disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0}),sV=class extends fB{get element(){return this._element}get disableResizing(){return this._disableResizing}set disableResizing(e){this._disableResizing=e}constructor(e,t=!1){super(),this._lastWidth=-1,this._lastHeight=-1,this._disableResizing=t,this._element=e,this.addDisposables(bB(this._element,e=>{if(this.isDisposed||this.disableResizing||!this._element.offsetParent||!NWe(this._element))return;let t=Math.round(e.contentRect.width),n=Math.round(e.contentRect.height);t===this._lastWidth&&n===this._lastHeight||(this._lastWidth=t,this._lastHeight=n,this.layout(t,n))}))}},KWe=VB();function cV(e){switch(e){case`left`:return`left`;case`right`:return`right`;case`above`:return`top`;case`below`:return`bottom`;default:return`center`}}var lV=class extends sV{get id(){return this._id}get size(){return this._groups.size}get groups(){return Array.from(this._groups.values()).map(e=>e.value)}get width(){return this.gridview.width}get height(){return this.gridview.height}get minimumHeight(){return this.gridview.minimumHeight}get maximumHeight(){return this.gridview.maximumHeight}get minimumWidth(){return this.gridview.minimumWidth}get maximumWidth(){return this.gridview.maximumWidth}get activeGroup(){return this._activeGroup}get locked(){return this.gridview.locked}set locked(e){this.gridview.locked=e}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._id=KWe.next(),this._groups=new Map,this._onDidRemove=new Q,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new Q,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new Q,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new Q,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new yB,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new yB,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height=`100%`,this.element.style.width=`100%`,this._classNames=new jB(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this.gridview=new aV(!!t.proportionalLayout,t.styles,t.orientation,t.locked,t.margin),this.gridview.locked=!!t.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(e=>{this._onDidMaximizedChange.fire({panel:e.view,isMaximized:e.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),dB.from(()=>{var e;(e=this.element.parentElement)==null||e.removeChild(this.element)}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),mB.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(tV(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(tV(e.element))}updateOptions(e){e.proportionalLayout,e.orientation&&(this.gridview.orientation=e.orientation),`disableResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),`locked`in e&&(this.locked=e.locked??!1),`margin`in e&&(this.gridview.margin=e.margin??0),`className`in e&&this._classNames.setClassNames(e.className??``)}maximizeGroup(e){this.gridview.maximizeView(e),this.doSetGroupActive(e)}isMaximizedGroup(e){return this.gridview.maximizedView()===e}exitMaximizedGroup(){this.gridview.exitMaximizedView()}hasMaximizedGroup(){return this.gridview.hasMaximizedView()}doAddGroup(e,t=[0],n,r=this.gridview){r.addView(e,n??KB.Distribute,t),this._onDidAdd.fire(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw Error(`invalid operation`);let n=this._groups.get(e.id),r=this.gridview.remove(e,KB.Distribute);if(n&&!t?.skipDispose&&(n.disposable.dispose(),n.value.dispose(),this._groups.delete(e.id),this._onDidRemove.fire(e)),!t?.skipActive&&this._activeGroup===e){let e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return r}getPanel(e){return this._groups.get(e)?.value}doSetGroupActive(e){this._activeGroup!==e&&(this._activeGroup&&this._activeGroup.setActive(!1),e&&e.setActive(!0),this._activeGroup=e,this._onDidActiveChange.fire(e))}removeGroup(e){this.doRemoveGroup(e)}moveToNext(e){if(e||={},!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}let t=tV(e.group.element),n=this.gridview.next(t)?.view;this.doSetGroupActive(n)}moveToPrevious(e){if(e||={},!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}let t=tV(e.group.element),n=this.gridview.previous(t)?.view;this.doSetGroupActive(n)}forceRelayout(){this.layout(this.width,this.height,!0)}layout(e,t,n){(n||e!==this.width||t!==this.height)&&(this.gridview.element.style.height=`${t}px`,this.gridview.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){this._onDidActiveChange.dispose(),this._onDidAdd.dispose(),this._onDidRemove.dispose();for(let e of this.groups)e.dispose();this.gridview.dispose(),super.dispose()}},uV=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get length(){return this.component.length}get orientation(){return this.component.orientation}get panels(){return this.component.panels}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}constructor(e){this.component=e}removePanel(e,t){this.component.removePanel(e,t)}focus(){this.component.focus()}getPanel(e){return this.component.getPanel(e)}layout(e,t){return this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},dV=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get panels(){return this.component.panels}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}get onDidDrop(){return this.component.onDidDrop}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}constructor(e){this.component=e}removePanel(e){this.component.removePanel(e)}getPanel(e){return this.component.getPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}focus(){this.component.focus()}layout(e,t){this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},fV=class{get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddPanel(){return this.component.onDidAddGroup}get onDidRemovePanel(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActiveGroupChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get panels(){return this.component.groups}get orientation(){return this.component.orientation}set orientation(e){this.component.updateOptions({orientation:e})}constructor(e){this.component=e}focus(){this.component.focus()}layout(e,t,n=!1){this.component.layout(e,t,n)}addPanel(e){return this.component.addPanel(e)}removePanel(e,t){this.component.removePanel(e,t)}movePanel(e,t){this.component.movePanel(e,t)}getPanel(e){return this.component.getPanel(e)}fromJSON(e){return this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},pV=class{get id(){return this.component.id}get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get size(){return this.component.size}get tabGroupColors(){return this.component.tabGroupColorPalette.entries()}get totalPanels(){return this.component.totalPanels}get onDidActiveGroupChange(){return this.component.onDidActiveGroupChange}get onDidAddGroup(){return this.component.onDidAddGroup}get onDidRemoveGroup(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActivePanelChange}get onDidAddPanel(){return this.component.onDidAddPanel}get onDidRemovePanel(){return this.component.onDidRemovePanel}get onDidMovePanel(){return this.component.onDidMovePanel}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}get onWillDrop(){return this.component.onWillDrop}get onWillMutateLayout(){return this.component.onWillMutateLayout}get onDidMutateLayout(){return this.component.onDidMutateLayout}get onWillShowOverlay(){return this.component.onWillShowOverlay}get onWillDragGroup(){return this.component.onWillDragGroup}get onWillDragPanel(){return this.component.onWillDragPanel}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}get onDidPopoutGroupSizeChange(){return this.component.onDidPopoutGroupSizeChange}get onDidPopoutGroupPositionChange(){return this.component.onDidPopoutGroupPositionChange}get onDidAddPopoutGroup(){return this.component.onDidAddPopoutGroup}get onDidRemovePopoutGroup(){return this.component.onDidRemovePopoutGroup}get onDidOpenPopoutWindowFail(){return this.component.onDidOpenPopoutWindowFail}getPopouts(){return this.component.getPopouts()}get onDidCreateTabGroup(){return this.component.onDidCreateTabGroup}get onDidDestroyTabGroup(){return this.component.onDidDestroyTabGroup}get onDidAddPanelToTabGroup(){return this.component.onDidAddPanelToTabGroup}get onDidRemovePanelFromTabGroup(){return this.component.onDidRemovePanelFromTabGroup}get onDidTabGroupChange(){return this.component.onDidTabGroupChange}get onDidTabGroupCollapsedChange(){return this.component.onDidTabGroupCollapsedChange}get panels(){return this.component.panels}get groups(){return this.component.groups}adjacentGroupInDirection(e,t){return this.component.adjacentGroupInDirection(e,t)}get activePanel(){return this.component.activePanel}get activeGroup(){return this.component.activeGroup}constructor(e){this.component=e}focus(){this.component.focus()}getPanel(e){return this.component.getGroupPanel(e)}layout(e,t,n=!1){this.component.layout(e,t,n)}addPanel(e){return this.component.withOrigin(`api`,()=>this.component.addPanel(e))}removePanel(e){this.component.withOrigin(`api`,()=>this.component.removePanel(e))}addGroup(e){return this.component.addGroup(e)}closeAllGroups(){return this.component.withOrigin(`api`,()=>this.component.closeAllGroups())}removeGroup(e){this.component.withOrigin(`api`,()=>this.component.removeGroup(e))}getGroup(e){return this.component.getPanel(e)}addFloatingGroup(e,t){return this.component.withOrigin(`api`,()=>this.component.addFloatingGroup(e,t))}fromJSON(e,t){this.component.withOrigin(`api`,()=>this.component.fromJSON(e,t))}toJSON(){return this.component.toJSON()}clear(){this.component.withOrigin(`api`,()=>this.component.clear())}moveToNext(e){this.component.moveToNext(e)}moveToPrevious(e){this.component.moveToPrevious(e)}maximizeGroup(e){this.component.maximizeGroup(e.group)}hasMaximizedGroup(){return this.component.hasMaximizedGroup()}exitMaximizedGroup(){this.component.exitMaximizedGroup()}get onDidMaximizedGroupChange(){return this.component.onDidMaximizedGroupChange}addPopoutGroup(e,t){return this.component.withOrigin(`api`,()=>this.component.addPopoutGroup(e,t))}addEdgeGroup(e,t){return this.component.addEdgeGroup(e,t)}getEdgeGroup(e){return this.component.getEdgeGroup(e)}setEdgeGroupVisible(e,t){this.component.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this.component.isEdgeGroupVisible(e)}removeEdgeGroup(e){this.component.removeEdgeGroup(e)}updateOptions(e){this.component.updateOptions(e)}_getGroupModel(e){let t=this.component.getPanel(e);if(!t)throw Error(`dockview: group '${e}' not found`);return t.model}createTabGroup(e){let t=this._getGroupModel(e.groupId);return this.component.withOrigin(`api`,()=>t.createTabGroup({label:e.label,color:e.color,componentParams:e.componentParams}))}dissolveTabGroup(e){let t=this._getGroupModel(e.groupId);this.component.withOrigin(`api`,()=>t.dissolveTabGroup(e.tabGroupId))}addPanelToTabGroup(e){let t=this._getGroupModel(e.groupId);this.component.withOrigin(`api`,()=>t.addPanelToTabGroup(e.tabGroupId,e.panelId,e.index))}removePanelFromTabGroup(e){let t=this._getGroupModel(e.groupId);this.component.withOrigin(`api`,()=>t.removePanelFromTabGroup(e.panelId))}getTabGroups(e){return this._getGroupModel(e.groupId).getTabGroups()}getTabGroupForPanel(e){return this._getGroupModel(e.groupId).getTabGroupForPanel(e.panelId)}moveTabGroup(e){this._getGroupModel(e.groupId).moveTabGroup(e.tabGroupId,e.index)}dispose(){this.component.dispose()}},mV=class extends fB{constructor(e,t){super(),this.element=e,this.callbacks=t,this.target=null,this.registerListeners()}onDragEnter(e){this.target=e.target,this.callbacks.onDragEnter(e)}onDragOver(e){e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}onDragLeave(e){this.target===e.target&&(this.target=null,this.callbacks.onDragLeave(e))}onDragEnd(e){this.target=null,this.callbacks.onDragEnd(e)}onDrop(e){this.callbacks.onDrop(e)}registerListeners(){this.addDisposables(vB(this.element,`dragenter`,e=>{this.onDragEnter(e)},!0)),this.addDisposables(vB(this.element,`dragover`,e=>{this.onDragOver(e)},!0)),this.addDisposables(vB(this.element,`dragleave`,e=>{this.onDragLeave(e)})),this.addDisposables(vB(this.element,`dragend`,e=>{this.onDragEnd(e)})),this.addDisposables(vB(this.element,`drop`,e=>{this.onDrop(e)}))}},qWe={value:50,type:`percentage`},JWe=100,YWe=100;function hV(){let e=document.createElement(`div`);e.className=`dv-drop-target-dropzone`;let t=document.createElement(`div`);return t.className=`dv-drop-target-selection`,e.appendChild(t),{dropzone:e,selection:t}}function gV(e,t,n,r){let i=r?.smallWidthBoundary??JWe,a=r?.smallHeightBoundary??YWe,o=t<i,s=n<a,c=e===`left`,l=e===`right`,u=e===`top`,d=e===`bottom`,f=!o&&l,p=!o&&c,m=!s&&u,h=!s&&d,g=1,_=r?.size??qWe;return _.type===`percentage`?g=BB(_.value,0,100)/100:((f||p)&&(g=BB(0,_.value,t)/t),(m||h)&&(g=BB(0,_.value,n)/n)),{isSmallX:o,isSmallY:s,isLeft:c,isRight:l,isTop:u,isBottom:d,rightClass:f,leftClass:p,topClass:m,bottomClass:h,size:g}}function _V(e,t,n,r,i){let a=gV(t,n,r,i),{rightClass:o,leftClass:s,topClass:c,bottomClass:l,size:u}=a,d={top:`0px`,left:`0px`,width:`100%`,height:`100%`};o?(d.left=`${100*(1-u)}%`,d.width=`${100*u}%`):s?d.width=`${100*u}%`:c?d.height=`${100*u}%`:l&&(d.top=`${100*(1-u)}%`,d.height=`${100*u}%`),a.isSmallX&&a.isLeft&&(d.width=`4px`),a.isSmallX&&a.isRight&&(d.left=`${n-4}px`,d.width=`4px`),a.isSmallY&&a.isTop&&(d.height=`4px`),a.isSmallY&&a.isBottom&&(d.top=`${r-4}px`,d.height=`4px`),e.style.top=d.top,e.style.left=d.left,e.style.width=d.width,e.style.height=d.height,e.style.visibility=`visible`,(!e.style.transform||e.style.transform===``)&&(e.style.transform=`translate3d(0, 0, 0)`);let f=a.isSmallX&&(a.isLeft||a.isRight)||a.isSmallY&&(a.isTop||a.isBottom);CB(e,`dv-drop-target-small-vertical`,a.isSmallY),CB(e,`dv-drop-target-small-horizontal`,a.isSmallX),CB(e,`dv-drop-target-selection-line`,f),CB(e,`dv-drop-target-left`,a.isLeft),CB(e,`dv-drop-target-right`,a.isRight),CB(e,`dv-drop-target-top`,a.isTop),CB(e,`dv-drop-target-bottom`,a.isBottom),CB(e,`dv-drop-target-center`,t===`center`)}function XWe(e,t){let n=`${Math.round(t.top)}px`,r=`${Math.round(t.left)}px`,i=`${Math.round(t.width)}px`,a=`${Math.round(t.height)}px`;return e.style.top!==n||e.style.left!==r||e.style.width!==i||e.style.height!==a}function ZWe(e,t){e.style.top=`${Math.round(t.top)}px`,e.style.left=`${Math.round(t.left)}px`,e.style.width=`${Math.round(t.width)}px`,e.style.height=`${Math.round(t.height)}px`,e.style.visibility=`visible`,(!e.style.transform||e.style.transform===``)&&(e.style.transform=`translate3d(0, 0, 0)`)}function vV(e){let t=gV(e.quadrant,e.width,e.height,e.overlayModel),{rightClass:n,leftClass:r,topClass:i,bottomClass:a,size:o}=t,s=e.outlineElement.getBoundingClientRect(),c=e.targetModel.getElements(void 0,e.outlineElement),l=c.root,u=c.overlay,d=l.getBoundingClientRect(),f=s.top-d.top,p=s.left-d.left,m={top:f,left:p,width:e.width,height:e.height};return n?(m.left=p+e.width*(1-o),m.width=e.width*o):r?m.width=e.width*o:i?m.height=e.height*o:a&&(m.top=f+e.height*(1-o),m.height=e.height*o),t.isSmallX&&t.isLeft&&(m.width=4),t.isSmallX&&t.isRight&&(m.left=p+e.width-4,m.width=4),t.isSmallY&&t.isTop&&(m.height=4),t.isSmallY&&t.isBottom&&(m.top=f+e.height-4,m.height=4),XWe(u,m)?(ZWe(u,m),u.className=`dv-drop-target-anchor${e.className?` ${e.className}`:``}`,CB(u,`dv-drop-target-left`,t.isLeft),CB(u,`dv-drop-target-right`,t.isRight),CB(u,`dv-drop-target-top`,t.isTop),CB(u,`dv-drop-target-bottom`,t.isBottom),CB(u,`dv-drop-target-anchor-line`,t.isSmallX&&(t.isLeft||t.isRight)||t.isSmallY&&(t.isTop||t.isBottom)),CB(u,`dv-drop-target-center`,e.quadrant===`center`),c.changed&&(CB(u,`dv-drop-target-anchor-container-changed`,!0),setTimeout(()=>{CB(u,`dv-drop-target-anchor-container-changed`,!1)},10)),{boundsChanged:!0,targetChanged:c.changed}):{boundsChanged:!1,targetChanged:c.changed}}var yV=class extends hB{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}constructor(e){super(),this.options=e}};function bV(e){switch(e){case`above`:return`top`;case`below`:return`bottom`;case`left`:return`left`;case`right`:return`right`;case`within`:return`center`;default:throw Error(`invalid direction '${e}'`)}}function QWe(e){switch(e){case`top`:return`above`;case`bottom`:return`below`;case`left`:return`left`;case`right`:return`right`;case`center`:return`within`;default:throw Error(`invalid position '${e}'`)}}var $We={value:20,type:`percentage`},xV=class e extends fB{get disabled(){return this._disabled}set disabled(e){this._disabled=e}get state(){return this._state}constructor(t,n){super(),this.element=t,this.options=n,this._onDrop=new Q,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new Q,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new mV(this.element,{onDragEnter:()=>{var e,t;(t=(e=this.options).getOverrideTarget?.call(e))==null||t.getElements()},onDragOver:t=>{var n,r;e.ACTUAL_TARGET=this;let i=(n=this.options).getOverrideTarget?.call(n);if(this._acceptedTargetZonesSet.size===0){if(i)return;this.removeDropTarget();return}let a=(r=this.options).getOverlayOutline?.call(r)??this.element,o=a.offsetWidth,s=a.offsetHeight;if(o===0||s===0)return;let c=t.currentTarget.getBoundingClientRect(),l=(t.clientX??0)-c.left,u=(t.clientY??0)-c.top,d=this.calculateQuadrant(this._acceptedTargetZonesSet,l,u,o,s);if(this.isAlreadyUsed(t)||d===null){this.removeDropTarget();return}if(!this.options.canDisplayOverlay(t,d)){if(i)return;this.removeDropTarget();return}let f=new yV({nativeEvent:t,position:d});if(this._onWillShowOverlay.fire(f),f.defaultPrevented){this.removeDropTarget();return}if(this.markAsUsed(t),!i&&!this.targetElement){let e=hV();this.targetElement=e.dropzone,this.overlayElement=e.selection,this._state=`center`,a.classList.add(`dv-drop-target`),a.append(this.targetElement)}this.toggleClasses(d,o,s),this._state=d},onDragLeave:()=>{var e;(e=this.options).getOverrideTarget?.call(e)||this.removeDropTarget()},onDragEnd:t=>{var n;let r=(n=this.options).getOverrideTarget?.call(n);r&&e.ACTUAL_TARGET===this&&this._state&&(t.stopPropagation(),this._onDrop.fire({position:this._state,nativeEvent:t})),this.removeDropTarget(),r?.clear()},onDrop:e=>{var t,n;e.preventDefault();let r=this._state;this.removeDropTarget(),(n=(t=this.options).getOverrideTarget?.call(t))==null||n.clear(),r&&(e.stopPropagation(),this._onDrop.fire({position:r,nativeEvent:e}))}}),this.addDisposables(this._onDrop,this._onWillShowOverlay,this.dnd)}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this.removeDropTarget(),super.dispose()}markAsUsed(t){t[e.USED_EVENT_ID]=!0}isAlreadyUsed(t){let n=t[e.USED_EVENT_ID];return typeof n==`boolean`&&n}toggleClasses(e,t,n){var r,i;let a=(r=this.options).getOverrideTarget?.call(r);if(a){vV({outlineElement:(i=this.options).getOverlayOutline?.call(i)??this.element,targetModel:a,quadrant:e,width:t,height:n,overlayModel:this.options.overlayModel,className:this.options.className});return}this.overlayElement&&_V(this.overlayElement,e,t,n,this.options.overlayModel)}calculateQuadrant(e,t,n,r,i){let a=this.options.overlayModel?.activationSize??$We;return a.type===`percentage`?SV(e,t,n,r,i,a.value):CV(e,t,n,r,i,a.value)}removeDropTarget(){var e;this.targetElement&&(this._state=void 0,(e=this.targetElement.parentElement)==null||e.classList.remove(`dv-drop-target`),this.targetElement.remove(),this.targetElement=void 0,this.overlayElement=void 0)}showOverlay(e){var t,n;let r=(t=this.options).getOverrideTarget?.call(t),i=(n=this.options).getOverlayOutline?.call(n)??this.element,a=i.offsetWidth,o=i.offsetHeight;if(!r&&!this.targetElement){let e=hV();this.targetElement=e.dropzone,this.overlayElement=e.selection,i.classList.add(`dv-drop-target`),i.append(this.targetElement)}this.toggleClasses(e,a,o),this._state=e}clearOverlay(){var e,t;this.removeDropTarget(),(t=(e=this.options).getOverrideTarget?.call(e))==null||t.clear(),this._state=void 0}};xV.USED_EVENT_ID=`__dockview_droptarget_event_is_used__`;function SV(e,t,n,r,i,a){let o=100*t/r,s=100*n/i;return e.has(`left`)&&o<a?`left`:e.has(`right`)&&o>100-a?`right`:e.has(`top`)&&s<a?`top`:e.has(`bottom`)&&s>100-a?`bottom`:e.has(`center`)?`center`:null}function CV(e,t,n,r,i,a){return e.has(`left`)&&t<a?`left`:e.has(`right`)&&t>r-a?`right`:e.has(`top`)&&n<a?`top`:e.has(`bottom`)&&n>i-a?`bottom`:e.has(`center`)?`center`:null}function eGe(e,t,n){SB(t,`dv-dragged`),t.style.top=`-9999px`,document.body.appendChild(t),e.setDragImage(t,n?.x??0,n?.y??0),setTimeout(()=>{xB(t,`dv-dragged`),t.remove()},0)}var wV=class e extends fB{static getInstance(){return e._instance||=new e,e._instance}constructor(){super(),this._targets=new Set,this._targetByElement=new Map,this._onDragStart=new Q,this.onDragStart=this._onDragStart.event,this._onDragMove=new Q,this.onDragMove=this._onDragMove.event,this._onDragEnd=new Q,this.onDragEnd=this._onDragEnd.event,this.addDisposables(this._onDragStart,this._onDragMove,this._onDragEnd)}get active(){return this._active}registerTarget(e){return this._targets.add(e),this._targetByElement.set(e.element,e),{dispose:()=>{this._targets.delete(e),this._targetByElement.get(e.element)===e&&this._targetByElement.delete(e.element),this._currentTarget===e&&(this._currentTarget=void 0)}}}beginDrag(e){this._active&&this.cancel();let{pointerEvent:t,source:n}=e,r=e.getData();this._active={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,source:n},this._onDragMoveCallback=e.onDragMove,this._onDragEndCallback=e.onDragEnd,this._dataDisposable=r,this._ghost=e.ghost,this._iframeShield=AB(n.ownerDocument??document);let i={clientX:t.clientX,clientY:t.clientY,pointerEvent:t};this._onDragStart.fire(i);let a=n.ownerDocument?.defaultView??window;this._moveListener=vB(a,`pointermove`,e=>{!this._active||e.pointerId!==this._active.pointerId||this._handleMove(e)}),this._upListener=vB(a,`pointerup`,e=>{!this._active||e.pointerId!==this._active.pointerId||this._handleEnd(e,!0)}),this._cancelListener=vB(a,`pointercancel`,e=>{!this._active||e.pointerId!==this._active.pointerId||this._handleEnd(e,!1)})}cancel(){var e,t;this._active&&((e=this._currentTarget)==null||e.handleDragLeave(),this._teardown(),(t=this._dataDisposable)==null||t.dispose(),this._dataDisposable=void 0)}_findTargetUnder(e,t){let n=(this._active?.source.ownerDocument??document).elementsFromPoint(e,t);for(let e of n){let t=e;for(;t;){let e=this._targetByElement.get(t);if(e)return e;t=t.parentElement}}}_handleMove(e){var t,n,r;(t=this._ghost)==null||t.update(e.clientX,e.clientY);let i={clientX:e.clientX,clientY:e.clientY,pointerEvent:e},a=this._findTargetUnder(e.clientX,e.clientY);a!==this._currentTarget&&((n=this._currentTarget)==null||n.handleDragLeave(),this._currentTarget=a),a&&a.handleDragOver(i),(r=this._onDragMoveCallback)==null||r.call(this,i),this._onDragMove.fire(i)}_handleEnd(e,t){var n;let r={clientX:e.clientX,clientY:e.clientY,pointerEvent:e};t&&this._currentTarget?this._currentTarget.handleDrop(r):(n=this._currentTarget)==null||n.handleDragLeave();let i=this._onDragEndCallback,a=this._dataDisposable;this._teardown(),this._dataDisposable=void 0,setTimeout(()=>a?.dispose(),0),i?.(r,t),this._onDragEnd.fire(r)}_teardown(){var e,t,n,r,i;this._currentTarget=void 0,this._active=void 0,this._onDragMoveCallback=void 0,this._onDragEndCallback=void 0,(e=this._ghost)==null||e.dispose(),this._ghost=void 0,(t=this._iframeShield)==null||t.release(),this._iframeShield=void 0,(n=this._moveListener)==null||n.dispose(),(r=this._upListener)==null||r.dispose(),(i=this._cancelListener)==null||i.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}},tGe={value:20,type:`percentage`},nGe=class extends fB{get disabled(){return this._disabled}set disabled(e){this._disabled=e,e&&this._removeOverlay()}get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._onDrop=new Q,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new Q,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(t.acceptedTargetZones);let n={element:this.element,handleDragOver:e=>this._onDragOver(e),handleDragLeave:()=>this._onDragLeave(),handleDrop:e=>this._onDropEvent(e)};this.addDisposables(this._onDrop,this._onWillShowOverlay,wV.getInstance().registerTarget(n))}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this._removeOverlay(),super.dispose()}_onDragOver(e){var t,n;if(this._disabled){this._removeOverlay();return}let r=(t=this.options).getOverrideTarget?.call(t);if(this._acceptedTargetZonesSet.size===0){if(r)return;this._removeOverlay();return}let i=(n=this.options).getOverlayOutline?.call(n)??this.element,a=i.offsetWidth,o=i.offsetHeight;if(a===0||o===0)return;let s=i.getBoundingClientRect(),c=e.clientX-s.left,l=e.clientY-s.top,u=this._calculateQuadrant(c,l,a,o);if(u===null){this._removeOverlay();return}if(!this.options.canDisplayOverlay(e.pointerEvent,u)){if(r)return;this._removeOverlay();return}let d=new yV({nativeEvent:e.pointerEvent,position:u});if(this._onWillShowOverlay.fire(d),d.defaultPrevented){this._removeOverlay();return}if(r){vV({outlineElement:i,targetModel:r,quadrant:u,width:a,height:o,overlayModel:this.options.overlayModel,className:this.options.className}),this._state=u;return}if(!this._targetElement){let e=hV();this._targetElement=e.dropzone,this._overlayElement=e.selection,this._state=`center`,this.element.classList.add(`dv-drop-target`),this.element.append(this._targetElement)}this._overlayElement&&_V(this._overlayElement,u,a,o,this.options.overlayModel),this._state=u}_onDragLeave(){var e;let t=(e=this.options).getOverrideTarget?.call(e);if(t){this._state=void 0,t.clear();return}this._removeOverlay()}_onDropEvent(e){var t;let n=this._state,r=(t=this.options).getOverrideTarget?.call(t);this._removeOverlay(),r?.clear(),n&&this._onDrop.fire({position:n,nativeEvent:e.pointerEvent})}_calculateQuadrant(e,t,n,r){let i=this.options.overlayModel?.activationSize??tGe;return i.type===`percentage`?SV(this._acceptedTargetZonesSet,e,t,n,r,i.value):CV(this._acceptedTargetZonesSet,e,t,n,r,i.value)}_removeOverlay(){var e;this._targetElement?(this._state=void 0,(e=this._targetElement.parentElement)==null||e.classList.remove(`dv-drop-target`),this._targetElement.remove(),this._targetElement=void 0,this._overlayElement=void 0):this._state=void 0}},rGe=5,iGe=250,aGe=8,oGe=class extends fB{constructor(e,t){super(),this.element=e,this.options=t,this._disabled=!1,this._armed=!1,this._startX=0,this._startY=0,this._touchOnly=t.touchOnly??!0,this.addDisposables(vB(this.element,`pointerdown`,e=>{this._onPointerDown(e)}))}setDisabled(e){this._disabled=e,e&&this._cancelPending()}setTouchOnly(e){this._touchOnly!==e&&(this._touchOnly=e,e&&this._cancelPending())}_shouldHandle(e){var t;return!(this._disabled||this._touchOnly&&e.pointerType!==`touch`&&e.pointerType!==`pen`||(t=this.options).isCancelled?.call(t,e))}_onPointerDown(e){if(!this._shouldHandle(e))return;this._cancelPending(),this._pendingPointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY,this._startEvent=e;let t=e.pointerType===`touch`||e.pointerType===`pen`,n=this.options.touchInitiationDelay,r=(typeof n==`function`?n():n)??iGe;this._armed=!t||r<=0,t&&r>0&&isFinite(r)&&(this._armTimer=setTimeout(()=>{this._armTimer=void 0,this._armed=!0},r));let i=this.options.threshold??rGe,a=this.options.pressTolerance,o=(typeof a==`function`?a():a)??aGe,s=this.element.ownerDocument?.defaultView??window;this._pendingMoveListener=vB(s,`pointermove`,e=>{if(e.pointerId!==this._pendingPointerId)return;let t=e.clientX-this._startX,n=e.clientY-this._startY,r=Math.hypot(t,n);if(this._armed){r>=i&&this._beginDrag(e);return}r>o&&this._beginDrag(e)}),this._pendingUpListener=vB(s,`pointerup`,e=>{e.pointerId===this._pendingPointerId&&this._cancelPending()}),this._pendingCancelListener=vB(s,`pointercancel`,e=>{e.pointerId===this._pendingPointerId&&this._cancelPending()})}cancelPending(){this._cancelPending()}_cancelPending(){var e,t,n;this._pendingPointerId=void 0,this._armTimer!==void 0&&(clearTimeout(this._armTimer),this._armTimer=void 0),this._armed=!1,(e=this._pendingMoveListener)==null||e.dispose(),(t=this._pendingUpListener)==null||t.dispose(),(n=this._pendingCancelListener)==null||n.dispose(),this._pendingMoveListener=void 0,this._pendingUpListener=void 0,this._pendingCancelListener=void 0,this._startEvent=void 0}_beginDrag(e){var t,n,r;let i=this._startEvent??e;this._cancelPending(),(n=(t=this.options).onDragStart)==null||n.call(t,i);let a=(r=this.options).createGhost?.call(r,i);wV.getInstance().beginDrag({pointerEvent:e,source:this.element,getData:()=>this.options.getData(i),ghost:a,onDragMove:this.options.onDragMove,onDragEnd:this.options.onDragEnd})}dispose(){this._cancelPending(),super.dispose()}},sGe=class{constructor(e){this._disposed=!1,this.element=e.element,this.offsetX=e.offsetX??0,this.offsetY=e.offsetY??0,this.element.style.position=`fixed`,this.element.style.left=`0px`,this.element.style.top=`0px`,this.element.style.pointerEvents=`none`,this.element.style.zIndex=`99999`,this.element.style.opacity=String(e.opacity??.8),this.element.style.willChange=`transform`,this.element.style.transform=`translate3d(${e.initialX-this.offsetX}px, ${e.initialY-this.offsetY}px, 0)`,(e.owner?.ownerDocument??document).body.appendChild(this.element)}update(e,t){this._disposed||(this.element.style.transform=`translate3d(${e-this.offsetX}px, ${t-this.offsetY}px, 0)`)}dispose(){this._disposed||(this._disposed=!0,this.element.remove())}},cGe=class extends fB{constructor(e,t){super(),this.el=e,this.opts=t,this._dataDisposable=new pB,this._pointerEventsDisposable=new pB,this._disabled=!!t.disabled,this.addDisposables(this._dataDisposable,this._pointerEventsDisposable,vB(this.el,`dragstart`,e=>{var t,n,r,i;if(e.defaultPrevented||this._disabled||(t=this.opts).isCancelled?.call(t,e)){e.preventDefault();return}let a=AB(this.el.ownerDocument??document);this._pointerEventsDisposable.value={dispose:()=>a.release()},this.el.classList.add(`dv-dragged`),setTimeout(()=>this.el.classList.remove(`dv-dragged`),0),this._dataDisposable.value=this.opts.getData(e);let o=(n=this.opts).createGhost?.call(n,e);if(o&&e.dataTransfer&&(eGe(e.dataTransfer,o.element,{x:o.offsetX??0,y:o.offsetY??0}),o.dispose)){let e=o.dispose;setTimeout(()=>e(),0)}e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.items.length===0&&e.dataTransfer.setData(`text/plain`,``)),(i=(r=this.opts).onDragStart)==null||i.call(r,e)}),vB(this.el,`dragend`,e=>{var t,n;this._pointerEventsDisposable.dispose(),setTimeout(()=>this._dataDisposable.dispose(),0),(n=(t=this.opts).onDragEnd)==null||n.call(t,e)}))}setDisabled(e){this._disabled=e}setTouchOnly(e){}cancelPending(){}},lGe=class{constructor(){this.kind=`html5`}createDropTarget(e,t){return new xV(e,t)}createDragSource(e,t){return new cGe(e,t)}},uGe=class{constructor(){this.kind=`pointer`}createDropTarget(e,t){return new nGe(e,t)}createDragSource(e,t){let n=t.createGhost?n=>{let r=t.createGhost(n);if(!r)return;let i=new sGe({element:r.element,initialX:n.clientX,initialY:n.clientY,offsetX:r.offsetX,offsetY:r.offsetY,owner:e});if(r.dispose){let e=i.dispose.bind(i),t=r.dispose;i.dispose=()=>{e(),t()}}return i}:void 0,r=new oGe(e,{getData:t.getData,isCancelled:t.isCancelled,onDragStart:t.onDragStart,onDragEnd:t.onDragEnd?e=>t.onDragEnd(e.pointerEvent):void 0,createGhost:n,touchOnly:t.touchOnly,touchInitiationDelay:t.touchInitiationDelay,pressTolerance:t.pressTolerance,threshold:t.threshold});return t.disabled&&r.setDisabled(!0),r}},TV=new lGe,EV=new uGe,DV=Object.keys({disableAutoResizing:void 0,disableDnd:void 0,className:void 0}),dGe=class extends gB{constructor(e,t,n,r){super(),this.nativeEvent=e,this.position=t,this.getData=n,this.panel=r}},OV=class extends hB{constructor(){super()}},kV=class extends fB{get isFocused(){return this._isFocused}get isActive(){return this._isActive}get isVisible(){return this._isVisible}get width(){return this._width}get height(){return this._height}constructor(e,t){super(),this.id=e,this.component=t,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this._parameters={},this.panelUpdatesDisposable=new pB,this._onDidDimensionChange=new Q,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new Q,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new Q,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new Q,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new Q,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new Q,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new Q,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new Q,this.onDidParametersChange=this._onDidParametersChange.event,this.addDisposables(this.onDidFocusChange(e=>{this._isFocused=e.isFocused}),this.onDidActiveChange(e=>{this._isActive=e.isActive}),this.onDidVisibilityChange(e=>{this._isVisible=e.isVisible}),this.onDidDimensionsChange(e=>{this._width=e.width,this._height=e.height}),this.panelUpdatesDisposable,this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onWillFocus,this._onActiveChange,this._onWillFocus,this._onWillVisibilityChange,this._onDidParametersChange)}getParameters(){return this._parameters}initialize(e){this.panelUpdatesDisposable.value=this._onDidParametersChange.event(t=>{this._parameters=t,e.update({params:t})})}setVisible(e){this._onWillVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onDidParametersChange.fire(e)}},AV=class extends kV{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new Q,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new Q({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new Q,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},fGe=class extends AV{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new Q({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new Q({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new Q({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;(t=this._pane)==null||t.setExpanded(e)}get isExpanded(){return!!this._pane?.isExpanded()}},jV=class extends fB{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){return this._params?.params}constructor(e,t,n){super(),this.id=e,this.component=t,this.api=n,this._height=0,this._width=0,this._element=document.createElement(`div`),this._element.tabIndex=-1,this._element.style.outline=`none`,this._element.style.height=`100%`,this._element.style.width=`100%`,this._element.style.overflow=`hidden`;let r=TB(this._element);this.addDisposables(this.api,r.onDidFocus(()=>{this.api._onDidChangeFocus.fire({isFocused:!0})}),r.onDidBlur(()=>{this.api._onDidChangeFocus.fire({isFocused:!1})}),r)}focus(){let e=new OV;this.api._onWillFocus.fire(e),!e.defaultPrevented&&this._element.focus()}layout(e,t){this._width=e,this._height=t,this.api._onDidDimensionChange.fire({width:e,height:t}),this.part&&this._params&&this.part.update(this._params.params)}init(e){this._params=e,this.part=this.getComponent()}update(e){var t;this._params=Object.assign(Object.assign({},this._params),{params:Object.assign(Object.assign({},this._params?.params),e.params)});for(let t of Object.keys(e.params))e.params[t]===void 0&&delete this._params.params[t];(t=this.part)==null||t.update({params:this._params.params})}toJSON(){let e=this._params?.params??{};return{id:this.id,component:this.component,params:Object.keys(e).length>0?e:void 0}}dispose(){var e;this.api.dispose(),(e=this.part)==null||e.dispose(),super.dispose()}},pGe=class extends jV{set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){return this.headerSize+(this.isExpanded()?this._minimumBodySize:0)}get maximumSize(){return this.headerSize+(this.isExpanded()?this._maximumBodySize:0)}get size(){return this._size}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get minimumBodySize(){return this._minimumBodySize}set minimumBodySize(e){this._minimumBodySize=typeof e==`number`?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize=typeof e==`number`?e:1/0}get headerVisible(){return this._headerVisible}set headerVisible(e){this._headerVisible=e,this.header.style.display=e?``:`none`}constructor(e){super(e.id,e.component,new fGe(e.id,e.component)),this._onDidChangeExpansionState=new Q({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._orthogonalSize=0,this._size=0,this._isExpanded=!1,this.api.pane=this,this.api.initialize(this),this.headerSize=e.headerSize,this.headerComponent=e.headerComponent,this._minimumBodySize=e.minimumBodySize,this._maximumBodySize=e.maximumBodySize,this._isExpanded=e.isExpanded,this._headerVisible=e.isHeaderVisible,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=e.orientation,this.element.classList.add(`dv-pane`),this.addDisposables(this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}),vB(this.element,`mouseenter`,e=>{this.api._onMouseEnter.fire(e)}),vB(this.element,`mouseleave`,e=>{this.api._onMouseLeave.fire(e)})),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState(e=>{this.api._onDidExpansionChange.fire({isExpanded:e})}),this.api.onDidFocusChange(e=>{this.header&&(e.isFocused?SB(this.header,`focused`):xB(this.header,`focused`))})),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):this.animationTimer=setTimeout(()=>{var e;(e=this.body)==null||e.remove()},200),this._onDidChange.fire(e?{size:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(e,t){this._size=e,this._orthogonalSize=t;let[n,r]=this.orientation===UB.HORIZONTAL?[e,t]:[t,e];super.layout(n,r)}init(e){var t,n;super.init(e),typeof e.minimumBodySize==`number`&&(this.minimumBodySize=e.minimumBodySize),typeof e.maximumBodySize==`number`&&(this.maximumBodySize=e.maximumBodySize),this.bodyPart=this.getBodyComponent(),this.headerPart=this.getHeaderComponent(),this.bodyPart.init(Object.assign(Object.assign({},e),{api:this.api})),this.headerPart.init(Object.assign(Object.assign({},e),{api:this.api})),(t=this.body)==null||t.append(this.bodyPart.element),(n=this.header)==null||n.append(this.headerPart.element),typeof e.isExpanded==`boolean`&&this.setExpanded(e.isExpanded)}toJSON(){let e=this._params;return Object.assign(Object.assign({},super.toJSON()),{headerComponent:this.headerComponent,title:e.title})}renderOnce(){this.header=document.createElement(`div`),this.header.tabIndex=0,this.header.className=`dv-pane-header`,this.header.style.height=`${this.headerSize}px`,this.header.style.lineHeight=`${this.headerSize}px`,this.header.style.minHeight=`${this.headerSize}px`,this.header.style.maxHeight=`${this.headerSize}px`,this.element.appendChild(this.header),this.body=document.createElement(`div`),this.body.className=`dv-pane-body`,this.element.appendChild(this.body)}getComponent(){return{update:e=>{var t,n;(t=this.bodyPart)==null||t.update({params:e}),(n=this.headerPart)==null||n.update({params:e})},dispose:()=>{var e,t;(e=this.bodyPart)==null||e.dispose(),(t=this.headerPart)==null||t.dispose()}}}},mGe=class extends pGe{constructor(e){super({id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,isHeaderVisible:!0,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this._onDidDrop=new Q,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOver=new Q,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.accessor=e.accessor,this.addDisposables(this._onDidDrop,this._onUnhandledDragOver),e.disableDnd||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;let e=this.id,t=this.accessor.id;this.header.draggable=!0;let n={getData:()=>(cB.getInstance().setData([new sB(t,e)],sB.prototype),{dispose:()=>{cB.getInstance().clearData(sB.prototype)}})};this.html5DragSource=TV.createDragSource(this.header,n),this.pointerDragSource=EV.createDragSource(this.header,n);let r={acceptedTargetZones:[`top`,`bottom`],overlayModel:{activationSize:{type:`percentage`,value:50}},canDisplayOverlay:(e,t)=>{let n=uB();if(n&&n.paneId!==this.id&&n.viewId===this.accessor.id)return!0;let r=new dGe(e,t,uB,this);return this._onUnhandledDragOver.fire(r),r.isAccepted}};this.target=TV.createDropTarget(this.element,r),this.pointerTarget=EV.createDropTarget(this.element,r),this.addDisposables(this._onDidDrop,this.html5DragSource,this.pointerDragSource,this.target,this.pointerTarget,this.target.onDrop(e=>{this.onDrop(e)}),this.pointerTarget.onDrop(e=>{this.onDrop(e)}))}onDrop(e){let t=uB();if(!t||t.viewId!==this.accessor.id){this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new dV(this.accessor),getData:uB}));return}let n=this._params.containerApi,r=t.paneId,i=n.getPanel(r);if(!i){this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,getData:uB,api:new dV(this.accessor)}));return}let a=n.panels,o=a.indexOf(i),s=n.panels.indexOf(this);(e.position===`left`||e.position===`top`)&&(s=Math.max(0,s-1)),(e.position===`right`||e.position===`bottom`)&&(o>s&&s++,s=Math.min(a.length-1,s)),n.movePanel(o,s)}},hGe=0,gGe=()=>`dv-tabpanel-${hGe++}`,_Ge=class extends fB{get element(){return this._element}constructor(e,t){var n,r,i;super(),this.accessor=e,this.group=t,this.disposable=new pB,this._onDidFocus=new Q,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new Q,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement(`div`),this._element.className=`dv-content-container`,this._element.tabIndex=-1,this._element.id=gGe(),this._element.setAttribute(`role`,`tabpanel`),this.addDisposables(this._onDidFocus,this._onDidBlur);let a=()=>t.dropTargetContainer?.model,o=(e,t)=>{if(this.group.locked===`no-drop-target`||this.group.locked&&t===`center`)return!1;let n=lB();return!n&&e.shiftKey&&this.group.location.type!==`floating`?!1:n&&n.viewId===this.accessor.id?!0:this.group.canDisplayOverlay(e,t,`content`)};this.dropTarget=new xV(this.element,{getOverlayOutline:()=>e.options.theme?.dndPanelOverlay===`group`?this.element.parentElement:null,className:`dv-drop-target-content`,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],canDisplayOverlay:o,getOverrideTarget:a,overlayModel:(n=this.accessor).resolveDropOverlayModel?.call(n,`content`)}),this.pointerDropTarget=EV.createDropTarget(this.element,{acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],canDisplayOverlay:o,getOverlayOutline:()=>e.options.theme?.dndPanelOverlay===`group`?this.element.parentElement:null,className:`dv-drop-target-content`,getOverrideTarget:a,overlayModel:(r=this.accessor).resolveDropOverlayModel?.call(r,`content`)}),this.addDisposables(this.dropTarget,this.pointerDropTarget,(i=this.accessor).onDidOptionsChange?.call(i,()=>{var e;let t=(e=this.accessor).resolveDropOverlayModel?.call(e,`content`)??{};this.dropTarget.setOverlayModel(t),this.pointerDropTarget.setOverlayModel(t)})??dB.NONE)}show(){this.element.style.display=``}hide(){this.element.style.display=`none`}setLabelledBy(e){e?this._element.setAttribute(`aria-labelledby`,e):this._element.removeAttribute(`aria-labelledby`)}renderPanel(e,t={asActive:!0}){var n,r,i,a;let o=t.asActive||this.panel&&this.group.isPanelActive(this.panel);this.panel&&this.panel.view.content.element.parentElement===this._element&&(this._element.removeChild(this.panel.view.content.element),(r=(n=this.panel.view.content).onHide)==null||r.call(n)),this.panel=e;let s;switch(e.api.renderer){case`onlyWhenVisible`:this.group.renderContainer.detatch(e),this.panel&&o&&(this._element.appendChild(this.panel.view.content.element),(a=(i=this.panel.view.content).onShow)==null||a.call(i)),s=this._element;break;case`always`:e.view.content.element.parentElement===this._element&&this._element.removeChild(e.view.content.element),s=this.group.renderContainer.attach({panel:e,referenceContainer:this});break;default:throw Error(`dockview: invalid renderer type '${e.api.renderer}'`)}if(o){let e=TB(s);this.focusTracker=e;let t=new fB;t.addDisposables(e,e.onDidFocus(()=>this._onDidFocus.fire()),e.onDidBlur(()=>this._onDidBlur.fire())),this.disposable.value=t}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){var e,t,n;this.panel&&this.panel.api.renderer===`onlyWhenVisible`&&((e=this.panel.view.content.element.parentElement)==null||e.removeChild(this.panel.view.content.element),(n=(t=this.panel.view.content).onHide)==null||n.call(t)),this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}refreshFocusState(){this.focusTracker?.refreshState&&this.focusTracker.refreshState()}},vGe=500,yGe=8,MV=class extends fB{constructor(e,t){super(),this.element=e,this.options=t,this._startX=0,this._startY=0,this.addDisposables(vB(this.element,`pointerdown`,e=>{this._onPointerDown(e)}))}_onPointerDown(e){if((this.options.touchOnly??!0)&&e.pointerType!==`touch`&&e.pointerType!==`pen`)return;this._cancelPending(),this._pointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY;let t=this.options.delay??vGe,n=this.options.tolerance??yGe,r=this.element.ownerDocument?.defaultView??window;this._timer=setTimeout(()=>{this._timer=void 0,this._cancelPending(),this._installContextMenuGuard(r),this._installClickGuard(r),this.options.onLongPress(e)},t),this._moveListener=vB(r,`pointermove`,e=>{if(e.pointerId!==this._pointerId)return;let t=e.clientX-this._startX,r=e.clientY-this._startY;Math.hypot(t,r)>n&&this._cancelPending()}),this._upListener=vB(r,`pointerup`,e=>{e.pointerId===this._pointerId&&this._cancelPending()}),this._cancelListener=vB(r,`pointercancel`,e=>{e.pointerId===this._pointerId&&this._cancelPending()})}_installContextMenuGuard(e){let t,n=setTimeout(()=>t?.dispose(),500);t=vB(e,`contextmenu`,e=>{e.preventDefault(),clearTimeout(n),t?.dispose()},{capture:!0})}_installClickGuard(e){let t,n=setTimeout(()=>t?.dispose(),500);t=vB(e,`click`,e=>{let r=e.target;r&&this.element.contains(r)&&(e.preventDefault(),e.stopPropagation()),clearTimeout(n),t?.dispose()},{capture:!0})}_cancelPending(){var e,t,n;this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0),this._pointerId=void 0,(e=this._moveListener)==null||e.dispose(),(t=this._upListener)==null||t.dispose(),(n=this._cancelListener)==null||n.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}dispose(){this._cancelPending(),super.dispose()}};function NV(e){if(e.disableDnd)return{html5:!1,pointer:!1,pointerHandlesMouse:!1};switch(e.dndStrategy){case`pointer`:return{html5:!1,pointer:!0,pointerHandlesMouse:!0};case`html5`:return{html5:!0,pointer:!1,pointerHandlesMouse:!1};case`auto`:case void 0:default:return bGe()?{html5:!1,pointer:!0,pointerHandlesMouse:!0}:{html5:!0,pointer:!0,pointerHandlesMouse:!1}}}function bGe(){if(typeof window>`u`||!window.matchMedia)return!1;let e=window.matchMedia(`(pointer: coarse)`).matches,t=window.matchMedia(`(pointer: fine)`).matches;return e&&!t}var xGe=0,SGe=()=>`dv-tab-${xGe++}`,CGe=class extends fB{get element(){return this._element}constructor(e,t,n){super(),this.panel=e,this.accessor=t,this.group=n,this.content=void 0,this.panelTransfer=cB.getInstance(),this._direction=`horizontal`,this._onPointDown=new Q,this.onPointerDown=this._onPointDown.event,this._onTabClick=new Q,this.onTabClick=this._onTabClick.event,this._onDropped=new Q,this.onDrop=this._onDropped.event,this._onDragStart=new Q,this.onDragStart=this._onDragStart.event,this._onDragEnd=new Q,this.onDragEnd=this._onDragEnd.event;let r=NV(this.accessor.options);this._element=document.createElement(`div`),this._element.className=`dv-tab`,this._element.tabIndex=-1,this._element.draggable=r.html5,this._element.id=SGe(),this._element.setAttribute(`role`,`tab`),this._element.setAttribute(`aria-selected`,`false`);let i=this.group?.model?.contentContainerId;i&&this._element.setAttribute(`aria-controls`,i),CB(this.element,`dv-inactive-tab`,!0);let a=(e,t)=>{if(this.group.locked)return!1;let n=lB();return n&&this.accessor.id===n.viewId?this.accessor.options.theme?.tabAnimation!==`smooth`:this.group.model.canDisplayOverlay(e,t,`tab`)};this.dropTarget=TV.createDropTarget(this._element,{acceptedTargetZones:[`left`,`right`],overlayModel:this._buildOverlayModel(),canDisplayOverlay:a,getOverrideTarget:()=>n.model.dropTargetContainer?.model}),this.pointerDropTarget=EV.createDropTarget(this._element,{acceptedTargetZones:[`left`,`right`],overlayModel:this._buildOverlayModel(),canDisplayOverlay:a,getOverrideTarget:()=>n.model.dropTargetContainer?.model});let o={getData:()=>(this.panelTransfer.setData([new oB(this.accessor.id,this.group.id,this.panel.id)],oB.prototype),{dispose:()=>{this.panelTransfer.clearData(oB.prototype)}}),createGhost:()=>({element:this._buildGhostElement(),offsetX:30,offsetY:-10}),onDragStart:e=>{this._onDragStart.fire(e),!(e instanceof PointerEvent)&&this.accessor.options.theme?.tabAnimation===`smooth`&&requestAnimationFrame(()=>{CB(this.element,`dv-tab--dragging`,!0)})},onDragEnd:e=>{this._onDragEnd.fire(e)}};this.html5DragSource=TV.createDragSource(this._element,Object.assign(Object.assign({},o),{disabled:!r.html5})),this.pointerDragSource=EV.createDragSource(this._element,Object.assign(Object.assign({},o),{disabled:!r.pointer,touchOnly:!r.pointerHandlesMouse,isCancelled:()=>!NV(this.accessor.options).pointer})),this.onWillShowOverlay=mB.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this._onPointDown,this._onTabClick,this._onDropped,this._onDragStart,this._onDragEnd,this.accessor.onDidOptionsChange(()=>{let e=this._buildOverlayModel();this.dropTarget.setOverlayModel(e),this.pointerDropTarget.setOverlayModel(e)}),vB(this._element,`dragend`,()=>{CB(this.element,`dv-tab--dragging`,!1)}),this.html5DragSource,vB(this._element,`pointerdown`,e=>{this._onPointDown.fire(e)}),vB(this._element,`click`,e=>{this._onTabClick.fire(e)}),vB(this._element,`contextmenu`,e=>{var t;(t=this.accessor.contextMenuService)==null||t.show(this.panel,this.group,e)}),new MV(this._element,{onLongPress:e=>{var t;this.pointerDragSource.cancelPending(),(t=this.accessor.contextMenuService)==null||t.show(this.panel,this.group,e)}}),this.dropTarget.onDrop(e=>{this._onDropped.fire(e)}),this.pointerDropTarget.onDrop(e=>{this._onDropped.fire(e)}),this.dropTarget,this.pointerDropTarget,this.pointerDragSource)}setActive(e){CB(this.element,`dv-active-tab`,e),CB(this.element,`dv-inactive-tab`,!e),this._element.setAttribute(`aria-selected`,e?`true`:`false`),this._element.tabIndex=e?0:-1}setContent(e){this.content&&this._element.removeChild(this.content.element),this.content=e,this._element.appendChild(this.content.element)}_buildOverlayModel(){var e;let t=(e=this.accessor).resolveDropOverlayModel?.call(e,`tab`,this.group);if(t)return t;let n=this.accessor.options.theme?.dndTabIndicator===`line`?1/0:0;return{activationSize:{value:50,type:`percentage`},smallWidthBoundary:n,smallHeightBoundary:n}}setDirection(e){this._direction=e;let t=e===`vertical`?[`top`,`bottom`]:[`left`,`right`];this.dropTarget.setTargetZones(t),this.pointerDropTarget.setTargetZones(t)}updateDragAndDropState(){let e=NV(this.accessor.options);this._element.draggable=e.html5,this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}_buildGhostElement(){let e=getComputedStyle(this.element),t=this.element.cloneNode(!0),n=this._direction===`vertical`,r=new Set([`writing-mode`,`inline-size`,`block-size`,`min-inline-size`,`min-block-size`,`max-inline-size`,`max-block-size`,`margin-inline`,`margin-inline-start`,`margin-inline-end`,`margin-block`,`margin-block-start`,`margin-block-end`,`padding-inline`,`padding-inline-start`,`padding-inline-end`,`padding-block`,`padding-block-start`,`padding-block-end`]);return Array.from(e).forEach(i=>{n&&r.has(i)||t.style.setProperty(i,e.getPropertyValue(i),e.getPropertyPriority(i))}),n&&(t.style.setProperty(`writing-mode`,`horizontal-tb`),t.style.setProperty(`width`,e.height),t.style.setProperty(`height`,e.width)),t.style.position=`absolute`,t.classList.add(`dv-tab-ghost-drag`),t}},PV=class{get kind(){return this.options.kind}get nativeEvent(){return this.event.nativeEvent}get position(){return this.event.position}get defaultPrevented(){return this.event.defaultPrevented}get panel(){return this.options.panel}get api(){return this.options.api}get group(){return this.options.group}preventDefault(){this.event.preventDefault()}getData(){return this.options.getData()}constructor(e,t){this.event=e,this.options=t}},wGe=500,FV=class extends fB{get group(){return this.groupAccessor()}constructor(e){super(),this.panelTransfer=cB.getInstance(),this._onDragStart=new Q,this.onDragStart=this._onDragStart.event,this._element=e.element,this.accessor=e.accessor;let t=e.group;this.groupAccessor=typeof t==`function`?t:()=>t,this.isFloatingMoveHandle=e.isFloatingMoveHandle??(()=>!0);let n=NV(this.accessor.options);this._element.draggable=n.html5,CB(this._element,`dv-draggable`,n.html5||n.pointer),this.addDisposables(this._onDragStart);let r=()=>{let e=document.createElement(`div`),t=window.getComputedStyle(this._element),n=t.getPropertyValue(`--dv-activegroup-visiblepanel-tab-background-color`),r=t.getPropertyValue(`--dv-activegroup-visiblepanel-tab-color`);return e.style.backgroundColor=n,e.style.color=r,e.style.padding=`2px 8px`,e.style.height=`24px`,e.style.fontSize=`11px`,e.style.lineHeight=`20px`,e.style.borderRadius=`12px`,e.style.whiteSpace=`nowrap`,e.style.boxSizing=`border-box`,e.style.display=`inline-block`,e.textContent=`Multiple Panels (${this.group.size})`,e},i={getData:()=>(this.panelTransfer.setData([new oB(this.accessor.id,this.group.id,null)],oB.prototype),{dispose:()=>{this.panelTransfer.clearData(oB.prototype)}}),createGhost:()=>{var e;return(e=this.accessor).buildGroupDragGhost?.call(e,this.group)||{element:r(),offsetX:30,offsetY:-10}},onDragStart:e=>{this._onDragStart.fire(e)}};this.html5DragSource=TV.createDragSource(this._element,Object.assign(Object.assign({},i),{disabled:!n.html5,isCancelled:e=>!!(this.group.api.location.type===`floating`&&this.isFloatingMoveHandle()&&!e.shiftKey||this.group.api.location.type===`edge`&&this.group.size===0)}));let a=()=>this.group?.api?.location?.type===`floating`&&this.isFloatingMoveHandle();this.pointerDragSource=EV.createDragSource(this._element,Object.assign(Object.assign({},i),{disabled:!n.pointer,touchOnly:!n.pointerHandlesMouse,touchInitiationDelay:()=>a()?wGe:250,pressTolerance:()=>a()?1/0:8,isCancelled:()=>!NV(this.accessor.options).pointer||this.group.api.location.type===`edge`&&this.group.size===0,onDragStart:e=>{var t;(t=this.getFloatingOverlay())==null||t.cancelPendingDrag(),this._onDragStart.fire(e)}}));let o=new pB,s=()=>{let e=this.getFloatingOverlay();o.value=e?e.onDidStartMoving(()=>{this.pointerDragSource.cancelPending()}):dB.NONE};s(),this.addDisposables(o);let c=this.group?.api?.onDidLocationChange;c&&this.addDisposables(c(s)),this.addDisposables(this.html5DragSource,this.pointerDragSource)}updateDragAndDropState(){let e=NV(this.accessor.options);this._element.draggable=e.html5,CB(this._element,`dv-draggable`,e.html5||e.pointer),this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}getFloatingOverlay(){if(this.group)return this.accessor.floatingGroups?.find(e=>e.group===this.group)?.overlay}},TGe=class extends fB{get element(){return this._element}constructor(e,t){var n,r,i;super(),this.accessor=e,this.group=t,this._onDrop=new Q,this.onDrop=this._onDrop.event,this._onDragStart=new Q,this.onDragStart=this._onDragStart.event,this._element=document.createElement(`div`),this._element.className=`dv-void-container`,this.addDisposables(this._onDrop,this._onDragStart,vB(this._element,`pointerdown`,()=>{this.accessor.doSetGroupActive(this.group)}),vB(this._element,`pointerdown`,e=>{e.shiftKey&&DB(e)},!0)),this.dragSource=new FV({element:this._element,accessor:this.accessor,group:this.group,isFloatingMoveHandle:()=>!this._element.closest(`.dv-resize-container-with-titlebar`)});let a=(e,n)=>{if(this.group.api.locked)return!1;let r=lB();return r&&this.accessor.id===r.viewId?!0:t.model.canDisplayOverlay(e,n,`header_space`)};this.dropTarget=TV.createDropTarget(this._element,{acceptedTargetZones:[`center`],canDisplayOverlay:a,getOverrideTarget:()=>t.model.dropTargetContainer?.model,overlayModel:(n=this.accessor).resolveDropOverlayModel?.call(n,`header_space`,this.group)}),this.pointerDropTarget=EV.createDropTarget(this._element,{acceptedTargetZones:[`center`],canDisplayOverlay:a,getOverrideTarget:()=>t.model.dropTargetContainer?.model,overlayModel:(r=this.accessor).resolveDropOverlayModel?.call(r,`header_space`,this.group)}),this.onWillShowOverlay=mB.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this.dragSource,this.dragSource.onDragStart(e=>{this._onDragStart.fire(e)}),this.dropTarget.onDrop(e=>{this._onDrop.fire(e)}),this.pointerDropTarget.onDrop(e=>{this._onDrop.fire(e)}),this.dropTarget,this.pointerDropTarget,(i=this.accessor).onDidOptionsChange?.call(i,()=>{var e;let t=(e=this.accessor).resolveDropOverlayModel?.call(e,`header_space`,this.group)??{};this.dropTarget.setOverlayModel(t),this.pointerDropTarget.setOverlayModel(t)})??dB.NONE)}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}},IV=class e extends fB{get element(){return this._element}get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._scrollOffset=0,this._orientation=e,xB(this._scrollbar,`dv-scrollbar-vertical`,`dv-scrollbar-horizontal`),e===`vertical`?SB(this._scrollbar,`dv-scrollbar-vertical`):SB(this._scrollbar,`dv-scrollbar-horizontal`))}constructor(t){super(),this.scrollableElement=t,this._scrollOffset=0,this._orientation=`horizontal`,this._element=document.createElement(`div`),this._element.className=`dv-scrollable`,this._scrollbar=document.createElement(`div`),this._scrollbar.className=`dv-scrollbar dv-scrollbar-horizontal`,this.element.appendChild(t),this.element.appendChild(this._scrollbar),this.addDisposables(vB(this.element,`wheel`,t=>{this._scrollOffset+=t.deltaY*e.MouseWheelSpeed,this.calculateScrollbarStyles()}),vB(this._scrollbar,`pointerdown`,e=>{e.preventDefault(),CB(this.element,`dv-scrollable-scrolling`,!0);let t=this._orientation===`horizontal`?e.clientX:e.clientY,n=this._scrollOffset,r=e=>{let r=this._orientation===`horizontal`?e.clientX-t:e.clientY-t,i=(this._orientation===`horizontal`?this.element.clientWidth:this.element.clientHeight)/(this._orientation===`horizontal`?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight);this._scrollOffset=n+r/i,this.calculateScrollbarStyles()},i=()=>{CB(this.element,`dv-scrollable-scrolling`,!1),document.removeEventListener(`pointermove`,r),document.removeEventListener(`pointerup`,i),document.removeEventListener(`pointercancel`,i)};document.addEventListener(`pointermove`,r),document.addEventListener(`pointerup`,i),document.addEventListener(`pointercancel`,i)}),vB(this.element,`scroll`,()=>{this.calculateScrollbarStyles()}),vB(this.scrollableElement,`scroll`,()=>{this._scrollOffset=this._orientation===`horizontal`?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.calculateScrollbarStyles()}),bB(this.element,()=>{CB(this.element,`dv-scrollable-resizing`,!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),CB(this.element,`dv-scrollable-resizing`,!1)},500),this.calculateScrollbarStyles()}))}calculateScrollbarStyles(){let e=this._orientation===`horizontal`?this.element.clientWidth:this.element.clientHeight,t=this._orientation===`horizontal`?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight;if(t>e){let n=e/t*e;this._orientation===`horizontal`?(this._scrollbar.style.width=`${n}px`,this._scrollbar.style.height=``):(this._scrollbar.style.height=`${n}px`,this._scrollbar.style.width=``),this._scrollOffset=BB(this._scrollOffset,0,t-e),this._orientation===`horizontal`?this.scrollableElement.scrollLeft=this._scrollOffset:this.scrollableElement.scrollTop=this._scrollOffset;let r=this._scrollOffset/(t-e);this._orientation===`horizontal`?(this._scrollbar.style.left=`${(e-n)*r}px`,this._scrollbar.style.top=``):(this._scrollbar.style.top=`${(e-n)*r}px`,this._scrollbar.style.left=``)}else this._orientation===`horizontal`?(this._scrollbar.style.width=`0px`,this._scrollbar.style.left=`0px`):(this._scrollbar.style.height=`0px`,this._scrollbar.style.top=`0px`),this._scrollOffset=0}};IV.MouseWheelSpeed=1;var LV=[{id:`grey`,value:`var(--dv-tab-group-color-grey)`,label:`Grey`},{id:`blue`,value:`var(--dv-tab-group-color-blue)`,label:`Blue`},{id:`red`,value:`var(--dv-tab-group-color-red)`,label:`Red`},{id:`yellow`,value:`var(--dv-tab-group-color-yellow)`,label:`Yellow`},{id:`green`,value:`var(--dv-tab-group-color-green)`,label:`Green`},{id:`pink`,value:`var(--dv-tab-group-color-pink)`,label:`Pink`},{id:`purple`,value:`var(--dv-tab-group-color-purple)`,label:`Purple`},{id:`cyan`,value:`var(--dv-tab-group-color-cyan)`,label:`Cyan`},{id:`orange`,value:`var(--dv-tab-group-color-orange)`,label:`Orange`}],RV=class{constructor(e,t=!0){this._entries=e.slice(),this._byId=new Map(e.map(e=>[e.id,e])),this._enabled=t}get enabled(){return this._enabled}set enabled(e){this._enabled=e}setEntries(e){this._entries=e.slice(),this._byId=new Map(e.map(e=>[e.id,e]))}entries(){return this._entries}has(e){return this._byId.has(e)}get(e){return this._byId.get(e)}defaultId(){return this._entries[0]?.id}resolveValue(e){if(!this._enabled||!e)return;let t=this._byId.get(e);return t?t.value:e}},zV;function BV(){return zV||=new RV(LV,!0),zV}function VV(e,t,n){let r=(n??BV()).resolveValue(t);r===void 0?e.style.removeProperty(`--dv-tab-group-color`):e.style.setProperty(`--dv-tab-group-color`,r)}function HV(e,t){return(t??BV()).resolveValue(e)}var UV=class extends fB{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new Q,this.onClick=this._onClick.event,this._onContextMenu=new Q,this.onContextMenu=this._onContextMenu.event,this._element=document.createElement(`div`),this._element.className=`dv-tab-group-chip`,this._element.tabIndex=0,this._label=document.createElement(`span`),this._label.className=`dv-tab-group-chip-label`,this._element.appendChild(this._label),this.addDisposables(this._onClick,this._onContextMenu,new MV(this._element,{onLongPress:e=>{this._onContextMenu.fire(e)}}),vB(this._element,`click`,e=>{this._onClick.fire(e)}),vB(this._element,`contextmenu`,e=>{this._onContextMenu.fire(e)}))}init(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed),this.addDisposables(e.tabGroup.onDidChange(()=>{this._tabGroup&&(this.updateColor(this._tabGroup.color),this.updateLabel(this._tabGroup.label))}),e.tabGroup.onDidCollapseChange(e=>{this.updateCollapsed(e)}),this._onClick.event(()=>{var e;(e=this._tabGroup)==null||e.toggle()}))}update(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed)}updateColor(e){VV(this._element,e,this._palette),CB(this._element,`dv-tab-group-chip--accent-off`,this._palette?.enabled===!1)}updateLabel(e){this._label.textContent=e,CB(this._label,`dv-tab-group-chip-label--empty`,!e)}updateCollapsed(e){CB(this._element,`dv-tab-group-chip--collapsed`,e)}},WV=class{get underlines(){return this._underlines}constructor(e){this._ctx=e,this._underlines=new Map,this._rafId=null}positionUnderlines(){requestAnimationFrame(()=>{this._positionUnderlinesSync()})}trackUnderlines(){this._rafId!==null&&cancelAnimationFrame(this._rafId);let e=performance.now(),t=()=>{this._positionUnderlinesSync(),performance.now()-e<250?this._rafId=requestAnimationFrame(t):this._rafId=null};this._rafId=requestAnimationFrame(t)}syncUnderlineElements(e){for(let t of e)if(!this._underlines.has(t)){let e=document.createElement(`div`);e.className=`dv-tab-group-underline`,this._ctx.tabsList.appendChild(e),this._underlines.set(t,e)}for(let[t,n]of this._underlines)e.has(t)||(n.remove(),this._underlines.delete(t))}getUnderline(e){return this._underlines.get(e)}dispose(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null);for(let[,e]of this._underlines)e.remove();this._underlines.clear()}_positionUnderlinesSync(){let e=this._ctx.tabsList.getBoundingClientRect(),t=this._ctx.getTabGroups(),n=this._ctx.getDirection()===`vertical`,r=n?e.width:e.height,i=this._ctx.getActivePanelId(),a=this._ctx.getTabMap();for(let o of t){let t=this._underlines.get(o.id);if(!t)continue;let s=o.panelIds;if(s.length===0){t.style.display=`none`;continue}t.style.display=``;let c=this._ctx.getChipElement(o.id),l;if(c){let t=c.getBoundingClientRect(),r=getComputedStyle(c),i=n?Number.parseFloat(r.marginTop)||0:Number.parseFloat(r.marginLeft)||0;l=n?t.top-e.top-i:t.left-e.left-i}else{let t=s[0],r=a.get(t);if(r){let t=r.value.element.getBoundingClientRect();l=n?t.top-e.top:t.left-e.left}else l=0}let u=s[s.length-1],d=a.get(u);if(!d){n?(t.style.top=`${l}px`,t.style.height=`0px`,t.style.left=``,t.style.width=``):(t.style.left=`${l}px`,t.style.width=`0px`,t.style.top=``,t.style.height=``);continue}let f=d.value.element.getBoundingClientRect(),p=n?f.bottom-e.top:f.right-e.left,m=p-l;if((o.collapsed||o.panelIds.some(e=>{let t=a.get(e);return t&&t.value.element.classList.contains(`dv-tab--group-expanding`)}))&&c){let t=c.getBoundingClientRect(),r=n?t.top+t.height/2-e.top:t.left+t.width/2-e.left,i=0,s=0;for(let e of o.panelIds){let t=a.get(e);if(!t)continue;let r=t.value.element;n?(i+=r.getBoundingClientRect().height,s+=r.scrollHeight):(i+=r.getBoundingClientRect().width,s+=r.scrollWidth)}let u=s>0?Math.min(1,i/s):0;l=r+(l-r)*u,p=r+(p-r)*u,m=Math.max(0,p-l)}n?(t.style.top=`${l}px`,t.style.height=`${Math.max(0,m)}px`,t.style.left=``,t.style.width=``):(t.style.left=`${l}px`,t.style.width=`${Math.max(0,m)}px`,t.style.top=``,t.style.height=``),this.applyShape(t,o,l,m,r,i,e,n)}}},EGe=class extends WV{_applyStraightLine(e,t,n,r,i,a){a?(e.setAttribute(`width`,String(r)),e.setAttribute(`height`,String(i)),n.style.width=`${r}px`,n.style.height=`${i}px`,t.setAttribute(`d`,`M ${r/2},0 L ${r/2},${i}`)):(e.setAttribute(`width`,String(i)),e.setAttribute(`height`,String(r)),n.style.width=`${i}px`,n.style.height=`${r}px`,t.setAttribute(`d`,`M 0,${r/2} L ${i},${r/2}`))}applyShape(e,t,n,r,i,a,o,s){let c=i,l=r,u=HV(t.color,this._ctx.getColorPalette());if(l<=0||c<=0||u===void 0){e.style.display=`none`;return}e.style.display=``;let d;a&&t.panelIds.includes(a)&&(d=this._ctx.getTabMap().get(a));let f=e.firstElementChild,p;if(!f||f.tagName!==`svg`?(e.replaceChildren(),f=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`),f.style.display=`block`,p=document.createElementNS(`http://www.w3.org/2000/svg`,`path`),p.setAttribute(`fill`,`none`),f.appendChild(p),e.appendChild(f)):p=f.firstElementChild,p.setAttribute(`stroke`,u),p.setAttribute(`stroke-width`,`2`),!d){this._applyStraightLine(f,p,e,2,l,s);return}let m=d.value.element.getBoundingClientRect(),h,g;if(s?(h=Math.max(0,m.top-o.top-n),g=Math.min(l,m.bottom-o.top-n)):(h=Math.max(0,m.left-o.left-n),g=Math.min(l,m.right-o.left-n)),g<=h){this._applyStraightLine(f,p,e,2,l,s);return}let _=this._ctx.getHeaderPosition();if(s){let t=c,n=l;f.setAttribute(`width`,String(t)),f.setAttribute(`height`,String(n)),e.style.width=`${t}px`,e.style.height=`${n}px`;let r=_===`right`,i=r?t-1:1,a=r?1:t-1,o=r?-1:1,s=[`M ${i},0`,`L ${i},${h-6}`,`Q ${i},${h} ${i+o*6},${h}`,`L ${a-o*6},${h}`,`Q ${a},${h} ${a},${h+6}`,`L ${a},${g-6}`,`Q ${a},${g} ${a-o*6},${g}`,`L ${i+o*6},${g}`,`Q ${i},${g} ${i},${g+6}`,`L ${i},${n}`].join(` `);p.setAttribute(`d`,s)}else{let t=l,n=c;f.setAttribute(`width`,String(t)),f.setAttribute(`height`,String(n)),e.style.width=`${t}px`,e.style.height=`${n}px`;let r=_===`bottom`,i=r?1:n-1,a=r?n-1:1,o=r?1:-1,s=[`M 0,${i}`,`L ${h-6},${i}`,`Q ${h},${i} ${h},${i+o*6}`,`L ${h},${a-o*6}`,`Q ${h},${a} ${h+6},${a}`,`L ${g-6},${a}`,`Q ${g},${a} ${g},${a-o*6}`,`L ${g},${i+o*6}`,`Q ${g},${i} ${g+6},${i}`,`L ${t},${i}`].join(` `);p.setAttribute(`d`,s)}}},DGe=class extends WV{applyShape(e,t,n,r,i,a,o,s){let c=HV(t.color,this._ctx.getColorPalette());if(r<=0||c===void 0){e.style.display=`none`;return}e.style.display=``,e.firstElementChild&&e.replaceChildren(),e.style.backgroundColor=c,s?(e.style.width=`2px`,e.style.height=`${r}px`):(e.style.width=`${r}px`,e.style.height=`2px`)}},OGe=new Map,kGe=class{get chipRenderers(){return this._chipRenderers}get groupUnderlines(){return this._indicator?.underlines??OGe}get skipNextCollapseAnimation(){return this._skipNextCollapseAnimation}set skipNextCollapseAnimation(e){this._skipNextCollapseAnimation=e}constructor(e,t){this._ctx=e,this._callbacks=t,this._chipRenderers=new Map,this._indicator=null,this._skipNextCollapseAnimation=!1,this._pendingTransitionCleanups=new Map}update(){let e=this._ctx.group.model.getTabGroups(),t=new Set;for(let n of e)t.add(n.id),this._ensureChipForGroup(n),this._positionChipForGroup(n);for(let[e,n]of this._chipRenderers)t.has(e)||(n.chip.element.remove(),n.chip.dispose(),n.disposable.dispose(),this._chipRenderers.delete(e));this._updateTabGroupClasses()}refreshAccents(){var e,t;for(let n of this._ctx.group.model.getTabGroups()){let r=this._chipRenderers.get(n.id);(t=r==null?void 0:(e=r.chip).update)==null||t.call(e,{tabGroup:n})}this._updateTabGroupClasses()}positionAllChips(){if(this._chipRenderers.size!==0)for(let e of this._ctx.group.model.getTabGroups())this._positionChipForGroup(e)}updateDirection(){let e=this._ctx.getDirection()===`vertical`;for(let[,t]of this._chipRenderers)t.dropTarget.setTargetZones(e?[`top`]:[`left`])}snapshotChipWidths(){let e=new Map;for(let[t,n]of this._chipRenderers)e.set(t,n.chip.element.getBoundingClientRect().width);return e}positionUnderlines(){var e;(e=this._indicator)==null||e.positionUnderlines()}trackUnderlines(){var e;(e=this._indicator)==null||e.trackUnderlines()}setGroupDragImage(e,t,n){if(!e.dataTransfer)return;let r=this._ctx.getDirection()===`vertical`,i=this._ctx.tabsList.cloneNode(!0);r?(i.classList.remove(`dv-tabs-container-vertical`,`dv-vertical`),i.classList.add(`dv-horizontal`),i.style.writingMode=`horizontal-tb`,i.style.height=`${this._ctx.tabsList.offsetWidth}px`):i.style.height=`${this._ctx.tabsList.offsetHeight}px`,i.style.width=`auto`,i.style.overflow=`visible`,i.style.pointerEvents=`none`;let a=Array.from(i.children),o=Array.from(this._ctx.tabsList.children);for(let e=a.length-1;e>=0;e--)o[e]!==n&&a[e].remove();let s=document.createElement(`div`);s.className=`dv-groupview dv-active-group`,s.style.position=`fixed`,s.style.top=`-10000px`,s.style.left=`0px`,s.style.height=`auto`,s.style.width=`auto`,s.style.pointerEvents=`none`;let c=document.createElement(`div`);c.className=`dv-tabs-and-actions-container`,c.style.height=`auto`,c.style.width=`auto`,s.appendChild(c),c.appendChild(i),this._ctx.accessor.element.appendChild(s);let l=i.querySelector(`.dv-tab-group-chip`),u=n.getBoundingClientRect(),d=e.clientX-u.left,f=e.clientY-u.top;if(l){let t=l.getBoundingClientRect(),n=s.getBoundingClientRect(),r=t.left-n.left+d,i=t.top-n.top+f;e.dataTransfer.setDragImage(s,r,i)}else e.dataTransfer.setDragImage(s,d,f);requestAnimationFrame(()=>{s.remove()})}cleanupTransition(e){var t;(t=this._pendingTransitionCleanups.get(e))==null||t(),this._pendingTransitionCleanups.delete(e)}updateDragAndDropState(){let e=NV(this._ctx.accessor.options);for(let t of this._chipRenderers.values())t.chip.element.draggable=e.html5,t.html5DragSource.setDisabled(!e.html5),t.pointerDragSource.setDisabled(!e.pointer),t.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}disposeChipDrag(e){var t,n;let r=this._chipRenderers.get(e);r&&((t=r.html5DragSource)==null||t.dispose(),(n=r.pointerDragSource)==null||n.dispose())}_buildChipGhostElement(e){let t=getComputedStyle(e),n=e.cloneNode(!0);return Array.from(t).forEach(e=>{n.style.setProperty(e,t.getPropertyValue(e),t.getPropertyPriority(e))}),n.style.position=`absolute`,n}disposeAll(){var e;(e=this._indicator)==null||e.dispose(),this._indicator=null;for(let[,e]of this._pendingTransitionCleanups)e();this._pendingTransitionCleanups.clear();for(let[,e]of this._chipRenderers)e.chip.element.remove(),e.chip.dispose(),e.disposable.dispose();this._chipRenderers.clear()}_ensureIndicator(){let e=(this._ctx.accessor.options.theme?.tabGroupIndicator??`wrap`)===`none`?DGe:EGe;this._indicator&&!(this._indicator instanceof e)&&(this._indicator.dispose(),this._indicator=null),this._indicator||=new e({tabsList:this._ctx.tabsList,getTabGroups:()=>this._ctx.group.model.getTabGroups(),getActivePanelId:()=>this._ctx.group.activePanel?.id,getTabMap:()=>this._ctx.getTabMap(),getChipElement:e=>this._chipRenderers.get(e)?.chip.element,getDirection:()=>this._ctx.getDirection(),getHeaderPosition:()=>this._ctx.group.model.headerPosition,getColorPalette:()=>this._ctx.accessor.tabGroupColorPalette})}_ensureChipForGroup(e){if(this._chipRenderers.has(e.id))return;let t=this._ctx.accessor.options.createTabGroupChipComponent,n=t?t(e):new UV(this._ctx.accessor.tabGroupColorPalette);n.init({tabGroup:e,api:this._ctx.accessor.api});let r=NV(this._ctx.accessor.options);n.element.draggable=r.html5;let i=cB.getInstance(),a=()=>(i.setData([new oB(this._ctx.accessor.id,this._ctx.group.id,null,e.id)],oB.prototype),{dispose:()=>{i.clearData(oB.prototype)}}),o=TV.createDragSource(n.element,{getData:a,disabled:!r.html5,isCancelled:()=>!NV(this._ctx.accessor.options).html5,onDragStart:t=>{`dataTransfer`in t&&t.dataTransfer&&this.setGroupDragImage(t,e,n.element),this._callbacks.onChipDragStart(e,n,t)},onDragEnd:t=>{var r,i;(i=(r=this._callbacks).onChipDragEnd)==null||i.call(r,e,n,t)}});n.element.addEventListener(`dragend`,()=>{i.clearData(oB.prototype)},{once:!0});let s=EV.createDragSource(n.element,{getData:a,disabled:!r.pointer,touchOnly:!r.pointerHandlesMouse,isCancelled:()=>!NV(this._ctx.accessor.options).pointer,createGhost:()=>({element:this._buildChipGhostElement(n.element),offsetX:8,offsetY:8}),onDragStart:t=>{this._callbacks.onChipDragStart(e,n,t)}}),c=[e.onDidChange(()=>{var t;(t=n.update)==null||t.call(n,{tabGroup:e}),this._updateTabGroupClasses()}),e.onDidPanelChange(()=>{this._positionChipForGroup(e),this._updateTabGroupClasses()}),e.onDidCollapseChange(()=>{this._updateTabGroupClasses()}),o,s],l=t=>{s.cancelPending(),this._callbacks.onChipContextMenu(e,t)};n instanceof UV?c.push(n.onContextMenu(l)):c.push(new MV(n.element,{onLongPress:l}),vB(n.element,`contextmenu`,l));let u=this._ctx.getDirection()===`vertical`,d=new xV(n.element,{acceptedTargetZones:u?[`top`]:[`left`],overlayModel:{activationSize:{value:100,type:`percentage`}},canDisplayOverlay:(e,t)=>{if(this._ctx.group.locked||this._ctx.accessor.options.disableDnd)return!1;let n=lB();return n&&this._ctx.accessor.id===n.viewId?this._ctx.accessor.options.theme?.tabAnimation!==`smooth`:this._ctx.group.model.canDisplayOverlay(e,t,`tab`)}});c.push(d,d.onDrop(t=>{this._callbacks.onChipDrop(e,t)}));let f=new fB(...c);this._chipRenderers.set(e.id,{chip:n,html5DragSource:o,pointerDragSource:s,disposable:f,dropTarget:d}),e.collapsed&&(this._skipNextCollapseAnimation=!0)}_positionChipForGroup(e){let t=this._chipRenderers.get(e.id);if(!t)return;let n=t.chip.element,r=e.panelIds;if(r.length===0){n.remove();return}let i=r[0],a=this._ctx.getTabMap().get(i);if(!a){n.remove();return}let o=a.value.element;n.nextSibling!==o&&this._ctx.tabsList.insertBefore(n,o)}_updateTabGroupClasses(){var e;let t=this._ctx.group.model.getTabGroups(),n=this._ctx.getTabs(),r=this._ctx.getTabMap(),i=!1,a=new Map;for(let e of t)for(let t of e.panelIds)a.set(t,e);for(let t of n){let n=t.value,r=n.panel.id,o=a.get(r),s=!!o;if(CB(n.element,`dv-tab--grouped`,s),o){let t=o.panelIds,a=t[0]===r,s=t[t.length-1]===r;CB(n.element,`dv-tab--group-first`,a),CB(n.element,`dv-tab--group-last`,s),VV(n.element,o.color,this._ctx.accessor.tabGroupColorPalette);let c=n.element.classList.contains(`dv-tab--group-collapsed`);if(!o.collapsed&&c){i=!0,n.element.classList.remove(`dv-tab--group-collapsed`),n.element.classList.add(`dv-tab--group-expanding`),(e=this._pendingTransitionCleanups.get(r))==null||e();let t=()=>{n.element.classList.remove(`dv-tab--group-expanding`),n.element.style.removeProperty(`width`),n.element.removeEventListener(`transitionend`,t),clearTimeout(a),this._pendingTransitionCleanups.delete(r)},a=setTimeout(t,300);this._pendingTransitionCleanups.set(r,t),n.element.addEventListener(`transitionend`,t)}}else CB(n.element,`dv-tab--group-first`,!1),CB(n.element,`dv-tab--group-last`,!1),n.element.classList.remove(`dv-tab--group-collapsed`,`dv-tab--group-expanding`),n.element.style.removeProperty(`width`),n.element.style.removeProperty(`--dv-tab-group-color`)}let o=new Set;for(let e of t)if(o.add(e.id),e.collapsed&&e.panelIds.some(e=>{let t=r.get(e);return t&&!t.value.element.classList.contains(`dv-tab--group-collapsed`)}))if(this._skipNextCollapseAnimation){let t=[];for(let n of e.panelIds){let e=r.get(n);e&&(e.value.element.style.transition=`none`,e.value.element.classList.add(`dv-tab--group-collapsed`),t.push(e.value.element))}if(t.length>0){t[0].offsetHeight;for(let e of t)e.style.removeProperty(`transition`)}}else{i=!0;let t=this._ctx.getDirection()===`vertical`;for(let n of e.panelIds){let e=r.get(n);if(e&&!e.value.element.classList.contains(`dv-tab--group-collapsed`)){let n=e.value.element.getBoundingClientRect();t?e.value.element.style.height=`${n.height}px`:e.value.element.style.width=`${n.width}px`,e.value.element.offsetHeight,e.value.element.classList.add(`dv-tab--group-collapsed`)}}}this._skipNextCollapseAnimation=!1,this._ensureIndicator(),this._indicator&&(this._indicator.syncUnderlineElements(o),i?this._indicator.trackUnderlines():this._indicator.positionUnderlines())}},AGe=class extends fB{get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e&&(this._showTabsOverflowControl=e,e)){let e=new AWe(this._tabsList);this._observerDisposable.value=new fB(e,e.onDidChange(e=>{let t=e.hasScrollX||e.hasScrollY;this.toggleDropdown({reset:!t}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),vB(this._tabsList,`scroll`,()=>{this.toggleDropdown({reset:!1}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}))}}get element(){return this._element}set voidContainer(e){var t;(t=this._voidContainerListeners)==null||t.dispose(),this._voidContainerListeners=null,this._voidContainer=e,e&&(this._voidContainerListeners=new fB(vB(e,`dragover`,e=>{this._animState&&e.preventDefault()}),vB(e,`drop`,e=>{this._animState?.sourceTabGroupId&&this._animState.currentInsertionIndex!==null&&(e.preventDefault(),e.stopPropagation(),this.handleVoidDrop())})))}handleVoidDrop(){if(!this._animState?.sourceTabGroupId)return!1;let e=this._animState.sourceTabGroupId,t=this._animState.currentInsertionIndex??this._tabs.length;return this._animState=null,this._commitGroupMove(e,t),!0}get panels(){return this._tabs.map(e=>e.value.panel.id)}get size(){return this._tabs.length}get tabs(){return this._tabs.map(e=>e.value)}get direction(){return this._direction}set direction(e){if(this._direction!==e){this._direction=e,this._tabsList.setAttribute(`aria-orientation`,e===`vertical`?`vertical`:`horizontal`),this._scrollbar&&(this._scrollbar.orientation=e),xB(this._tabsList,`dv-horizontal`,`dv-vertical`),e===`vertical`?SB(this._tabsList,`dv-tabs-container-vertical`,`dv-vertical`):(xB(this._tabsList,`dv-tabs-container-vertical`),SB(this._tabsList,`dv-horizontal`));for(let t of this._tabs)t.value.setDirection(e);this._tabGroupManager.updateDirection()}}constructor(e,t,n){super(),this.group=e,this.accessor=t,this._observerDisposable=new pB,this._scrollbar=null,this._tabs=[],this._tabMap=new Map,this.selectedIndex=-1,this._showTabsOverflowControl=!1,this._direction=`horizontal`,this._animState=null,this._pendingMarginCleanups=new Map,this._pendingCollapse=!1,this._flipTransitionCleanup=null,this._voidContainer=null,this._voidContainerListeners=null,this._extendedDropZone=null,this._pointerInsideTabsList=!1,this._onTabDragStart=new Q,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new Q,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new Q,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new Q,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement(`div`),this._tabsList.className=`dv-tabs-container`,this._tabsList.setAttribute(`role`,`tablist`),this._tabsList.setAttribute(`aria-orientation`,this._direction===`vertical`?`vertical`:`horizontal`),this.showTabsOverflowControl=n.showTabsOverflowControl,t.options.scrollbars===`native`?this._element=this._tabsList:(this._scrollbar=new IV(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new kGe({group:this.group,accessor:this.accessor,tabsList:this._tabsList,getTabs:()=>this._tabs,getTabMap:()=>this._tabMap,getDirection:()=>this._direction},{onChipContextMenu:(e,t)=>{var n;(n=this.accessor.contextMenuService)==null||n.showForChip(e,this.group,t)},onChipDragStart:(e,t,n)=>{this._handleChipDragStart(e,t,n)},onChipDragEnd:()=>{this.resetDragAnimation()},onChipDrop:(e,t)=>{this._handleChipDrop(e,t)}}),this.addDisposables(this._onOverflowTabsChange,this._observerDisposable,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,{dispose:()=>{var e;(e=this._flipTransitionCleanup)==null||e.call(this)}},wV.getInstance().onDragEnd(()=>{this._pointerInsideTabsList=!1,this.resetDragAnimation()}),wV.getInstance().onDragMove(e=>{this._handlePointerDragMove(e.clientX,e.clientY)}),vB(this.element,`pointerdown`,e=>{e.defaultPrevented||e.button===0&&this.accessor.doSetGroupActive(this.group)}),vB(this._tabsList,`wheel`,e=>{let t=this._direction===`vertical`,n=t?e.deltaY||e.deltaX:e.deltaX||e.deltaY;if(n===0)return;let r=t?this._tabsList.scrollHeight-this._tabsList.clientHeight:this._tabsList.scrollWidth-this._tabsList.clientWidth;if(r<=0)return;let i=t?this._tabsList.scrollTop:this._tabsList.scrollLeft;n<0&&i<=0||n>0&&i>=r||(e.preventDefault(),e.stopPropagation(),t?this._tabsList.scrollTop=i+n:this._tabsList.scrollLeft=i+n)},{passive:!1}),vB(this._tabsList,`keydown`,e=>{this._onKeyDown(e)}),vB(this._tabsList,`dragover`,e=>{this._processDragOver(e.clientX)&&e.preventDefault()},!0),vB(this._tabsList,`dragleave`,e=>{this._processDragLeave(e.relatedTarget)},!0),vB(this._tabsList,`dragend`,()=>{this.resetDragAnimation()}),vB(this._tabsList,`drop`,e=>{var t;if(!this._animState||this._animState.currentInsertionIndex===null||this.accessor.options.theme?.tabAnimation!==`smooth`&&!this._animState.sourceTabGroupId)return;e.stopPropagation(),e.preventDefault(),(t=this.group.model.dropTargetContainer?.model)==null||t.clear();let n=this._animState;if(this._animState=null,this._pendingCollapse=!1,n.sourceTabGroupId){this._commitGroupMove(n.sourceTabGroupId,n.currentInsertionIndex);return}let r=n.currentInsertionIndex,i=n.sourceIndex,a=r-+(i!==-1&&i<r),o=this.group.model.getTabGroupForPanel(n.sourceTabId);if(a===i&&!n.targetTabGroupId&&!o){this._uncollapsSourceTab(n.sourceTabId),this.resetTabTransforms();return}this._uncollapsSourceTab(n.sourceTabId);let s=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:e,index:a,targetTabGroupId:n.targetTabGroupId}),this.runFlipAnimation(s,n.sourceTabId,n.sourceIndex===-1,{from:Math.min(i,a),to:Math.max(i,a)})},!0),dB.from(()=>{var e;(e=this._voidContainerListeners)==null||e.dispose(),this.resetDragAnimation(),this._tabGroupManager.disposeAll();for(let{value:e,disposable:t}of this._tabs)t.dispose(),e.dispose();this._tabs=[],this._tabMap.clear()}))}indexOf(e){return this._tabs.findIndex(t=>t.value.panel.id===e)}getTabId(e){return this._tabMap.get(e)?.value.element.id}isActive(e){return this.selectedIndex>-1&&this._tabs[this.selectedIndex].value===e}_onKeyDown(e){let t=this._tabs.findIndex(t=>t.value.element===e.target);if(t===-1)return;let n=this._direction===`vertical`,r=n?`ArrowDown`:`ArrowRight`,i=n?`ArrowUp`:`ArrowLeft`,a=this._tabs.length-1;switch(e.key){case r:e.preventDefault(),this._focusTab(Math.min(t+1,a));break;case i:e.preventDefault(),this._focusTab(Math.max(t-1,0));break;case`Home`:e.preventDefault(),this._focusTab(0);break;case`End`:e.preventDefault(),this._focusTab(a);break;case`Enter`:case` `:e.preventDefault(),this.accessor.withOrigin(`user`,()=>this._tabs[t].value.panel.api.setActive());break;case`Delete`:case`Backspace`:e.preventDefault(),this._closeTab(t);break}}_closeTab(e){let t=this._tabs[e]?.value;if(!t)return;let n=(this._tabs[e+1]?.value??this._tabs[e-1]?.value)?.panel.id;if(t.panel.api.close(),n!==void 0){let e=this._tabs.findIndex(e=>e.value.panel.id===n);e>-1&&this._focusTab(e)}}_focusTab(e){for(let t=0;t<this._tabs.length;t++)this._tabs[t].value.element.tabIndex=t===e?0:-1;this._tabs[e].value.element.focus()}focusActiveTab(){if(this._tabs.length===0)return;let e=this.group.activePanel?.id,t=e?this._tabs.findIndex(t=>t.value.panel.id===e):-1;this._focusTab(t>-1?t:0)}setActivePanel(e){let t=this._direction===`vertical`,n=0;for(let r of this._tabs){let i=e.id===r.value.panel.id;if(r.value.setActive(i),i){let e=r.value.element,i=e.parentElement;t?(n<i.scrollTop||n+e.clientHeight>i.scrollTop+i.clientHeight)&&(i.scrollTop=n):(n<i.scrollLeft||n+e.clientWidth>i.scrollLeft+i.clientWidth)&&(i.scrollLeft=n)}n+=t?r.value.element.clientHeight:r.value.element.clientWidth}this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}openPanel(e,t=this._tabs.length){if(this._tabMap.has(e.id))return;let n=new CGe(e,this.accessor,this.group);n.setContent(e.view.tab),this._direction!==`horizontal`&&n.setDirection(this._direction);let r={value:n,disposable:new fB(n.onDragStart(t=>{if(this._onTabDragStart.fire({nativeEvent:t,panel:e}),this.accessor.options.theme?.tabAnimation===`smooth`){let t=n.element.getBoundingClientRect().width,r=this._tabs.findIndex(e=>e.value===n);this._animState={sourceTabId:e.id,sourceIndex:r,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:t/2,sourceGapWidth:t,containerLeft:this._tabsList.getBoundingClientRect().left},this._pendingCollapse=!0,requestAnimationFrame(()=>{var e;this._pendingCollapse=!1,this._animState&&(n.element.style.transition=`none`,CB(n.element,`dv-tab--dragging`,!0),n.element.offsetHeight,(e=this._animState).currentInsertionIndex??(e.currentInsertionIndex=r),this.applyDragOverTransforms(!0),n.element.style.removeProperty(`transition`))})}}),n.onTabClick(t=>{t.defaultPrevented||this.group.api.location.type===`edge`&&(this.group.activePanel===e?this.group.api.isCollapsed()?this.group.api.expand():this.group.api.collapse():(this.group.model.openPanel(e),this.group.api.isCollapsed()&&this.group.api.expand()))}),n.onPointerDown(t=>{if(t.defaultPrevented)return;let r=!this.accessor.options.disableFloatingGroups,i=this.group.api.location.type===`floating`&&this.size===1;if(r&&!i&&t.shiftKey){t.preventDefault();let e=this.accessor.getGroupPanel(n.panel.id),{top:r,left:i}=n.element.getBoundingClientRect(),{top:a,left:o}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(e,{x:i-o,y:r-a,inDragMode:!0});return}switch(t.button){case 0:this.group.api.location.type===`edge`||this.group.activePanel!==e&&this.group.model.openPanel(e);break}}),n.onDrop(e=>{let t=this._animState;this._animState=null,this._pendingCollapse=!1;let r=this._tabs.findIndex(e=>e.value===n);if(t){let n=e.position===`right`?r+1:r;if(t.sourceTabGroupId){this._commitGroupMove(t.sourceTabGroupId,t.currentInsertionIndex??n);return}this._uncollapsSourceTab(t.sourceTabId);let i=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:e.nativeEvent,index:n,targetTabGroupId:t.targetTabGroupId}),this.accessor.options.theme?.tabAnimation===`smooth`&&this.runFlipAnimation(i,t.sourceTabId,t.sourceIndex===-1,t.sourceIndex===-1?void 0:{from:Math.min(t.sourceIndex,n),to:Math.max(t.sourceIndex,n)})}else{let t=this._direction===`vertical`?`bottom`:`right`,i=e.position===t?r+1:r,a=lB(),o=a?this._tabs.findIndex(e=>e.value.panel.id===a.panelId):-1,s=i-+(o!==-1&&o<i),c=this.group.model.getTabGroupForPanel(n.panel.id)?.id??null;this._onDrop.fire({event:e.nativeEvent,index:s,targetTabGroupId:c})}}),n.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new PV(e,{kind:`tab`,panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:lB}))}))};this.addTab(r,t),this._tabGroupManager.positionAllChips(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}delete(e){this._animState?.sourceTabId===e&&(this.resetTabTransforms(),this._animState=null),this._tabGroupManager.cleanupTransition(e);let t=this.indexOf(e),n=this._tabs.splice(t,1)[0];if(this._tabMap.delete(e),n){let{value:e,disposable:t}=n;t.dispose(),e.dispose(),e.element.remove()}this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}addTab(e,t=this._tabs.length){if(t<0||t>this._tabs.length)throw Error(`invalid location`);let n=t<this._tabs.length?this._tabs[t].value.element:null;this._tabsList.insertBefore(e.value.element,n),this._tabs=[...this._tabs.slice(0,t),e,...this._tabs.slice(t)],this._tabMap.set(e.value.panel.id,e),this.selectedIndex<0&&(this.selectedIndex=t)}toggleDropdown(e){if(e.reset){this._onOverflowTabsChange.fire({tabs:[],tabGroups:[],reset:!0});return}let t=this._tabs.filter(e=>!NB(e.value.element,this._tabsList)).map(e=>e.value.panel.id),n=new Set(t),r=[];for(let e of this.group.model.getTabGroups()){let i=this._tabGroupManager.chipRenderers.get(e.id),a=i&&!NB(i.chip.element,this._tabsList),o=e.panelIds.length>0&&e.panelIds.every(e=>n.has(e));if((a||o)&&(r.push(e.id),e.collapsed))for(let r of e.panelIds)n.has(r)||(n.add(r),t.push(r))}this._onOverflowTabsChange.fire({tabs:t,tabGroups:r,reset:!1})}updateDragAndDropState(){for(let e of this._tabs)e.value.updateDragAndDropState();this._tabGroupManager.updateDragAndDropState()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,t,n){let r=e.panelIds[0],i=r?this._tabs.findIndex(e=>e.value.panel.id===r):-1,a=t.element.getBoundingClientRect(),o=a.width;for(let t of e.panelIds){let e=this._tabMap.get(t);e&&(o+=e.value.element.getBoundingClientRect().width)}if(this._animState={sourceTabId:``,sourceIndex:i,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.id,sourceGroupPanelIds:new Set(e.panelIds),sourceChipWidth:a.width,cursorOffsetFromDragLeft:n.clientX-a.left,sourceGapWidth:o,containerLeft:this._tabsList.getBoundingClientRect().left},this.accessor.options.theme?.tabAnimation!==`smooth`)return;let s=new Set(e.panelIds);this._pendingCollapse=!0,requestAnimationFrame(()=>{var t;if(this._pendingCollapse=!1,!this._animState)return;for(let e of this._tabs)s.has(e.value.panel.id)&&(e.value.element.style.transition=`none`,CB(e.value.element,`dv-tab--dragging`,!0));let n=this._tabGroupManager.chipRenderers.get(e.id);n&&(n.chip.element.style.transition=`none`,CB(n.chip.element,`dv-tab-group-chip--dragging`,!0)),this._tabsList.offsetHeight;let r=this._tabGroupManager.groupUnderlines.get(e.id);r&&(r.style.display=`none`),(t=this._animState).currentInsertionIndex??(t.currentInsertionIndex=i),this.applyDragOverTransforms(!0);for(let e of this._tabs)s.has(e.value.panel.id)&&e.value.element.style.removeProperty(`transition`);n&&n.chip.element.style.removeProperty(`transition`)})}_handleChipDrop(e,t){let n=e.panelIds[0];if(!n)return;let r=this._tabs.findIndex(e=>e.value.panel.id===n);if(r===-1)return;let i=lB(),a=i&&i.groupId===this.group.id&&i.panelId?this._tabs.findIndex(e=>e.value.panel.id===i.panelId):-1,o=r-+(a!==-1&&a<r);this._onDrop.fire({event:t.nativeEvent,index:o,targetTabGroupId:null})}setExtendedDropZone(e){this._extendedDropZone=e}setExternalInsertionIndex(e){this._animState&&e!==this._animState.currentInsertionIndex&&(this._animState.currentInsertionIndex=e,this.applyDragOverTransforms())}clearExternalAnimState(){this._animState&&(this.resetTabTransforms(),this._animState.sourceIndex===-1?this._animState=null:this._animState.currentInsertionIndex=null)}snapshotTabPositions(){let e=new Map;for(let t of this._tabs)e.set(t.value.panel.id,t.value.element.getBoundingClientRect());return e}getAverageTabWidth(){if(this._tabs.length===0)return 0;let e=this._direction===`vertical`,t=0;for(let n of this._tabs){let r=n.value.element.getBoundingClientRect();t+=e?r.height:r.width}return t/this._tabs.length}_handlePointerDragMove(e,t){let n=(this._tabsList.ownerDocument??document).elementFromPoint(e,t);if(!(n&&(this._tabsList.contains(n)||this._extendedDropZone&&this._extendedDropZone.contains(n)))){this._pointerInsideTabsList&&(this._pointerInsideTabsList=!1,this._processDragLeave(n));return}this._pointerInsideTabsList=!0,this._processDragOver(e)}_processDragOver(e){var t;if(this.accessor.options.disableDnd)return!1;if(this._animState){let e=lB();e?.tabGroupId&&e.groupId!==this.group.id&&this._animState.sourceTabGroupId!==e.tabGroupId&&(this._animState=null)}if(!this._animState){let e=lB();if(this.accessor.options.theme?.tabAnimation==="default"&&!e?.tabGroupId)return!1;if(e&&(e.panelId||e.tabGroupId)&&e.groupId!==this.group.id){let t=this.getAverageTabWidth();if(e.tabGroupId){let n=this.accessor.getPanel(e.groupId)?.model.getTabGroups().find(t=>t.id===e.tabGroupId),r=t*(n?.panelIds.length??1)+t;this._animState={sourceTabId:``,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.tabGroupId,sourceGroupPanelIds:n?new Set(n.panelIds):new Set,sourceChipWidth:t,cursorOffsetFromDragLeft:r/2,sourceGapWidth:r,containerLeft:this._tabsList.getBoundingClientRect().left}}else this._animState={sourceTabId:e.panelId,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:t/2,sourceGapWidth:t,containerLeft:this._tabsList.getBoundingClientRect().left}}else return!1}return this._animState.sourceIndex!==-1&&((t=this.group.model.dropTargetContainer?.model)==null||t.clear()),this.handleDragOver({clientX:e}),!0}_processDragLeave(e){var t;if(this._animState&&!(e&&this._tabsList.contains(e))){if(e&&this._extendedDropZone?.contains(e)){this.resetTabTransforms(),this._animState.currentInsertionIndex=null;return}this._voidContainer&&e&&(e===this._voidContainer||this._voidContainer.contains(e))||(this.resetTabTransforms(),this._animState.sourceIndex===-1?((t=this.group.model.dropTargetContainer?.model)==null||t.clear(),this._animState=null):this._animState.currentInsertionIndex=null)}}handleDragOver(e){if(!this._animState)return;let t=e.clientX,n=null,r=null,i=this._animState.sourceGroupPanelIds,a=t-this._animState.cursorOffsetFromDragLeft-this._animState.containerLeft,o=0,s=new Map;if(this._tabGroupManager.chipRenderers.size>0){let e=this.group.model.getTabGroups();for(let t of e)t.id!==this._animState.sourceTabGroupId&&t.panelIds.length>0&&s.set(t.panelIds[0],t.id)}for(let e=0;e<this._tabs.length;e++){let t=this._tabs[e].value;if(t.panel.id===this._animState.sourceTabId||i?.has(t.panel.id))continue;let r=s.get(t.panel.id);if(r){let t=this._animState.chipPositions.get(r)??0;if(o+t>a){n??=e;break}o+=t}let c=this._animState.tabPositions.get(t.panel.id),l=c?c.width:t.element.getBoundingClientRect().width;if(o+l/2<=a)o+=l,n=e+1;else{n??=e;break}}if(n!==null&&this._tabGroupManager.chipRenderers.size>0){let e=!!this._animState.sourceTabGroupId,a=this.group.model.getTabGroups(),o=0;for(let e=0;e<this._tabs.length;e++){let t=this._tabs[e].value;if(t.panel.id===this._animState.sourceTabId||i?.has(t.panel.id))continue;if(e>=n)break;let r=s.get(t.panel.id);r&&(o+=this._animState.chipPositions.get(r)??0);let a=this._animState.tabPositions.get(t.panel.id);o+=a?a.width:t.element.getBoundingClientRect().width}for(let s of a){let a=s.panelIds.filter(e=>e!==this._animState.sourceTabId&&!i?.has(e));if(a.length===0)continue;let c=this._tabs.findIndex(e=>e.value.panel.id===a[0]),l=this._tabs.findIndex(e=>e.value.panel.id===a[a.length-1]);if(c===-1||l===-1)continue;let u=n>=c&&n<=l,d=!u&&n===c-1;if(!(!u&&!d)){if(e&&u){let e=(c+l+1)/2;n=n<e?c:l+1;break}if(e&&d)break;if(d){let e=!0;for(let t=n;t<c;t++){let n=this._tabs[t].value.panel.id;if(n!==this._animState.sourceTabId&&!i?.has(n)){e=!1;break}}if(!e)continue;let a=this._animState.chipPositions.get(s.id)??0;t>=(s.collapsed?this._animState.containerLeft+o+a/2:this._animState.containerLeft+o+a)&&(n=c,r=s.id);break}if(u){let e=this._animState.chipPositions.get(s.id)??0,i=this._animState.containerLeft+o+e;n===c?t>=i&&(r=s.id):r=s.id;break}}}}n===this._animState.currentInsertionIndex&&r===this._animState.targetTabGroupId||(this._animState.currentInsertionIndex=n,this._animState.targetTabGroupId=r,this.accessor.options.theme?.tabAnimation===`smooth`&&this.applyDragOverTransforms())}_removeClassInstantlyBatch(e,t){let n=[];for(let r of e)r.classList.contains(t)&&(r.style.transition=`none`,CB(r,t,!1),n.push(r));if(n.length>0){n[0].offsetHeight;for(let e of n)e.style.removeProperty(`transition`)}}_uncollapsSourceTab(e){let t=this._tabMap.get(e);t&&this._removeClassInstantlyBatch([t.value.element],`dv-tab--dragging`)}applyDragOverTransforms(e=!1){if(!this._animState||this._animState.currentInsertionIndex===null){this.resetTabTransforms();return}if(this._pendingCollapse)return;let t=this._animState.currentInsertionIndex,n,r=this._animState.sourceGroupPanelIds;if(this._animState.sourceTabGroupId&&r)n=this._animState.sourceGapWidth;else{let e=this._animState.tabPositions.get(this._animState.sourceTabId);n=e?e.width:this.getAverageTabWidth()}let i=null;if(this._tabGroupManager.chipRenderers.size>0){let e=this.group.model.getTabGroups();for(let n of e){if(n.id===this._animState.sourceTabGroupId||n.panelIds.includes(this._animState.sourceTabId))continue;let e=n.panelIds.filter(e=>e!==this._animState.sourceTabId&&!r?.has(e));if(e.length===0)continue;let a=this._tabs.findIndex(t=>t.value.panel.id===e[0]);if((!this._animState.targetTabGroupId||this._animState.targetTabGroupId===n.id&&n.collapsed)&&a>=t){let e=!1;for(let n=t;n<a;n++){let t=this._tabs[n].value.panel.id;if(t!==this._animState.sourceTabId&&!r?.has(t)){e=!0;break}}if(!e){let e=this._tabGroupManager.chipRenderers.get(n.id);e&&(i=e.chip.element)}break}}}let a=e=>e.classList.contains(`dv-tab-group-chip`)?`dv-tab-group-chip--shifting`:`dv-tab--shifting`,o=(t,n)=>{e?(t.style.transition=`none`,t.style.marginLeft=n,t.offsetHeight,t.style.removeProperty(`transition`)):t.style.marginLeft=n,CB(t,a(t),!0)},s=t=>{let n=a(t),r=this._pendingMarginCleanups.get(t);if(r&&r(),e||!t.style.marginLeft)t.style.removeProperty(`margin-left`),CB(t,n,!1);else{t.style.marginLeft=`0px`,CB(t,n,!0);let e=()=>{t.style.removeProperty(`margin-left`),CB(t,n,!1),t.removeEventListener(`transitionend`,e),clearTimeout(r),this._pendingMarginCleanups.delete(t)},r=setTimeout(e,300);this._pendingMarginCleanups.set(t,e),t.addEventListener(`transitionend`,e)}},c=!1;for(let[e,t]of this._tabGroupManager.chipRenderers)e!==this._animState.sourceTabGroupId&&s(t.chip.element);i&&(o(i,`${n}px`),c=!0);for(let e=0;e<this._tabs.length;e++){let i=this._tabs[e].value;i.panel.id!==this._animState.sourceTabId&&(r?.has(i.panel.id)||(!c&&e>=t?(o(i.element,`${n}px`),c=!0):s(i.element)))}this._tabGroupManager.trackUnderlines()}resetTabTransforms(){for(let[,e]of this._pendingMarginCleanups)e();this._pendingMarginCleanups.clear();for(let e of this._tabs)e.value.element.style.removeProperty(`margin-left`),e.value.element.style.removeProperty(`margin-right`),e.value.element.style.removeProperty(`margin-top`),e.value.element.style.removeProperty(`margin-bottom`),e.value.element.style.removeProperty(`transform`),CB(e.value.element,`dv-tab--shifting`,!1);for(let[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty(`margin-left`),CB(e.chip.element,`dv-tab-group-chip--shifting`,!1);this._tabGroupManager.positionUnderlines()}_commitGroupMove(e,t){let n=lB();if(this._tabGroupManager.disposeChipDrag(e),this.group.model.getTabGroups().some(t=>t.id===e))if(this.accessor.options.theme?.tabAnimation===`smooth`){this._clearGroupDragClasses(e);let n=this.snapshotTabPositions();this.resetTabTransforms(),this.group.model.moveTabGroup(e,t),this.runFlipAnimation(n,``,!1)}else this._tabGroupManager.skipNextCollapseAnimation=!0,this.group.model.moveTabGroup(e,t);else n&&(this.resetTabTransforms(),this.accessor.moveGroupOrPanel({from:{groupId:n.groupId,tabGroupId:n.tabGroupId??e},to:{group:this.group,position:`center`,index:t}}))}_clearGroupDragClasses(e){let t=this._tabGroupManager.chipRenderers.get(e);t&&this._removeClassInstantlyBatch([t.chip.element],`dv-tab-group-chip--dragging`),this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),`dv-tab--dragging`);let n=this._tabGroupManager.groupUnderlines.get(e);n&&n.style.removeProperty(`display`),this._tabGroupManager.skipNextCollapseAnimation=!0}resetDragAnimation(){if(this._pendingCollapse=!1,this._animState){this.resetTabTransforms(),this._animState.sourceTabGroupId?this._clearGroupDragClasses(this._animState.sourceTabGroupId):this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),`dv-tab--dragging`),this._animState=null;for(let[,e]of this._tabGroupManager.groupUnderlines)e.style.removeProperty(`display`)}}runFlipAnimation(e,t,n=!1,r){let i=this._direction===`vertical`,a=!1;for(let o=0;o<this._tabs.length;o++){let s=this._tabs[o],c=s.value.panel.id;if(c===t){if(n){let e=s.value.element.getBoundingClientRect();s.value.element.style.transform=i?`translateY(${e.height}px)`:`translateX(${e.width}px)`,CB(s.value.element,`dv-tab--shifting`,!0),a=!0}continue}if(r!==void 0&&(o<r.from||o>r.to))continue;let l=e.get(c);if(!l)continue;let u=s.value.element.getBoundingClientRect(),d=i?l.top-u.top:l.left-u.left;Math.abs(d)<1||(s.value.element.style.transform=i?`translateY(${d}px)`:`translateX(${d}px)`,CB(s.value.element,`dv-tab--shifting`,!0),a=!0)}a&&requestAnimationFrame(()=>{var e;for(let e of this._tabs)e.value.element.style.transform&&(e.value.element.style.transform=``);this._tabGroupManager.trackUnderlines(),(e=this._flipTransitionCleanup)==null||e.call(this);let t=e=>{if(e.propertyName===`transform`){n();for(let e of this._tabs)CB(e.value.element,`dv-tab--shifting`,!1);this._tabGroupManager.positionUnderlines()}},n=()=>{this._tabsList.removeEventListener(`transitionend`,t),this._flipTransitionCleanup=null};this._flipTransitionCleanup=n,this._tabsList.addEventListener(`transitionend`,t)})}},GV=e=>{let t=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);t.setAttributeNS(null,`height`,e.height),t.setAttributeNS(null,`width`,e.width),t.setAttributeNS(null,`viewBox`,e.viewbox),t.setAttributeNS(null,`aria-hidden`,`false`),t.setAttributeNS(null,`focusable`,`false`),t.classList.add(`dv-svg`);let n=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return n.setAttributeNS(null,`d`,e.path),t.appendChild(n),t},jGe=()=>GV({width:`11`,height:`11`,viewbox:`0 0 28 28`,path:`M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z`}),MGe=()=>GV({width:`11`,height:`11`,viewbox:`0 0 24 15`,path:`M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z`}),KV=()=>GV({width:`11`,height:`11`,viewbox:`0 0 15 25`,path:`M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z`});function NGe(){let e=document.createElement(`div`);e.className=`dv-tabs-overflow-dropdown-default`;let t=document.createElement(`span`);t.textContent=``;let n=KV();return e.appendChild(n),e.appendChild(t),{element:e,update:e=>{t.textContent=`${e.tabs}`}}}var PGe=class extends fB{get onTabDragStart(){return this.tabs.onTabDragStart}get panels(){return this.tabs.panels}get size(){return this.tabs.size}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?`none`:``}get direction(){return this._direction}set direction(e){this._direction=e,e===`vertical`?(SB(this._element,`dv-groupview-header-vertical`),SB(this.rightActionsContainer,`dv-right-actions-container-vertical`),this.tabs.direction=e):(xB(this._element,`dv-groupview-header-vertical`),xB(this.rightActionsContainer,`dv-right-actions-container-vertical`),this.tabs.direction=e)}get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._hidden=!1,this._direction=`horizontal`,this.dropdownPart=null,this._overflowTabs=[],this._overflowTabGroups=[],this._dropdownDisposable=new pB,this._onDrop=new Q,this.onDrop=this._onDrop.event,this._onGroupDragStart=new Q,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new Q,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement(`div`),this._element.className=`dv-tabs-and-actions-container`,CB(this._element,`dv-full-width-single-tab`,this.accessor.options.singleTabMode===`fullwidth`),this.rightActionsContainer=document.createElement(`div`),this.rightActionsContainer.className=`dv-right-actions-container`,this.leftActionsContainer=document.createElement(`div`),this.leftActionsContainer.className=`dv-left-actions-container`,this.preActionsContainer=document.createElement(`div`),this.preActionsContainer.className=`dv-pre-actions-container`,this.tabs=new AGe(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new TGe(this.accessor,this.group),this.tabs.voidContainer=this.voidContainer.element,this._element.appendChild(this.preActionsContainer),this._element.appendChild(this.tabs.element),this._element.appendChild(this.leftActionsContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.rightActionsContainer),this.tabs.setExtendedDropZone(this._element),this.addDisposables(this.tabs.onDrop(e=>this._onDrop.fire(e)),this.tabs.onWillShowOverlay(e=>this._onWillShowOverlay.fire(e)),e.onDidOptionsChange(()=>{this.tabs.showTabsOverflowControl=!e.options.disableTabsOverflowList}),this.tabs.onOverflowTabsChange(e=>{this.toggleDropdown(e)}),this.tabs,this._onWillShowOverlay,this._onDrop,this._onGroupDragStart,this.voidContainer,this.voidContainer.onDragStart(e=>{this._onGroupDragStart.fire({nativeEvent:e,group:this.group})}),this.voidContainer.onDrop(e=>{this.tabs.handleVoidDrop()||this._onDrop.fire({event:e.nativeEvent,index:this.tabs.size})}),this.voidContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new PV(e,{kind:`header_space`,panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:lB}))}),vB(this.leftActionsContainer,`dragleave`,e=>{let t=e.relatedTarget;!this.leftActionsContainer.contains(t)&&!this._element.contains(t)&&this.tabs.clearExternalAnimState()}),vB(this.voidContainer.element,`dragleave`,e=>{let t=e.relatedTarget;this.voidContainer.element.contains(t)||(this._element.contains(t)?this.tabs.setExternalInsertionIndex(null):this.tabs.clearExternalAnimState())}),vB(this.voidContainer.element,`pointerdown`,e=>{if(!e.defaultPrevented&&!this.accessor.options.disableFloatingGroups&&e.shiftKey&&this.group.api.location.type!==`floating`&&this.group.api.location.type!==`edge`){e.preventDefault();let{top:t,left:n}=this.element.getBoundingClientRect(),{top:r,left:i}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:n-i+20,y:t-r+20,inDragMode:!0})}}))}show(){this.hidden||(this.element.style.display=``)}hide(){this._element.style.display=`none`}setRightActionsElement(e){this.rightActions!==e&&(this.rightActions&&=(this.rightActions.remove(),void 0),e&&(this.rightActionsContainer.appendChild(e),this.rightActions=e))}setLeftActionsElement(e){this.leftActions!==e&&(this.leftActions&&=(this.leftActions.remove(),void 0),e&&(this.leftActionsContainer.appendChild(e),this.leftActions=e))}setPrefixActionsElement(e){this.preActions!==e&&(this.preActions&&=(this.preActions.remove(),void 0),e&&(this.preActionsContainer.appendChild(e),this.preActions=e))}isActive(e){return this.tabs.isActive(e)}indexOf(e){return this.tabs.indexOf(e)}getTabId(e){return this.tabs.getTabId(e)}setActive(e){}delete(e){this.tabs.delete(e),this.updateClassnames()}setActivePanel(e){this.tabs.setActivePanel(e)}focusActiveTab(){this.tabs.focusActiveTab()}openPanel(e,t=this.tabs.size){this.tabs.openPanel(e,t),this.updateClassnames()}closePanel(e){this.delete(e.id)}updateClassnames(){CB(this._element,`dv-single-tab`,this.size===1)}toggleDropdown(e){let t=e.reset?[]:e.tabs,n=e.reset?[]:e.tabGroups;this._overflowTabs=t,this._overflowTabGroups=n;let r=this._overflowTabs.length;if(r>0&&this.dropdownPart){this.dropdownPart.update({tabs:r});return}if(r===0){this._dropdownDisposable.dispose();return}let i=document.createElement(`div`);i.className=`dv-tabs-overflow-dropdown-root`;let a=NGe();a.update({tabs:r}),this.dropdownPart=a,i.appendChild(a.element),this.rightActionsContainer.prepend(i),this._dropdownDisposable.value=new fB(dB.from(()=>{var e,t;i.remove(),(t=(e=this.dropdownPart)?.dispose)==null||t.call(e),this.dropdownPart=null}),vB(i,`pointerdown`,e=>{e.preventDefault()},{capture:!0}),vB(i,`click`,e=>{let t=document.createElement(`div`);t.style.overflow=`auto`,t.className=`dv-tabs-overflow-container`;let n=new Set(this._overflowTabGroups),r=this.group.model.getTabGroups(),a=new Map;for(let e of r)if(n.has(e.id))for(let t of e.panelIds)a.set(t,e);let o=new Set;for(let e of this.tabs.tabs.filter(e=>this._overflowTabs.includes(e.panel.id))){let n=a.get(e.panel.id);if(n&&!o.has(n.id)){o.add(n.id);let e=document.createElement(`div`);e.className=`dv-tabs-overflow-group-header`;let r=document.createElement(`span`);r.className=`dv-tabs-overflow-group-color`,VV(r,n.color,this.accessor.tabGroupColorPalette),e.appendChild(r);let i=document.createElement(`span`);if(i.className=`dv-tabs-overflow-group-label`,i.textContent=n.label||n.id,e.appendChild(i),n.collapsed){let t=document.createElement(`span`);t.className=`dv-tabs-overflow-group-collapsed-badge`,t.textContent=`${n.panelIds.length}`,e.appendChild(t)}e.addEventListener(`click`,()=>{this.accessor.getPopupServiceForGroup(this.group).close(),n.collapsed&&n.expand();let e=n.panelIds[0];if(e){let t=this.group.panels.find(t=>t.id===e);this.accessor.withOrigin(`user`,()=>t?.api.setActive())}}),t.appendChild(e)}let r=this.group.panels.find(t=>t===e.panel),i=r.view.createTabRenderer(`headerOverflow`).element,s=document.createElement(`div`);CB(s,`dv-tab`,!0),CB(s,`dv-active-tab`,r.api.isActive),CB(s,`dv-inactive-tab`,!r.api.isActive),n&&CB(s,`dv-tab--grouped`,!0),s.addEventListener(`click`,t=>{this.accessor.getPopupServiceForGroup(this.group).close(),!t.defaultPrevented&&(n?.collapsed&&n.expand(),e.element.scrollIntoView(),this.accessor.withOrigin(`user`,()=>e.panel.api.setActive()))}),s.appendChild(i),t.appendChild(s)}let s=PB(i);this.accessor.getPopupServiceForGroup(this.group).openPopover(t,{x:e.clientX,y:e.clientY,zIndex:s?.style.zIndex?`calc(${s.style.zIndex} * 2)`:void 0})}))}updateDragAndDropState(){this.tabs.updateDragAndDropState(),this.voidContainer.updateDragAndDropState()}updateTabGroups(){this.tabs.updateTabGroups()}refreshTabGroupAccent(){this.tabs.refreshTabGroupAccent()}},qV=class extends gB{constructor(e,t,n,r,i){super(),this.nativeEvent=e,this.target=t,this.position=n,this.getData=r,this.group=i}},JV=Object.keys({disableAutoResizing:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,transformFloatingGroupDrag:void 0,floatingGroupDragHandle:void 0,popoutUrl:void 0,nonce:void 0,defaultRenderer:void 0,defaultHeaderPosition:void 0,debug:void 0,locked:void 0,disableDnd:void 0,dndStrategy:void 0,className:void 0,noPanelsOverlay:void 0,dndEdges:void 0,theme:void 0,disableTabsOverflowList:void 0,scrollbars:void 0,getTabContextMenuItems:void 0,getTabGroupChipContextMenuItems:void 0,createTabGroupChipComponent:void 0,createGroupDragGhostComponent:void 0,dropOverlayModel:void 0,announcements:void 0,getAnnouncement:void 0,announcer:void 0,messages:void 0,keyboardNavigation:void 0,tabGroupColors:void 0,tabGroupAccent:void 0});function FGe(e){return!!e.referencePanel}function IGe(e){return!!e.referenceGroup}function LGe(e){return!!e.referencePanel}function RGe(e){return!!e.referenceGroup}var zGe=class extends fB{get label(){return this._label}get color(){return this._color}get componentParams(){return this._componentParams}setLabel(e){this.isDisposed||this._label===e||(this._label=e,this._onDidChange.fire())}setColor(e){if(this.isDisposed)return;let t=e===``?void 0:e;this._color!==t&&(this._color=t,this._onDidChange.fire())}setComponentParams(e){this.isDisposed||(this._componentParams=e,this._onDidChange.fire())}get collapsed(){return this._collapsed}get panelIds(){return this._panelIds}get size(){return this._panelIds.length}get isEmpty(){return this._panelIds.length===0}constructor(e,t){super(),this.id=e,this._collapsed=!1,this._panelIds=[],this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new Q,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new Q,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new Q,this.onDidDestroy=this._onDidDestroy.event,this._label=t?.label??``,this._color=t?.color===``?void 0:t?.color,this._collapsed=t?.collapsed??!1,this._componentParams=t?.componentParams,this.addDisposables(this._onDidChange,this._onDidPanelChange,this._onDidCollapseChange,this._onDidDestroy)}addPanel(e,t){if(this.isDisposed||this._panelIds.includes(e))return;let n=t===void 0?this._panelIds.length:Math.max(0,Math.min(t,this._panelIds.length));this._panelIds.splice(n,0,e),this._onDidPanelChange.fire({panelId:e,type:`add`})}removePanel(e){if(this.isDisposed)return!1;let t=this._panelIds.indexOf(e);return t===-1?!1:(this._panelIds.splice(t,1),this._onDidPanelChange.fire({panelId:e,type:`remove`}),!0)}indexOfPanel(e){return this._panelIds.indexOf(e)}containsPanel(e){return this._panelIds.includes(e)}collapse(){this.isDisposed||this._collapsed||(this._collapsed=!0,this._onDidCollapseChange.fire(!0))}expand(){this.isDisposed||!this._collapsed||(this._collapsed=!1,this._onDidCollapseChange.fire(!1))}toggle(){this._collapsed?this.expand():this.collapse()}toJSON(){let e={id:this.id,collapsed:this._collapsed,panelIds:[...this._panelIds]};return this._label&&(e.label=this._label),this._color!==void 0&&(e.color=this._color),this._componentParams!==void 0&&(e.componentParams=this._componentParams),e}dispose(){this._onDidDestroy.fire(),super.dispose()}},YV=class extends hB{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get panel(){return this.options.panel}get group(){return this.options.group}get api(){return this.options.api}constructor(e){super(),this.options=e}getData(){return this.options.getData()}},XV=class extends YV{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}},BGe=class extends fB{get tabGroups(){return this._tabGroups}get element(){throw Error(`dockview: not supported`)}get activePanel(){return this._activePanel}get contentContainerId(){return this.contentContainer.element.id}get contentDropTarget(){return this.contentContainer.dropTarget}get locked(){return this._locked}set locked(e){this._locked=e,CB(this.container,`dv-locked-groupview`,e===`no-drop-target`||e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return this._panels.length===0}get hasWatermark(){return!!(this.watermark&&this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get isContentFocused(){return document.activeElement?wB(document.activeElement,this.contentContainer.element):!1}get headerPosition(){return this._headerPosition??`top`}set headerPosition(e){this._headerPosition=e,xB(this.container,`dv-groupview-header-top`,`dv-groupview-header-bottom`,`dv-groupview-header-left`,`dv-groupview-header-right`),SB(this.container,`dv-groupview-header-${e}`);let t=e===`top`||e===`bottom`?`horizontal`:`vertical`;this.tabsContainer.direction=t,this.header.direction=t,this._activePanel?.layout&&this._activePanel.layout(this._width,this._height),this.updateHeaderActions()}get location(){return this._location}set location(e){this._location=e,CB(this.container,`dv-groupview-floating`,!1),CB(this.container,`dv-groupview-popout`,!1),CB(this.container,`dv-groupview-edge`,!1);let t=e=>{this.contentContainer.dropTarget.setTargetZones(e),this.contentContainer.pointerDropTarget.setTargetZones(e)};switch(e.type){case`grid`:t([`top`,`bottom`,`left`,`right`,`center`]);break;case`floating`:t([`top`,`bottom`,`left`,`right`,`center`]),CB(this.container,`dv-groupview-floating`,!0);break;case`popout`:t([`top`,`bottom`,`left`,`right`,`center`]),CB(this.container,`dv-groupview-popout`,!0);break;case`edge`:t([`center`]),CB(this.container,`dv-groupview-edge`,!0);break}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,n,r,i){super(),this.container=e,this.accessor=t,this.id=n,this.options=r,this.groupPanel=i,this._isGroupActive=!1,this._locked=!1,this._location={type:`grid`},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._panelDisposables=new Map,this._tabGroupDisposables=new Map,this._pendingMicrotaskDisposables=new Set,this._onMove=new Q,this.onMove=this._onMove.event,this._onDidDrop=new Q,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new Q,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new Q,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new Q,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new Q,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new Q,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new Q,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new Q,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new Q,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new Q,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOver=new Q,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new Q,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new Q,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new Q,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new Q,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new Q,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new Q,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,CB(this.container,`dv-groupview`,!0),this.container.setAttribute(`role`,`region`),this._api=new pV(this.accessor),this.tabsContainer=new PGe(this.accessor,this.groupPanel),this.contentContainer=new _Ge(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!r.hideHeader,this.locked=r.locked??!1,this.headerPosition=r.headerPosition??t.defaultHeaderPosition,this.addDisposables(this._onDidPanelTitleChange.event(()=>this.updateAccessibleLabel()),this._onTabDragStart,this._onGroupDragStart,this._onWillShowOverlay,this.tabsContainer.onTabDragStart(e=>{this._onTabDragStart.fire(e)}),this.tabsContainer.onGroupDragStart(e=>{this._onGroupDragStart.fire(e)}),this.tabsContainer.onDrop(e=>{let t=lB()?.panelId??null;if(this.handleDropEvent(`header`,e.event,`center`,e.index),t&&e.targetTabGroupId){let n=this._tabGroupMap.get(e.targetTabGroupId),r;if(n){let e=this._panels.findIndex(e=>e.id===t);if(e!==-1){r=0;for(let t of n.panelIds)this._panels.findIndex(e=>e.id===t)<e&&r++}}this.addPanelToTabGroup(e.targetTabGroupId,t,r)}else t&&e.targetTabGroupId===null&&this.removePanelFromTabGroup(t)}),this.contentContainer.onDidFocus(()=>{this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.onDidBlur(()=>{}),this.contentContainer.dropTarget.onDrop(e=>{this.handleDropEvent(`content`,e.nativeEvent,e.position)}),this.contentContainer.pointerDropTarget.onDrop(e=>{this.handleDropEvent(`content`,e.nativeEvent,e.position)}),this.tabsContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(e)}),this.contentContainer.dropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new PV(e,{kind:`content`,panel:this.activePanel,api:this._api,group:this.groupPanel,getData:lB}))}),this.contentContainer.pointerDropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new PV(e,{kind:`content`,panel:this.activePanel,api:this._api,group:this.groupPanel,getData:lB}))}),this._onMove,this._onDidChange,this._onDidDrop,this._onWillDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange,this._onUnhandledDragOver,this._onDidPanelTitleChange,this._onDidPanelParametersChange,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,this._onDidCreateTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidDestroyTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidAddPanelToTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidRemovePanelFromTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupChange.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupCollapsedChange.event(()=>{this._scheduleTabGroupUpdate()}))}_scheduleTabGroupUpdate(){this._pendingTabGroupUpdate||(this._pendingTabGroupUpdate=!0,queueMicrotask(()=>{this._pendingTabGroupUpdate=!1,this.isDisposed||this.tabsContainer.updateTabGroups()}))}_bracketTabGroupMutation(e){return this.accessor.mutation?this.accessor.mutation(`tab-group`,e):e()}createTabGroup(e){return this._bracketTabGroupMutation(()=>this._doCreateTabGroup(e))}_doCreateTabGroup(e){let t=e?.id??`tg-${this.id}-${this._tabGroupIdCounter++}`,n=new zGe(t,{label:e?.label,color:e?.color,collapsed:e?.collapsed,componentParams:e?.componentParams});return this._tabGroups.push(n),this._tabGroupMap.set(t,n),this._tabGroupDisposables.set(t,new fB(n.onDidChange(()=>{this._onDidTabGroupChange.fire({tabGroup:n})}),n.onDidCollapseChange(e=>{e?this._handleGroupCollapse(n):this._handleGroupExpand(n),this._onDidTabGroupCollapsedChange.fire({tabGroup:n})}),n.onDidDestroy(()=>{this._removeTabGroupInternal(n)}))),this._onDidCreateTabGroup.fire({tabGroup:n}),n}dissolveTabGroup(e){let t=this._tabGroupMap.get(e);t&&this._bracketTabGroupMutation(()=>{let e=[...t.panelIds];for(let n of e)t.removePanel(n),this._panelToTabGroup.delete(n),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:n});t.dispose()})}addPanelToTabGroup(e,t,n){let r=this._tabGroupMap.get(e);if(!r||!this._panels.some(e=>e.id===t))return;let i=this.getTabGroupForPanel(t);i&&i.id===e||this._bracketTabGroupMutation(()=>{i&&this.removePanelFromTabGroup(t),r.addPanel(t,n),this._panelToTabGroup.set(t,r),this._enforceContiguity(r,t),this._onDidAddPanelToTabGroup.fire({tabGroup:r,panelId:t})})}movePanelWithinGroup(e,t,n){let r=this._tabGroupMap.get(e);!r||!r.containsPanel(t)||(r.removePanel(t),r.addPanel(t,n),this._enforceContiguity(r,t),this.tabsContainer.updateTabGroups())}movePanelBetweenGroups(e,t,n){let r=this._findTabGroupForPanel(e),i=this._tabGroupMap.get(t);i&&(r&&(r.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:r,panelId:e}),r.isEmpty&&r.dispose()),i.addPanel(e,n),this._panelToTabGroup.set(e,i),this._enforceContiguity(i,e),this._onDidAddPanelToTabGroup.fire({tabGroup:i,panelId:e}))}moveTabGroup(e,t){let n=this._tabGroupMap.get(e);if(!n||n.panelIds.length===0)return;let r=new Set(n.panelIds),i=n.panelIds.map(e=>this._panels.find(t=>t.id===e)).filter(e=>e!==void 0);if(i.length===0)return;let a=0;for(let e=0;e<Math.min(t,this._panels.length);e++)r.has(this._panels[e].id)&&a++;for(let e of i){let t=this._panels.indexOf(e);t!==-1&&this._panels.splice(t,1)}let o=t-a,s=Math.max(0,Math.min(o,this._panels.length));this._panels.splice(s,0,...i);for(let e of this._panels)this.tabsContainer.delete(e.id);for(let e=0;e<this._panels.length;e++)this.tabsContainer.openPanel(this._panels[e],e);this.tabsContainer.updateTabGroups()}_enforceContiguity(e,t){let n=this._panels.find(e=>e.id===t);if(!n)return;let r=e.indexOfPanel(t),i=this._computeGlobalIndex(e,r),a=this._panels.indexOf(n);if(a===i)return;this._panels.splice(a,1);let o=i>a?i-1:i;this._panels.splice(o,0,n),this.tabsContainer.delete(t),this.tabsContainer.openPanel(n,o)}_computeGlobalIndex(e,t){let n=e.panelIds;if(n.length<=1){let e=this._panels.find(e=>e.id===n[0]);return e?this._panels.indexOf(e):this._panels.length}for(let e=0;e<n.length;e++){if(e===t)continue;let r=this._panels.find(t=>t.id===n[e]);if(r){let n=this._panels.indexOf(r);return Math.max(0,n+(t-e))}}return this._panels.length}removePanelFromTabGroup(e){let t=this._findTabGroupForPanel(e);t&&this._bracketTabGroupMutation(()=>{t.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:e}),t.isEmpty&&t.dispose()})}getTabGroups(){return this._tabGroups}updateTabGroups(){this.tabsContainer.updateTabGroups()}refreshTabGroupAccent(){this.tabsContainer.refreshTabGroupAccent()}refreshWatermark(){var e,t;this.watermark&&=(this.watermark.element.remove(),(t=(e=this.watermark).dispose)==null||t.call(e),void 0),this.updateContainer()}getTabGroupForPanel(e){return this._findTabGroupForPanel(e)}_findTabGroupForPanel(e){return this._panelToTabGroup.get(e)}_removeTabGroupInternal(e){let t=this._tabGroups.indexOf(e);if(t!==-1){this._tabGroups.splice(t,1),this._tabGroupMap.delete(e.id);for(let t of e.panelIds)this._panelToTabGroup.delete(t);this._onDidDestroyTabGroup.fire({tabGroup:e});let n=this._tabGroupDisposables.get(e.id);this._tabGroupDisposables.delete(e.id),n&&(this._pendingMicrotaskDisposables.add(n),queueMicrotask(()=>{this._pendingMicrotaskDisposables.delete(n),n.dispose()}))}}_handleGroupCollapse(e){if(!this._activePanel||!e.containsPanel(this._activePanel.id))return;let t=this._panels.indexOf(this._activePanel);for(let e=t+1;e<this._panels.length;e++){let t=this._panels[e],n=this._findTabGroupForPanel(t.id);if(!n||!n.collapsed){this.doSetActivePanel(t),this.updateContainer();return}}for(let e=t-1;e>=0;e--){let t=this._panels[e],n=this._findTabGroupForPanel(t.id);if(!n||!n.collapsed){this.doSetActivePanel(t),this.updateContainer();return}}this.contentContainer.closePanel(),this.doSetActivePanel(void 0),this.updateContainer()}_handleGroupExpand(e){if(this._activePanel)return;let t=e.panelIds[0];if(t){let e=this._panels.find(e=>e.id===t);e&&(this.doSetActivePanel(e),this.updateContainer())}}restoreTabGroups(e){for(let t of e){let e=t.id.match(/-(\d+)$/);if(e){let t=parseInt(e[1],10)+1;t>this._tabGroupIdCounter&&(this._tabGroupIdCounter=t)}}for(let t of e){let e=this.createTabGroup({id:t.id,label:t.label,color:t.color,componentParams:t.componentParams}),n=this._tabGroupMap.get(e.id);for(let r of t.panelIds)this._panels.some(e=>e.id===r)&&(e.addPanel(r),this._panelToTabGroup.set(r,n),this._enforceContiguity(n,r));t.collapsed&&e.collapse(),e.isEmpty&&e.dispose()}}focusContent(){this.contentContainer.element.focus()}focusActiveTab(){this.tabsContainer.focusActiveTab()}set renderContainer(e){this.panels.forEach(e=>{this.renderContainer.detatch(e)}),this._overwriteRenderContainer=e,this.panels.forEach(e=>{this.rerender(e)})}get renderContainer(){return this._overwriteRenderContainer??this.accessor.overlayRenderContainer}set dropTargetContainer(e){this._overwriteDropTargetContainer=e}get dropTargetContainer(){return this._overwriteDropTargetContainer??this.accessor.rootDropTargetContainer}initialize(){this.options.panels&&this.options.panels.forEach(e=>{this.doAddPanel(e)}),this.options.activePanel&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0),this.updateContainer(),this.updateHeaderActions()}updateHeaderActions(){var e;(e=this.accessor.headerActionsService)==null||e.refresh(this.groupPanel)}attachHeaderAction(e,t){switch(e){case`left`:this.tabsContainer.setLeftActionsElement(t);break;case`right`:this.tabsContainer.setRightActionsElement(t);break;case`prefix`:this.tabsContainer.setPrefixActionsElement(t);break}}rerender(e){this.contentContainer.renderPanel(e,{asActive:!1})}indexOf(e){return this.tabsContainer.indexOf(e.id)}toJSON(){let e={views:this.tabsContainer.panels,activeView:this._activePanel?.id,id:this.id};return this.locked!==!1&&(e.locked=this.locked),this.header.hidden&&(e.hideHeader=!0),this.headerPosition!==`top`&&(e.headerPosition=this.headerPosition),this._tabGroups.length>0&&(e.tabGroups=this._tabGroups.map(e=>e.toJSON())),e}moveToNext(e){e||={},e.panel||=this.activePanel;let t=e.panel?this.panels.indexOf(e.panel):-1,n;if(t<this.panels.length-1)n=t+1;else if(!e.suppressRoll)n=0;else return;this.openPanel(this.panels[n])}moveToPrevious(e){if(e||={},e.panel||=this.activePanel,!e.panel)return;let t=this.panels.indexOf(e.panel),n;if(t>0)n=t-1;else if(!e.suppressRoll)n=this.panels.length-1;else return;this.openPanel(this.panels[n])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;(e=this._activePanel)==null||e.focus()}openPanel(e,t={}){(typeof t.index!=`number`||t.index>this.panels.length)&&(t.index=this.panels.length);let n=!!t.skipSetActive;if(e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:n}),this._activePanel===e){this.contentContainer.renderPanel(e,{asActive:!0});return}n||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive||this.updateContainer()}removePanel(e,t={skipSetActive:!1}){let n=typeof e==`string`?e:e.id,r=this._panels.find(e=>e.id===n);if(!r)throw Error(`invalid operation`);return this._removePanel(r,t)}closeAllPanels(){if(this.panels.length>0){let e=[...this.panels];for(let t of e)this.doClose(t)}else this.accessor.removeGroup(this.groupPanel)}closePanel(e){this.doClose(e)}doClose(e){let t=this.panels.length===1&&this.accessor.groups.length===1;this.accessor.removePanel(e,t&&this.accessor.options.noPanelsOverlay===`emptyGroup`?{removeEmptyGroup:!1}:void 0)}isPanelActive(e){return this._activePanel===e}updateActions(e){this.tabsContainer.setRightActionsElement(e)}setActive(e,t=!1){if(!(!t&&this.isActive===e)){if(this._isGroupActive=e,CB(this.container,`dv-active-group`,e),CB(this.container,`dv-inactive-group`,!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0){let e=this._panels.find(e=>{let t=this._findTabGroupForPanel(e.id);return!t||!t.collapsed});e&&this.doSetActivePanel(e)}this.updateContainer()}}layout(e,t){this._width=e,this._height=t,this.contentContainer.layout(this._width,this._height),this._activePanel?.layout&&this._activePanel.layout(this._width,this._height)}_removePanel(e,t){let n=this._activePanel===e;if(this.doRemovePanel(e),n&&this.panels.length>0){let e=this.mostRecentlyUsed[0];this.openPanel(e,{skipSetActive:t.skipSetActive,skipSetGroupActive:t.skipSetActiveGroup})}return this._activePanel&&this.panels.length===0&&this.doSetActivePanel(void 0),t.skipSetActive||this.updateContainer(),e}doRemovePanel(e){let t=this.panels.indexOf(e);if(this._activePanel===e&&this.contentContainer.closePanel(),this.tabsContainer.delete(e.id),this._panels.splice(t,1),this.mostRecentlyUsed.includes(e)){let t=this.mostRecentlyUsed.indexOf(e);this.mostRecentlyUsed.splice(t,1)}let n=this._panelDisposables.get(e.id);n&&(n.dispose(),this._panelDisposables.delete(e.id)),this.removePanelFromTabGroup(e.id),this._onDidRemovePanel.fire({panel:e})}doAddPanel(e,t=this.panels.length,n={skipSetActive:!1}){let r=this._panels.indexOf(e)>-1;this.tabsContainer.show(),this.contentContainer.show(),this.tabsContainer.openPanel(e,t),n.skipSetActive?e.api.renderer===`always`&&this.contentContainer.renderPanel(e,{asActive:!1}):this.contentContainer.openPanel(e),!r&&(this.updateMru(e),this.panels.splice(t,0,e),this._panelDisposables.set(e.id,new fB(e.api.onDidTitleChange(e=>this._onDidPanelTitleChange.fire(e)),e.api.onDidParametersChange(e=>this._onDidPanelParametersChange.fire(e)))),this._onDidAddPanel.fire({panel:e}))}doSetActivePanel(e){var t;this._activePanel!==e&&(this._activePanel=e,e&&(this.tabsContainer.setActivePanel(e),this.contentContainer.setLabelledBy(this.tabsContainer.getTabId(e.id)),this.contentContainer.openPanel(e),e.layout(this._width,this._height),this.updateMru(e),this.contentContainer.refreshFocusState(),this._onDidActivePanelChange.fire({panel:e,origin:(t=this.accessor).currentOrigin?.call(t)??`user`})),this.updateAccessibleLabel())}updateAccessibleLabel(){let e=this._activePanel?.title;e?this.container.setAttribute(`aria-label`,e):this.container.removeAttribute(`aria-label`)}updateMru(e){this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this.mostRecentlyUsed=[e,...this.mostRecentlyUsed]}updateContainer(){var e,t;this.panels.forEach(e=>e.runEvents());let n=this.isEmpty||!this._activePanel;if(n&&!this.watermark){let e=this.accessor.createWatermarkComponent();e.init({containerApi:this._api,group:this.groupPanel}),this.watermark=e,vB(this.watermark.element,`pointerdown`,()=>{this.isActive||this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.element.appendChild(this.watermark.element)}!n&&this.watermark&&(this.watermark.element.remove(),(t=(e=this.watermark).dispose)==null||t.call(e),this.watermark=void 0)}canDisplayOverlay(e,t,n){let r=new qV(e,n,t,lB,this.accessor.getPanel(this.id));return this._onUnhandledDragOver.fire(r),r.isAccepted}handleDropEvent(e,t,n,r){if(this.locked===`no-drop-target`)return;function i(){switch(e){case`header`:return typeof r==`number`?`tab`:`header_space`;case`content`:return`content`}}let a=typeof r==`number`?this.panels[r]:void 0,o=new XV({nativeEvent:t,position:n,panel:a,getData:()=>lB(),kind:i(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(o),o.defaultPrevented)return;let s=lB();if(s&&s.viewId===this.accessor.id){if(e===`content`&&s.groupId===this.id&&(n===`center`||s.panelId===null&&!s.tabGroupId)||e===`header`&&s.groupId===this.id&&s.panelId===null&&!s.tabGroupId)return;if(s.panelId===null){let{groupId:e}=s;this._onMove.fire({target:n,groupId:e,index:r,tabGroupId:s.tabGroupId});return}if(this.tabsContainer.indexOf(s.panelId)!==-1&&this.tabsContainer.size===1)return;let{groupId:t,panelId:i}=s;if(this.id===t&&!n&&this.tabsContainer.indexOf(i)===r)return;this._onMove.fire({target:n,groupId:s.groupId,itemId:s.panelId,index:r})}else this._onDidDrop.fire(new YV({nativeEvent:t,position:n,panel:a,getData:()=>lB(),group:this.groupPanel,api:this._api}))}updateDragAndDropState(){this.tabsContainer.updateDragAndDropState()}dispose(){var e,t,n;super.dispose(),(e=this.watermark)==null||e.element.remove(),(n=(t=this.watermark)?.dispose)==null||n.call(t),this.watermark=void 0;for(let e of[...this._tabGroups])e.dispose();for(let e of this._tabGroupDisposables.values())e.dispose();this._tabGroupDisposables.clear();for(let e of this._pendingMicrotaskDisposables)e.dispose();this._pendingMicrotaskDisposables.clear();for(let e of this.panels)e.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}},ZV=class extends kV{constructor(e,t,n){super(e,t),this._onDidConstraintsChangeInternal=new Q,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new Q,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new Q,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),n&&this.initialize(n)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},QV=class extends jV{get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){return this.__minimumWidth()}get minimumHeight(){return this.__minimumHeight()}get maximumHeight(){return this.__maximumHeight()}get maximumWidth(){return this.__maximumWidth()}__minimumWidth(){let e=typeof this._minimumWidth==`function`?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}__maximumWidth(){let e=typeof this._maximumWidth==`function`?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}__minimumHeight(){let e=typeof this._minimumHeight==`function`?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}__maximumHeight(){let e=typeof this._maximumHeight==`function`?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}get isVisible(){return this.api.isVisible}constructor(e,t,n,r){super(e,t,r??new ZV(e,t)),this._evaluatedMinimumWidth=0,this._evaluatedMaximumWidth=2**53-1,this._evaluatedMinimumHeight=0,this._evaluatedMaximumHeight=2**53-1,this._minimumWidth=0,this._minimumHeight=0,this._maximumWidth=2**53-1,this._maximumHeight=2**53-1,this._snap=!1,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,typeof n?.minimumWidth==`number`&&(this._minimumWidth=n.minimumWidth),typeof n?.maximumWidth==`number`&&(this._maximumWidth=n.maximumWidth),typeof n?.minimumHeight==`number`&&(this._minimumHeight=n.minimumHeight),typeof n?.maximumHeight==`number`&&(this._maximumHeight=n.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onActiveChange(()=>{let{accessor:e}=this._params;e.doSetGroupActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{(typeof e.minimumWidth==`number`||typeof e.minimumWidth==`function`)&&(this._minimumWidth=e.minimumWidth),(typeof e.minimumHeight==`number`||typeof e.minimumHeight==`function`)&&(this._minimumHeight=e.minimumHeight),(typeof e.maximumWidth==`number`||typeof e.maximumWidth==`function`)&&(this._maximumWidth=e.maximumWidth),(typeof e.maximumHeight==`number`||typeof e.maximumHeight==`function`)&&(this._maximumHeight=e.maximumHeight)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({height:e.height,width:e.width})}),this._onDidChange)}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}init(e){e.maximumHeight&&(this._maximumHeight=e.maximumHeight),e.minimumHeight&&(this._minimumHeight=e.minimumHeight),e.maximumWidth&&(this._maximumWidth=e.maximumWidth),e.minimumWidth&&(this._minimumWidth=e.minimumWidth),this._priority=e.priority,this._snap=!!e.snap,super.init(e),typeof e.isVisible==`boolean`&&this.setVisible(e.isVisible)}updateConstraints(){this.api._onDidConstraintsChange.fire({minimumWidth:this._evaluatedMinimumWidth,maximumWidth:this._evaluatedMaximumWidth,minimumHeight:this._evaluatedMinimumHeight,maximumHeight:this._evaluatedMaximumHeight})}toJSON(){let e=super.toJSON(),t=e=>e===2**53-1?void 0:e,n=e=>e<=0?void 0:e;return Object.assign(Object.assign({},e),{minimumHeight:n(this.minimumHeight),maximumHeight:t(this.maximumHeight),minimumWidth:n(this.minimumWidth),maximumWidth:t(this.maximumWidth),snap:this.snap,priority:this.priority})}},$V=`dockview: DockviewGroupPanelApiImpl not initialized`,VGe=class extends ZV{get location(){if(!this._group)throw Error($V);return this._group.model.location}get boundingBox(){if(!this._group||this._group.model.location.type===`popout`)return;let e=this.accessor.element.getBoundingClientRect(),t=this._group.element.getBoundingClientRect();return{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}}get locked(){if(!this._group)throw Error($V);return this._group.locked}set locked(e){if(!this._group)throw Error($V);this._group.locked=e}constructor(e,t){super(e,`__dockviewgroup__`),this.accessor=t,this._onDidLocationChange=new Q,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new Q,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new Q,this.onDidCollapsedChange=this._onDidCollapsedChange.event,this.addDisposables(this._onDidLocationChange,this._onDidActivePanelChange,this._onDidCollapsedChange,this._onDidVisibilityChange.event(e=>{e.isVisible&&this._pendingSize&&(super.setSize(this._pendingSize),this._pendingSize=void 0)}))}setSize(e){this._pendingSize=Object.assign({},e),super.setSize(e)}close(){if(this._group)return this.accessor.removeGroup(this._group)}getWindow(){return this.location.type===`popout`?this.location.getWindow():window}setHeaderPosition(e){if(!this._group)throw Error($V);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw Error($V);return this._group.model.headerPosition}moveTo(e){if(!this._group)throw Error($V);let t=e.group??this.accessor.addGroup({direction:QWe(e.position??`right`),skipSetActive:e.skipSetActive??!1});this.accessor.moveGroupOrPanel({from:{groupId:this._group.id},to:{group:t,position:e.group?e.position??`center`:`center`,index:e.index},skipSetActive:e.skipSetActive})}maximize(){if(!this._group)throw Error($V);this.location.type===`grid`&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw Error($V);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw Error($V);this.isMaximized()&&this.accessor.exitMaximizedGroup()}collapse(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!0)}expand(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!1)}isCollapsed(){return this._group?this.accessor.isEdgeGroupCollapsed(this._group):!1}initialize(e){this._group=e}},HGe=100,UGe=100,eH=class extends QV{get minimumWidth(){if(typeof this._explicitConstraints.minimumWidth==`number`)return this._explicitConstraints.minimumWidth;let e=this.activePanel?.minimumWidth;return typeof e==`number`?e:super.__minimumWidth()}get minimumHeight(){if(typeof this._explicitConstraints.minimumHeight==`number`)return this._explicitConstraints.minimumHeight;let e=this.activePanel?.minimumHeight;return typeof e==`number`?e:super.__minimumHeight()}get maximumWidth(){if(typeof this._explicitConstraints.maximumWidth==`number`)return this._explicitConstraints.maximumWidth;let e=this.activePanel?.maximumWidth;return typeof e==`number`?e:super.__maximumWidth()}get maximumHeight(){if(typeof this._explicitConstraints.maximumHeight==`number`)return this._explicitConstraints.maximumHeight;let e=this.activePanel?.maximumHeight;return typeof e==`number`?e:super.__maximumHeight()}get panels(){return this._model.panels}get activePanel(){return this._model.activePanel}get size(){return this._model.size}get model(){return this._model}get locked(){return this._model.locked}set locked(e){this._model.locked=e}get header(){return this._model.header}constructor(e,t,n){super(t,`groupview_default`,{minimumHeight:n.constraints?.minimumHeight??UGe,minimumWidth:n.constraints?.minimumWidth??HGe,maximumHeight:n.constraints?.maximumHeight,maximumWidth:n.constraints?.maximumWidth},new VGe(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new BGe(this.element,e,t,n,this),this.addDisposables(this.model.onDidActivePanelChange(e=>{this.api._onDidActivePanelChange.fire(e)}),this.api.onDidConstraintsChangeInternal(e=>{e.minimumWidth!==void 0&&(this._explicitConstraints.minimumWidth=typeof e.minimumWidth==`function`?e.minimumWidth():e.minimumWidth),e.minimumHeight!==void 0&&(this._explicitConstraints.minimumHeight=typeof e.minimumHeight==`function`?e.minimumHeight():e.minimumHeight),e.maximumWidth!==void 0&&(this._explicitConstraints.maximumWidth=typeof e.maximumWidth==`function`?e.maximumWidth():e.maximumWidth),e.maximumHeight!==void 0&&(this._explicitConstraints.maximumHeight=typeof e.maximumHeight==`function`?e.maximumHeight():e.maximumHeight)}))}focus(){this.api.isActive||this.api.setActive(),super.focus()}initialize(){this._model.initialize()}setActive(e){super.setActive(e),this.model.setActive(e)}layout(e,t){super.layout(e,t),this.model.layout(e,t)}getComponent(){return this._model}toJSON(){return this.model.toJSON()}},WGe={name:`abyss`,className:`dockview-theme-abyss`,colorScheme:`dark`,tabGroupIndicator:`none`},GGe=class extends ZV{get location(){return this.group.api.location}get title(){return this.panel.title}get isGroupActive(){return this.group.isActive}get renderer(){return this.panel.renderer}set group(e){let t=this._group;this._group!==e&&(this._group=e,this._onDidGroupChange.fire({}),this.setupGroupEventListeners(t),this._onDidLocationChange.fire({location:this.group.api.location}))}get group(){return this._group}get tabComponent(){return this._tabComponent}constructor(e,t,n,r,i){super(e.id,r),this.panel=e,this.accessor=n,this._onDidTitleChange=new Q,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new Q,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new Q,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new Q,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new Q,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new pB,this._tabComponent=i,this.initialize(e),this._group=t,this.setupGroupEventListeners(),this.addDisposables(this.groupEventsDisposable,this._onDidRendererChange,this._onDidTitleChange,this._onDidGroupChange,this._onDidActiveGroupChange,this._onDidLocationChange)}getWindow(){return this.group.api.getWindow()}setActive(){this.accessor.withOrigin(`api`,()=>super.setActive())}moveTo(e){this.accessor.moveGroupOrPanel({from:{groupId:this._group.id,panelId:this.panel.id},to:{group:e.group??this._group,position:e.group?e.position??`center`:`center`,index:e.index},skipSetActive:e.skipSetActive})}setTitle(e){this.panel.setTitle(e)}setRenderer(e){this.panel.setRenderer(e)}close(){this.group.model.closePanel(this.panel)}maximize(){this.group.api.maximize()}isMaximized(){return this.group.api.isMaximized()}exitMaximized(){this.group.api.exitMaximized()}setupGroupEventListeners(e){let t=e?.isActive??!1;this.groupEventsDisposable.value=new fB(this.group.api.onDidVisibilityChange(e=>{let t=!e.isVisible&&this.isVisible,n=e.isVisible&&!this.isVisible,r=this.group.model.isPanelActive(this.panel);(t||n&&r)&&this._onDidVisibilityChange.fire(e)}),this.group.api.onDidLocationChange(e=>{this.group===this.panel.group&&this._onDidLocationChange.fire(e)}),this.group.api.onDidActiveChange(()=>{this.group===this.panel.group&&t!==this.isGroupActive&&(t=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}},tH=class extends fB{get params(){return this._params}get title(){return this._title}get group(){return this._group}get renderer(){return this._renderer??this.accessor.renderer}get minimumWidth(){return this._minimumWidth}get minimumHeight(){return this._minimumHeight}get maximumWidth(){return this._maximumWidth}get maximumHeight(){return this._maximumHeight}constructor(e,t,n,r,i,a,o,s){super(),this.id=e,this.accessor=r,this.containerApi=i,this.view=o,this._renderer=s.renderer,this._group=a,this._minimumWidth=s.minimumWidth,this._minimumHeight=s.minimumHeight,this._maximumWidth=s.maximumWidth,this._maximumHeight=s.maximumHeight,this.api=new GGe(this,this._group,r,t,n),this.addDisposables(this.api.onActiveChange(()=>{r.setActivePanel(this)}),this.api.onDidSizeChange(e=>{this.group.api.setSize(e)}),this.api.onDidRendererChange(()=>{this.group.model.rerender(this)}))}init(e){this._params=e.params,this.view.init(Object.assign(Object.assign({},e),{api:this.api,containerApi:this.containerApi})),this.setTitle(e.title)}focus(){let e=new OV;this.api._onWillFocus.fire(e),!e.defaultPrevented&&(this.api.isActive||this.api.setActive())}toJSON(){return{id:this.id,contentComponent:this.view.contentComponent,tabComponent:this.view.tabComponent,params:Object.keys(this._params||{}).length>0?this._params:void 0,title:this.title,renderer:this._renderer,minimumHeight:this._minimumHeight,maximumHeight:this._maximumHeight,minimumWidth:this._minimumWidth,maximumWidth:this._maximumWidth}}setTitle(e){e!==this.title&&(this._title=e,this.view.setTitle(e),this.api._onDidTitleChange.fire({title:e}))}setRenderer(e){e!==this.renderer&&(this._renderer=e,this.api._onDidRendererChange.fire({renderer:e}))}update(e){this._params=Object.assign(Object.assign({},this._params??{}),e.params);for(let t of Object.keys(e.params))e.params[t]===void 0&&delete this._params[t];this.view.update({params:this._params})}updateFromStateModel(e){this._maximumHeight=e.maximumHeight,this._minimumHeight=e.minimumHeight,this._maximumWidth=e.maximumWidth,this._minimumWidth=e.minimumWidth,this.update({params:e.params??{}}),this.setTitle(e.title??this.id),this.setRenderer(e.renderer??this.accessor.renderer)}updateParentGroup(e,t){this._group=e,this.api.group=this._group;let n=this._group.model.isPanelActive(this),r=this.group.api.isActive&&n;t?.skipSetActive||this.api.isActive!==r&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&n}),this.api.isVisible!==n&&this.api._onDidVisibilityChange.fire({isVisible:n})}runEvents(){let e=this._group.model.isPanelActive(this),t=this.group.api.isActive&&e;this.api.isActive!==t&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&e}),this.api.isVisible!==e&&this.api._onDidVisibilityChange.fire({isVisible:e})}layout(e,t){this.api._onDidDimensionChange.fire({width:e,height:t}),this.view.layout(e,t)}dispose(){this.api.dispose(),this.view.dispose()}},nH=class extends fB{get element(){return this._element}constructor(){super(),this._element=document.createElement(`div`),this._element.className=`dv-default-tab`,this._content=document.createElement(`div`),this._content.className=`dv-default-tab-content`,this.action=document.createElement(`div`),this.action.className=`dv-default-tab-action`,this.action.appendChild(jGe()),this._element.appendChild(this._content),this._element.appendChild(this.action),this.render()}init(e){this._title=e.title,this.addDisposables(e.api.onDidTitleChange(e=>{this._title=e.title,this.render()}),vB(this.action,`pointerdown`,e=>{e.preventDefault()}),vB(this.action,`click`,t=>{t.defaultPrevented||(t.preventDefault(),e.api.close())})),this.render()}render(){this._content.textContent!==this._title&&(this._content.textContent=this._title??``)}},rH=class{get content(){return this._content}get tab(){return this._tab}constructor(e,t,n,r){this.accessor=e,this.id=t,this.contentComponent=n,this.tabComponent=r,this._content=this.createContentComponent(this.id,n),this._tab=this.createTabComponent(this.id,r)}createTabRenderer(e){var t;let n=this.createTabComponent(this.id,this.tabComponent);return this._params&&n.init(Object.assign(Object.assign({},this._params),{tabLocation:e})),this._updateEvent&&((t=n.update)==null||t.call(n,this._updateEvent)),n}init(e){this._params=e,this.content.init(e),this.tab.init(Object.assign(Object.assign({},e),{tabLocation:`header`}))}setTitle(e){this._params&&(this._params.title=e)}layout(e,t){var n,r;(r=(n=this.content).layout)==null||r.call(n,e,t)}update(e){var t,n,r,i;this._updateEvent=e,(n=(t=this.content).update)==null||n.call(t,e),(i=(r=this.tab).update)==null||i.call(r,e)}dispose(){var e,t,n,r;(t=(e=this.content).dispose)==null||t.call(e),(r=(n=this.tab).dispose)==null||r.call(n)}createContentComponent(e,t){return this.accessor.options.createComponent({id:e,name:t})}createTabComponent(e,t){let n=t??this.accessor.options.defaultTabComponent;if(n){if(this.accessor.options.createTabComponent)return this.accessor.options.createTabComponent({id:e,name:n})||new nH;console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new nH}},KGe=class{constructor(e){this.accessor=e}fromJSON(e,t){let n=e.id,r=e.params,i=e.title,a=e.view,o=a?a.content.id:e.contentComponent??`unknown`,s=a?a.tab?.id:e.tabComponent,c=new rH(this.accessor,n,o,s),l=new tH(n,o,s,this.accessor,new pV(this.accessor),t,c,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return l.init({title:i??n,params:r??{}}),l}},qGe=class extends fB{get element(){return this._element}constructor(){super(),this._element=document.createElement(`div`),this._element.className=`dv-watermark`}init(e){}},iH=new class{constructor(){this._orderedList=[]}push(e){this._orderedList=[...this._orderedList.filter(t=>t!==e),e],this.update()}destroy(e){this._orderedList=this._orderedList.filter(t=>t!==e),this.update()}update(){for(let e=0;e<this._orderedList.length;e++)this._orderedList[e].setAttribute(`aria-level`,`${e}`),this._orderedList[e].style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2})`}},aH=class e extends fB{set minimumInViewportWidth(e){this.options.minimumInViewportWidth=e}set minimumInViewportHeight(e){this.options.minimumInViewportHeight=e}get element(){return this._element}get isVisible(){return this._isVisible}get headerHeight(){return this.options.header?.offsetHeight??0}constructor(e){super(),this.options=e,this._element=document.createElement(`div`),this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new Q,this.onDidChangeEnd=this._onDidChangeEnd.event,this._onDidStartMoving=new Q,this.onDidStartMoving=this._onDidStartMoving.event,this._dragMove=new pB,this._dragCancelled=!1,this.addDisposables(this._onDidChange,this._onDidChangeEnd,this._onDidStartMoving,this._dragMove),this._element.className=`dv-resize-container`,this._element.setAttribute(`role`,`dialog`),this._element.setAttribute(`aria-modal`,`false`),this._isVisible=!0,this.setupResize(`top`),this.setupResize(`bottom`),this.setupResize(`left`),this.setupResize(`right`),this.setupResize(`topleft`),this.setupResize(`topright`),this.setupResize(`bottomleft`),this.setupResize(`bottomright`),this.options.header&&(CB(this._element,`dv-resize-container-with-titlebar`,!0),this._element.appendChild(this.options.header)),this._element.appendChild(this.options.content),this.options.container.appendChild(this._element),this.setBounds(Object.assign(Object.assign(Object.assign(Object.assign({height:this.options.height,width:this.options.width},`top`in this.options&&{top:this.options.top}),`bottom`in this.options&&{bottom:this.options.bottom}),`left`in this.options&&{left:this.options.left}),`right`in this.options&&{right:this.options.right})),iH.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,CB(this.element,`dv-hidden`,!this.isVisible))}bringToFront(){iH.push(this._element)}setBounds(e={}){typeof e.height==`number`&&(this._element.style.height=`${e.height}px`),typeof e.width==`number`&&(this._element.style.width=`${e.width}px`),`top`in e&&typeof e.top==`number`&&(this._element.style.top=`${e.top}px`,this._element.style.bottom=`auto`,this.verticalAlignment=`top`),`bottom`in e&&typeof e.bottom==`number`&&(this._element.style.bottom=`${e.bottom}px`,this._element.style.top=`auto`,this.verticalAlignment=`bottom`),`left`in e&&typeof e.left==`number`&&(this._element.style.left=`${e.left}px`,this._element.style.right=`auto`,this.horiziontalAlignment=`left`),`right`in e&&typeof e.right==`number`&&(this._element.style.right=`${e.right}px`,this._element.style.left=`auto`,this.horiziontalAlignment=`right`);let t=this.options.container.getBoundingClientRect(),n=this._element.getBoundingClientRect(),r=Math.max(0,this.getMinimumWidth(n.width)),i=Math.max(0,this.getMinimumHeight(n.height));if(this.verticalAlignment===`top`){let e=BB(n.top-t.top,-i,Math.max(0,t.height-n.height+i));this._element.style.top=`${e}px`,this._element.style.bottom=`auto`}if(this.verticalAlignment===`bottom`){let e=BB(t.bottom-n.bottom,-i,Math.max(0,t.height-n.height+i));this._element.style.bottom=`${e}px`,this._element.style.top=`auto`}if(this.horiziontalAlignment===`left`){let e=BB(n.left-t.left,-r,Math.max(0,t.width-n.width+r));this._element.style.left=`${e}px`,this._element.style.right=`auto`}if(this.horiziontalAlignment===`right`){let e=BB(t.right-n.right,-r,Math.max(0,t.width-n.width+r));this._element.style.right=`${e}px`,this._element.style.left=`auto`}this._onDidChange.fire()}toJSON(){let e=this.options.container.getBoundingClientRect(),t=this._element.getBoundingClientRect(),n={};return this.verticalAlignment===`top`?n.top=parseFloat(this._element.style.top):this.verticalAlignment===`bottom`?n.bottom=parseFloat(this._element.style.bottom):n.top=t.top-e.top,this.horiziontalAlignment===`left`?n.left=parseFloat(this._element.style.left):this.horiziontalAlignment===`right`?n.right=parseFloat(this._element.style.right):n.left=t.left-e.left,n.width=t.width,n.height=t.height,n}cancelPendingDrag(){this._dragMove.value&&(this._dragCancelled=!0,CB(this._element,`dv-resize-container-dragging`,!1),this._dragMove.value=dB.NONE)}setupDrag(e,t={inDragMode:!1}){let n=(e,t)=>{var n;let r=null,i=!1;this._dragCancelled=!1;let a=this.options.transformDragPosition?(n=this.options).getSiblingBoxes?.call(n)??[]:[],o=AB();if(e&&typeof t==`number`&&typeof e.setPointerCapture==`function`)try{e.setPointerCapture(t)}catch{}let s=()=>{CB(this._element,`dv-resize-container-dragging`,!1),this._dragMove.value=dB.NONE,this._onDidChangeEnd.fire()};this._dragMove.value=new fB({dispose:()=>{if(o.release(),e&&typeof t==`number`&&typeof e.releasePointerCapture==`function`)try{e.releasePointerCapture(t)}catch{}}},vB(window,`pointermove`,e=>{if(this._dragCancelled)return;let t=this.options.container.getBoundingClientRect(),n=e.clientX-t.left,o=e.clientY-t.top;CB(this._element,`dv-resize-container-dragging`,!0);let s=this._element.getBoundingClientRect();r===null&&(r={x:e.clientX-s.left,y:e.clientY-s.top});let c=Math.max(0,this.getMinimumWidth(s.width)),l=Math.max(0,this.getMinimumHeight(s.height)),u=o-r.y,d=n-r.x;if(this.options.transformDragPosition){let e=this.options.transformDragPosition({proposed:{top:u,left:d,width:s.width,height:s.height},container:{width:t.width,height:t.height},others:a});e&&(u=e.top,d=e.left)}let f=Math.max(0,t.height-s.height+l),p=Math.max(0,t.width-s.width+c),m=BB(u,-l,f),h=BB(t.height-s.height-u,-l,f),g=BB(d,-c,p),_=BB(t.width-s.width-d,-c,p),v={};m<=h?v.top=m:v.bottom=h,g<=_?v.left=g:v.right=_,this.setBounds(v),i||(i=!0,this._onDidStartMoving.fire())}),vB(window,`pointerup`,s),vB(window,`pointercancel`,s))};this.addDisposables(vB(e,`pointerdown`,t=>{if(t.defaultPrevented){t.preventDefault();return}OB(t)||n(e,t.pointerId)}),vB(this.options.content,`pointerdown`,e=>{e.defaultPrevented||OB(e)||e.shiftKey&&n(this.options.content,e.pointerId)}),vB(this.options.content,`pointerdown`,()=>{iH.push(this._element)},!0)),t.inDragMode&&n()}setupResize(t){let n=document.createElement(`div`);n.className=`dv-resize-handle-${t}`,this._element.appendChild(n);let r=new pB;this.addDisposables(r,vB(n,`pointerdown`,i=>{i.preventDefault();let a=null,o=AB(),s=i.pointerId;if(typeof n.setPointerCapture==`function`)try{n.setPointerCapture(s)}catch{}let c=()=>{r.dispose(),this._onDidChangeEnd.fire()};r.value=new fB(vB(window,`pointermove`,n=>{let r=this.options.container.getBoundingClientRect(),i=this._element.getBoundingClientRect(),o=n.clientY-r.top,s=n.clientX-r.left;a===null&&(a={originalY:o,originalHeight:i.height,originalX:s,originalWidth:i.width});let c,l,u,d,f,p,m=()=>{let t=a.originalY+a.originalHeight>r.height?Math.max(0,r.height-e.MINIMUM_HEIGHT):Math.max(0,a.originalY+a.originalHeight-e.MINIMUM_HEIGHT);c=BB(o,0,t),u=a.originalY+a.originalHeight-c,l=r.height-c-u},h=()=>{c=a.originalY-a.originalHeight;let t=c<0&&typeof this.options.minimumInViewportHeight==`number`?-c+this.options.minimumInViewportHeight:e.MINIMUM_HEIGHT,n=r.height-Math.max(0,c);u=BB(o-c,t,n),l=r.height-c-u},g=()=>{let t=a.originalX+a.originalWidth>r.width?Math.max(0,r.width-e.MINIMUM_WIDTH):Math.max(0,a.originalX+a.originalWidth-e.MINIMUM_WIDTH);d=BB(s,0,t),p=a.originalX+a.originalWidth-d,f=r.width-d-p},_=()=>{d=a.originalX-a.originalWidth;let t=d<0&&typeof this.options.minimumInViewportWidth==`number`?-d+this.options.minimumInViewportWidth:e.MINIMUM_WIDTH,n=r.width-Math.max(0,d);p=BB(s-d,t,n),f=r.width-d-p};switch(t){case`top`:m();break;case`bottom`:h();break;case`left`:g();break;case`right`:_();break;case`topleft`:m(),g();break;case`topright`:m(),_();break;case`bottomleft`:h(),g();break;case`bottomright`:h(),_();break}let v={};c<=l?v.top=c:v.bottom=l,d<=f?v.left=d:v.right=f,v.height=u,v.width=p,this.setBounds(v)}),{dispose:()=>{if(o.release(),typeof n.releasePointerCapture==`function`)try{n.releasePointerCapture(s)}catch{}}},vB(window,`pointerup`,c),vB(window,`pointercancel`,c))}))}getMinimumWidth(e){return typeof this.options.minimumInViewportWidth==`number`?e-this.options.minimumInViewportWidth:0}getMinimumHeight(e){return typeof this.options.minimumInViewportHeight==`number`?e-this.options.minimumInViewportHeight:0}dispose(){iH.destroy(this._element),this._element.remove(),super.dispose()}};aH.MINIMUM_HEIGHT=20,aH.MINIMUM_WIDTH=20;var JGe=class extends fB{get element(){return this._element}get group(){return this._group}setGroup(e){this._group=e}constructor(e,t){super(),this.accessor=e,this._onDragStart=new Q,this.onDragStart=this._onDragStart.event,this._group=t,this._element=document.createElement(`div`),this._element.className=`dv-floating-titlebar`,this.addDisposables(this._onDragStart,vB(this._element,`pointerdown`,()=>{this.accessor.doSetGroupActive(this._group)}),vB(this._element,`pointerdown`,e=>{e.shiftKey&&DB(e)},!0)),this.dragSource=new FV({element:this._element,accessor:this.accessor,group:()=>this._group}),this.addDisposables(this.dragSource,this.dragSource.onDragStart(e=>{this._onDragStart.fire(e)}))}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}};function oH(e){return{moduleName:e.name,services:{[e.serviceKey]:e.create},init:e.init?(t,n)=>e.init(t,n[e.serviceKey]):void 0,dependsOn:e.dependsOn}}var sH=new Set;function cH(e,t,n){if(e!==void 0)return e;let r=`${t}|${n??``}`;if(sH.has(r))return;sH.add(r);let i=n?` for ${n}`:``;console.error(`dockview: module "${t}" is not registered${i}.`)}var YGe=class{constructor(){this._modules=new Map,this._services={},this._initDisposables=[]}get services(){return this._services}register(e){if(!this._modules.has(e.moduleName)){if(e.dependsOn)for(let t of e.dependsOn)this.register(t);this._modules.set(e.moduleName,e)}}initialize(e){for(let t of this._modules.values())if(t.services)for(let[n,r]of Object.entries(t.services))this._services[n]=r(e)}postConstruct(e){for(let t of this._modules.values())t.init&&this._initDisposables.push(t.init(e,this._services))}has(e){return this._modules.has(e)}dispose(){for(let e of this._initDisposables)e.dispose();this._initDisposables.length=0;for(let e of Object.values(this._services))e!==void 0&&typeof e.dispose==`function`&&e.dispose()}},lH=[];function XGe(e){for(let t of e)lH.some(e=>e.moduleName===t.moduleName)||lH.push(t)}function ZGe(){return[...lH]}var uH=!1;function QGe(){uH=!0}function $Ge(){return uH}var dH=100,fH={left:100,top:100,width:300,height:300},eKe=100,tKe=class extends fB{get group(){return this._group}setTitleBar(e){this._titleBar=e}setAnchorGroup(e){var t;this._group=e,(t=this._titleBar)==null||t.setGroup(e)}constructor(e,t,n){super(),this.overlay=t,this.gridview=n,this._group=e,this.addDisposables(t,{dispose:()=>this.gridview.dispose()})}position(e){this.overlay.setBounds(e)}},nKe=class{get floatingGroups(){return this._floatingGroups}constructor(e){this._floatingGroups=[],this._host=e}add(e,t,n){let r=new tKe(e,t,n),i=new fB(e.api.onDidActiveChange(e=>{e.isActive&&t.bringToFront()}),(()=>{let e=-1,t=-1;return bB(n.element,r=>{let i=Math.round(r.contentRect.width),a=Math.round(r.contentRect.height);i===e&&a===t||(e=i,t=a,n.layout(i,a))})})()),a=()=>{let n=e.activePanel?.title;n?t.element.setAttribute(`aria-label`,n):t.element.removeAttribute(`aria-label`)};return a(),r.addDisposables(e.api.onDidActivePanelChange(()=>a()),t.onDidChange(()=>{n.layout(n.width,n.height)}),t.onDidChangeEnd(()=>{this._host.fireLayoutChange()}),e.onDidChange(e=>{t.setBounds({height:typeof e?.height==`number`?e.height+t.headerHeight:e?.height,width:e?.width})}),{dispose:()=>{i.dispose(),zB(this._floatingGroups,r),e.model.location={type:`grid`}}}),this._floatingGroups.push(r),r}findByGroup(e){return this._floatingGroups.find(t=>t.group===e||t.gridview.element.contains(e.element))}serialize(){return this._floatingGroups.map(e=>{let t=e.gridview.serialize(),n=e.overlay.toJSON(),r=t.root;return r.type===`branch`&&r.data.length===1&&r.data[0].type===`leaf`?{data:r.data[0].data,position:n}:{grid:t,position:n}})}constrainBounds(){for(let e of this._floatingGroups)e.overlay.setBounds()}updateBounds(e){if(`floatingGroupBounds`in e)for(let t of this._floatingGroups){switch(e.floatingGroupBounds){case`boundedWithinViewport`:t.overlay.minimumInViewportHeight=void 0,t.overlay.minimumInViewportWidth=void 0;break;case void 0:t.overlay.minimumInViewportHeight=dH,t.overlay.minimumInViewportWidth=dH;break;default:t.overlay.minimumInViewportHeight=e.floatingGroupBounds?.minimumHeightWithinViewport,t.overlay.minimumInViewportWidth=e.floatingGroupBounds?.minimumWidthWithinViewport}t.overlay.setBounds()}}disposeAll(){for(let e of[...this._floatingGroups])e.dispose()}dispose(){this.disposeAll()}},rKe=oH({name:`FloatingGroup`,serviceKey:`floatingGroupService`,create:e=>new nKe(e)}),iKe=class{constructor(e){this._entries=[],this._popupServices=new Map,this._restorationCleanups=new Set,this._restorationPromise=Promise.resolve(),this._onDidRemove=new Q,this.onDidRemove=this._onDidRemove.event,this._host=e}get entries(){return this._entries}get restorationPromise(){return this._restorationPromise}add(e){this._entries.push(e)}remove(e){zB(this._entries,e)&&!this._host.isDisposed&&this._onDidRemove.fire(e)}findByGroup(e){return this._entries.find(t=>t.popoutGroup===e||t.gridview.element.contains(e.element))}findReferenceGroupId(e){return this._entries.find(t=>t.popoutGroup===e)?.referenceGroup}observeGridviewSize(e,t,n){let r=e.window?.ResizeObserver;if(!r)return;let i=-1,a=-1,o=()=>{let r=e.window;if(this._host.isDisposed||!r||r.closed)return;let o=Math.round(t.element.clientWidth),s=Math.round(t.element.clientHeight);o===i&&s===a||(i=o,a=s,o>0&&s>0&&t.layout(o,s),n.updateAllPositions())},s=new r(()=>{let t=e.window?.requestAnimationFrame;t?t.call(e.window,o):o()});return s.observe(t.element),{dispose:()=>s.disconnect()}}getPopupService(e){return this._popupServices.get(e)}setPopupService(e,t){this._popupServices.set(e,t)}deletePopupService(e){this._popupServices.delete(e)}scheduleRestoration(e,t,n){return new Promise(r=>{let i=()=>{this._restorationCleanups.delete(i),clearTimeout(a),n?.(),r()},a=setTimeout(()=>{if(this._restorationCleanups.delete(i),this._host.isDisposed){r();return}t(),r()},e);this._restorationCleanups.add(i)})}finishRestoration(e){this._restorationPromise=Promise.all(e).then(()=>void 0)}cancelPendingRestorations(){for(let e of[...this._restorationCleanups])e();this._restorationCleanups.clear()}serialize(){return this._entries.map(e=>{let t=e.gridview.serialize(),n=t.root,r=e.popoutGroup.api.location.type===`popout`?e.popoutGroup.api.location.popoutUrl:void 0,i={gridReferenceGroup:e.referenceGroup,position:e.window.dimensions(),url:r};return n.type===`branch`&&n.data.length===1&&n.data[0].type===`leaf`?Object.assign(Object.assign({},i),{data:n.data[0].data}):Object.assign(Object.assign({},i),{grid:t})})}disposeAll(){for(let e of[...this._entries])e.disposable.dispose()}dispose(){this.cancelPendingRestorations(),this.disposeAll(),this._onDidRemove.dispose()}},aKe=oH({name:`PopoutWindow`,serviceKey:`popoutWindowService`,create:e=>new iKe(e)}),oKe=class{constructor(e){this._watermark=null,this._host=e}update(){if(this._host.hasVisibleGridGroup()){this._unmount();return}if(this._watermark)return;this._watermark=this._host.createWatermarkComponent(),this._watermark.init({containerApi:this._host.api});let e=document.createElement(`div`);e.className=`dv-watermark-container`,PWe(e,`watermark-component`),e.appendChild(this._watermark.element),this._host.mountElement.appendChild(e)}refresh(){this._unmount(),this.update()}_unmount(){var e,t;this._watermark&&=(this._watermark.element.parentElement.remove(),(t=(e=this._watermark).dispose)==null||t.call(e),null)}dispose(){this._unmount()}},sKe=oH({name:`Watermark`,serviceKey:`watermarkService`,create:e=>new oKe(e),init:(e,t)=>(t.update(),new fB(mB.any(e.onDidAdd,e.onDidRemove)(()=>{t.update()}),e.onDidViewVisibilityChangeMicroTaskQueue(()=>{t.update()})))}),cKe=class{constructor(){this._edgeGroups=new Map,this._edgeGroupDisposables=new Map}add(e,t,n){this._edgeGroups.set(e,t),this._edgeGroupDisposables.set(e,n)}remove(e){var t;(t=this._edgeGroupDisposables.get(e))==null||t.dispose(),this._edgeGroupDisposables.delete(e),this._edgeGroups.delete(e)}get(e){return this._edgeGroups.get(e)}has(e){return this._edgeGroups.has(e)}hasAny(){return this._edgeGroups.size>0}entries(){return this._edgeGroups.entries()}includes(e){for(let t of this._edgeGroups.values())if(t===e)return!0;return!1}findPositionOf(e){for(let[t,n]of this._edgeGroups)if(n===e)return t}disposeAll(){for(let e of this._edgeGroupDisposables.values())e.dispose();this._edgeGroupDisposables.clear(),this._edgeGroups.clear()}dispose(){this.disposeAll()}},lKe=oH({name:`EdgeGroup`,serviceKey:`edgeGroupService`,create:()=>new cKe}),pH={activationSize:{type:`pixels`,value:10},size:{type:`pixels`,value:20}},uKe=class{constructor(e){let t=(t,n)=>{let r=lB();return r?r.viewId===e.id?n!==`center`||e.isGridEmpty():!1:n===`center`&&!e.isGridEmpty()?!1:e.dispatchUnhandledDragOver(t,n)},n=typeof e.options.dndEdges==`object`&&e.options.dndEdges!==null?e.options.dndEdges:pH;this._html5Target=TV.createDropTarget(e.element,{className:`dv-drop-target-edge`,canDisplayOverlay:t,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],overlayModel:n,getOverrideTarget:()=>e.rootDropTargetOverrideTarget()}),this._pointerTarget=EV.createDropTarget(e.element,{className:`dv-drop-target-edge`,canDisplayOverlay:t,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],overlayModel:n,getOverrideTarget:()=>e.rootDropTargetOverrideTarget()}),this.onWillShowOverlay=mB.any(this._html5Target.onWillShowOverlay,this._pointerTarget.onWillShowOverlay),this.onDrop=mB.any(this._html5Target.onDrop,this._pointerTarget.onDrop),this.setOptions(e.options)}setOptions(e){if(`dndEdges`in e){let t=typeof e.dndEdges==`boolean`&&e.dndEdges===!1;this._html5Target.disabled=t,this._pointerTarget.disabled=t,typeof e.dndEdges==`object`&&e.dndEdges!==null?(this._html5Target.setOverlayModel(e.dndEdges),this._pointerTarget.setOverlayModel(e.dndEdges)):(this._html5Target.setOverlayModel(pH),this._pointerTarget.setOverlayModel(pH))}}dispose(){this._html5Target.dispose(),this._pointerTarget.dispose()}},dKe=oH({name:`RootDropTarget`,serviceKey:`rootDropTargetService`,create:e=>new uKe(e)}),fKe={left:`createLeftHeaderActionComponent`,right:`createRightHeaderActionComponent`,prefix:`createPrefixHeaderActionComponent`},pKe=class{constructor(e){this._perGroup=new Map,this._host=e}refresh(e){if(!e?.model)return;let t=this._ensureState(e);this._refreshSlot(`left`,e,t.left),this._refreshSlot(`right`,e,t.right),this._refreshSlot(`prefix`,e,t.prefix)}refreshAll(){for(let e of this._host.groups)this.refresh(e)}disposeGroup(e){let t=this._perGroup.get(e);t&&(t.left.dispose(),t.right.dispose(),t.prefix.dispose(),this._perGroup.delete(e))}dispose(){for(let e of[...this._perGroup.keys()])this.disposeGroup(e)}_ensureState(e){let t=this._perGroup.get(e);return t||(t={left:new pB,right:new pB,prefix:new pB},this._perGroup.set(e,t)),t}_refreshSlot(e,t,n){let r=this._host.options[fKe[e]];if(r){let i=r(t);n.value=i,i.init({containerApi:this._host.api,api:t.api,group:t}),t.model.attachHeaderAction(e,i.element)}else n.dispose(),t.model.attachHeaderAction(e,void 0)}},mKe=oH({name:`HeaderActions`,serviceKey:`headerActionsService`,create:e=>new pKe(e),init:(e,t)=>new fB(e.onDidRemoveGroup(e=>{t.disposeGroup(e)}))});function hKe(e,t){return e===`center`?`Tab into ${t}`:`Split ${e} of ${t}`}function gKe(e,t){return e===`center`?`docked into ${t}`:`split ${e} of ${t}`}var mH={panelOpened:e=>`${e} opened`,panelClosed:e=>`${e} closed`,groupMaximized:e=>`${e} maximized`,groupRestored:e=>`${e} restored`,groupFloated:e=>`${e} floated`,groupDocked:e=>`${e} docked`,groupPoppedOut:e=>`${e} opened in a new window`,movePickTarget:(e,t,n,r)=>`Moving ${e}. Target ${t}, ${n} of ${r}. Enter to choose where, Escape to cancel.`,movePickEdge:(e,t)=>`${hKe(e,t)}. Arrows to change, Enter to confirm, Escape to go back.`,moveCommitted:(e,t,n)=>`${e} ${gKe(n,t)}.`,moveCancelled:()=>`Move cancelled.`,moveNotAllowed:()=>`That move is not allowed.`};function hH(e){return e?Object.assign(Object.assign({},mH),e):mH}var gH=e=>e===`load`||e===`clear`;function _H(e){let t=document.createElement(`div`);return t.className=e===`assertive`?`dv-live-region-assertive`:`dv-live-region`,t.setAttribute(`role`,e===`assertive`?`alert`:`status`),t.setAttribute(`aria-live`,e),t.setAttribute(`aria-atomic`,`true`),Object.assign(t.style,{position:`absolute`,width:`1px`,height:`1px`,margin:`-1px`,padding:`0`,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(50%)`,whiteSpace:`nowrap`,border:`0`}),t}var _Ke=class extends fB{constructor(e){super(),this._suppressDepth=0,this._locationSubs=new Map,this._host=e,this._polite=_H(`polite`),this._assertive=_H(`assertive`),e.element.appendChild(this._polite),e.element.appendChild(this._assertive),this.addDisposables({dispose:()=>this._polite.remove()},{dispose:()=>this._assertive.remove()},e.onDidAddPanel(e=>this._announce(e,`open`)),e.onDidRemovePanel(e=>this._announce(e,`close`)),e.onWillMutateLayout(e=>{gH(e.kind)&&this._suppressDepth++}),e.onDidMutateLayout(e=>{gH(e.kind)&&(this._suppressDepth=Math.max(0,this._suppressDepth-1))}),e.onDidMaximizedGroupChange(e=>{let t=e.group.activePanel;t&&this._announce(t,e.isMaximized?`maximize`:`restore`)}),e.onDidAddGroup(e=>this._trackLocation(e)),e.onDidRemoveGroup(e=>{var t;(t=this._locationSubs.get(e.id))==null||t.dispose(),this._locationSubs.delete(e.id)}),{dispose:()=>{this._locationSubs.forEach(e=>e.dispose()),this._locationSubs.clear()}})}_trackLocation(e){let t=e.api.location.type,n=e.api.onDidLocationChange(n=>{let r=n.location.type;if(r===t)return;t=r;let i=e.activePanel;if(!i)return;let a=r===`floating`?`float`:r===`popout`?`popout`:`dock`;this._announce(i,a)});this._locationSubs.set(e.id,n)}announce(e,t=`polite`){if(this._host.options.announcements===!1||this._suppressDepth>0||!e)return;let n=this._host.options.announcer;if(n){n({message:e,politeness:t});return}let r=t===`assertive`?this._assertive:this._polite;r.textContent=``,r.textContent=e}_announce(e,t){var n;let r=(n=this._host.options).getAnnouncement?.call(n,{kind:t,panel:e});r===null||r===``||this.announce(r??this._defaultMessage(e,t))}_defaultMessage(e,t){let n=hH(this._host.options.messages),r=e.title??e.id;switch(t){case`open`:return n.panelOpened(r);case`close`:return n.panelClosed(r);case`maximize`:return n.groupMaximized(r);case`restore`:return n.groupRestored(r);case`float`:return n.groupFloated(r);case`dock`:return n.groupDocked(r);case`popout`:return n.groupPoppedOut(r)}}},vH=oH({name:`LiveRegion`,serviceKey:`liveRegionService`,create:e=>new _Ke(e)}),vKe=[rKe,aKe,sKe,lKe,dKe,mKe,vH],yKe=class{constructor(){this.cache=new Map,this.currentFrameId=0,this.rafId=null}getPosition(e){let t=this.cache.get(e);if(t&&t.frameId===this.currentFrameId)return t.rect;this.scheduleFrameUpdate();let n=kB(e);return this.cache.set(e,{rect:n,frameId:this.currentFrameId}),n}invalidate(){this.currentFrameId++}scheduleFrameUpdate(){this.rafId||=requestAnimationFrame(()=>{this.currentFrameId++,this.rafId=null})}};function bKe(){let e=document.createElement(`div`);return e.tabIndex=-1,e}var yH=class extends fB{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this.positionCache=new yKe,this.pendingUpdates=new Set,this.addDisposables(dB.from(()=>{for(let e of Object.values(this.map))e.disposable.dispose(),e.destroy.dispose();this._disposed=!0}))}updateAllPositions(){if(!this._disposed){this.positionCache.invalidate();for(let e of Object.values(this.map))e.panel.api.isVisible&&e.resize&&e.resize()}}detatch(e){if(this.map[e.api.id]){let{disposable:t,destroy:n}=this.map[e.api.id];return t.dispose(),n.dispose(),delete this.map[e.api.id],!0}return!1}attach(e){let{panel:t,referenceContainer:n}=e;if(!this.map[t.api.id]){let e=bKe();e.className=`dv-render-overlay`,e.style.visibility=`hidden`,this.map[t.api.id]={panel:t,disposable:dB.NONE,destroy:dB.NONE,element:e}}let r=this.map[t.api.id].element,i=t.view.content.element;i.parentElement!==r&&r.appendChild(i),r.parentElement!==this.element&&this.element.appendChild(r);let a=()=>{let e=t.api.id;this.pendingUpdates.has(e)||(this.pendingUpdates.add(e),requestAnimationFrame(()=>{if(this.pendingUpdates.delete(e),this.isDisposed||!this.map[e])return;let i=this.positionCache.getPosition(n.element),a=this.positionCache.getPosition(this.element),o=i.left-a.left,s=i.top-a.top,c=i.width,l=i.height;r.style.left=`${o}px`,r.style.top=`${s}px`,r.style.width=`${c}px`,r.style.height=`${l}px`,t.api.isVisible?(r.style.visibility=``,r.style.pointerEvents=``):(r.style.visibility=`hidden`,r.style.pointerEvents=`none`),CB(r,`dv-render-overlay-float`,t.group.api.location.type===`floating`)}))},o=()=>{t.api.isVisible?(this.positionCache.invalidate(),a(),r.style.pointerEvents=``):(r.style.visibility=`hidden`,r.style.pointerEvents=`none`)},s=new pB,c=()=>{t.api.location.type===`floating`?queueMicrotask(()=>{let e=this.accessor.floatingGroups.find(e=>e.group===t.api.group);if(!e)return;let n=e.overlay.element,i=()=>{let e=Number(n.getAttribute(`aria-level`));r.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2+1})`},a=new MutationObserver(()=>{i()});s.value=dB.from(()=>a.disconnect()),a.observe(n,{attributeFilter:[`aria-level`],attributes:!0}),i()}):r.style.zIndex=``},l=new fB(s,new mV(r,{onDragEnd:e=>{n.dropTarget.dnd.onDragEnd(e)},onDragEnter:e=>{n.dropTarget.dnd.onDragEnter(e)},onDragLeave:e=>{n.dropTarget.dnd.onDragLeave(e)},onDrop:e=>{n.dropTarget.dnd.onDrop(e)},onDragOver:e=>{n.dropTarget.dnd.onDragOver(e)}}),t.api.onDidVisibilityChange(()=>{o()}),t.api.onDidDimensionsChange(()=>{t.api.isVisible&&a()}),t.api.onDidLocationChange(()=>{c()}));return this.map[t.api.id].destroy=dB.from(()=>{var e;i.parentElement===r&&r.removeChild(i),(e=r.parentElement)==null||e.removeChild(r)}),c(),queueMicrotask(()=>{this.isDisposed||o()}),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=l,this.map[t.api.id].resize=a,r}};function xKe(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function SKe(e){let t;try{t=new URL(e,window.location.href)}catch{throw Error(`dockview: invalid popout URL: ${e}`)}if(!(t.protocol===`http:`||t.protocol===`https:`)||t.origin!==window.location.origin)throw Error(`dockview: popout URL must be same-origin http(s); got: ${e}`)}var CKe=class extends fB{get window(){return this._window?.value??null}constructor(e,t,n){super(),this.target=e,this.className=t,this.options=n,this._onWillClose=new Q,this.onWillClose=this._onWillClose.event,this._onDidClose=new Q,this.onDidClose=this._onDidClose.event,this._window=null,this.addDisposables(this._onWillClose,this._onDidClose,{dispose:()=>{this.close()}})}dimensions(){if(!this._window)return null;let e=this._window.value.screenX;return{top:this._window.value.screenY,left:e,width:this._window.value.innerWidth,height:this._window.value.innerHeight}}close(){var e,t;this._window&&(this._onWillClose.fire(),(t=(e=this.options).onWillClose)==null||t.call(e,{id:this.target,window:this._window.value}),this._window.disposable.dispose(),this._window=null,this._onDidClose.fire())}open(){return xKe(this,void 0,void 0,function*(){var e,t;if(this._window)throw Error(`instance of popout window is already open`);let n=`${this.options.url}`;SKe(n);let r=Object.entries({top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height}).map(([e,t])=>`${e}=${t}`).join(`,`),i=window.open(n,this.target,r);if(!i)return null;let a=new fB;this._window={value:i,disposable:a},a.addDisposables(dB.from(()=>{i.close()}),vB(window,`beforeunload`,()=>{this.close()}));let o=this.createPopoutWindowContainer();return this.className&&o.classList.add(this.className),(t=(e=this.options).onDidOpen)==null||t.call(e,{id:this.target,window:i}),new Promise((e,t)=>{i.addEventListener(`unload`,e=>{}),i.addEventListener(`load`,()=>{try{let t=i.document;t.title=document.title,t.body.appendChild(o),MWe(t,window.document.styleSheets,{nonce:this.options.nonce}),vB(i,`beforeunload`,()=>{this.close()}),e(o)}catch(e){t(e)}})})})}createPopoutWindowContainer(){let e=document.createElement(`div`);return e.classList.add(`dv-popout-window`),e.id=`dv-popout-window`,e.style.position=`absolute`,e.style.width=`100%`,e.style.height=`100%`,e.style.top=`0px`,e.style.left=`0px`,e}},wKe=class extends fB{constructor(e){super(),this.accessor=e,this.init()}init(){let e=new Set,t=new Set;this.addDisposables(this.accessor.onDidAddPanel(t=>{if(e.has(t.api.id))throw Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${t.api.id} but panel already exists`);e.add(t.api.id)}),this.accessor.onDidRemovePanel(t=>{if(e.has(t.api.id))e.delete(t.api.id);else throw Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${t.api.id} but panel does not exists`)}),this.accessor.onDidAddGroup(e=>{if(t.has(e.api.id))throw Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${e.api.id} but group already exists`);t.add(e.api.id)}),this.accessor.onDidRemoveGroup(e=>{if(t.has(e.api.id))t.delete(e.api.id);else throw Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${e.api.id} but group does not exists`)}))}};function TKe(e){if(!e.matchMedia)return!1;let t=e.matchMedia(`(pointer: coarse)`).matches,n=e.matchMedia(`(pointer: fine)`).matches;return t&&!n}var bH=class extends fB{constructor(e,t=window){super(),this._active=null,this._activeDisposable=new pB,this._root=e,this._window=t,this._element=t.document.createElement(`div`),this._element.className=`dv-popover-anchor`,this._element.style.position=`relative`,this._root.prepend(this._element),this.addDisposables(dB.from(()=>{this.close()}),this._activeDisposable)}updateRoot(e){e.prepend(this._element),this._root=e}openPopover(e,t){this.close();let n=this._window.document.createElement(`div`);n.style.position=`absolute`,n.style.zIndex=t.zIndex??`var(--dv-overlay-z-index)`,n.appendChild(e);let r=this._element.getBoundingClientRect(),i=r.left,a=r.top;n.style.top=`${t.y-a}px`,n.style.left=`${t.x-i}px`,this._element.appendChild(n),this._active=n;let o=Date.now();this._activeDisposable.value=new fB(vB(this._window,`pointerdown`,e=>{if(Date.now()-o<200)return;let t=e.target;if(!(t instanceof HTMLElement))return;let r=t;for(;r&&r!==n;)r=r?.parentElement??null;r||this.close()}),vB(this._window,`keydown`,e=>{(e.key===`Escape`||e.key===`Enter`)&&this.close()}),vB(this._window,`resize`,()=>{TKe(this._window)||this.close()})),this._window.requestAnimationFrame(()=>{zWe(n,this._root)})}close(){this._active&&=(this._active.remove(),this._activeDisposable.dispose(),null)}},xH=class extends fB{get disabled(){return this._disabled}set disabled(e){var t;this.disabled!==e&&(this._disabled=e,e&&((t=this.model)==null||t.clear()))}get model(){if(!this.disabled)return{clear:()=>{var e;this._model&&((e=this._model.root.parentElement)==null||e.removeChild(this._model.root)),this._model=void 0},exists:()=>!!this._model,getElements:(e,t)=>{let n=this._outline!==t;if(this._outline=t,this._model)return this._model.changed=n,this._model;let r=this.createContainer(),i=this.createAnchor();if(this._model={root:r,overlay:i,changed:n},r.appendChild(i),this.element.appendChild(r),e?.target instanceof HTMLElement){let t=e.target.getBoundingClientRect(),n=this.element.getBoundingClientRect();i.style.left=`${t.left-n.left}px`,i.style.top=`${t.top-n.top}px`}return this._model}}}constructor(e,t){super(),this.element=e,this._disabled=!1,this._disabled=t.disabled,this.addDisposables(dB.from(()=>{var e;(e=this.model)==null||e.clear()}))}createContainer(){let e=document.createElement(`div`);return e.className=`dv-drop-target-container`,e}createAnchor(){let e=document.createElement(`div`);return e.className=`dv-drop-target-anchor`,e.style.visibility=`hidden`,e}},EKe=class{get minimumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMinimumSize}get maximumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMaximumSize}get element(){return this._group.element}get isCollapsed(){return this._isCollapsed}get lastExpandedSize(){return this._lastExpandedSize}get collapsedSize(){return this._collapsedSize}constructor(e,t,n){this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority=GB.Low,this._isCollapsed=!1,this._group=t,this._orientation=n,t.element.classList.add(`dv-edge-group`),t.element.dataset.testid=`dv-edge-group-${e.id}`,this._collapsedSize=e.collapsedSize??35,this._expandedMaximumSize=e.maximumSize??1/0,this._expandedMinimumSize=e.minimumSize===void 0?this._collapsedSize+50:e.minimumSize,this._lastExpandedSize=e.initialSize??200,e.collapsed&&(this._isCollapsed=!0,t.element.classList.add(`dv-edge-collapsed`))}layout(e,t){this._isCollapsed||(this._lastExpandedSize=e),this._orientation===`horizontal`?this._group.layout(e,t):this._group.layout(t,e)}setCollapsed(e){this._isCollapsed!==e&&(this._isCollapsed=e,this._group.element.classList.toggle(`dv-edge-collapsed`,e))}setVisible(e){}restoreExpandedSize(e){this._lastExpandedSize=e}updateCollapsedSize(e,t){this._collapsedSize=e,this._expandedMinimumSize=t}dispose(){this._onDidChange.dispose()}},DKe=class{get element(){return this._dockviewElement}constructor(e,t){this._dockviewElement=e,this._layoutDockview=t,this.priority=GB.High,this.minimumSize=100,this.maximumSize=1/0,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}},OKe=class{get element(){return this._element}constructor(e,t=0){this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=1/0,this.priority=GB.High,this._element=document.createElement(`div`),this._element.className=`dv-shell-middle-column`,this._element.style.height=`100%`,this._element.style.width=`100%`,this._splitview=new qB(this._element,{orientation:UB.VERTICAL,proportionalLayout:!1,margin:t}),this._centerIndex=0,this._splitview.addView(e,{type:`distribute`},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,this._bottomIndex!==void 0&&(this._bottomIndex+=1)}addBottomView(e,t){let n=this._splitview.length;this._splitview.addView(e,t,n),this._bottomIndex=n}removeView(e){let t=e===`top`?this._topIndex:this._bottomIndex;t!==void 0&&(this._splitview.removeView(t),e===`top`?(this._topIndex=void 0,--this._centerIndex,this._bottomIndex!==void 0&&--this._bottomIndex):this._bottomIndex=void 0)}layout(e,t){this._splitview.layout(t,e)}setVisible(e){}setViewVisible(e,t){let n=e===`top`?this._topIndex:this._bottomIndex;n!==void 0&&this._splitview.setViewVisible(n,t)}isViewVisible(e){let t=e===`top`?this._topIndex:this._bottomIndex;return t!==void 0&&this._splitview.isViewVisible(t)}getViewSize(e){let t=e===`top`?this._topIndex:this._bottomIndex;return t===void 0?0:this._splitview.getViewSize(t)}resizeView(e,t){let n=e===`top`?this._topIndex:this._bottomIndex;n!==void 0&&this._splitview.resizeView(n,t)}updateMargin(e){this._splitview.margin=e}dispose(){this._onDidChange.dispose(),this._splitview.dispose()}};function kKe(e,t,n){let r=(e.collapsedSize??t)+n,i=Object.assign(Object.assign({},e),{collapsedSize:r});return e.minimumSize!==void 0&&(i.minimumSize=e.minimumSize+n),i}var AKe=class{constructor(e,t,n,r=0,i=35){this._disposables=new fB,this._viewConfigs=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=r,this._defaultCollapsedSize=i,this._shellElement=document.createElement(`div`),this._shellElement.className=`dv-shell`,this._shellElement.style.height=`100%`,this._shellElement.style.width=`100%`,this._shellElement.style.position=`relative`,e.appendChild(this._shellElement);let a=new DKe(t,n);this._middleColumn=new OKe(a,r),this._outerSplitview=new qB(this._shellElement,{orientation:UB.HORIZONTAL,proportionalLayout:!1,margin:r}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:`distribute`},0),this._disposables.addDisposables(bB(this._shellElement,e=>{let t=Math.round(e.contentRect.width),n=Math.round(e.contentRect.height);t===this._currentWidth&&n===this._currentHeight||(this._currentWidth=t,this._currentHeight=n,this.layout(t,n))}),this._outerSplitview,this._middleColumn,a)}get element(){return this._shellElement}addEdgeView(e,t,n){if(this.hasEdgeGroup(e))throw Error(`dockview: edge group already registered at position '${e}'`);this._viewConfigs.set(e,t);let r=1+ +!!this._viewConfigs.has(`left`)+ +!!this._viewConfigs.has(`right`),i=1+ +!!this._viewConfigs.has(`top`)+ +!!this._viewConfigs.has(`bottom`),a=r>1?this._gap*(r-1)/r:0,o=i>1?this._gap*(i-1)/i:0,s=e===`left`||e===`right`,c=s?a:o,l=s?`horizontal`:`vertical`,u=new EKe(kKe(Object.assign({collapsedSize:this._defaultCollapsedSize},t),this._defaultCollapsedSize,c),n,l),d=u.isCollapsed?u.collapsedSize:u.lastExpandedSize;switch(e){case`left`:this._outerSplitview.addView(u,d,0),this._leftIndex=0,this._middleIndex+=1,this._rightIndex!==void 0&&(this._rightIndex+=1),this._leftView=u;break;case`right`:{let e=this._outerSplitview.length;this._outerSplitview.addView(u,d,e),this._rightIndex=e,this._rightView=u}break;case`top`:this._middleColumn.addTopView(u,d),this._topView=u;break;case`bottom`:this._middleColumn.addBottomView(u,d),this._bottomView=u;break}return this._disposables.addDisposables(u),this.updateTheme(this._gap,this._defaultCollapsedSize),u}layout(e,t){this._outerSplitview.layout(e,t)}updateTheme(e,t){this._gap=e,this._defaultCollapsedSize=t;let n=1+ +!!this._viewConfigs.has(`left`)+ +!!this._viewConfigs.has(`right`),r=1+ +!!this._viewConfigs.has(`top`)+ +!!this._viewConfigs.has(`bottom`),i=n>1?e*(n-1)/n:0,a=r>1?e*(r-1)/r:0;this._outerSplitview.margin=e,this._middleColumn.updateMargin(e);let o=(e,n,r)=>{let i=(n.collapsedSize??t)+r,a=n.minimumSize,o=a===void 0?i+50:a+r;e.updateCollapsedSize(i,o)},s=this._viewConfigs.get(`top`);this._topView&&s&&o(this._topView,s,a);let c=this._viewConfigs.get(`bottom`);this._bottomView&&c&&o(this._bottomView,c,a);let l=this._viewConfigs.get(`left`);this._leftView&&l&&o(this._leftView,l,i);let u=this._viewConfigs.get(`right`);this._rightView&&u&&o(this._rightView,u,i),this._leftView?.isCollapsed&&this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,this._leftView.collapsedSize),this._rightView?.isCollapsed&&this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,this._rightView.collapsedSize),this._topView?.isCollapsed&&this._middleColumn.resizeView(`top`,this._topView.collapsedSize),this._bottomView?.isCollapsed&&this._middleColumn.resizeView(`bottom`,this._bottomView.collapsedSize),this._currentWidth>0&&this._currentHeight>0&&this.layout(this._currentWidth,this._currentHeight)}removeEdgeView(e){let t=this._getView(e);if(t){switch(e){case`left`:this._outerSplitview.removeView(this._leftIndex),this._leftIndex=void 0,this._leftView=void 0,--this._middleIndex,this._rightIndex!==void 0&&--this._rightIndex;break;case`right`:this._outerSplitview.removeView(this._rightIndex),this._rightIndex=void 0,this._rightView=void 0;break;case`top`:this._middleColumn.removeView(`top`),this._topView=void 0;break;case`bottom`:this._middleColumn.removeView(`bottom`),this._bottomView=void 0;break}this._disposables.removeDisposable(t),t.dispose(),this._viewConfigs.delete(e),this.updateTheme(this._gap,this._defaultCollapsedSize)}}hasEdgeGroup(e){switch(e){case`top`:return this._topView!==void 0;case`bottom`:return this._bottomView!==void 0;case`left`:return this._leftView!==void 0;case`right`:return this._rightView!==void 0}}setEdgeGroupVisible(e,t){switch(e){case`left`:this._leftIndex!==void 0&&this._outerSplitview.setViewVisible(this._leftIndex,t);break;case`right`:this._rightIndex!==void 0&&this._outerSplitview.setViewVisible(this._rightIndex,t);break;case`top`:case`bottom`:this._middleColumn.setViewVisible(e,t);break}}isEdgeGroupVisible(e){switch(e){case`left`:return this._leftIndex!==void 0&&this._outerSplitview.isViewVisible(this._leftIndex);case`right`:return this._rightIndex!==void 0&&this._outerSplitview.isViewVisible(this._rightIndex);case`top`:case`bottom`:return this._middleColumn.isViewVisible(e)}}setEdgeGroupCollapsed(e,t){let n=this._getView(e);if(!n)return;n.setCollapsed(t);let r=t?n.collapsedSize:n.lastExpandedSize;switch(e){case`left`:this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,r);break;case`right`:this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,r);break;case`top`:case`bottom`:this._middleColumn.resizeView(e,r);break}}isEdgeGroupCollapsed(e){return this._getView(e)?.isCollapsed??!1}_getView(e){switch(e){case`top`:return this._topView;case`bottom`:return this._bottomView;case`left`:return this._leftView;case`right`:return this._rightView}}toJSON(){let e={};return this._leftView&&this._leftIndex!==void 0&&(e.left={size:this._leftView.isCollapsed?this._leftView.lastExpandedSize:this._outerSplitview.getViewSize(this._leftIndex),visible:this._outerSplitview.isViewVisible(this._leftIndex),collapsed:this._leftView.isCollapsed||void 0}),this._rightView&&this._rightIndex!==void 0&&(e.right={size:this._rightView.isCollapsed?this._rightView.lastExpandedSize:this._outerSplitview.getViewSize(this._rightIndex),visible:this._outerSplitview.isViewVisible(this._rightIndex),collapsed:this._rightView.isCollapsed||void 0}),this._topView&&(e.top={size:this._topView.isCollapsed?this._topView.lastExpandedSize:this._middleColumn.getViewSize(`top`),visible:this._middleColumn.isViewVisible(`top`),collapsed:this._topView.isCollapsed||void 0}),this._bottomView&&(e.bottom={size:this._bottomView.isCollapsed?this._bottomView.lastExpandedSize:this._middleColumn.getViewSize(`bottom`),visible:this._middleColumn.isViewVisible(`bottom`),collapsed:this._bottomView.isCollapsed||void 0}),e}fromJSON(e){var t,n,r,i,a,o,s,c;e.left&&this._leftIndex!==void 0&&((t=this._leftView)==null||t.restoreExpandedSize(e.left.size),(n=this._leftView)==null||n.setCollapsed(e.left.collapsed??!1),this._outerSplitview.resizeView(this._leftIndex,e.left.collapsed?this._leftView?.collapsedSize??e.left.size:e.left.size),e.left.visible||this._outerSplitview.setViewVisible(this._leftIndex,!1)),e.right&&this._rightIndex!==void 0&&((r=this._rightView)==null||r.restoreExpandedSize(e.right.size),(i=this._rightView)==null||i.setCollapsed(e.right.collapsed??!1),this._outerSplitview.resizeView(this._rightIndex,e.right.collapsed?this._rightView?.collapsedSize??e.right.size:e.right.size),e.right.visible||this._outerSplitview.setViewVisible(this._rightIndex,!1)),e.top&&((a=this._topView)==null||a.restoreExpandedSize(e.top.size),(o=this._topView)==null||o.setCollapsed(e.top.collapsed??!1),this._middleColumn.resizeView(`top`,e.top.collapsed?this._topView?.collapsedSize??e.top.size:e.top.size),e.top.visible||this._middleColumn.setViewVisible(`top`,!1)),e.bottom&&((s=this._bottomView)==null||s.restoreExpandedSize(e.bottom.size),(c=this._bottomView)==null||c.setCollapsed(e.bottom.collapsed??!1),this._middleColumn.resizeView(`bottom`,e.bottom.collapsed?this._bottomView?.collapsedSize??e.bottom.size:e.bottom.size),e.bottom.visible||this._middleColumn.setViewVisible(`bottom`,!1))}dispose(){var e;this._disposables.dispose(),(e=this._shellElement.parentElement)==null||e.removeChild(this._shellElement)}};function jKe(e){return new RV(e.tabGroupColors??LV,e.tabGroupAccent!==`off`)}function SH(e){let t=e.from.activePanel;[...e.from.panels].map(t=>{let n=e.from.model.removePanel(t);return e.from.model.renderContainer.detatch(t),n}).forEach(n=>{e.to.model.openPanel(n,{skipSetActive:t!==n,skipSetGroupActive:!0})})}var CH=!1;function MKe(){typeof process<`u`||CH||$Ge()||(CH=!0,console.warn(`dockview: do not use "dockview-core" directly — it is an internal package. Use the "dockview" package, the JavaScript version of dockview, instead. This notice is shown once.`))}var NKe=class extends lV{fireDidCreateTabGroup(e){this._onDidCreateTabGroup.fire(e)}fireDidDestroyTabGroup(e){this._onDidDestroyTabGroup.fire(e)}fireDidAddPanelToTabGroup(e){this._onDidAddPanelToTabGroup.fire(e)}fireDidRemovePanelFromTabGroup(e){this._onDidRemovePanelFromTabGroup.fire(e)}fireDidTabGroupChange(e){this._onDidTabGroupChange.fire(e)}fireDidTabGroupCollapsedChange(e){this._onDidTabGroupCollapsedChange.fire(e)}get orientation(){return this.gridview.orientation}get totalPanels(){return this.panels.length}get panels(){return this.groups.flatMap(e=>e.panels)}get options(){return this._options}get tabGroupColorPalette(){return this._tabGroupColorPalette}get activePanel(){let e=this.activeGroup;if(e)return e.activePanel}get renderer(){return this.options.defaultRenderer??`onlyWhenVisible`}get defaultHeaderPosition(){return this.options.defaultHeaderPosition??`top`}get api(){return this._api}get floatingGroups(){return this._moduleRegistry?.services.floatingGroupService?.floatingGroups??[]}_gatherFloatingGroupBoxes(e){let t=(this._floatingOverlayHost??this.gridview.element).getBoundingClientRect();return this.floatingGroups.filter(t=>t.group!==e).map(e=>{let n=e.overlay.element.getBoundingClientRect();return{left:n.left-t.left,top:n.top-t.top,width:n.width,height:n.height}})}get _floatingGroupService(){return this._moduleRegistry.services.floatingGroupService}get _popoutWindowService(){return this._moduleRegistry.services.popoutWindowService}get _watermarkService(){return this._moduleRegistry.services.watermarkService}get _edgeGroupService(){return this._moduleRegistry.services.edgeGroupService}get _rootDropTargetService(){return this._moduleRegistry.services.rootDropTargetService}get _advancedDnDService(){return this._moduleRegistry.services.advancedDnDService}get headerActionsService(){return this._moduleRegistry.services.headerActionsService}isGridEmpty(){return this.gridview.length===0}rootDropTargetOverrideTarget(){return this.rootDropTargetContainer?.model}dispatchUnhandledDragOver(e,t){let n=new qV(e,`edge`,t,lB);return this._onUnhandledDragOver.fire(n),n.isAccepted}fireWillDragPanel(e){this._onWillDragPanel.fire(e)}fireWillDragGroup(e){this._onWillDragGroup.fire(e)}fireWillDrop(e){this._onWillDrop.fire(e)}fireWillShowOverlay(e){this._onWillShowOverlay.fire(e)}buildGroupDragGhost(e){return this._advancedDnDService?.buildGroupDragGhost(e)}resolveDropOverlayModel(e,t){return this._advancedDnDService?.resolveOverlayModel(e,t)}get rootElement(){return this._shellManager?.element??this.element}adjacentGroup(e,t){if(e.api.location.type!==`grid`)return;let n=tV(e.element);return(t?this.gridview.previous(n):this.gridview.next(n))?.view}adjacentGroupInDirection(e,t){if(e.api.location.type!==`grid`)return;let n=e.element.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height/2,a,o=1/0;for(let n of this.groups){if(n===e||n.api.location.type!==`grid`)continue;let s=n.element.getBoundingClientRect(),c=s.left+s.width/2-r,l=s.top+s.height/2-i;if(!(t===`left`?c<0&&Math.abs(c)>=Math.abs(l):t===`right`?c>0&&Math.abs(c)>=Math.abs(l):t===`up`?l<0&&Math.abs(l)>=Math.abs(c):l>0&&Math.abs(l)>=Math.abs(c)))continue;let u=c*c+l*l;u<o&&(o=u,a=n)}return a}showDropPreview(e,t){return this._advancedDnDService?.showPreviewOverlay(e,t)??dB.NONE}announce(e){var t;(t=this._moduleRegistry.services.liveRegionService)==null||t.announce(e)}dockPanel(e,t,n){this.moveGroupOrPanel({from:{groupId:e.group.id,panelId:e.id},to:{group:t,position:n}})}get contextMenuService(){return this._moduleRegistry.services.contextMenuService}get mountElement(){return this.gridview.element}hasVisibleGridGroup(){return this.groups.some(e=>e.api.location.type===`grid`&&e.api.isVisible)}fireLayoutChange(){this._bufferOnDidLayoutChange.fire()}get popoutRestorationPromise(){return this._popoutWindowService?.restorationPromise??Promise.resolve()}constructor(e,t){super(e,{proportionalLayout:!0,orientation:UB.HORIZONTAL,styles:t.hideBorders?{separatorBorder:`transparent`}:void 0,disableAutoResizing:t.disableAutoResizing,locked:t.locked,margin:t.theme?.gap??0,className:t.className}),this.nextGroupId=VB(),this._deserializer=new KGe(this),this._moduleRegistry=new YGe,this._onWillDragPanel=new Q,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new Q,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new Q,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new Q,this.onWillDrop=this._onWillDrop.event,this._mutationDepth=0,this._origin=`user`,this._originDepth=0,this._onWillMutateLayout=new Q,this.onWillMutateLayout=this._onWillMutateLayout.event,this._onDidMutateLayout=new Q,this.onDidMutateLayout=this._onDidMutateLayout.event,this._onWillShowOverlay=new Q,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOver=new Q,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._onDidRemovePanel=new Q,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new Q,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new Q,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new Q,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidAddPopoutGroup=new Q,this.onDidAddPopoutGroup=this._onDidAddPopoutGroup.event,this._onDidRemovePopoutGroup=new Q,this.onDidRemovePopoutGroup=this._onDidRemovePopoutGroup.event,this._onDidOpenPopoutWindowFail=new Q,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidLayoutFromJSON=new Q,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new Q({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidMovePanel=new Q,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new Q,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new Q,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new Q,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new Q,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new Q,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new Q,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new Q,this.onDidMaximizedGroupChange=this._onDidMaximizedGroupChange.event,this._inShellLayout=!1,this._onDidRemoveGroup=new Q,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new Q,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new Q,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new Q,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._moving=!1,this._options=t,this._tabGroupColorPalette=jKe(t);let n=t.modules??[...vKe,...ZGe()];for(let e of n)this._moduleRegistry.register(e);this._moduleRegistry.initialize(this);let r=this._popoutWindowService;r&&this.addDisposables(r.onDidRemove(e=>{this._onDidRemovePopoutGroup.fire({id:e.popoutGroup.id,group:e.popoutGroup,window:e.getWindow()})})),MKe(),this.popupService=new bH(this.element),this._api=new pV(this),this.disableResizing=!0,e.removeChild(this.element),this._shellManager=new AKe(e,this.element,(e,t)=>this._layoutFromShell(e,t),t.theme?.gap??0,t.theme?.edgeGroupCollapsedSize),this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new jB(this._shellManager.element),this.rootDropTargetContainer=new xH(this._shellManager.element,{disabled:!0}),this.overlayRenderContainer=new yH(this._shellManager.element,this),this._floatingOverlayHost=document.createElement(`div`),this._floatingOverlayHost.className=`dv-floating-overlay-host`,this._shellManager.element.appendChild(this._floatingOverlayHost),CB(this.gridview.element,`dv-dockview`,!0),CB(this.element,`dv-debug`,!!t.debug),this.updateTheme(),t.debug&&this.addDisposables(new wKe(this)),this.addDisposables(this.rootDropTargetContainer,this.overlayRenderContainer,this._onWillDragPanel,this._onWillDragGroup,this._onWillShowOverlay,this._onDidActivePanelChange,this._onDidAddPanel,this._onDidRemovePanel,this._onDidLayoutFromJSON,this._onDidDrop,this._onWillDrop,this._onWillMutateLayout,this._onDidMutateLayout,this._onDidMovePanel,this._onDidMovePanel.event(()=>{this.debouncedUpdateAllPositions()}),this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this._onUnhandledDragOver,this._onDidMaximizedGroupChange,this._onDidPopoutGroupSizeChange,this._onDidPopoutGroupPositionChange,this._onDidAddPopoutGroup,this._onDidRemovePopoutGroup,this._onDidOpenPopoutWindowFail,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,mB.any(this.onDidPopoutGroupSizeChange,this.onDidPopoutGroupPositionChange,this.onDidCreateTabGroup,this.onDidDestroyTabGroup,this.onDidAddPanelToTabGroup,this.onDidRemovePanelFromTabGroup,this.onDidTabGroupChange,this.onDidTabGroupCollapsedChange)(()=>{this.fireLayoutChange()}),this._onDidOptionsChange,this.onDidAdd(e=>{this._moving||this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._moving||this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._moving||this._onDidActiveGroupChange.fire(e)}),this.onDidMaximizedChange(e=>{this._onDidMaximizedGroupChange.fire({group:e.panel,isMaximized:e.isMaximized})}),mB.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidAddGroup,this.onDidRemove,this.onDidRemoveGroup,this.onDidMovePanel,this.onDidActivePanelChange)(()=>{this._bufferOnDidLayoutChange.fire()}),dB.from(()=>{var e;this._moduleRegistry.dispose(),(e=this._shellManager)==null||e.dispose()}));let i=this._rootDropTargetService;i&&this.addDisposables(i.onWillShowOverlay(e=>{this.gridview.length>0&&e.position===`center`||this._onWillShowOverlay.fire(new PV(e,{kind:`edge`,panel:void 0,api:this._api,group:void 0,getData:lB}))}),i.onDrop(e=>{let t=new XV({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:lB,kind:`edge`});if(this._onWillDrop.fire(t),t.defaultPrevented)return;let n=lB();n?this.moveGroupOrPanel({from:{groupId:n.groupId,panelId:n.panelId??void 0},to:{group:this.orthogonalize(e.position),position:`center`}}):this._onDidDrop.fire(new YV({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:lB}))})),this._moduleRegistry.postConstruct(this)}setVisible(e,t){switch(e.api.location.type){case`grid`:super.setVisible(e,t);break;case`floating`:{let n=this.floatingGroups.find(t=>t.group===e);n&&(n.overlay.setVisible(t),e.api._onDidVisibilityChange.fire({isVisible:t}));break}case`popout`:console.warn(`dockview: You cannot hide a group that is in a popout window`);break}}getPopupServiceForGroup(e){return this._popoutWindowService?.getPopupService(e.id)??this.popupService}addPopoutGroup(e,t){return this.mutation(`popout`,()=>this._doAddPopoutGroup(e,t))}getPopouts(){return this._popoutWindowService?.entries.map(e=>({id:e.popoutGroup.id,group:e.popoutGroup,window:e.getWindow()}))??[]}_doAddPopoutGroup(e,t){let n=cH(this._popoutWindowService,`PopoutWindow`,`api.addPopoutGroup`);if(!n||e instanceof eH&&e.model.location.type===`edge`)return Promise.resolve(!1);if(e instanceof tH&&e.group.size===1)return this.addPopoutGroup(e.group,t);let r=IWe(this.gridview.element),i=this.element;function a(){return t?.position?t.position:e instanceof eH?e.element.getBoundingClientRect():e.group?e.group.element.getBoundingClientRect():i.getBoundingClientRect()}let o=a(),s=t?.overridePopoutGroup?.id??this.getNextGroupId(),c=t?.popoutUrl??this.options?.popoutUrl,l=new CKe(`${this.id}-${s}`,r??``,{url:c??`/popout.html`,left:window.screenX+o.left,top:window.screenY+o.top,width:o.width,height:o.height,onDidOpen:t?.onDidOpen,onWillClose:t?.onWillClose,nonce:this.options?.nonce}),u=new fB(l,l.onDidClose(()=>{u.dispose()}));return l.open().then(r=>{if(l.isDisposed)return!1;let i=t?.referenceGroup?t.referenceGroup:e instanceof tH?e.group:e,a=e.api.location.type,o=i.element.parentElement!==null,d;if(t?.overridePopoutGridview?d=t.overridePopoutGroup??i:o?t?.overridePopoutGroup?d=t.overridePopoutGroup:(d=this.createGroup({id:s}),r&&this._onDidAddGroup.fire(d)):d=i,r===null)return this.handleBlockedPopout({group:d,referenceGroup:i,options:t,popoutWindowDisposable:u}),!1;let f=document.createElement(`div`);f.className=`dv-overlay-render-container`;let p=new yH(f,this);d.model.renderContainer=p;let m=t?.overridePopoutGridview??this.createNestedGridview();t?.overridePopoutGridview||m.addView(d,KB.Distribute,[0]),m.element.style.width=`100%`,m.element.style.height=`100%`,m.layout(l.window.innerWidth,l.window.innerHeight);let h=!1,g=()=>{h||(h=!0,m.dispose())},_;if(!t?.overridePopoutGroup&&!t?.overridePopoutGridview&&o)if(e instanceof tH)this.movingLock(()=>{let t=i.model.removePanel(e);d.model.openPanel(t)});else switch(this.movingLock(()=>SH({from:i,to:d})),a){case`grid`:i.api.setVisible(!1);break;case`floating`:case`popout`:_=this.floatingGroups.find(t=>t.group.api.id===e.api.id)?.overlay.toJSON(),this.removeGroup(i);break}r.classList.add(`dv-dockview`),r.style.overflow=`hidden`,r.appendChild(f),r.appendChild(m.element);let v=document.createElement(`div`),y=new xH(v,{disabled:this.rootDropTargetContainer.disabled});r.appendChild(v),d.model.dropTargetContainer=y;let b=new bH(r,l.window);if(n.setPopupService(d.id,b),u.addDisposables(b,dB.from(()=>{n.deletePopupService(d.id)})),d.model.location={type:`popout`,getWindow:()=>l.window,popoutUrl:c},t?.overridePopoutGridview){let e=this.groups.filter(e=>m.element.contains(e.element));for(let t of e)t.model.renderContainer=p,t.model.dropTargetContainer=y,t.model.location={type:`popout`,getWindow:()=>l.window,popoutUrl:c}}o&&e.api.location.type===`grid`&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(d);let x=n.observeGridviewSize(l,m,p);x&&u.addDisposables(x),u.addDisposables(d.api.onDidActiveChange(e=>{var t;e.isActive&&((t=l.window)==null||t.focus())}),d.api.onWillFocus(()=>{var e;(e=l.window)==null||e.focus()}));let S={},C=o&&i&&this.getPanel(i.id),w={window:l,popoutGroup:d,gridview:m,overlayRenderContainer:p,dropTargetContainer:y,getWindow:()=>l.window,popoutUrl:c,referenceGroup:C?i.id:void 0,disposable:{dispose:()=>(u.dispose(),S.returnedGroup)}},T=LWe(l.window);return u.addDisposables(T,RWe(l.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:l.window.innerWidth,height:l.window.innerHeight,group:d})}),T.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:l.window.screenX,screenY:l.window.screenX,group:d})}),vB(l.window,`resize`,()=>{m.layout(l.window.innerWidth,l.window.innerHeight)}),p,dB.from(()=>this.disposePopoutWindow({group:d,referenceGroup:i,popoutGridview:m,isGroupAddedToDom:o,floatingBox:_,disposePopoutGridview:g,closeResult:S}))),n.add(w),this._onDidAddPopoutGroup.fire({id:w.popoutGroup.id,group:w.popoutGroup,window:w.getWindow()}),!0}).catch(e=>(console.error(`dockview: failed to create popout.`,e),!1))}handleBlockedPopout(e){let{group:t,referenceGroup:n,options:r,popoutWindowDisposable:i}=e;if(console.error(`dockview: failed to create popout. perhaps you need to allow pop-ups for this website`),i.dispose(),this._onDidOpenPopoutWindowFail.fire(),r?.overridePopoutGridview){let e=r.overridePopoutGridview,t=this.groups.filter(t=>e.element.contains(t.element));for(let n of t)this.movingLock(()=>{e.remove(n),this.redockGroupToMainGrid(n)});e.dispose(),n&&!n.api.isVisible&&n.api.setVisible(!0);return}t===n?this.gridview.element.contains(t.element)||(this.movingLock(()=>this.doAddGroup(t,[0])),t.model.location={type:`grid`}):(this.movingLock(()=>SH({from:t,to:n})),t.model.size===0&&this._groups.has(t.id)&&(t.dispose(),this._groups.delete(t.id),this._onDidRemoveGroup.fire(t))),n.api.isVisible||n.api.setVisible(!0)}redockGroupToMainGrid(e){e.model.renderContainer=this.overlayRenderContainer,e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location={type:`grid`},this.doAddGroup(e,[0])}disposePopoutWindow(e){let{group:t,referenceGroup:n,popoutGridview:r,isGroupAddedToDom:i,floatingBox:a,disposePopoutGridview:o,closeResult:s}=e;if(this.isDisposed){o();return}let c=!!this._popoutWindowService?.entries.find(e=>e.gridview===r),l=this.groups.filter(e=>r.element.contains(e.element)),u=l.includes(t),d=u&&l.length===1;if(c)for(let e of l)e!==t&&this.movingLock(()=>{this.doRemoveGroup(e,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),this.redockGroupToMainGrid(e)});if(u&&i&&this.getPanel(n.id))this.movingLock(()=>SH({from:t,to:n})),n.api.isVisible||n.api.setVisible(!0),this.getPanel(t.id)&&this.doRemoveGroup(t,{skipPopoutAssociated:!0});else if(u&&this.getPanel(t.id)){if(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,s.returnedGroup=t,!c){o();return}a&&d?this.addFloatingGroup(t,{height:a.height,width:a.width,position:a}):(this.doRemoveGroup(t,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),t.model.location={type:`grid`},this.movingLock(()=>{this.doAddGroup(t,[0])})),this.doSetGroupAndPanelActive(t)}o()}addFloatingGroup(e,t){this.mutation(`float`,()=>this._doAddFloatingGroup(e,t))}_doAddFloatingGroup(e,t){if(!cH(this._floatingGroupService,`FloatingGroup`,`api.addFloatingGroup`)||e instanceof eH&&e.model.location.type===`edge`)return;let n;if(e instanceof tH)n=this.createGroup(),this._onDidAddGroup.fire(n),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0,skipSetActiveGroup:!0})),this.movingLock(()=>n.model.openPanel(e,{skipSetGroupActive:!0}));else{n=e;let r=this._popoutWindowService?.findReferenceGroupId(n),i=r?this.getPanel(r):void 0;typeof t?.skipRemoveGroup==`boolean`&&t.skipRemoveGroup||(i?(this.movingLock(()=>SH({from:e,to:i})),this.doRemoveGroup(e,{skipPopoutReturn:!0,skipPopoutAssociated:!0}),this.doRemoveGroup(i,{skipDispose:!0}),n=i):this.doRemoveGroup(e,{skipDispose:!0,skipPopoutReturn:!0,skipPopoutAssociated:!1}))}function r(){if(t?.position){let e={};return`left`in t.position?e.left=Math.max(t.position.left,0):`right`in t.position?e.right=Math.max(t.position.right,0):e.left=fH.left,`top`in t.position?e.top=Math.max(t.position.top,0):`bottom`in t.position?e.bottom=Math.max(t.position.bottom,0):e.top=fH.top,typeof t.width==`number`?e.width=Math.max(t.width,0):e.width=fH.width,typeof t.height==`number`?e.height=Math.max(t.height,0):e.height=fH.height,e}return{left:typeof t?.x==`number`?Math.max(t.x,0):fH.left,top:typeof t?.y==`number`?Math.max(t.y,0):fH.top,width:typeof t?.width==`number`?Math.max(t.width,0):fH.width,height:typeof t?.height==`number`?Math.max(t.height,0):fH.height}}let i=r(),a=this.createNestedGridview();a.addView(n,KB.Distribute,[0]),this.mountFloatingWindow(a,n,[n],i,{dragHandle:t?.dragHandle,inDragMode:t?.inDragMode,skipActiveGroup:t?.skipActiveGroup})}createNestedGridview(e=UB.HORIZONTAL){return new aV(!0,this.options.hideBorders?{separatorBorder:`transparent`}:void 0,e,!1,this.options.theme?.gap??0)}mountFloatingWindow(e,t,n,r,i){let a=cH(this._floatingGroupService,`FloatingGroup`,`api.addFloatingGroup`);if(!a)return;let o=(i?.dragHandle??this.options.floatingGroupDragHandle??`titlebar`)===`titlebar`?new JGe(this,t):void 0,s=new aH(Object.assign(Object.assign({container:this._floatingOverlayHost??this.gridview.element,content:e.element,header:o?.element},r),{minimumInViewportWidth:this.options.floatingGroupBounds===`boundedWithinViewport`?void 0:this.options.floatingGroupBounds?.minimumWidthWithinViewport??dH,minimumInViewportHeight:this.options.floatingGroupBounds===`boundedWithinViewport`?void 0:this.options.floatingGroupBounds?.minimumHeightWithinViewport??dH,transformDragPosition:this.options.transformFloatingGroupDrag?e=>this.options.transformFloatingGroupDrag({group:t,proposed:e.proposed,container:e.container,others:e.others}):void 0,getSiblingBoxes:()=>this._gatherFloatingGroupBoxes(t)})),c=o?.element??t.element.querySelector(`.dv-void-container`);if(!c)throw Error(`dockview: failed to find drag handle`);s.setupDrag(c,{inDragMode:typeof i?.inDragMode==`boolean`&&i.inDragMode});let l=a.add(t,s,e);o&&(l.setTitleBar(o),l.addDisposables(o,dB.from(()=>l.setTitleBar(void 0)),o.onDragStart(e=>{this._onWillDragGroup.fire({nativeEvent:e,group:l.group})})));for(let e of n)e.model.location={type:`floating`};i?.skipActiveGroup||this.doSetGroupAndPanelActive(t)}orthogonalize(e,t){switch(this.gridview.normalize(),e){case`top`:case`bottom`:this.gridview.orientation===UB.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case`left`:case`right`:this.gridview.orientation===UB.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break}switch(e){case`top`:case`left`:case`center`:return this.createGroupAtLocation([0],void 0,t);case`bottom`:case`right`:return this.createGroupAtLocation([this.gridview.length],void 0,t);default:throw Error(`dockview: unsupported position ${e}`)}}updateOptions(e){var t,n,r,i;super.updateOptions(e),(t=this._floatingGroupService)==null||t.updateBounds(e),(n=this._rootDropTargetService)==null||n.setOptions(e);let a=this.options.disableDnd,o=this.options.dndStrategy;this._options=Object.assign(Object.assign({},this.options),e);let s=this.options.disableDnd,c=this.options.dndStrategy;if((a!==s||o!==c)&&this.updateDragAndDropState(),`theme`in e&&this.updateTheme(),(`createRightHeaderActionComponent`in e||`createLeftHeaderActionComponent`in e||`createPrefixHeaderActionComponent`in e)&&((r=this.headerActionsService)==null||r.refreshAll()),`createWatermarkComponent`in e){(i=this._watermarkService)==null||i.refresh();for(let e of this.groups)e.model.refreshWatermark()}if(`tabGroupColors`in e||`tabGroupAccent`in e){this._tabGroupColorPalette.setEntries(this._options.tabGroupColors??LV),this._tabGroupColorPalette.enabled=this._options.tabGroupAccent!==`off`;for(let e of this.groups)e.model.refreshTabGroupAccent()}this._onDidOptionsChange.fire(),this._layoutFromShell(this.gridview.width,this.gridview.height)}layout(e,t,n){var r;this._shellManager&&!this._inShellLayout?this._shellManager.layout(e,t):super.layout(e,t,n),this._syncFloatingOverlayHost(),(r=this._moduleRegistry?.services.floatingGroupService)==null||r.constrainBounds()}_syncFloatingOverlayHost(){if(!this._floatingOverlayHost||!this._shellManager)return;let e=this._shellManager.element.getBoundingClientRect(),t=this.element.getBoundingClientRect(),n=this._floatingOverlayHost;n.style.left=`${t.left-e.left}px`,n.style.top=`${t.top-e.top}px`,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`}_layoutFromShell(e,t){this._inShellLayout=!0,this.layout(e,t,!0),this._inShellLayout=!1}forceRelayout(){this._shellManager?this._layoutFromShell(this.width,this.height):super.forceRelayout()}addEdgeGroup(e,t){let n=cH(this._edgeGroupService,`EdgeGroup`,`api.addEdgeGroup`);if(!n)throw Error(`dockview: EdgeGroup module is not registered`);if(n.has(e))throw Error(`dockview: edge group already exists at position '${e}'`);return this.mutation(`add`,()=>{let r=this.createGroup({id:t.id});r.model.location={type:`edge`,position:e},r.model.headerPosition=e;let i=r.model.onDidRemovePanel(()=>{r.model.isEmpty&&this.setEdgeGroupCollapsed(r,!0)});return n.add(e,r,i),this._onDidAddGroup.fire(r),this._shellManager.addEdgeView(e,t,r),r.api})}getEdgeGroup(e){return this._edgeGroupService?.get(e)?.api}setEdgeGroupVisible(e,t){this._shellManager.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this._shellManager.isEdgeGroupVisible(e)}removeEdgeGroup(e){let t=cH(this._edgeGroupService,`EdgeGroup`,`api.removeEdgeGroup`);if(!t)return;let n=t.get(e);if(!n)throw Error(`dockview: no edge group exists at position '${e}'`);this.mutation(`remove`,()=>{for(let e of[...n.panels])this.removePanel(e,{removeEmptyGroup:!1,skipDispose:!1});this._shellManager.removeEdgeView(e),t.remove(e),n.dispose(),this._groups.delete(n.id),this._onDidRemoveGroup.fire(n)})}setEdgeGroupCollapsed(e,t){let n=this._edgeGroupService?.findPositionOf(e);n&&this._shellManager.isEdgeGroupCollapsed(n)!==t&&(this._shellManager.setEdgeGroupCollapsed(n,t),e.api._onDidCollapsedChange.fire({isCollapsed:t}))}isEdgeGroupCollapsed(e){let t=this._edgeGroupService?.findPositionOf(e);return t?this._shellManager.isEdgeGroupCollapsed(t):!1}updateDragAndDropState(){for(let e of this.groups)e.model.updateDragAndDropState()}focus(){var e;(e=this.activeGroup)==null||e.focus()}getGroupPanel(e){return this.panels.find(t=>t.id===e)}setActivePanel(e){e.group.model.openPanel(e),this.doSetGroupAndPanelActive(e.group)}moveToNext(e={}){if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[e.group.panels.length-1]){e.group.model.moveToNext({suppressRoll:!0});return}let t=tV(e.group.element),n=this.gridview.next(t)?.view;this.doSetGroupAndPanelActive(n)}moveToPrevious(e={}){if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[0]){e.group.model.moveToPrevious({suppressRoll:!0});return}let t=tV(e.group.element),n=this.gridview.previous(t)?.view;n&&this.doSetGroupAndPanelActive(n)}toJSON(){let e=this.gridview.serialize(),t=this.panels.reduce((e,t)=>(e[t.id]=t.toJSON(),e),{}),n=this._floatingGroupService?.serialize()??[],r=this._popoutWindowService?.serialize()??[],i={grid:e,panels:t,activeGroup:this.activeGroup?.id};n.length>0&&(i.floatingGroups=n),r.length>0&&(i.popoutGroups=r);let a=this._edgeGroupService?.entries()??[];if(this._edgeGroupService?.hasAny()){let e=this._shellManager.toJSON();for(let[t,n]of a){let r=e[t];r&&(r.group=n.toJSON())}i.edgeGroups=e}return i}fromJSON(e,t){this.mutation(`load`,()=>this._doFromJSON(e,t))}_doFromJSON(e,t){var n,r,i,a,o;(n=this._popoutWindowService)==null||n.cancelPendingRestorations();let s=new Map,c;if(t?.reuseExistingPanels){c=this.createGroup(),this._groups.delete(c.api.id);let t=Object.keys(e.panels);for(let e of this.panels)t.includes(e.api.id)&&s.set(e.api.id,e);this.movingLock(()=>{Array.from(s.values()).forEach(e=>{this.moveGroupOrPanel({from:{groupId:e.api.group.api.id,panelId:e.api.id},to:{group:c,position:`center`},keepEmptyGroups:!0})})})}if(this.clear(),typeof e!=`object`||!e)throw Error(`dockview: serialized layout must be a non-null object`);let{grid:l,panels:u,activeGroup:d}=e;if(l.root.type!==`branch`||!Array.isArray(l.root.data))throw Error(`dockview: root must be of type branch`);try{let t=this.width,n=this.height,o=e=>{let{id:t,locked:n,hideHeader:r,headerPosition:i,views:a,activeView:o}=e;if(typeof t!=`string`)throw Error(`dockview: group id must be of type string`);let l=this.createGroup({id:t,locked:!!n,hideHeader:!!r,headerPosition:i});this._onDidAddGroup.fire(l);let d=[];for(let e of a){let t=s.get(e);if(c&&t)this.movingLock(()=>{c.model.removePanel(t)}),d.push(t),t.updateFromStateModel(u[e]);else{let t=this._deserializer.fromJSON(u[e],l);d.push(t)}}for(let e=0;e<a.length;e++){let t=d[e],n=typeof o==`string`&&o===t.id;s.has(t.api.id)?this.movingLock(()=>{l.model.openPanel(t,{skipSetActive:!n,skipSetGroupActive:!0})}):l.model.openPanel(t,{skipSetActive:!n,skipSetGroupActive:!0})}return e.tabGroups&&e.tabGroups.length>0&&l.model.restoreTabGroups(e.tabGroups),!l.activePanel&&l.panels.length>0&&l.model.openPanel(l.panels[l.panels.length-1],{skipSetGroupActive:!0}),l};this.gridview.deserialize(l,{fromJSON:e=>o(e.data)}),this._layoutFromShell(t,n),e.edgeGroups&&this.deserializeEdgeGroups(e.edgeGroups,u),this.deserializeFloatingWindows(e.floatingGroups??[],o);let f=this.deserializePopoutWindows(e.popoutGroups??[],o);if((r=this._popoutWindowService)==null||r.finishRestoration(f),(i=this._floatingGroupService)==null||i.constrainBounds(),typeof d==`string`){let e=this.getPanel(d);e&&this.doSetGroupAndPanelActive(e)}(a=this._watermarkService)==null||a.update()}catch(e){console.error(`dockview: failed to deserialize layout. Reverting changes`,e);for(let e of this.groups)for(let t of e.panels)this.removePanel(t,{removeEmptyGroup:!1,skipDispose:!1});for(let e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);throw(o=this._floatingGroupService)==null||o.disposeAll(),this.clear(),e}this.debouncedUpdateAllPositions(),this._onDidLayoutFromJSON.fire()}deserializeNestedGridview(e,t){let n=this.createNestedGridview(e.orientation),r=[];return n.deserialize(e,{fromJSON:e=>{let n=t(e.data);return r.push(n),n}}),{gridview:n,members:r}}deserializeEdgeGroups(e,t){let n=cH(this._edgeGroupService,`EdgeGroup`,`fromJSON edge restoration`);if(n){for(let t of[`top`,`bottom`,`left`,`right`]){let r=e[t];if(r&&!n.has(t)){let e=r.group?.id??`${t}-group`;this.addEdgeGroup(t,{id:e})}}for(let[r,i]of n.entries()){let n=e[r]?.group;if(n){let{views:e,activeView:r}=n,a=[];for(let n of e)if(t[n]){let e=this._deserializer.fromJSON(t[n],i);a.push(e)}for(let e=0;e<a.length;e++){let t=a[e],n=r===t.id;i.model.openPanel(t,{skipSetActive:!n,skipSetGroupActive:!0})}n.tabGroups&&n.tabGroups.length>0&&i.model.restoreTabGroups(n.tabGroups),!i.activePanel&&i.panels.length>0&&i.model.openPanel(i.panels[i.panels.length-1],{skipSetGroupActive:!0})}}this._shellManager.fromJSON(e)}}deserializeFloatingWindows(e,t){for(let n of e){let{data:e,grid:r,position:i}=n;if(r){let{gridview:e,members:n}=this.deserializeNestedGridview(r,t);if(n.length===0)continue;this.mountFloatingWindow(e,n[0],n,i,{inDragMode:!1})}else if(e){let n=t(e);this.addFloatingGroup(n,{position:i,width:i.width,height:i.height,skipRemoveGroup:!0,inDragMode:!1})}}}deserializePopoutWindows(e,t){let n=e.length>0?cH(this._popoutWindowService,`PopoutWindow`,`fromJSON popout restoration`):this._popoutWindowService;return n?e.flatMap((e,r)=>{let{data:i,grid:a,position:o,gridReferenceGroup:s,url:c}=e,l,u=[];if(a){let e=this.deserializeNestedGridview(a,t);if(l=e.gridview,u=e.members,u.length===0)return l.dispose(),[]}let d=a?u[0]:t(i);return n.scheduleRestoration(r*eKe,()=>{this.addPopoutGroup(d,{position:o??void 0,overridePopoutGroup:s?d:void 0,overridePopoutGridview:l,referenceGroup:s?this.getPanel(s):void 0,popoutUrl:c})},()=>{for(let e of u.length>0?u:[d])if(!this.isDisposed&&this._groups.has(e.id)&&e.element.parentElement===null){for(let t of[...e.panels])this.removePanel(t,{removeEmptyGroup:!1});e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}})}):[]}clear(){this.mutation(`clear`,()=>this._doClear())}_doClear(){let e=Array.from(this._groups.values()).map(e=>e.value),t=!!this.activeGroup;for(let t of e){if(this._edgeGroupService?.includes(t)){let e=[...t.panels];for(let t of e)this.removePanel(t,{removeEmptyGroup:!1});continue}this.removeGroup(t,{skipActive:!0})}t&&this.doSetGroupAndPanelActive(void 0),this.gridview.clear()}closeAllGroups(){this.mutation(`remove`,()=>{for(let e of this._groups.entries()){let[t,n]=e;n.value.model.closeAllPanels()}})}addPanel(e){return this.mutation(`add`,()=>this._doAddPanel(e))}_doAddPanel(e){if(this.panels.find(t=>t.id===e.id))throw Error(`dockview: panel with id ${e.id} already exists`);let t;if(e.position&&e.floating)throw Error(`dockview: you can only provide one of: position, floating as arguments to .addPanel(...)`);let n={width:e.initialWidth,height:e.initialHeight},r;if(e.position)if(FGe(e.position)){let n=typeof e.position.referencePanel==`string`?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(r=e.position.index,!n)throw Error(`dockview: referencePanel '${e.position.referencePanel}' does not exist`);t=this.findGroup(n)}else if(IGe(e.position)){if(t=typeof e.position.referenceGroup==`string`?this._groups.get(e.position.referenceGroup)?.value:e.position.referenceGroup,r=e.position.index,!t)throw Error(`dockview: referenceGroup '${e.position.referenceGroup}' does not exist`)}else{let t=this.orthogonalize(bV(e.position.direction)),i=this.createPanel(e,t);return t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(t),t.api.setSize({height:n?.height,width:n?.width}),i}else t=this.activeGroup;let i;if(t){let a=cV(e.position?.direction||`within`);if(e.floating){let t=this.createGroup();this._onDidAddGroup.fire(t);let n=typeof e.floating==`object`&&e.floating!==null?e.floating:{};this.addFloatingGroup(t,Object.assign(Object.assign({},n),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),i=this.createPanel(e,t),t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r})}else if(t.api.location.type===`floating`||t.api.location.type===`edge`||a===`center`)i=this.createPanel(e,t),t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),t.api.setSize({width:n?.width,height:n?.height}),e.inactive||this.doSetGroupAndPanelActive(t);else{let o=tV(t.element),s=nV(this.gridview.orientation,o,a),c=this.createGroupAtLocation(s,this.orientationAtLocation(s)===UB.VERTICAL?n?.height:n?.width);i=this.createPanel(e,c),c.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(c)}}else if(e.floating){let t=this.createGroup();this._onDidAddGroup.fire(t);let n=typeof e.floating==`object`&&e.floating!==null?e.floating:{};this.addFloatingGroup(t,Object.assign(Object.assign({},n),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),i=this.createPanel(e,t),t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r})}else{let t=this.createGroupAtLocation([0],this.gridview.orientation===UB.VERTICAL?n?.height:n?.width);i=this.createPanel(e,t),t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(t)}return i}removePanel(e,t={removeEmptyGroup:!0}){this.mutation(`remove`,()=>this._doRemovePanel(e,t))}_doRemovePanel(e,t={removeEmptyGroup:!0}){let n=e.group;if(!n)throw Error(`dockview: cannot remove panel ${e.id}. it's missing a group.`);n.model.removePanel(e,{skipSetActiveGroup:t.skipSetActiveGroup}),t.skipDispose||(e.group.model.renderContainer.detatch(e),e.dispose()),n.size===0&&t.removeEmptyGroup&&this.removeGroup(n,{skipActive:t.skipSetActiveGroup})}createWatermarkComponent(){return this.options.createWatermarkComponent?this.options.createWatermarkComponent():new qGe}addGroup(e){return this.mutation(`add`,()=>this._doAddGroup(e))}_doAddGroup(e){if(e){let t;if(LGe(e)){let n=typeof e.referencePanel==`string`?this.panels.find(t=>t.id===e.referencePanel):e.referencePanel;if(!n)throw Error(`dockview: reference panel ${e.referencePanel} does not exist`);if(t=this.findGroup(n),!t)throw Error(`dockview: reference group for reference panel ${e.referencePanel} does not exist`)}else if(RGe(e)){if(t=typeof e.referenceGroup==`string`?this._groups.get(e.referenceGroup)?.value:e.referenceGroup,!t)throw Error(`dockview: reference group ${e.referenceGroup} does not exist`)}else{let t=this.orthogonalize(bV(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(t),t}let n=cV(e.direction||`within`),r=tV(t.element),i=nV(this.gridview.orientation,r,n),a=this.createGroup(e),o=this.getLocationOrientation(i)===UB.VERTICAL?e.initialHeight:e.initialWidth;return this.doAddGroup(a,i,o),e.skipSetActive||this.doSetGroupAndPanelActive(a),a}else{let t=this.createGroup(e);return this.doAddGroup(t),this.doSetGroupAndPanelActive(t),t}}getLocationOrientation(e){return e.length%2==0&&this.gridview.orientation===UB.HORIZONTAL?UB.HORIZONTAL:UB.VERTICAL}removeGroup(e,t){this.mutation(`remove`,()=>this.doRemoveGroup(e,t))}detachFromNestedWindow(e){let t=this._floatingGroupService?.findByGroup(e);if(t){let n=this.nestedWindowMembers(e);return n.length<=1?!1:(t.gridview.remove(e),t.group===e&&t.setAnchorGroup(n.find(t=>t!==e)),!0)}let n=this._popoutWindowService?.findByGroup(e);if(n){let t=this.nestedWindowMembers(e);return t.length<=1?!1:(n.gridview.remove(e),n.popoutGroup===e&&(n.popoutGroup=t.find(t=>t!==e)),!0)}return!1}disposeGroupRecord(e){e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}activateFallbackGroupIfRemoved(e,t){if(!t&&this._activeGroup===e){let e=Array.from(this._groups.values());this.doSetGroupAndPanelActive(e.length>0?e[0].value:void 0)}}doRemoveGroup(e,t){var n;if(this._edgeGroupService?.includes(e))return e;let r=[...e.panels];if(!t?.skipDispose)for(let e of r)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:t?.skipDispose??!1});let i=this.activePanel;if(e.api.location.type===`floating`){let n=this._floatingGroupService?.findByGroup(e);if(!n)throw Error(`dockview: failed to find floating group`);return this.detachFromNestedWindow(e)?(t?.skipDispose?e.model.location={type:`grid`}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e):(t?.skipDispose||this.disposeGroupRecord(e),n.dispose(),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e)}if(e.api.location.type===`popout`){let r=this._popoutWindowService?.findByGroup(e);if(!r)throw Error(`dockview: failed to find popout group`);if(this.detachFromNestedWindow(e))return t?.skipDispose?e.model.location={type:`grid`}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e;if(!t?.skipDispose){if(!t?.skipPopoutAssociated){let e=r.referenceGroup?this.getPanel(r.referenceGroup):void 0;e&&e.panels.length===0&&this.removeGroup(e)}r.popoutGroup.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}(n=this._popoutWindowService)==null||n.remove(r);let i=r.disposable.dispose();return!t?.skipPopoutReturn&&i&&(this.doAddGroup(i,[0]),this.doSetGroupAndPanelActive(i)),this.activateFallbackGroupIfRemoved(e,t?.skipActive),r.popoutGroup}if(!this.gridview.element.contains(e.element))return t?.skipDispose||(this._groups.get(e.id)?.disposable.dispose(),this.disposeGroupRecord(e)),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e;let a=super.doRemoveGroup(e,t);return t?.skipActive||this.activePanel!==i&&this.fireActivePanelChange(this.activePanel),a}debouncedUpdateAllPositions(){this._updatePositionsFrameId!==void 0&&cancelAnimationFrame(this._updatePositionsFrameId),this._updatePositionsFrameId=requestAnimationFrame(()=>{this._updatePositionsFrameId=void 0,this.overlayRenderContainer.updateAllPositions();for(let e of this._popoutWindowService?.entries??[])e.overlayRenderContainer.updateAllPositions()})}movingLock(e){let t=this._moving;try{return this._moving=!0,e()}finally{this._moving=t}}mutation(e,t){let n=this._mutationDepth===0,r=this._origin;n&&this._onWillMutateLayout.fire({kind:e,origin:r}),this._mutationDepth++;try{return t()}finally{this._mutationDepth--,n&&this._onDidMutateLayout.fire({kind:e,origin:r})}}currentOrigin(){return this._origin}withOrigin(e,t){if(this._originDepth>0||this._mutationDepth>0)return t();let n=this._origin;this._origin=e,this._originDepth++;try{return t()}finally{this._originDepth--,this._origin=n}}fireActivePanelChange(e){this._onDidActivePanelChange.fire({panel:e,origin:this._origin})}moveGroupOrPanel(e){this.mutation(`move`,()=>this._doMoveGroupOrPanel(e))}_doMoveGroupOrPanel(e){let t=e.to.group,n=e.from.groupId,r=e.from.panelId,i=e.to.position,a=e.to.index,o=n?this._groups.get(n)?.value:void 0;if(!o)throw Error(`dockview: Failed to find group id ${n}`);if(r===void 0){e.from.tabGroupId?this.moveTabGroupToGroup({sourceGroup:o,tabGroupId:e.from.tabGroupId,destinationGroup:t,destinationTarget:i,destinationIndex:a,skipSetActive:e.skipSetActive,keepEmptyGroups:e.keepEmptyGroups}):this.moveGroup({from:{group:o},to:{group:t,position:i},skipSetActive:e.skipSetActive});return}if(!i||i===`center`){let n=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!n)throw Error(`dockview: No panel with id ${r}`);!e.keepEmptyGroups&&o.model.size===0&&this.doRemoveGroup(o,{skipActive:!0});let i=t.model.size===0;this.movingLock(()=>t.model.openPanel(n,{index:a,skipSetActive:(e.skipSetActive??!1)&&!i,skipSetGroupActive:!0})),e.skipSetActive||this.doSetGroupAndPanelActive(t),this._onDidMovePanel.fire({panel:n,from:o})}else{let e=this.getGridviewForGroup(t),n=tV(t.element),a=nV(e.orientation,n,i);if(o.size<2){let[n,s]=FB(a);if(o.api.location.type===`grid`&&e===this.gridview){let[e,t]=FB(tV(o.element));if(IB(e,n)){this.gridview.moveView(e,t,s),this._onDidMovePanel.fire({panel:this.getGroupPanel(r),from:o});return}}if(o.api.location.type===`popout`&&this.nestedWindowMembers(o).length<=1){let n=this._popoutWindowService?.findByGroup(o);if(!n)return;let a=this.movingLock(()=>n.popoutGroup.model.removePanel(n.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(o,{skipActive:!0});let s=nV(e.orientation,tV(t.element),i),c=this.createGroupAtLocation(s,void 0,void 0,e);this.movingLock(()=>c.model.openPanel(a,{skipSetActive:!0})),this.doSetGroupAndPanelActive(c),this._onDidMovePanel.fire({panel:this.getGroupPanel(r),from:o});return}if(o.api.location.type===`edge`){let t=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!t)throw Error(`dockview: No panel with id ${r}`);let n=this.createGroupAtLocation(a,void 0,void 0,e);this.movingLock(()=>n.model.openPanel(t,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(n),this._onDidMovePanel.fire({panel:t,from:o});return}let c=this.movingLock(()=>this.doRemoveGroup(o,{skipActive:!0,skipDispose:!0})),l=tV(t.element),u=nV(e.orientation,l,i);this.movingLock(()=>this.doAddGroup(c,u,void 0,e)),this.setGroupLocationForRoot(c,e),this.doSetGroupAndPanelActive(c),this._onDidMovePanel.fire({panel:this.getGroupPanel(r),from:o})}else{let t=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!t)throw Error(`dockview: No panel with id ${r}`);let a=nV(e.orientation,n,i),s=this.createGroupAtLocation(a,void 0,void 0,e);this.movingLock(()=>s.model.openPanel(t,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(s),this._onDidMovePanel.fire({panel:t,from:o})}}}moveTabGroupToGroup(e){let{sourceGroup:t,tabGroupId:n,destinationGroup:r,destinationTarget:i,destinationIndex:a}=e,o=t.model.getTabGroups().find(e=>e.id===n);if(!o||o.panelIds.length===0)return;let s=o.label,c=o.color,l=o.collapsed,u=o.componentParams,d=[...o.panelIds],f=i&&i!==`center`?tV(r.element):void 0,p=this.movingLock(()=>d.map(e=>t.model.removePanel(e,{skipSetActive:!1,skipSetActiveGroup:!0})).filter(e=>e!==void 0));if(p.length===0)return;let m=n=>{this.movingLock(()=>{for(let e of p)n.model.openPanel(e,{index:a,skipSetActive:!0,skipSetGroupActive:!0})});let r=n.model.createTabGroup({label:s,color:c,collapsed:l,componentParams:u});for(let e of p)n.model.addPanelToTabGroup(r.id,e.id);e.skipSetActive||this.doSetGroupAndPanelActive(n);for(let e of p)this._onDidMovePanel.fire({panel:e,from:t})},h;if(!i||i===`center`||!f)h=r;else{let e=nV(this.gridview.orientation,f,i);h=this.createGroupAtLocation(e)}!e.keepEmptyGroups&&t.model.size===0&&t!==h&&this.doRemoveGroup(t,{skipActive:!0}),m(h)}moveGroup(e){this.mutation(`move`,()=>this._doMoveGroup(e))}maximizeGroup(e){this.mutation(`maximize`,()=>super.maximizeGroup(e))}exitMaximizedGroup(){this.mutation(`maximize`,()=>super.exitMaximizedGroup())}_doMoveGroup(e){var t;let n=e.from.group,r=e.to.group,i=e.to.position,a=n;if(i===`center`){let t=n.activePanel,i=n.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),a=this.movingLock(()=>[...n.panels].map(e=>n.model.removePanel(e.id,{skipSetActive:!0})));n?.model.size===0&&this.doRemoveGroup(n,{skipActive:!0}),this.movingLock(()=>{for(let e of a)r.model.openPanel(e,{skipSetActive:e!==t,skipSetGroupActive:!0})});for(let e of i){let t=r.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(let n of e.panelIds)r.model.addPanelToTabGroup(t.id,n)}e.skipSetActive===!0&&this.activePanel||this.doSetGroupAndPanelActive(r)}else{if(n.api.location.type===`edge`){let e=n.activePanel,t=n.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),r=this.movingLock(()=>[...n.panels].map(e=>n.model.removePanel(e.id,{skipSetActive:!0})));a=this.createGroup(),this._onDidAddGroup.fire(a),this.movingLock(()=>{for(let t of r)a.model.openPanel(t,{skipSetActive:t!==e,skipSetGroupActive:!0})});for(let e of t){let t=a.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(let n of e.panelIds)a.model.addPanelToTabGroup(t.id,n)}}else switch(n.api.location.type){case`grid`:this.gridview.removeView(tV(n.element));break;case`floating`:{let e=this._floatingGroupService?.findByGroup(n);if(!e)throw Error(`dockview: failed to find floating group`);this.detachFromNestedWindow(n)||e.dispose();break}case`popout`:{let e=this._popoutWindowService?.findByGroup(n);if(!e)throw Error(`dockview: failed to find popout group`);if(this.detachFromNestedWindow(n))break;if((t=this._popoutWindowService)==null||t.remove(e),e.referenceGroup){let t=this.getPanel(e.referenceGroup);t&&!t.api.isVisible&&this.doRemoveGroup(t,{skipActive:!0})}e.window.dispose();break}}if(r.api.location.type===`grid`||r.api.location.type===`floating`||r.api.location.type===`popout`){let e=this.getGridviewForGroup(r),t=tV(r.element),o=nV(e.orientation,t,i),s;switch(e.orientation){case UB.VERTICAL:s=t.length%2==0?n.api.width:n.api.height;break;case UB.HORIZONTAL:s=t.length%2==0?n.api.height:n.api.width;break}e.addView(a,s,o),this.setGroupLocationForRoot(a,e)}}if(a.panels.forEach(e=>{this._onDidMovePanel.fire({panel:e,from:n})}),this.debouncedUpdateAllPositions(),e.skipSetActive===!1){let e=r??n;this.doSetGroupAndPanelActive(e)}else a!==n&&e.skipSetActive!==!0&&this.doSetGroupAndPanelActive(a)}doSetGroupActive(e){super.doSetGroupActive(e);let t=this.activePanel;!this._moving&&t!==this._onDidActivePanelChange.value?.panel&&this.fireActivePanelChange(t)}doSetGroupAndPanelActive(e){super.doSetGroupActive(e);let t=this.activePanel;e&&this.hasMaximizedGroup()&&!this.isMaximizedGroup(e)&&this.exitMaximizedGroup(),!this._moving&&t!==this._onDidActivePanelChange.value?.panel&&this.fireActivePanelChange(t)}getNextGroupId(){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}createGroup(e){e||={};let t=e?.id;if(t&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${e?.id}. reassigning group id to avoid errors`),t=void 0),!t)for(t=this.nextGroupId.next();this._groups.has(t);)t=this.nextGroupId.next();let n=new eH(this,t,e);if(n.init({params:{},accessor:this}),!this._groups.has(n.id)){let e=new fB(n.model.onTabDragStart(e=>{var t;(t=this._advancedDnDService)==null||t.dispatchWillDragPanel(e)}),n.model.onGroupDragStart(e=>{var t;(t=this._advancedDnDService)==null||t.dispatchWillDragGroup(e)}),n.model.onMove(e=>{let{groupId:t,itemId:r,target:i,index:a,tabGroupId:o}=e;this.moveGroupOrPanel({from:{groupId:t,panelId:r,tabGroupId:o},to:{group:n,position:i,index:a}})}),n.model.onDidDrop(e=>{this._onDidDrop.fire(e)}),n.model.onWillDrop(e=>{var t;(t=this._advancedDnDService)==null||t.dispatchWillDrop(e)}),n.model.onWillShowOverlay(e=>{var t;if(this.options.disableDnd){e.preventDefault();return}(t=this._advancedDnDService)==null||t.dispatchWillShowOverlay(e)}),n.model.onUnhandledDragOver(e=>{this._onUnhandledDragOver.fire(e)}),n.model.onDidAddPanel(e=>{this._moving||this._onDidAddPanel.fire(e.panel)}),n.model.onDidRemovePanel(e=>{this._moving||this._onDidRemovePanel.fire(e.panel)}),n.model.onDidActivePanelChange(e=>{this._moving||e.panel===this.activePanel&&this._onDidActivePanelChange.value?.panel!==e.panel&&this.fireActivePanelChange(e.panel)}),mB.any(n.model.onDidPanelTitleChange,n.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(n.id,{value:n,disposable:e})}return n.initialize(),n}createPanel(e,t){let n=e.component,r=e.tabComponent??this.options.defaultTabComponent,i=new rH(this,e.id,n,r),a=new tH(e.id,n,r,this,this._api,t,i,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return a.init({title:e.title??e.id,params:e?.params??{}}),a}createGroupAtLocation(e,t,n,r=this.gridview){let i=this.createGroup(n);return this.doAddGroup(i,e,t,r),this.setGroupLocationForRoot(i,r),i}setGroupLocationForRoot(e,t){let n=this._popoutWindowService?.entries.find(e=>e.gridview===t);if(n){e.model.renderContainer!==n.overlayRenderContainer&&(e.model.renderContainer=n.overlayRenderContainer),e.model.dropTargetContainer=n.dropTargetContainer,e.model.location={type:`popout`,getWindow:n.getWindow,popoutUrl:n.popoutUrl};return}e.model.renderContainer!==this.overlayRenderContainer&&(e.model.renderContainer=this.overlayRenderContainer),e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location=t===this.gridview?{type:`grid`}:{type:`floating`}}getGridviewForGroup(e){let t=this._floatingGroupService?.findByGroup(e);if(t)return t.gridview;let n=this._popoutWindowService?.findByGroup(e);return n?n.gridview:this.gridview}nestedWindowMembers(e){let t=this.getGridviewForGroup(e);return t===this.gridview?[]:this.groups.filter(e=>t.element.contains(e.element))}findGroup(e){return Array.from(this._groups.values()).find(t=>t.value.model.containsPanel(e))?.value}orientationAtLocation(e){let t=this.gridview.orientation;return e.length%2==1?t:rV(t)}updateTheme(){var e,t,n,r;let i=this._options.theme??WGe;(e=this._shellThemeClassnames)==null||e.setClassNames(i.className);let a=i.gap??0;this.gridview.margin=a;for(let e of this.floatingGroups)e.gridview.margin=a;for(let e of this._popoutWindowService?.entries??[])e.gridview.margin=a;switch((t=this._shellManager)==null||t.updateTheme(a,i.edgeGroupCollapsedSize??35),i.dndOverlayBorder===void 0?(this.element.style.removeProperty(`--dv-drag-over-border`),(r=this._shellManager)==null||r.element.style.removeProperty(`--dv-drag-over-border`)):(this.element.style.setProperty(`--dv-drag-over-border`,i.dndOverlayBorder),(n=this._shellManager)==null||n.element.style.setProperty(`--dv-drag-over-border`,i.dndOverlayBorder)),i.dndOverlayMounting){case`absolute`:this.rootDropTargetContainer.disabled=!1;break;default:this.rootDropTargetContainer.disabled=!0;break}let o=(i.tabGroupIndicator??`wrap`)===`none`;CB(this.element,`dv-tab-group-indicator-none`,o),this._shellManager&&CB(this._shellManager.element,`dv-tab-group-indicator-none`,o);for(let e of this.groups)e.model.updateTabGroups()}},PKe=class extends lV{get orientation(){return this.gridview.orientation}set orientation(e){this.gridview.orientation=e}get options(){return this._options}get deserializer(){return this._deserializer}set deserializer(e){this._deserializer=e}constructor(e,t){super(e,{proportionalLayout:t.proportionalLayout??!0,orientation:t.orientation,styles:t.hideBorders?{separatorBorder:`transparent`}:void 0,disableAutoResizing:t.disableAutoResizing,className:t.className}),this._onDidLayoutfromJSON=new Q,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new Q,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new Q,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new Q,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._options=t,this.addDisposables(this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this.onDidAdd(e=>{this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._onDidActiveGroupChange.fire(e)}))}updateOptions(e){super.updateOptions(e);let t=typeof e.orientation==`string`&&this.gridview.orientation!==e.orientation;this._options=Object.assign(Object.assign({},this.options),e),t&&(this.gridview.orientation=e.orientation),this.layout(this.gridview.width,this.gridview.height,!0)}removePanel(e){this.removeGroup(e)}toJSON(){return{grid:this.gridview.serialize(),activePanel:this.activeGroup?.id}}setVisible(e,t){this.gridview.setViewVisible(tV(e.element),t)}setActive(e){this._groups.forEach((t,n)=>{t.value.setActive(e===t.value)})}focus(){var e;(e=this.activeGroup)==null||e.focus()}fromJSON(e){this.clear();let{grid:t,activePanel:n}=e;try{let e=[],r=this.width,i=this.height;if(this.gridview.deserialize(t,{fromJSON:t=>{let{data:n}=t,r=this.options.createComponent({id:n.id,name:n.component});return e.push(()=>r.init({params:n.params,minimumWidth:n.minimumWidth,maximumWidth:n.maximumWidth,minimumHeight:n.minimumHeight,maximumHeight:n.maximumHeight,priority:n.priority,snap:!!n.snap,accessor:this,isVisible:t.visible})),this._onDidAddGroup.fire(r),this.registerPanel(r),r}}),this.layout(r,i,!0),e.forEach(e=>e()),typeof n==`string`){let e=this.getPanel(n);e&&this.doSetGroupActive(e)}}catch(e){for(let e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);throw this.clear(),e}this._onDidLayoutfromJSON.fire()}clear(){let e=this.activeGroup,t=Array.from(this._groups.values());for(let e of t)e.disposable.dispose(),this.doRemoveGroup(e.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){let n,r=this.gridview.remove(e),i=this._groups.get(t.reference)?.value;if(!i)throw Error(`reference group ${t.reference} does not exist`);let a=cV(t.direction);if(a===`center`)throw Error(`${a} not supported as an option`);{let e=tV(i.element);n=nV(this.gridview.orientation,e,a)}this.doAddGroup(r,n,t.size)}addPanel(e){let t=e.location??[0];if(e.position?.referencePanel){let n=this._groups.get(e.position.referencePanel)?.value;if(!n)throw Error(`reference group ${e.position.referencePanel} does not exist`);let r=cV(e.position.direction);if(r===`center`)throw Error(`${r} not supported as an option`);{let e=tV(n.element);t=nV(this.gridview.orientation,e,r)}}let n=this.options.createComponent({id:e.id,name:e.component});return n.init({params:e.params??{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.doAddGroup(n,t,e.size),this.registerPanel(n),this.doSetGroupActive(n),n}registerPanel(e){let t=new fB(e.api.onDidFocusChange(t=>{t.isFocused&&this._groups.forEach(t=>{let n=t.value;n===e?n.setActive(!0):n.setActive(!1)})}));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,n){let r=this.getPanel(t);if(!r)throw Error(`invalid operation`);let i=tV(e.element),[a,o]=FB(nV(this.gridview.orientation,i,n)),[s,c]=FB(tV(r.element));if(IB(s,a)){this.gridview.moveView(s,c,o);return}let l=this.doRemoveGroup(r,{skipActive:!0,skipDispose:!0}),u=tV(e.element),d=nV(this.gridview.orientation,u,n);this.doAddGroup(l,d)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}},FKe=class extends sV{get panels(){return this.splitview.getViews()}get options(){return this._options}get length(){return this._panels.size}get orientation(){return this.splitview.orientation}get splitview(){return this._splitview}set splitview(e){this._splitview&&this._splitview.dispose(),this._splitview=e,this._splitviewChangeDisposable.value=new fB(this._splitview.onDidSashEnd(()=>{this._onDidLayoutChange.fire(void 0)}),this._splitview.onDidAddView(e=>this._onDidAddView.fire(e)),this._splitview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===UB.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===UB.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._splitviewChangeDisposable=new pB,this._panels=new Map,this._onDidLayoutfromJSON=new Q,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new Q,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new Q,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new Q,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height=`100%`,this.element.style.width=`100%`,this._classNames=new jB(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this._options=t,this.splitview=new qB(this.element,t),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}updateOptions(e){`className`in e&&this._classNames.setClassNames(e.className??``),`disableResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),typeof e.orientation==`string`&&(this.splitview.orientation=e.orientation),this._options=Object.assign(Object.assign({},this.options),e),this.splitview.layout(this.splitview.size,this.splitview.orthogonalSize)}focus(){var e;(e=this._activePanel)==null||e.focus()}movePanel(e,t){this.splitview.moveView(e,t)}setVisible(e,t){let n=this.panels.indexOf(e);this.splitview.setViewVisible(n,t)}setActive(e,t){this._activePanel=e,this.panels.filter(t=>t!==e).forEach(e=>{e.api._onDidActiveChange.fire({isActive:!1}),t||e.focus()}),e.api._onDidActiveChange.fire({isActive:!0}),t||e.focus()}removePanel(e,t){let n=this._panels.get(e.id);if(!n)throw Error(`unknown splitview panel ${e.id}`);n.dispose(),this._panels.delete(e.id);let r=this.panels.findIndex(t=>t===e);this.splitview.removeView(r,t).dispose();let i=this.panels;i.length>0&&this.setActive(i[i.length-1])}getPanel(e){return this.panels.find(t=>t.id===e)}addPanel(e){if(this._panels.has(e.id))throw Error(`panel ${e.id} already exists`);let t=this.options.createComponent({id:e.id,name:e.component});t.orientation=this.splitview.orientation,t.init({params:e.params??{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});let n=typeof e.size==`number`?e.size:KB.Distribute,r=typeof e.index==`number`?e.index:void 0;return this.splitview.addView(t,n,r),this.doAddView(t),this.setActive(t),t}layout(e,t){let[n,r]=this.splitview.orientation===UB.HORIZONTAL?[e,t]:[t,e];this.splitview.layout(n,r)}doAddView(e){let t=e.api.onDidFocusChange(t=>{t.isFocused&&this.setActive(e,!0)});this._panels.set(e.id,t)}toJSON(){return{views:this.splitview.getViews().map((e,t)=>({size:this.splitview.getViewSize(t),data:e.toJSON(),snap:!!e.snap,priority:e.priority})),activeView:this._activePanel?.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();let{views:t,orientation:n,size:r,activeView:i}=e,a=[],o=this.width,s=this.height;if(this.splitview=new qB(this.element,{orientation:n,proportionalLayout:this.options.proportionalLayout,descriptor:{size:r,views:t.map(e=>{let t=e.data;if(this._panels.has(t.id))throw Error(`panel ${t.id} already exists`);let r=this.options.createComponent({id:t.id,name:t.component});return a.push(()=>{r.init({params:t.params??{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:e.snap,priority:e.priority,accessor:this})}),r.orientation=n,this.doAddView(r),setTimeout(()=>{this._onDidAddView.fire(r)},0),{size:e.size,view:r}})}}),this.layout(o,s),a.forEach(e=>e()),typeof i==`string`){let e=this.getPanel(i);e&&this.setActive(e)}this._onDidLayoutfromJSON.fire()}clear(){for(let e of this._panels.values())e.dispose();for(this._panels.clear();this.splitview.length>0;)this.splitview.removeView(0,KB.Distribute,!0).dispose()}dispose(){for(let e of this._panels.values())e.dispose();this._panels.clear();let e=this.splitview.getViews();this._splitviewChangeDisposable.dispose(),this.splitview.dispose();for(let t of e)t.dispose();this.element.remove(),super.dispose()}},wH=class extends fB{get element(){return this._element}constructor(){super(),this._expandedIcon=MGe(),this._collapsedIcon=KV(),this.disposable=new pB,this.apiRef={api:null},this._element=document.createElement(`div`),this.element.className=`dv-default-header`,this._content=document.createElement(`span`),this._expander=document.createElement(`div`),this._expander.className=`dv-pane-header-icon`,this.element.appendChild(this._expander),this.element.appendChild(this._content),this.addDisposables(vB(this._element,`click`,()=>{var e;(e=this.apiRef.api)==null||e.setExpanded(!this.apiRef.api.isExpanded)}))}init(e){this.apiRef.api=e.api,this._content.textContent=e.title,this.updateIcon(),this.disposable.value=e.api.onDidExpansionChange(()=>{this.updateIcon()})}updateIcon(){let e=!!this.apiRef.api?.isExpanded;CB(this._expander,`collapsed`,!e),e?(this._expander.contains(this._collapsedIcon)&&this._collapsedIcon.remove(),this._expander.contains(this._expandedIcon)||this._expander.appendChild(this._expandedIcon)):(this._expander.contains(this._expandedIcon)&&this._expandedIcon.remove(),this._expander.contains(this._collapsedIcon)||this._expander.appendChild(this._collapsedIcon))}update(e){}dispose(){this.disposable.dispose(),super.dispose()}},IKe=VB(),TH=22,EH=0,DH=2**53-1,OH=class extends mGe{constructor(e){super({accessor:e.accessor,id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,disableDnd:e.disableDnd,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}},LKe=class extends sV{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new fB(this._paneview.onDidChange(()=>{this._onDidLayoutChange.fire(void 0)}),this._paneview.onDidAddView(e=>this._onDidAddView.fire(e)),this._paneview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===UB.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===UB.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._id=IKe.next(),this._disposable=new pB,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new Q,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new Q,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new Q,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new Q,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new Q,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOver=new Q,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.element.style.height=`100%`,this.element.style.width=`100%`,this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView,this._onUnhandledDragOver),this._classNames=new jB(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this._options=t,this.paneview=new YB(this.element,{orientation:UB.VERTICAL}),this.addDisposables(this._disposable)}setVisible(e,t){let n=this.panels.indexOf(e);this.paneview.setViewVisible(n,t)}focus(){}updateOptions(e){`className`in e&&this._classNames.setClassNames(e.className??``),`disableResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),this._options=Object.assign(Object.assign({},this.options),e)}addPanel(e){let t=this.options.createComponent({id:e.id,name:e.component}),n;e.headerComponent&&this.options.createHeaderComponent&&(n=this.options.createHeaderComponent({id:e.id,name:e.headerComponent})),n||=new wH;let r=new OH({id:e.id,component:e.component,headerComponent:e.headerComponent,header:n,body:t,orientation:UB.VERTICAL,isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:e.headerSize??TH,minimumBodySize:EH,maximumBodySize:DH});this.doAddPanel(r);let i=typeof e.size==`number`?e.size:KB.Distribute,a=typeof e.index==`number`?e.index:void 0;return r.init({params:e.params??{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new dV(this),accessor:this}),this.paneview.addPane(r,i,a),r.orientation=this.paneview.orientation,r}removePanel(e){let t=this.panels.findIndex(t=>t===e);this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find(t=>t.id===e)}layout(e,t){let[n,r]=this.paneview.orientation===UB.HORIZONTAL?[e,t]:[t,e];this.paneview.layout(n,r)}toJSON(){let e=e=>e===2**53-1||e===1/0?void 0:e,t=e=>e<=0?void 0:e;return{views:this.paneview.getPanes().map((n,r)=>({size:this.paneview.getViewSize(r),data:n.toJSON(),minimumSize:t(n.minimumBodySize),maximumSize:e(n.maximumBodySize),headerSize:n.headerSize,expanded:n.isExpanded()})),size:this.paneview.size}}fromJSON(e){this.clear();let{views:t,size:n}=e,r=[],i=this.width,a=this.height;this.paneview=new YB(this.element,{orientation:UB.VERTICAL,descriptor:{size:n,views:t.map(e=>{let t=e.data,n=this.options.createComponent({id:t.id,name:t.component}),i;t.headerComponent&&this.options.createHeaderComponent&&(i=this.options.createHeaderComponent({id:t.id,name:t.headerComponent})),i||=new wH;let a=new OH({id:t.id,component:t.component,headerComponent:t.headerComponent,header:i,body:n,orientation:UB.VERTICAL,isExpanded:!!e.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:e.headerSize??TH,minimumBodySize:e.minimumSize??EH,maximumBodySize:e.maximumSize??DH});return this.doAddPanel(a),r.push(()=>{a.init({params:t.params??{},minimumBodySize:e.minimumSize,maximumBodySize:e.maximumSize,title:t.title,isExpanded:!!e.expanded,containerApi:new dV(this),accessor:this}),a.orientation=this.paneview.orientation}),setTimeout(()=>{this._onDidAddView.fire(a)},0),{size:e.size,view:a}})}}),this.layout(i,a),r.forEach(e=>e()),this._onDidLayoutfromJSON.fire()}clear(){for(let[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.paneview.dispose()}doAddPanel(e){let t=new fB(e.onDidDrop(e=>{this._onDidDrop.fire(e)}),e.onUnhandledDragOver(e=>{this._onUnhandledDragOver.fire(e)}));this._viewDisposables.set(e.id,t)}doRemovePanel(e){let t=this._viewDisposables.get(e.id);t&&(t.dispose(),this._viewDisposables.delete(e.id))}dispose(){super.dispose();for(let[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.element.remove(),this.paneview.dispose()}},RKe=class extends jV{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){let e=typeof this._minimumSize==`function`?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){let e=typeof this._maximumSize==`function`?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}constructor(e,t){super(e,t,new AV(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=1/0,this._minimumSize=0,this._maximumSize=1/0,this._snap=!1,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onActiveChange(()=>{let{accessor:e}=this._params;e.setActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{(typeof e.minimumSize==`number`||typeof e.minimumSize==`function`)&&(this._minimumSize=e.minimumSize),(typeof e.maximumSize==`number`||typeof e.maximumSize==`function`)&&(this._maximumSize=e.maximumSize),this.updateConstraints()}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(e,t){let[n,r]=this.orientation===UB.HORIZONTAL?[e,t]:[t,e];super.layout(n,r)}init(e){super.init(e),this._priority=e.priority,e.minimumSize&&(this._minimumSize=e.minimumSize),e.maximumSize&&(this._maximumSize=e.maximumSize),e.snap&&(this._snap=e.snap)}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{minimumSize:(e=>e<=0?void 0:e)(this.minimumSize),maximumSize:(e=>e===2**53-1||e===1/0?void 0:e)(this.maximumSize)})}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}};function zKe(e,t){return new NKe(e,t).api}function BKe(e,t){return new uV(new FKe(e,t))}function VKe(e,t){return new fV(new PKe(e,t))}function HKe(e,t){return new dV(new LKe(e,t))}var UKe=class{constructor(e){this._host=e}attachToGroup(e){return new fB(e.model.onDidCreateTabGroup(e=>{this._host.fireDidCreateTabGroup(e)}),e.model.onDidDestroyTabGroup(e=>{this._host.fireDidDestroyTabGroup(e)}),e.model.onDidAddPanelToTabGroup(e=>{this._host.fireDidAddPanelToTabGroup(e)}),e.model.onDidRemovePanelFromTabGroup(e=>{this._host.fireDidRemovePanelFromTabGroup(e)}),e.model.onDidTabGroupChange(e=>{this._host.fireDidTabGroupChange(e)}),e.model.onDidTabGroupCollapsedChange(e=>{this._host.fireDidTabGroupCollapsedChange(e)}))}dispose(){}},WKe=oH({name:`TabGroupChips`,serviceKey:`tabGroupChipsService`,create:e=>new UKe(e),init:(e,t)=>{let n=new Map;return new fB(e.onDidAddGroup(e=>{n.set(e,t.attachToGroup(e))}),e.onDidRemoveGroup(e=>{var t;(t=n.get(e))==null||t.dispose(),n.delete(e)}),{dispose:()=>{for(let e of n.values())e.dispose();n.clear()}})}});function kH(e){if(!(e instanceof HTMLElement))return;let t=PB(e);return t?.style.zIndex?`calc(${t.style.zIndex} * 2)`:void 0}var GKe=0,KKe=()=>`dv-ctx-menu-item-${GKe++}`;function AH(e){return typeof e==`object`}function jH(e,t,n,r){let i=document.createElement(`div`);return i.className=`dv-context-menu-item`,i.setAttribute(`role`,`menuitem`),r&&(i.classList.add(`dv-context-menu-item--disabled`),i.setAttribute(`aria-disabled`,`true`)),i.textContent=e,r||i.addEventListener(`click`,()=>{n(),t()}),i}function MH(){let e=document.createElement(`div`);return e.className=`dv-context-menu-separator`,e.setAttribute(`role`,`separator`),e}function qKe(){if(typeof window>`u`||!window.matchMedia)return!1;let e=window.matchMedia(`(pointer: coarse)`).matches,t=window.matchMedia(`(pointer: fine)`).matches;return e&&!t}function JKe(e){let t=document.createElement(`div`);t.className=`dv-context-menu-rename`;let n=document.createElement(`input`);return n.className=`dv-context-menu-rename-input`,n.type=`text`,n.placeholder=`Name This Group`,n.value=e.label,n.addEventListener(`input`,()=>{e.setLabel(n.value)}),n.addEventListener(`keydown`,e=>{e.key!==`Escape`&&e.key!==`Enter`&&e.stopPropagation()}),n.addEventListener(`click`,e=>{e.stopPropagation()}),t.appendChild(n),qKe()||requestAnimationFrame(()=>{n.focus(),n.select()}),t}function YKe(e,t){let n=document.createElement(`div`);if(n.className=`dv-context-menu-color-picker`,!t.enabled)return n;for(let r of t.entries()){let t=document.createElement(`div`);t.className=`dv-context-menu-color-swatch`,t.style.setProperty(`--dv-tab-group-color`,r.value),r.label&&(t.title=r.label),e.color===r.id&&t.classList.add(`dv-context-menu-color-swatch--selected`),t.addEventListener(`click`,()=>{e.setColor(r.id)}),n.appendChild(t)}return n}var XKe=class{constructor(e){this.accessor=e}show(e,t,n){var r;if(!this.accessor.options.getTabContextMenuItems)return;let i=this.accessor.options.getTabContextMenuItems({panel:e,group:t,api:this.accessor.api,event:n});if(i.length===0)return;n.preventDefault();let a=this.accessor.getPopupServiceForGroup(t),o=()=>a.close(),s=document.createElement(`div`);s.className=`dv-context-menu`,s.setAttribute(`role`,`menu`);for(let n of i)if(n===`separator`)s.appendChild(MH());else if(n===`close`)s.appendChild(jH(`Close`,o,()=>e.api.close()));else if(n===`closeOthers`)s.appendChild(jH(`Close Others`,o,()=>{t.panels.filter(t=>t!==e).forEach(e=>e.api.close())}));else if(n===`closeAll`)s.appendChild(jH(`Close All`,o,()=>{[...t.panels].forEach(e=>e.api.close())}));else if(AH(n)&&n.element)s.appendChild(n.element);else if(AH(n)&&n.component){let i=(r=this.accessor.options).createContextMenuItemComponent?.call(r,{id:KKe(),component:n.component});i&&(i.init({panel:e,group:t,api:this.accessor.api,close:o,componentProps:n.componentProps}),s.appendChild(i.element))}else AH(n)&&n.label&&s.appendChild(jH(n.label,o,()=>n.action?.call(n),n.disabled));a.openPopover(s,{x:n.clientX,y:n.clientY,zIndex:kH(n.target)})}showForChip(e,t,n){if(!this.accessor.options.getTabGroupChipContextMenuItems)return;let r=this.accessor.options.getTabGroupChipContextMenuItems({tabGroup:e,group:t,api:this.accessor.api,event:n});if(r.length===0)return;n.preventDefault();let i=this.accessor.getPopupServiceForGroup(t),a=()=>i.close(),o=document.createElement(`div`);o.className=`dv-context-menu`,o.setAttribute(`role`,`menu`);for(let t of r)t===`separator`?o.appendChild(MH()):t===`rename`?o.appendChild(JKe(e)):t===`colorPicker`?o.appendChild(YKe(e,this.accessor.tabGroupColorPalette)):AH(t)&&t.element?o.appendChild(t.element):AH(t)&&t.label&&o.appendChild(jH(t.label,a,()=>t.action?.call(t),t.disabled));i.openPopover(o,{x:n.clientX,y:n.clientY,zIndex:kH(n.target)})}},ZKe=oH({name:`ContextMenu`,serviceKey:`contextMenuService`,create:e=>new XKe(e)}),QKe=30,$Ke=-10,eqe=class{constructor(e){this.host=e}dispatchWillDragPanel(e){this.host.fireWillDragPanel(e)}dispatchWillDragGroup(e){this.host.fireWillDragGroup(e)}dispatchWillDrop(e){this.host.fireWillDrop(e)}dispatchWillShowOverlay(e){this.host.fireWillShowOverlay(e)}buildGroupDragGhost(e){let t=this.host.options.createGroupDragGhostComponent;if(!t)return;let n=t(e);return n.init({group:e,api:this.host.api}),{element:n.element,offsetX:QKe,offsetY:$Ke,dispose:n.dispose?()=>n.dispose?.call(n):void 0}}resolveOverlayModel(e,t){var n;return(n=this.host.options).dropOverlayModel?.call(n,{location:e,group:t})}showPreviewOverlay(e,t){let n=e.model.contentDropTarget;return n.showOverlay(t),dB.from(()=>n.clearOverlay())}dispose(){}},NH=oH({name:`AdvancedDnD`,serviceKey:`advancedDnDService`,create:e=>new eqe(e)}),PH=`data-dv-kbd-moving`;function FH(e,t){let n=t.toLowerCase().split(`+`),r=n[n.length-1],i=n.slice(0,-1);return e.ctrlKey===i.includes(`ctrl`)&&e.shiftKey===i.includes(`shift`)&&e.altKey===i.includes(`alt`)&&e.metaKey===(i.includes(`meta`)||i.includes(`cmd`))&&e.key.toLowerCase()===r}function IH(e){let t=e.keyboardNavigation;if(t)return t===!0?{}:t}var tqe={nextTab:`ctrl+]`,prevTab:`ctrl+[`,focusNextGroup:`f6`,focusPrevGroup:`shift+f6`,focusTabs:`ctrl+shift+\\`},nqe=class extends fB{constructor(e){super(),this.host=e,this._focusWasInside=!1;let t=e.rootElement.ownerDocument,n=e=>this._onKeyDown(e);t.addEventListener(`keydown`,n,!0);let r=e=>{let t=e.target;t instanceof HTMLElement&&this.host.rootElement.contains(t)&&!t.closest(`[role="dialog"]`)&&(this._lastNonFloatFocus=t)};t.addEventListener(`focusin`,r,!0);let i=e=>this._onFloatingEscape(e);t.addEventListener(`keydown`,i,!1),this.addDisposables({dispose:()=>t.removeEventListener(`keydown`,n,!0)},{dispose:()=>t.removeEventListener(`focusin`,r,!0)},{dispose:()=>t.removeEventListener(`keydown`,i,!1)},e.onWillMutateLayout(e=>{e.kind===`remove`&&this._nav&&(this._focusWasInside=this._isFocusInside())}),e.onDidMutateLayout(e=>{e.kind===`remove`&&this._nav&&this._focusWasInside&&!this._isFocusInside()&&this._restoreFocus()}))}get _moveActive(){return this.host.rootElement.hasAttribute(PH)}_isFocusInside(){let e=this.host.rootElement.ownerDocument.activeElement;return e instanceof Node&&this.host.rootElement.contains(e)}_onFloatingEscape(e){if(!this._nav||this._moveActive||e.defaultPrevented||e.key!==`Escape`)return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[role="dialog"]`);!n||!this.host.rootElement.contains(n)||(e.preventDefault(),e.stopPropagation(),this._returnFocusFromFloat())}_trapFloatTab(e){let t=e.target;if(!(t instanceof Element))return!1;let n=t.closest(`[role="dialog"]`);if(!n||!this.host.rootElement.contains(n))return!1;e.preventDefault();let r=this._tabbables(n);if(r.length===0)return!0;let i=n.ownerDocument.activeElement,a=i instanceof HTMLElement?r.indexOf(i):-1,o=r.length;return r[a===-1?e.shiftKey?o-1:0:(a+(e.shiftKey?-1:1)+o)%o].focus(),!0}_tabbables(e){let t=e.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]`);return Array.from(t).filter(e=>e.tabIndex>=0)}_returnFocusFromFloat(){var e;let t=this._lastNonFloatFocus;if(t&&t.isConnected&&this.host.rootElement.contains(t)&&!t.closest(`[role="dialog"]`)){t.focus();return}(e=this.host.groups.find(e=>e.api.location.type===`grid`))==null||e.model.focusContent()}get _nav(){return IH(this.host.options)}get _keymap(){return Object.assign(Object.assign({},tqe),this._nav?.keymap)}_onKeyDown(e){if(!this._nav||this._moveActive||!(e.target instanceof Node)||!this.host.rootElement.contains(e.target)||e.key===`Tab`&&this._trapFloatTab(e))return;let t=this._keymap;FH(e,t.nextTab)?(this._consume(e),this._switchTab(!1)):FH(e,t.prevTab)?(this._consume(e),this._switchTab(!0)):FH(e,t.focusNextGroup)?(this._consume(e),this._cycleGroup(!1)):FH(e,t.focusPrevGroup)?(this._consume(e),this._cycleGroup(!0)):FH(e,t.focusTabs)&&(this._consume(e),this._focusTabs())}_focusTabs(){var e;(e=this.host.activeGroup)==null||e.model.focusActiveTab()}_switchTab(e){let t=this.host.activeGroup;t&&(e?t.model.moveToPrevious():t.model.moveToNext(),t.model.focusContent())}_cycleGroup(e){let t=this.host.activeGroup,n=t?this.host.adjacentGroup(t,e):this.host.groups[0];this._focusGroup(n)}_focusGroup(e){e&&(e.api.setActive(),e.model.focusContent())}_restoreFocus(){var e;(e=this.host.activeGroup)==null||e.model.focusContent()}_consume(e){e.preventDefault(),e.stopPropagation()}},rqe=oH({name:`Accessibility`,serviceKey:`accessibilityService`,create:e=>new nqe(e)}),iqe={ArrowLeft:`left`,ArrowRight:`right`,ArrowUp:`top`,ArrowDown:`bottom`},LH={focusGroupLeft:`ctrl+shift+arrowleft`,focusGroupRight:`ctrl+shift+arrowright`,focusGroupUp:`ctrl+shift+arrowup`,focusGroupDown:`ctrl+shift+arrowdown`,dock:`ctrl+m`},aqe=class extends fB{constructor(e){super(),this.host=e,this._move=null;let t=e.rootElement.ownerDocument,n=e=>this._onKeyDown(e);t.addEventListener(`keydown`,n,!0),this.addDisposables({dispose:()=>this._exit()},{dispose:()=>t.removeEventListener(`keydown`,n,!0)})}get _enabled(){return!!IH(this.host.options)}get _keymap(){let e=IH(this.host.options)?.keymap??{};return{focusGroupLeft:e.focusGroupLeft??LH.focusGroupLeft,focusGroupRight:e.focusGroupRight??LH.focusGroupRight,focusGroupUp:e.focusGroupUp??LH.focusGroupUp,focusGroupDown:e.focusGroupDown??LH.focusGroupDown,dock:e.dock??LH.dock}}get _messages(){return hH(this.host.options.messages)}_onKeyDown(e){if(!this._enabled)return;if(this._move){this._onMoveKey(e);return}if(!(e.target instanceof Node)||!this.host.rootElement.contains(e.target))return;let t=this._keymap;FH(e,t.dock)?this._enterMoveMode(e):FH(e,t.focusGroupLeft)?(this._consume(e),this._focusGroupInDirection(`left`)):FH(e,t.focusGroupRight)?(this._consume(e),this._focusGroupInDirection(`right`)):FH(e,t.focusGroupUp)?(this._consume(e),this._focusGroupInDirection(`up`)):FH(e,t.focusGroupDown)&&(this._consume(e),this._focusGroupInDirection(`down`))}_focusGroupInDirection(e){let t=this.host.activeGroup;t&&this._focusGroup(this.host.adjacentGroupInDirection(t,e))}_focusGroup(e){e&&(e.api.setActive(),e.model.focusContent())}_restoreFocus(){var e;(e=this.host.activeGroup)==null||e.model.focusContent()}_enterMoveMode(e){let t=this.host.activePanel,n=this.host.groups;if(!t||n.length===0)return;e.preventDefault(),e.stopPropagation();let r=Math.max(0,n.indexOf(t.group));this._move={source:t,groups:n,groupIndex:r,phase:`target`,position:`center`},this.host.rootElement.setAttribute(PH,``),this._render()}_onMoveKey(e){let t=this._move;if(e.key===`Escape`){this._consume(e),t.phase===`edge`?(t.phase=`target`,t.position=`center`,this._render()):(this._exit(),this.host.announce(this._messages.moveCancelled()),this._restoreFocus());return}if(e.key===`Enter`){this._consume(e),t.phase===`target`?(t.phase=`edge`,t.position=`center`,this._render()):this._commit();return}if(t.phase===`target`){let n=t.groups.length;e.key===`ArrowRight`||e.key===`ArrowDown`?(this._consume(e),t.groupIndex=(t.groupIndex+1)%n,this._render()):(e.key===`ArrowLeft`||e.key===`ArrowUp`)&&(this._consume(e),t.groupIndex=(t.groupIndex-1+n)%n,this._render());return}let n=iqe[e.key];n?(this._consume(e),t.position=n,this._render()):(e.key===` `||e.key===`c`||e.key===`C`)&&(this._consume(e),t.position=`center`,this._render())}_render(){let e=this._move,t=e.groups[e.groupIndex];this._clearPreview(),this._preview=this.host.showDropPreview(t,e.position);let n=t.activePanel?.title??t.id,r=this._messages;e.phase===`target`?this.host.announce(r.movePickTarget(this._label(e.source),n,e.groupIndex+1,e.groups.length)):this.host.announce(r.movePickEdge(e.position,n))}_commit(){let e=this._move,t=e.groups[e.groupIndex],n=e.position,r=e.source,i=t.activePanel?.title??t.id,a=this._messages;this._exit();try{this.host.dockPanel(r,t,n),this.host.announce(a.moveCommitted(this._label(r),i,n))}catch{this.host.announce(a.moveNotAllowed())}this._restoreFocus()}_exit(){this._clearPreview(),this._move=null,this.host.rootElement.removeAttribute(PH)}_clearPreview(){var e;(e=this._preview)==null||e.dispose(),this._preview=void 0}_consume(e){e.preventDefault(),e.stopPropagation()}_label(e){return e.title??e.id}};oH({name:`KeyboardDocking`,serviceKey:`keyboardDockingService`,create:e=>new aqe(e),dependsOn:[NH,vH]}),XGe([WKe,ZKe,NH,rqe]),QGe();var RH=(e,t)=>{let[,n]=I.useState(0),r=I.useRef(e.componentProps);return I.useImperativeHandle(t,()=>({update:e=>{r.current=Object.assign(Object.assign({},r.current),e),n(e=>e+1)}}),[]),I.createElement(e.component,r.current)};RH.displayName=`DockviewReactJsBridge`;var oqe=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),sqe=I.createContext({}),zH=class{constructor(e,t,n,r,i){this.parent=e,this.portalStore=t,this.component=n,this.parameters=r,this.context=i,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw Error(`invalid operation: resource is already disposed`);this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw Error(`invalid operation: resource is already disposed`);if(!cqe(this.component))throw Error(`Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components`);let e=I.createElement(I.forwardRef(RH),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?I.createElement(sqe.Provider,{value:this.context},e):e,n=Pn.createPortal(t,this.parent,oqe.next());this.ref={portal:n,disposable:this.portalStore.addPortal(n)}}dispose(){var e;(e=this.ref)==null||e.disposable.dispose(),this.disposed=!0}},BH=()=>{let[e,t]=I.useState([]);return I.useDebugValue(`Portal count: ${e.length}`),[e,I.useCallback(e=>{t(t=>[...t,e]);let n=!1;return dB.from(()=>{if(n)throw Error(`invalid operation: resource already disposed`);n=!0,t(t=>t.filter(t=>t!==e))})},[])]};function cqe(e){return typeof e==`function`||!!e?.$$typeof}var VH=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._onDidFocus=new Q,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new Q,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}focus(){}init(e){this.part=new zH(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;(t=this.part)==null||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),(e=this.part)==null||e.dispose()}},HH=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}focus(){}init(e){this.part=new zH(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;(t=this.part)==null||t.update({params:e.params})}layout(e,t){}dispose(){var e;(e=this.part)==null||e.dispose()}},UH=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new zH(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t;this.parameters&&(this.parameters.params=e.params),(t=this.part)==null||t.update({params:this.parameters?.params??{}})}layout(e,t){}dispose(){var e;(e=this.part)==null||e.dispose()}},lqe=class{get element(){return this._element}get part(){return this._part}constructor(e,t,n){this.component=e,this.reactPortalStore=t,this._group=n,this.mutableDisposable=new pB,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.mutableDisposable.value=new fB(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()}),e.api.onDidLocationChange(e=>{this.updateLocation(e.location)})),this._part=new zH(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:e.api.location})}dispose(){var e;this.mutableDisposable.dispose(),(e=this._part)==null||e.dispose()}update(e){var t;(t=this._part)==null||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}},uqe=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new zH(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;(e=this.part)==null||e.dispose()}},WH=class{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.display=`inline-flex`}init(e){this.part=new zH(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;(t=this.part)==null||t.update({tabGroup:e.tabGroup})}dispose(){var e;(e=this.part)==null||e.dispose()}},GH=class{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.display=`inline-flex`}init(e){this.part=new zH(this._element,this.reactPortalStore,this.component,{group:e.group,api:e.api})}dispose(){var e;(e=this.part)==null||e.dispose()}};function KH(e,t){return e?n=>new lqe(e,t,n):void 0}var qH=`props.defaultTabComponent`;function dqe(e){return JV.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var JH=I.forwardRef((e,t)=>{let n=I.useRef(null),r=I.useRef(void 0),[i,a]=BH();I.useImperativeHandle(t,()=>n.current,[]);let o=I.useRef({});return I.useEffect(()=>{let t={};JV.forEach(n=>{let r=n,i=e[r];r in e&&i!==o.current[r]&&(t[r]=i)}),r.current&&r.current.updateOptions(t),o.current=e},JV.map(t=>e[t])),I.useEffect(()=>{if(!n.current)return;let t=e.tabComponents??{};e.defaultTabComponent&&(t[qH]=e.defaultTabComponent);let i={createLeftHeaderActionComponent:KH(e.leftHeaderActionsComponent,{addPortal:a}),createRightHeaderActionComponent:KH(e.rightHeaderActionsComponent,{addPortal:a}),createPrefixHeaderActionComponent:KH(e.prefixHeaderActionsComponent,{addPortal:a}),createComponent:t=>new VH(t.id,e.components[t.name],{addPortal:a}),createTabComponent(e){return new HH(e.id,t[e.name],{addPortal:a})},createWatermarkComponent:e.watermarkComponent?()=>new UH(`watermark`,e.watermarkComponent,{addPortal:a}):void 0,defaultTabComponent:e.defaultTabComponent?qH:void 0,createContextMenuItemComponent:e=>{if(e.component)return new uqe(e.id,e.component,{addPortal:a})}},o=dqe(e);if(e.tabGroupChipComponent){let t=e.tabGroupChipComponent;o.createTabGroupChipComponent=()=>new WH(t,{addPortal:a})}if(e.groupDragGhostComponent){let t=e.groupDragGhostComponent;o.createGroupDragGhostComponent=()=>new GH(t,{addPortal:a})}let s=zKe(n.current,Object.assign(Object.assign({},o),i)),{clientWidth:c,clientHeight:l}=n.current;return s.layout(c,l),e.onReady&&e.onReady({api:s}),r.current=s,()=>{r.current=void 0,s.dispose()}},[]),I.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),I.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onWillDrop(t=>{e.onWillDrop&&e.onWillDrop(t)});return()=>{t.dispose()}},[e.onWillDrop]),I.useEffect(()=>{r.current&&r.current.updateOptions({createTabGroupChipComponent:e.tabGroupChipComponent?()=>new WH(e.tabGroupChipComponent,{addPortal:a}):void 0})},[e.tabGroupChipComponent]),I.useEffect(()=>{r.current&&r.current.updateOptions({createGroupDragGhostComponent:e.groupDragGhostComponent?()=>new GH(e.groupDragGhostComponent,{addPortal:a}):void 0})},[e.groupDragGhostComponent]),I.useEffect(()=>{r.current&&r.current.updateOptions({createComponent:t=>new VH(t.id,e.components[t.name],{addPortal:a})})},[e.components]),I.useEffect(()=>{if(!r.current)return;let t=e.tabComponents??{};e.defaultTabComponent&&(t[qH]=e.defaultTabComponent),r.current.updateOptions({defaultTabComponent:e.defaultTabComponent?qH:void 0,createTabComponent(e){return new HH(e.id,t[e.name],{addPortal:a})}})},[e.tabComponents,e.defaultTabComponent]),I.useEffect(()=>{r.current&&r.current.updateOptions({createWatermarkComponent:e.watermarkComponent?()=>new UH(`watermark`,e.watermarkComponent,{addPortal:a}):void 0})},[e.watermarkComponent]),I.useEffect(()=>{r.current&&r.current.updateOptions({createRightHeaderActionComponent:KH(e.rightHeaderActionsComponent,{addPortal:a})})},[e.rightHeaderActionsComponent]),I.useEffect(()=>{r.current&&r.current.updateOptions({createLeftHeaderActionComponent:KH(e.leftHeaderActionsComponent,{addPortal:a})})},[e.leftHeaderActionsComponent]),I.useEffect(()=>{r.current&&r.current.updateOptions({createPrefixHeaderActionComponent:KH(e.prefixHeaderActionsComponent,{addPortal:a})})},[e.prefixHeaderActionsComponent]),I.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});JH.displayName=`DockviewComponent`;var YH=class extends RKe{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){return new zH(this.element,this.reactPortalStore,this.reactComponent,{params:this._params?.params??{},api:this.api,containerApi:new uV(this._params.accessor)})}};function fqe(e){return JB.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var pqe=I.forwardRef((e,t)=>{let n=I.useRef(null),r=I.useRef(void 0),[i,a]=BH();I.useImperativeHandle(t,()=>n.current,[]);let o=I.useRef({});return I.useEffect(()=>{let t={};JB.forEach(n=>{let r=n,i=e[r];r in e&&i!==o.current[r]&&(t[r]=i)}),r.current&&r.current.updateOptions(t),o.current=e},JB.map(t=>e[t])),I.useEffect(()=>{if(!n.current)return()=>{};let t=BKe(n.current,Object.assign(Object.assign({},fqe(e)),{createComponent:t=>new YH(t.id,t.name,e.components[t.name],{addPortal:a})})),{clientWidth:i,clientHeight:o}=n.current;return t.layout(i,o),e.onReady&&e.onReady({api:t}),r.current=t,()=>{r.current=void 0,t.dispose()}},[]),I.useEffect(()=>{r.current&&r.current.updateOptions({createComponent:t=>new YH(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),I.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});pqe.displayName=`SplitviewComponent`;var XH=class extends QV{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){return new zH(this.element,this.reactPortalStore,this.reactComponent,{params:this._params?.params??{},api:this.api,containerApi:new fV(this._params.accessor)})}};function mqe(e){return oV.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var hqe=I.forwardRef((e,t)=>{let n=I.useRef(null),r=I.useRef(void 0),[i,a]=BH();I.useImperativeHandle(t,()=>n.current,[]);let o=I.useRef({});return I.useEffect(()=>{let t={};oV.forEach(n=>{let r=n,i=e[r];r in e&&i!==o.current[r]&&(t[r]=i)}),r.current&&r.current.updateOptions(t),o.current=e},oV.map(t=>e[t])),I.useEffect(()=>{if(!n.current)return()=>{};let t=VKe(n.current,Object.assign(Object.assign({},mqe(e)),{createComponent:t=>new XH(t.id,t.name,e.components[t.name],{addPortal:a})})),{clientWidth:i,clientHeight:o}=n.current;return t.layout(i,o),e.onReady&&e.onReady({api:t}),r.current=t,()=>{r.current=void 0,t.dispose()}},[]),I.useEffect(()=>{r.current&&r.current.updateOptions({createComponent:t=>new XH(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),I.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});hqe.displayName=`GridviewComponent`;var ZH=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new zH(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;(t=this.part)==null||t.update(e.params)}dispose(){var e;(e=this.part)==null||e.dispose()}};function gqe(e){return DV.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var _qe=I.forwardRef((e,t)=>{let n=I.useRef(null),r=I.useRef(void 0),[i,a]=BH();I.useImperativeHandle(t,()=>n.current,[]);let o=I.useRef({});return I.useEffect(()=>{let t={};DV.forEach(n=>{let r=n,i=e[r];r in e&&i!==o.current[r]&&(t[r]=i)}),r.current&&r.current.updateOptions(t),o.current=e},DV.map(t=>e[t])),I.useEffect(()=>{if(!n.current)return()=>{};let t=e.headerComponents??{},i=HKe(n.current,Object.assign(Object.assign({},gqe(e)),{createComponent:t=>new ZH(t.id,e.components[t.name],{addPortal:a}),createHeaderComponent:e=>new ZH(e.id,t[e.name],{addPortal:a})})),{clientWidth:o,clientHeight:s}=n.current;return i.layout(o,s),e.onReady&&e.onReady({api:i}),r.current=i,()=>{r.current=void 0,i.dispose()}},[]),I.useEffect(()=>{r.current&&r.current.updateOptions({createComponent:t=>new ZH(t.id,e.components[t.name],{addPortal:a})})},[e.components]),I.useEffect(()=>{if(!r.current)return;let t=e.headerComponents??{};r.current.updateOptions({createHeaderComponent:e=>new ZH(e.id,t[e.name],{addPortal:a})})},[e.headerComponents]),I.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),I.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});_qe.displayName=`PaneviewComponent`;var QH=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},vqe=(e=>e?QH(e):QH),yqe=e=>e;function $H(e,t=yqe){let n=I.useSyncExternalStore(e.subscribe,I.useCallback(()=>t(e.getState()),[e,t]),I.useCallback(()=>t(e.getInitialState()),[e,t]));return I.useDebugValue(n),n}var eU=e=>{let t=vqe(e),n=e=>$H(t,e);return Object.assign(n,t),n},bqe=(e=>e?eU(e):eU),tU=null;function nU(e){tU=e}function rU(){if(!tU)throw Error(`Workspace store not initialized. Wrap your app in WorkspaceProvider.`);return tU}function xqe(){return $H(rU(),e=>e.activeFile)}function Sqe(){return $H(rU(),e=>e.activePanel)}function iU(){return $H(rU(),e=>e.sidebar)}function aU(){return $H(rU(),e=>e.setSidebar)}function Cqe(){return $H(rU(),e=>e.panels)}function wqe(){return $H(rU(),e=>e.dirtyFiles)}function oU(){return $H(rU(),e=>e.preferences.theme)}function sU(){return $H(rU(),e=>e.hydrationComplete)}function Tqe(){return $H(rU(),e=>e.resetLayout)}var cU=`-`,Eqe=e=>{let t=Oqe(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{let n=e.split(cU);return n[0]===``&&n.length!==1&&n.shift(),lU(n,t)||Dqe(e)},getConflictingClassGroupIds:(e,t)=>{let i=n[e]||[];return t&&r[e]?[...i,...r[e]]:i}}},lU=(e,t)=>{if(e.length===0)return t.classGroupId;let n=e[0],r=t.nextPart.get(n),i=r?lU(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;let a=e.join(cU);return t.validators.find(({validator:e})=>e(a))?.classGroupId},uU=/^\[(.+)\]$/,Dqe=e=>{if(uU.test(e)){let t=uU.exec(e)[1],n=t?.substring(0,t.indexOf(`:`));if(n)return`arbitrary..`+n}},Oqe=e=>{let{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return Aqe(Object.entries(e.classGroups),n).forEach(([e,n])=>{dU(n,r,e,t)}),r},dU=(e,t,n,r)=>{e.forEach(e=>{if(typeof e==`string`){let r=e===``?t:fU(t,e);r.classGroupId=n;return}if(typeof e==`function`){if(kqe(e)){dU(e(r),t,n,r);return}t.validators.push({validator:e,classGroupId:n});return}Object.entries(e).forEach(([e,i])=>{dU(i,fU(t,e),n,r)})})},fU=(e,t)=>{let n=e;return t.split(cU).forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},kqe=e=>e.isThemeGetter,Aqe=(e,t)=>t?e.map(([e,n])=>[e,n.map(e=>typeof e==`string`?t+e:typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,n])=>[t+e,n])):e)]):e,jqe=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=new Map,r=new Map,i=(i,a)=>{n.set(i,a),t++,t>e&&(t=0,r=n,n=new Map)};return{get(e){let t=n.get(e);if(t!==void 0)return t;if((t=r.get(e))!==void 0)return i(e,t),t},set(e,t){n.has(e)?n.set(e,t):i(e,t)}}},pU=`!`,Mqe=e=>{let{separator:t,experimentalParseClassName:n}=e,r=t.length===1,i=t[0],a=t.length,o=e=>{let n=[],o=0,s=0,c;for(let l=0;l<e.length;l++){let u=e[l];if(o===0){if(u===i&&(r||e.slice(l,l+a)===t)){n.push(e.slice(s,l)),s=l+a;continue}if(u===`/`){c=l;continue}}u===`[`?o++:u===`]`&&o--}let l=n.length===0?e:e.substring(s),u=l.startsWith(pU);return{modifiers:n,hasImportantModifier:u,baseClassName:u?l.substring(1):l,maybePostfixModifierPosition:c&&c>s?c-s:void 0}};return n?e=>n({className:e,parseClassName:o}):o},Nqe=e=>{if(e.length<=1)return e;let t=[],n=[];return e.forEach(e=>{e[0]===`[`?(t.push(...n.sort(),e),n=[]):n.push(e)}),t.push(...n.sort()),t},Pqe=e=>({cache:jqe(e.cacheSize),parseClassName:Mqe(e),...Eqe(e)}),Fqe=/\s+/,Iqe=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,a=[],o=e.trim().split(Fqe),s=``;for(let e=o.length-1;e>=0;--e){let t=o[e],{modifiers:c,hasImportantModifier:l,baseClassName:u,maybePostfixModifierPosition:d}=n(t),f=!!d,p=r(f?u.substring(0,d):u);if(!p){if(!f){s=t+(s.length>0?` `+s:s);continue}if(p=r(u),!p){s=t+(s.length>0?` `+s:s);continue}f=!1}let m=Nqe(c).join(`:`),h=l?m+pU:m,g=h+p;if(a.includes(g))continue;a.push(g);let _=i(p,f);for(let e=0;e<_.length;++e){let t=_[e];a.push(h+t)}s=t+(s.length>0?` `+s:s)}return s};function Lqe(){let e=0,t,n,r=``;for(;e<arguments.length;)(t=arguments[e++])&&(n=mU(t))&&(r&&(r+=` `),r+=n);return r}var mU=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=mU(e[r]))&&(n&&(n+=` `),n+=t);return n};function Rqe(e,...t){let n,r,i,a=o;function o(o){return n=Pqe(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)}function s(e){let t=r(e);if(t)return t;let a=Iqe(e,n);return i(e,a),a}return function(){return a(Lqe.apply(null,arguments))}}var hU=e=>{let t=t=>t[e]||[];return t.isThemeGetter=!0,t},gU=/^\[(?:([a-z-]+):)?(.+)\]$/i,zqe=/^\d+\/\d+$/,Bqe=new Set([`px`,`full`,`screen`]),Vqe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Hqe=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Uqe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Wqe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Gqe=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_U=e=>yU(e)||Bqe.has(e)||zqe.test(e),vU=e=>TU(e,`length`,$qe),yU=e=>!!e&&!Number.isNaN(Number(e)),bU=e=>TU(e,`number`,yU),xU=e=>!!e&&Number.isInteger(Number(e)),Kqe=e=>e.endsWith(`%`)&&yU(e.slice(0,-1)),SU=e=>gU.test(e),CU=e=>Vqe.test(e),qqe=new Set([`length`,`size`,`percentage`]),Jqe=e=>TU(e,qqe,EU),Yqe=e=>TU(e,`position`,EU),Xqe=new Set([`image`,`url`]),Zqe=e=>TU(e,Xqe,tJe),Qqe=e=>TU(e,``,eJe),wU=()=>!0,TU=(e,t,n)=>{let r=gU.exec(e);return r?r[1]?typeof t==`string`?r[1]===t:t.has(r[1]):n(r[2]):!1},$qe=e=>Hqe.test(e)&&!Uqe.test(e),EU=()=>!1,eJe=e=>Wqe.test(e),tJe=e=>Gqe.test(e),nJe=Rqe(()=>{let e=hU(`colors`),t=hU(`spacing`),n=hU(`blur`),r=hU(`brightness`),i=hU(`borderColor`),a=hU(`borderRadius`),o=hU(`borderSpacing`),s=hU(`borderWidth`),c=hU(`contrast`),l=hU(`grayscale`),u=hU(`hueRotate`),d=hU(`invert`),f=hU(`gap`),p=hU(`gradientColorStops`),m=hU(`gradientColorStopPositions`),h=hU(`inset`),g=hU(`margin`),_=hU(`opacity`),v=hU(`padding`),y=hU(`saturate`),b=hU(`scale`),x=hU(`sepia`),S=hU(`skew`),C=hU(`space`),w=hU(`translate`),T=()=>[`auto`,`contain`,`none`],E=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],D=()=>[`auto`,SU,t],O=()=>[SU,t],k=()=>[``,_U,vU],A=()=>[`auto`,yU,SU],ee=()=>[`bottom`,`center`,`left`,`left-bottom`,`left-top`,`right`,`right-bottom`,`right-top`,`top`],te=()=>[`solid`,`dashed`,`dotted`,`double`,`none`],ne=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],j=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`],M=()=>[``,`0`,SU],N=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],re=()=>[yU,SU];return{cacheSize:500,separator:`:`,theme:{colors:[wU],spacing:[_U,vU],blur:[`none`,``,CU,SU],brightness:re(),borderColor:[e],borderRadius:[`none`,``,`full`,CU,SU],borderSpacing:O(),borderWidth:k(),contrast:re(),grayscale:M(),hueRotate:re(),invert:M(),gap:O(),gradientColorStops:[e],gradientColorStopPositions:[Kqe,vU],inset:D(),margin:D(),opacity:re(),padding:O(),saturate:re(),scale:re(),sepia:M(),skew:re(),space:O(),translate:O()},classGroups:{aspect:[{aspect:[`auto`,`square`,`video`,SU]}],container:[`container`],columns:[{columns:[CU]}],"break-after":[{"break-after":N()}],"break-before":[{"break-before":N()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:[...ee(),SU]}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:[h]}],"inset-x":[{"inset-x":[h]}],"inset-y":[{"inset-y":[h]}],start:[{start:[h]}],end:[{end:[h]}],top:[{top:[h]}],right:[{right:[h]}],bottom:[{bottom:[h]}],left:[{left:[h]}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[`auto`,xU,SU]}],basis:[{basis:D()}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`wrap`,`wrap-reverse`,`nowrap`]}],flex:[{flex:[`1`,`auto`,`initial`,`none`,SU]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:[`first`,`last`,`none`,xU,SU]}],"grid-cols":[{"grid-cols":[wU]}],"col-start-end":[{col:[`auto`,{span:[`full`,xU,SU]},SU]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[wU]}],"row-start-end":[{row:[`auto`,{span:[xU,SU]},SU]}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":[`auto`,`min`,`max`,`fr`,SU]}],"auto-rows":[{"auto-rows":[`auto`,`min`,`max`,`fr`,SU]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:[`normal`,...j()]}],"justify-items":[{"justify-items":[`start`,`end`,`center`,`stretch`]}],"justify-self":[{"justify-self":[`auto`,`start`,`end`,`center`,`stretch`]}],"align-content":[{content:[`normal`,...j(),`baseline`]}],"align-items":[{items:[`start`,`end`,`center`,`baseline`,`stretch`]}],"align-self":[{self:[`auto`,`start`,`end`,`center`,`stretch`,`baseline`]}],"place-content":[{"place-content":[...j(),`baseline`]}],"place-items":[{"place-items":[`start`,`end`,`center`,`baseline`,`stretch`]}],"place-self":[{"place-self":[`auto`,`start`,`end`,`center`,`stretch`]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[C]}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":[C]}],"space-y-reverse":[`space-y-reverse`],w:[{w:[`auto`,`min`,`max`,`fit`,`svw`,`lvw`,`dvw`,SU,t]}],"min-w":[{"min-w":[SU,t,`min`,`max`,`fit`]}],"max-w":[{"max-w":[SU,t,`none`,`full`,`min`,`max`,`fit`,`prose`,{screen:[CU]},CU]}],h:[{h:[SU,t,`auto`,`min`,`max`,`fit`,`svh`,`lvh`,`dvh`]}],"min-h":[{"min-h":[SU,t,`min`,`max`,`fit`,`svh`,`lvh`,`dvh`]}],"max-h":[{"max-h":[SU,t,`min`,`max`,`fit`,`svh`,`lvh`,`dvh`]}],size:[{size:[SU,t,`auto`,`min`,`max`,`fit`]}],"font-size":[{text:[`base`,CU,vU]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`,bU]}],"font-family":[{font:[wU]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`,SU]}],"line-clamp":[{"line-clamp":[`none`,yU,bU]}],leading:[{leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`,_U,SU]}],"list-image":[{"list-image":[`none`,SU]}],"list-style-type":[{list:[`none`,`disc`,`decimal`,SU]}],"list-style-position":[{list:[`inside`,`outside`]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[_]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[_]}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...te(),`wavy`]}],"text-decoration-thickness":[{decoration:[`auto`,`from-font`,_U,vU]}],"underline-offset":[{"underline-offset":[`auto`,_U,SU]}],"text-decoration-color":[{decoration:[e]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:O()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,SU]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,SU]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-opacity":[{"bg-opacity":[_]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:[...ee(),Yqe]}],"bg-repeat":[{bg:[`no-repeat`,{repeat:[``,`x`,`y`,`round`,`space`]}]}],"bg-size":[{bg:[`auto`,`cover`,`contain`,Jqe]}],"bg-image":[{bg:[`none`,{"gradient-to":[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},Zqe]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[s]}],"border-w-x":[{"border-x":[s]}],"border-w-y":[{"border-y":[s]}],"border-w-s":[{"border-s":[s]}],"border-w-e":[{"border-e":[s]}],"border-w-t":[{"border-t":[s]}],"border-w-r":[{"border-r":[s]}],"border-w-b":[{"border-b":[s]}],"border-w-l":[{"border-l":[s]}],"border-opacity":[{"border-opacity":[_]}],"border-style":[{border:[...te(),`hidden`]}],"divide-x":[{"divide-x":[s]}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":[s]}],"divide-y-reverse":[`divide-y-reverse`],"divide-opacity":[{"divide-opacity":[_]}],"divide-style":[{divide:te()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:[``,...te()]}],"outline-offset":[{"outline-offset":[_U,SU]}],"outline-w":[{outline:[_U,vU]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:k()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[_]}],"ring-offset-w":[{"ring-offset":[_U,vU]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:[``,`inner`,`none`,CU,Qqe]}],"shadow-color":[{shadow:[wU]}],opacity:[{opacity:[_]}],"mix-blend":[{"mix-blend":[...ne(),`plus-lighter`,`plus-darker`]}],"bg-blend":[{"bg-blend":ne()}],filter:[{filter:[``,`none`]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":[``,`none`,CU,SU]}],grayscale:[{grayscale:[l]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[y]}],sepia:[{sepia:[x]}],"backdrop-filter":[{"backdrop-filter":[``,`none`]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[l]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[_]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[x]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[`none`,`all`,``,`colors`,`opacity`,`shadow`,`transform`,SU]}],duration:[{duration:re()}],ease:[{ease:[`linear`,`in`,`out`,`in-out`,SU]}],delay:[{delay:re()}],animate:[{animate:[`none`,`spin`,`ping`,`pulse`,`bounce`,SU]}],transform:[{transform:[``,`gpu`,`none`]}],scale:[{scale:[b]}],"scale-x":[{"scale-x":[b]}],"scale-y":[{"scale-y":[b]}],rotate:[{rotate:[xU,SU]}],"translate-x":[{"translate-x":[w]}],"translate-y":[{"translate-y":[w]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:[`center`,`top`,`top-right`,`right`,`bottom-right`,`bottom`,`bottom-left`,`left`,`top-left`,SU]}],accent:[{accent:[`auto`,e]}],appearance:[{appearance:[`none`,`auto`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,SU]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":[`none`,`auto`]}],resize:[{resize:[`none`,`y`,`x`,``]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,SU]}],fill:[{fill:[e,`none`]}],"stroke-w":[{stroke:[_U,vU,bU]}],stroke:[{stroke:[e,`none`]}],sr:[`sr-only`,`not-sr-only`],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-s`,`border-w-e`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-s`,`border-color-e`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]}}});function DU(...e){return nJe(s(e))}function rJe(e){return`api`in e&&e.api?e.api:e}function iJe(e){let t=rJe(e);return{id:t.id??(`id`in e?e.id:void 0),close:t.close?()=>t.close?.():void 0}}function aJe(e){let t=e.api.group?.panels;if(Array.isArray(t))return t;let n=e.containerApi.panels;return Array.isArray(n)?n:[]}function oJe(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return typeof n==`string`&&n.length>0?n:null}function sJe(e){if(!e)return null;if(e.startsWith(`file:`)){let t=e.slice(5);return t.length>0?t:null}let t=`surface:${iB}:`;if(e.startsWith(t)){let n=e.slice(t.length);return n.length>0?n:null}return null}async function cJe(e){if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(typeof document>`u`)throw Error(`Clipboard not available`);let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.left=`-9999px`,document.body.appendChild(t);let n=!1;try{t.focus(),t.select(),n=document.execCommand?.(`copy`)??!1}finally{t.remove()}if(!n)throw Error(`Clipboard not available`)}function lJe(){typeof document>`u`||document.body.dispatchEvent(new PointerEvent(`pointerdown`,{bubbles:!0,cancelable:!0}))}function uJe(e){let{api:t}=e,n=e.tabLocation===`headerOverflow`,[r,i]=(0,I.useState)(t.title??t.id),[a,o]=(0,I.useState)(null),s=(0,I.useRef)(null);(0,I.useEffect)(()=>{let e=()=>i(t.title??t.id);e();let n=t.onDidTitleChange?.(e);return()=>n?.dispose?.()},[t]),(0,I.useEffect)(()=>{if(!a)return;function e(e){s.current&&!s.current.contains(e.target)&&o(null)}return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]);let c=r.endsWith(` ●`),l=c?r.slice(0,-2):r,u=rB(l),d=oJe(e.params,`path`)??sJe(t.id),f=aJe(e).map(iJe).filter(e=>e.close),p=f.filter(e=>e.id!==t.id),[m,h]=(0,I.useState)(!1);oc(nc.editorSaveStart,e=>{e.panelId===t.id&&h(!0)}),oc(nc.editorSaveEnd,e=>{e.panelId===t.id&&h(!1)});let g=e=>{e.preventDefault(),e.stopPropagation(),n&&e.nativeEvent.stopImmediatePropagation(),t.close(),n&&lJe()},_=e=>{!d&&p.length===0||(e.preventDefault(),e.stopPropagation(),o({x:e.clientX,y:e.clientY}))},v=e=>{o(null),cJe(e)},y=a&&typeof document<`u`?(0,Pn.createPortal)((0,L.jsxs)(`div`,{ref:s,role:`menu`,className:`fixed z-[1000] min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md`,style:{left:a.x,top:a.y},onPointerDown:e=>e.stopPropagation(),onContextMenu:e=>{e.preventDefault(),e.stopPropagation()},children:[d?(0,L.jsx)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center rounded-sm px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground`,onClick:()=>v(d),children:`Copy path`}):null,p.length>0?(0,L.jsx)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center rounded-sm px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground`,onClick:()=>{o(null),t.setActive?.();for(let e of p)e.close?.()},children:`Close other tabs`}):null,f.length>0?(0,L.jsx)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center rounded-sm px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground`,onClick:()=>{o(null),t.setActive?.();for(let e of f)e.close?.()},children:`Close all`}):null]}),document.body):null;return(0,L.jsxs)(I.Fragment,{children:[(0,L.jsxs)(`div`,{className:DU(`group relative flex h-full w-full min-w-0 items-center gap-2 px-3 select-none`,`text-[12.5px] leading-none tracking-tight`,`cursor-pointer transition-colors`),title:c?`${l} (unsaved changes)`:l,onPointerDown:e=>{e.button===2&&_(e)},onContextMenu:_,children:[(0,L.jsx)(u,{className:DU(`h-3.5 w-3.5 shrink-0 text-muted-foreground/70`,`[.dv-active-tab_&]:text-[color:var(--accent)] [.active-tab_&]:text-[color:var(--accent)]`),strokeWidth:1.5}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap`,children:l}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[c||m?(0,L.jsx)(`span`,{"data-testid":`tab-dirty-dot`,"aria-hidden":`true`,className:DU(`h-1.5 w-1.5 shrink-0 rounded-full bg-foreground/35`,`[.dv-active-tab_&]:bg-foreground/45 [.active-tab_&]:bg-foreground/45`)}):null,(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,className:DU(`h-5 w-5 shrink-0 text-muted-foreground/80 opacity-0`,`focus-visible:opacity-100 group-hover:opacity-100`,`[.dv-active-tab_&]:opacity-55 [.active-tab_&]:opacity-55`,`[.dv-active-tab_&]:hover:opacity-100 [.active-tab_&]:hover:opacity-100`),...n?{onClickCapture:g}:{onClick:g},"aria-label":`Close ${l}`,children:(0,L.jsx)(ea,{className:`h-3 w-3`,strokeWidth:2.25})})]})]}),y]})}var dJe=300,OU=(0,I.createContext)(null);function fJe(e,t){if(`id`in t)return e.id===t.id;let n=e.params;if(`paramPrefix`in t){let e=n?.[t.paramPrefix],r=typeof e==`string`&&e.startsWith(t.value),i=!t.params||Object.entries(t.params).every(([e,t])=>n?.[e]===t);return r&&i}return`params`in t?Object.entries(t.params).every(([e,t])=>n?.[e]===t):n?.[t.param]===t.value}function kU(e,t){let n=Array.isArray(t)?t:[t],r=new Set,i=[];for(let t of e.panels)n.some(e=>fJe(t,e))&&(r.has(t.id)||(r.add(t.id),i.push(t)));return i}function pJe(){let e=(0,I.useContext)(OU);if(!e)throw Error(`useDockviewApi must be used within a DockviewShell`);return e}function mJe(e){switch(e){case`left`:return`left`;case`right`:return`right`;case`bottom`:return`below`;default:return`within`}}function hJe(e){function t(){if(!e.current)throw Error(`DockviewShell not initialized`);return e.current}return{addPanel(e,n){let r=t(),i=r.groups.find(t=>t.id===e);r.addPanel({id:n.id,component:n.component,title:n.title,params:n.params,position:i?{referenceGroup:i}:void 0})},removePanel(e){let n=t(),r=n.getPanel(e);r&&n.removePanel(r)},activatePanel(e){let n=t().getPanel(e);n&&n.api.setActive()},movePanel(e,n){let r=t(),i=r.getPanel(e);if(!i)return;let a=i.view.contentComponent,o=i.params,s=i.title;r.removePanel(i);let c={id:e,component:a,params:o,title:s};if(`groupId`in n){let e=r.groups.find(e=>e.id===n.groupId);r.addPanel({...c,position:e?{referenceGroup:e}:void 0})}else{let e=r.getPanel(n.referencePanelId);r.addPanel({...c,position:e?{referencePanel:e,direction:n.direction}:void 0})}},updatePanelParams(e,n){let r=t().getPanel(e);r&&r.api.updateParameters({...r.params??{},...n})},setPanelTitle(e,n){let r=t().getPanel(e);r&&r.api.setTitle(n)},findPanelsByParam(e,n){return t().panels.filter(t=>t.params?.[e]===n).map(e=>e.id)},getActivePanel(){return t().activePanel?.id??null},toJSON(){return t().toJSON()}}}function gJe(e){if(!e.constraints)return null;let t=e.constraints.maxWidth,n=e.constraints.maxWidthViewportRatio;if(typeof n==`number`&&n>0&&typeof window<`u`){let e=Math.floor(window.innerWidth*n);t=typeof t==`number`?Math.min(t,e):e}return{minimumWidth:e.constraints.minWidth,maximumWidth:t,minimumHeight:e.constraints.minHeight,maximumHeight:e.constraints.maxHeight}}function AU(e,t){let n=e.getPanel(t.panel??t.id);if(!n?.group)return;let r=gJe(t);r&&n.group.api.setConstraints(r)}function _Je(e,t,n,r,i,a){let o=e.api;a.current=o;let s=!0;if(n)try{o.fromJSON(n),s=!1}catch(e){console.warn(`[DockviewShell] Ignoring invalid persisted layout`,e)}if(s){let e=!1;for(let n of t.groups)if(n.panel){if(!r.has(n.panel)){console.error(`[DockviewShell] Panel "${n.panel}" not found in registry. Available: ${r.list().map(e=>e.id).join(`, `)}`);continue}o.addPanel({id:n.panel,component:n.panel,params:n.params,position:e?{direction:mJe(n.position)}:void 0}),e=!0}}for(let e of t.groups){let t=o.getPanel(e.panel??e.id);t?.group&&(e.locked&&(t.group.locked=`no-drop-target`),e.hideHeader&&(t.group.header.hidden=!0),AU(o,e))}let c=t.groups.filter(e=>typeof e.constraints?.maxWidthViewportRatio==`number`),l;if(c.length>0){let e=()=>{for(let e of c)AU(o,e)};window.addEventListener(`resize`,e),l=()=>window.removeEventListener(`resize`,e)}let u;if(i){let e=null,t=o.onDidLayoutChange(()=>{e&&clearTimeout(e),e=setTimeout(()=>{i(o.toJSON())},dJe)}),n=()=>{e&&(clearTimeout(e),i(o.toJSON()))};window.addEventListener(`beforeunload`,n),u=()=>{n(),t.dispose(),window.removeEventListener(`beforeunload`,n),l?.()}}else u=()=>{l?.()};return u}function jU({layout:e,persistedLayout:t,onReady:n,onLayoutChange:r,allowedPanels:i,className:a,prefixHeaderActions:o,rightHeaderActions:s,watermarkComponent:c}){let l=ir(),u=(0,I.useSyncExternalStore)(l.subscribe,l.getSnapshot,l.getSnapshot),d=sU(),f=(0,I.useRef)(null),p=(0,I.useRef)(null),m=(0,I.useRef)(void 0),h=(0,I.useRef)(null),g=(0,I.useMemo)(()=>{let e=l.getComponents(),t=i?Object.fromEntries(Object.entries(e).filter(([e])=>i.includes(e))):e,n=h.current;if(n){let e=Object.keys(n),r=Object.keys(t);if(e.length===r.length&&r.every(e=>n[e]===t[e]))return n}return h.current=t,t},[l,u,i]),_=(0,I.useMemo)(()=>hJe(f),[]),v=(0,I.useCallback)(i=>{m.current?.(),m.current=_Je(i,e,t,l,r,f),n?.(i.api)},[e,t,l,r,n]);(0,I.useEffect)(()=>()=>m.current?.(),[]),(0,I.useEffect)(()=>{let e=lc.on(nc.panelUpdate,({match:e,params:t,title:n})=>{let r=f.current;if(r)for(let i of kU(r,e))t&&i.api.updateParameters({...i.params??{},...t}),n&&i.api.setTitle(n)}),t=lc.on(nc.panelClose,({match:e})=>{let t=f.current;if(t)for(let n of kU(t,e))t.removePanel(n)});return()=>{e(),t()}},[]);let y=(0,I.useCallback)(e=>{if(!d){p.current=e;return}v(e)},[d,v]);return(0,I.useEffect)(()=>{d&&p.current&&(v(p.current),p.current=null)},[d,v]),d?(0,L.jsx)(OU.Provider,{value:_,children:(0,L.jsx)(JH,{className:`dv-shell ${a??``}`,components:g,defaultTabComponent:uJe,prefixHeaderActionsComponent:o,rightHeaderActionsComponent:s,watermarkComponent:c,onReady:y})}):(0,L.jsx)(vJe,{})}function vJe(){return(0,L.jsx)(N,{centered:!0,className:`bg-background`,label:`Loading workspace...`})}function yJe(e){return{get panelId(){return e.id},get title(){return e.title??e.id},setTitle(t){e.setTitle(t)},close(){e.close()},focus(){e.setActive()},get isActive(){return e.isActive}}}function MU({title:e,icon:t,essential:n,children:r,className:i,panelApi:a}){return(0,I.useMemo)(()=>a?yJe(a):null,[a]),(0,L.jsxs)(`div`,{className:DU(`flex h-full flex-col overflow-hidden`,i),children:[(0,L.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border bg-muted/50 px-3`,children:[t&&(0,L.jsx)(t,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e}),(0,L.jsx)(`div`,{className:`flex-1`}),!n&&a&&(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`h-5 w-5 text-muted-foreground`,onClick:()=>a.close(),"aria-label":`Close ${e}`,children:(0,L.jsx)(`svg`,{className:`h-3 w-3`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,L.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}),(0,L.jsx)(`div`,{className:`flex-1 overflow-auto`,children:r})]})}var bJe=[`node_modules`,`.git`,`.worktrees`,`.boring-agent`,`dist`,`test-results`,/^\.tsbuildinfo/,`.vite`,`.turbo`,`.next`,`.cache`];function NU(e,t){for(let n of t)if(typeof n==`string`?n===e:n.test(e))return!0;return!1}function xJe(e,t){return t.length===0?e:e?.filter(e=>!NU(e.name,t))}function PU(e){let t=e.trim();return t&&SJe(/[*?\[\]{}]/.test(t)?t:`*${t}*`)}function SJe(e){let t=``,n=!1,r=!1;for(let i of e){if(r){t+=i,r=!1;continue}if(i===`\\`){t+=i,r=!0;continue}if(i===`[`&&!n){n=!0,t+=i;continue}if(i===`]`&&n){n=!1,t+=i;continue}if(!n&&/[a-z]/i.test(i)){let e=i.toLowerCase(),n=i.toUpperCase();t+=e===n?i:`[${n}${e}]`;continue}t+=i}return t}async function FU(e){if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(typeof document>`u`)throw Error(`Clipboard not available`);let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-9999px`,t.style.left=`-9999px`,t.style.opacity=`0`,document.body.appendChild(t);let n=!1;try{t.focus(),t.select(),n=!!document.execCommand?.(`copy`)}finally{document.body.removeChild(t)}if(!n)throw Error(`Clipboard not available`)}var IU=()=>P(()=>Promise.resolve().then(()=>Agt).then(e=>({default:e.FileTree})),void 0);function CJe(){IU()}var wJe=(0,I.lazy)(IU),LU=8,TJe=250;function EJe(e,t,n,r,i){return{x:Math.max(LU,Math.min(e,r-n.width-LU)),y:Math.max(LU,Math.min(t,i-n.height-LU))}}function RU(e){return e.trim().replace(/\\/g,`/`).replace(/^\.\/+/,``).replace(/^\/+/,``).replace(/\/+/g,`/`).replace(/\/+$/,``)||`.`}function zU(e){let t=RU(e).split(`/`).filter(Boolean),n=[];for(let e=1;e<t.length;e++)n.push(t.slice(0,e).join(`/`));return n}function DJe(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function BU(e,t){return!e||t.size===0?e:e.filter(e=>!t.has(e.path))}function VU({rootDir:e=`.`,searchQuery:t,bridge:n,revealFileTreeRequest:r,filesystem:i=`user`,access:a=`readwrite`,ignoreNames:o=bJe,className:s}){let c=zu(),l=a!==`readonly`,u=ba(i),d=u===`user`?void 0:u,p=(0,I.useCallback)(e=>d?c.getTree(e,void 0,d):c.getTree(e),[c,d]),{data:m,error:h,isLoading:g}=td(e,d),[_,v]=(0,I.useState)(new Map),[y,b]=(0,I.useState)(new Set),x=hu(e),S=(0,I.useMemo)(()=>BU(gu(m,_.get(x)),y),[m,_,x,y]),C=(0,I.useMemo)(()=>xJe(S,o),[S,o]),{mutateAsync:w}=rd(),{mutateAsync:T}=see(),{mutateAsync:E}=id(),{mutateAsync:D}=ad(),[O,k]=(0,I.useState)(new Map),A=(0,I.useMemo)(()=>{if(_.size===0&&y.size===0)return O;let e=new Map;for(let[t,n]of O)e.set(t,BU(n,y)??n);for(let[t,n]of _){if(t===x)continue;let r=BU(gu(e.get(t),n),y);r&&e.set(t,r)}return e},[O,_,x,y]),ee=(0,I.useRef)(null),[te,ne]=(0,I.useState)(400),[j,M]=(0,I.useState)(null),{data:N}=nd(j&&!j.isBackground&&j.node.kind===`file`?j.node.path:null),[re,ae]=(0,I.useState)(null),oe=(0,I.useRef)(null),[se,ce]=(0,I.useState)(n?.getActiveFile?.()??null),[le,ue]=(0,I.useState)(null),[de,fe]=(0,I.useState)(null),pe=(0,I.useRef)(0),me=(0,I.useRef)(0),he=(0,I.useRef)(0),_e=(t?.trim().length??0)>0,{data:ve}=oee(_e&&i===`user`?PU(t??``):``,50);(0,I.useEffect)(()=>{if(!j)return;function e(e){oe.current&&!oe.current.contains(e.target)&&M(null)}return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[j]),(0,I.useLayoutEffect)(()=>{if(!j||!oe.current)return;let{x:e,y:t}=EJe(j.x,j.y,oe.current.getBoundingClientRect(),window.innerWidth,window.innerHeight);e===j.x&&t===j.y||M(n=>!n||n.x===e&&n.y===t?n:{...n,x:e,y:t})},[j]),(0,I.useEffect)(()=>{let e=ee.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&ne(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[]);let xe=_u((_e&&ve?ve.map(e=>({name:e.split(`/`).pop()??e,kind:`file`,path:e})):void 0)??pu(C??[],A),le,e),Ce=(0,I.useCallback)(e=>{ce(e),n?.openFile(e,{mode:`edit`,...d?{filesystem:d}:{}})},[n,d]),we=(0,I.useCallback)(async e=>{try{let t=await p(e),n=o.length===0?t:t.filter(e=>!NU(e.name,o));k(t=>new Map(t).set(e,n))}catch{}},[p,o]),Te=(0,I.useCallback)(async(t,n)=>{let r=Array.from(new Set(t)).filter(t=>t&&t!==e&&t!==`.`);if(r.length===0)return;let i=await Promise.all(r.map(async e=>{try{let t=await p(e);return[e,o.length===0?t:t.filter(e=>!NU(e.name,o))]}catch{return null}}));k(e=>{let t=new Map(e);for(let e of i){if(!e)continue;let[r,i]=e;(n?.force||t.has(r))&&t.set(r,i)}return t})},[p,e,o]),Ee=(0,I.useRef)(new Set);(0,I.useLayoutEffect)(()=>{Ee.current=new Set(O.keys())},[O]),(0,I.useEffect)(()=>{let e=new Set,t=e=>Array.from(new Set(e.map(mu))).filter(e=>Ee.current.has(e)),n=e=>ba(e)===u,r=t=>{if(!t.length)return;Te(t);let n=setTimeout(()=>{e.delete(n),Te(t)},TJe);e.add(n)},i=lc.on(eu.created,e=>{e.cause===`user`||!n(e.filesystem)||r(t([e.path]))}),a=lc.on(eu.deleted,e=>{e.cause===`user`||!n(e.filesystem)||r(t([e.path]))}),o=lc.on(eu.moved,e=>{e.cause===`user`||!n(e.filesystem)||r(t([e.from,e.to]))});return()=>{i(),a(),o();for(let t of e)clearTimeout(t);e.clear()}},[u,Te]);let De=(0,I.useCallback)(async(e,t)=>{if(!e)return;let n=RU(e),r=++pe.current;ce(n);let i=t?.refreshTargetDir?[...zU(n),n]:zU(n);await Te([...new Set(i)],{force:!0}),pe.current===r&&fe(n)},[Te]),Oe=(0,I.useCallback)(e=>{fe(t=>t===e?null:t)},[]),ke=(0,I.useCallback)(async e=>{let t=++me.current;try{await De(e,{refreshTargetDir:!0})}finally{me.current===t&&(me.current=0)}},[De]);(0,I.useEffect)(()=>{r&&ke(r.path)},[r,ke]),(0,I.useEffect)(()=>{let e=n?.getActiveFile?.()??null;e&&me.current===0&&De(e);let t=[];return n?.select&&t.push(n.select(e=>e.activeFile,e=>{e?me.current===0&&De(e):ce(null)})),n?.subscribe&&t.push(n.subscribe(`tree:expand`,({path:e})=>{ke(e)})),()=>{for(let e of t)e()}},[n,ke,De]);let Ae=(0,I.useCallback)((e,t)=>{v(n=>{let r=hu(e),i=new Map(n),a=gu(i.get(r),[t])??[t];return i.set(r,a),i})},[]),Me=(0,I.useCallback)((e,t)=>{v(n=>{let r=hu(e),i=n.get(r);if(!i?.length)return n;let a=i.filter(e=>e.path!==t),o=new Map(n);return a.length>0?o.set(r,a):o.delete(r),o})},[]),Ne=(0,I.useCallback)(e=>{b(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),Pe=(0,I.useCallback)(e=>{b(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]);(0,I.useEffect)(()=>{let e=e=>e===x||Ee.current.has(e),t=e=>ba(e)===u,n=lc.on(eu.created,n=>{if(!t(n.filesystem)||(Pe(n.path),n.cause===`user`))return;let r=mu(n.path);e(r)&&Ae(r,{name:DJe(n.path),kind:n.kind,path:n.path})}),r=lc.on(eu.deleted,e=>{e.cause===`user`||!t(e.filesystem)||(Ne(e.path),Me(mu(e.path),e.path))}),i=lc.on(eu.moved,e=>{e.cause===`user`||!t(e.filesystem)||(Ne(e.from),Pe(e.to),Me(mu(e.from),e.from))});return()=>{n(),r(),i()}},[u,Ae,Ne,Me,x,Pe]);let[Fe,Ie]=(0,I.useState)(new Set),Re=(0,I.useCallback)(e=>{Ie(t=>{let n=new Set(t);return n.add(e),n})},[]),ze=(0,I.useCallback)(e=>{Ie(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),Be=(0,I.useCallback)((e,t)=>{M({node:t,x:e.clientX,y:e.clientY})},[]),He=(0,I.useCallback)(t=>{let n=t.target;n.closest(`[role=treeitem]`)||n.closest(`[data-path]`)||(t.preventDefault(),M({node:{name:e,kind:`dir`,path:e},x:t.clientX,y:t.clientY,isBackground:!0}))},[e]),We=(0,I.useCallback)(async(t,n)=>{let r=t.split(`/`).pop()??t,i=n===`.`?e:n,a=i===`.`?r:`${i}/${r}`;if(a!==t){Re(t);try{if(!l)return;await E({from:t,to:a,...d?{filesystem:d}:{}}),await Te([mu(t),mu(a)]),ie.success({title:`Moved`,description:`${t} → ${a}`})}catch(e){ie.error({title:`Move failed`,description:e instanceof Error?e.message:String(e)})}finally{ze(t)}}},[l,d,E,Te,e,Re,ze]);function Ge(e){return()=>{M(null),(async()=>{try{await e()}catch(e){ie.error({title:`Action failed`,description:e instanceof Error?e.message:String(e)})}})()}}let Ke=t=>{let n=j?.node;M(null);let r=n?.kind===`dir`?n.path:n?mu(n.path):e,i=`__draft__:${++he.current}`;ue({kind:t,parentDir:r,path:i})},qe=()=>Ke(`create-file`),Ye=()=>Ke(`create-folder`),Ze=()=>{let e=j?.node;M(null),e&&ue({kind:`rename`,path:e.path,initialValue:e.name})},Qe=(0,I.useCallback)(async(e,t)=>{let n=le;if(ue(null),!n)return;let r=t.trim();if(!r||!l)return;let i=n.kind===`rename`?mu(n.path):n.parentDir,a=n.kind===`rename`?n.path:i===`.`||i===``?r:`${i}/${r}`,o=n.kind===`rename`?n.path:a;Re(o);let s=null;try{if(n.kind===`rename`){if(r===n.initialValue)return;let e=n.path.split(`/`);e[e.length-1]=r;let t=e.join(`/`);await E({from:n.path,to:t,...d?{filesystem:d}:{}}),await Te([mu(n.path)]),ie.success({title:`Renamed`,description:`${n.path} → ${t}`})}else{let e={name:r,kind:n.kind===`create-file`?`file`:`dir`,path:a,filesystem:d};Ae(i,e),s=a,n.kind===`create-file`?(await w({path:a,content:``,returnMtimeMs:!1,...d?{filesystem:d}:{}}),lc.emit(eu.created,{...rc(),path:a,filesystem:d,kind:`file`}),Ce(a),ie.success({title:`File created`,description:a})):(await T({path:a,...d?{filesystem:d}:{}}),ie.success({title:`Folder created`,description:a})),await Te([i],{force:!0}),fe(a)}}catch(e){s&&Me(i,s);let t=e instanceof Error?e.message:String(e);ie.error({title:n.kind===`rename`?`Rename failed`:n.kind===`create-file`?`Create file failed`:`Create folder failed`,description:t})}finally{ze(o)}},[le,l,d,E,w,T,Te,Re,ze,Ae,Me,Ce]),$e=(0,I.useCallback)(()=>{ue(null)},[]),et=Ge(async()=>{j?.node&&(await FU(j.node.path),ie.success({title:`Path copied`,description:j.node.path}))}),tt=Ge(async()=>{if(!N?.enabled||!N.url)throw Error(N?.reason??`Git URL unavailable`);await FU(N.url),ie.success({title:`Git URL copied`,description:N.url})}),nt=(0,I.useCallback)(async()=>{if(!re)return;let e=re;ae(null),Re(e.path);try{if(!l)return;await D({path:e.path,...d?{filesystem:d}:{}}),Me(mu(e.path),e.path),e.kind===`dir`&&k(t=>{let n=new Map(t);for(let t of n.keys())(t===e.path||t.startsWith(`${e.path}/`))&&n.delete(t);return n}),await Te([mu(e.path)]),ie.success({title:`Deleted`,description:e.path})}catch(e){ie.error({title:`Delete failed`,description:e instanceof Error?e.message:String(e)})}finally{ze(e.path)}},[re,D,Te,Re,ze,Me,l,d]),rt=(!_e||i!==`user`)&&(t?.length??0)>0?t:void 0;return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[h&&(0,L.jsx)(f,{className:`m-2 rounded-md p-3`,title:`Failed to load files`,description:h.message}),(0,L.jsx)(`div`,{ref:ee,className:`min-h-0 flex-1 overflow-hidden`,onContextMenu:He,children:g?(0,L.jsx)(`div`,{className:`space-y-1 p-2`,"data-testid":`tree-skeleton`,children:Array.from({length:8}).map((e,t)=>(0,L.jsx)(ye,{className:`h-5`,style:{width:`${60+t*13%30}%`}},t))}):(0,L.jsx)(I.Suspense,{fallback:(0,L.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(ot,{className:`size-3.5`}),(0,L.jsx)(`span`,{children:`Loading...`})]}),children:(0,L.jsx)(wJe,{files:xe,selectedPath:se,searchQuery:rt,editing:le?{path:le.path,isDraft:le.kind!==`rename`,initialValue:le.kind===`rename`?le.initialValue:void 0}:null,revealPath:de,onRevealHandled:Oe,pendingPaths:Fe,onSelect:Ce,onExpand:we,onContextMenu:Be,onSubmitEdit:Qe,onCancelEdit:$e,onDragDrop:l?We:void 0,height:te,className:DU(s)})})}),j&&(0,Pn.createPortal)((0,L.jsxs)(`div`,{ref:oe,role:`menu`,className:`fixed z-50 min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md`,style:{left:j.x,top:j.y},children:[l&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Se,{type:`button`,role:`menuitem`,variant:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:qe,children:`New file`}),(0,L.jsx)(Se,{type:`button`,role:`menuitem`,variant:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:Ye,children:`New folder`})]}),!j.isBackground&&(0,L.jsxs)(L.Fragment,{children:[l&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Se,{type:`button`,role:`menuitem`,variant:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:Ze,children:`Rename`}),(0,L.jsx)(Se,{type:`button`,role:`menuitem`,variant:`ghost`,size:`sm`,className:`w-full justify-start text-destructive hover:bg-destructive/10 hover:text-destructive`,onClick:()=>{ae(j.node),M(null)},children:`Delete`})]}),(0,L.jsx)(Se,{type:`button`,role:`menuitem`,variant:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:et,children:`Copy path`}),N?.enabled?(0,L.jsx)(Se,{type:`button`,role:`menuitem`,variant:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:tt,children:`Copy Git URL`}):N?.reason?(0,L.jsx)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,"aria-live":`polite`,children:N.reason}):null]})]}),document.body),(0,L.jsx)(Ve,{open:re!==null,onOpenChange:e=>{e||ae(null)},children:(0,L.jsxs)(ge,{children:[(0,L.jsxs)(be,{children:[(0,L.jsxs)(Le,{children:[`Delete `,re?.name,`?`]}),(0,L.jsx)(Ue,{children:`This action cannot be undone.`})]}),(0,L.jsxs)(Xe,{children:[(0,L.jsx)(je,{children:`Cancel`}),(0,L.jsx)(Je,{onClick:nt,children:`Delete`})]})]})})]})}function HU({params:e,rootDir:t=`.`,searchQuery:n,panelApi:r,bridge:i,api:a,chromeless:o=!1,filesystem:s=`user`,access:c=`readwrite`,roots:l,className:u}){let d=e?.rootDir??t,f=e?.bridge??i,p=e?.chromeless??o,m=e?.filesystem??s,h=e?.access??c,g=e?.roots??l,_=e?.revealFileTreeRequest??null,v=e?.searchQuery??e?.query??n,y=r??a,[b,x]=(0,I.useState)(``),[S,C]=(0,I.useState)(``),w=(0,I.useMemo)(()=>g?.length?g:[{filesystem:m,label:m===`user`?`Workspace`:m,rootDir:m===`user`?d:`/`,access:h}],[h,m,d,g]),[E,D]=(0,I.useState)(w[0]?.filesystem??`user`);(0,I.useEffect)(()=>{let e=w.some(e=>e.filesystem===m)?m:w[0]?.filesystem??`user`;D(e)},[m,w]);let O=w.find(e=>e.filesystem===E)??w[0],k=O?.filesystem??`user`,A=O?.rootDir??(k===`user`?d:`/`),ee=O?.access??h,te=(0,I.useRef)(void 0);(0,I.useEffect)(()=>(clearTimeout(te.current),te.current=setTimeout(()=>C(b),200),()=>clearTimeout(te.current)),[b]);let ne=v===void 0?S||void 0:v||void 0;return p?(0,L.jsx)(VU,{rootDir:A,searchQuery:ne,bridge:f,filesystem:k,access:ee,revealFileTreeRequest:_,className:DU(`px-1 pt-1 [&_[role=treeitem]]:!indent-0`,u)},`${k}:${A}`):(0,L.jsx)(MU,{title:`Files`,panelApi:y,children:(0,L.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,L.jsxs)(`div`,{className:`space-y-1.5 border-b border-border px-2 py-1.5`,children:[w.length>1&&(0,L.jsxs)(tt,{value:k,onValueChange:e=>D(e),children:[(0,L.jsx)(Ke,{size:`sm`,className:`h-7 w-full text-xs`,"aria-label":`File root`,children:(0,L.jsx)(Be,{})}),(0,L.jsx)(Ce,{children:w.map(e=>(0,L.jsx)(Ee,{value:e.filesystem,className:`text-xs`,children:e.label},e.filesystem))})]}),(0,L.jsx)(T,{placeholder:O?.searchPlaceholder??`Search files...`,value:v??b,onChange:e=>x(e.target.value),className:`h-7 text-xs`,"aria-label":`Search files`})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,L.jsx)(VU,{rootDir:A,searchQuery:ne,bridge:f,filesystem:k,access:ee,revealFileTreeRequest:_,className:u},`${k}:${A}`)})]})})}function OJe(e){return e.split(`/`).pop()??e}function kJe(){return(0,I.useEffect)(()=>{let e=lc.on(eu.moved,({filesystem:e,from:t,to:n,...r})=>{let i=ba(e);lc.emit(nc.panelUpdate,{...r,match:[{id:`file:${Sa({filesystem:i,path:t})}`},{params:{path:t,filesystem:i}}],params:{path:n,filesystem:i},title:OJe(n)})}),t=lc.on(eu.deleted,({filesystem:e,path:t,...n})=>{let r=ba(e);lc.emit(nc.panelClose,{...n,match:[{id:`file:${Sa({filesystem:r,path:t})}`},{params:{path:t,filesystem:r}},{paramPrefix:`path`,value:`${t}/`,params:{filesystem:r}}]})});return()=>{e(),t()}},[]),null}var AJe=new Set([`write`,`edit`,`unlink`,`rename`,`mkdir`]);function jJe(e){if(typeof e!=`object`||!e)return null;let t=e;if(t.type!==`data-file-changed`)return null;let n=t.data;if(typeof n!=`object`||!n)return null;let r=n;return typeof r.op!=`string`||!AJe.has(r.op)||typeof r.path!=`string`||r.path.length===0||typeof r.toolCallId!=`string`||r.toolCallId.length===0||r.oldPath!==void 0&&(typeof r.oldPath!=`string`||r.oldPath.length===0)?null:r}function UU(e){let t=jJe(e);if(!t)return;let n=ic(t.toolCallId);switch(t.op){case`rename`:t.oldPath&&lc.emit(eu.moved,{...n,from:t.oldPath,to:t.path});return;case`unlink`:lc.emit(eu.deleted,{...n,path:t.path});return;case`mkdir`:lc.emit(eu.created,{...n,path:t.path,kind:`dir`});return;case`write`:t.existsBefore===!1?lc.emit(eu.created,{...n,path:t.path,kind:`file`}):lc.emit(eu.changed,{...n,path:t.path});return;case`edit`:lc.emit(eu.changed,{...n,path:t.path});return}}function WU(e,t={}){let{skip:n,filesOnly:r=!0}=t;oc(eu.created,t=>{t.cause===`agent`&&(r&&t.kind!==`file`||n?.(t.path)||e(t.path))})}function MJe(e){return lc.on(eu.changed,e)}function NJe(){return(0,I.useEffect)(()=>lc.on(nc.agentData,({part:e})=>{UU(e)}),[]),WU(e=>{dc({kind:`openFile`,params:{path:e}})}),null}var PJe=250,FJe=3e3,IJe=3e4;function GU(e,t){let{adapter:n,panelId:r,onDirtyChange:i,serverMtime:a}=t,[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(!1),[m,h]=(0,I.useState)(!1),g=(0,I.useRef)(void 0),_=(0,I.useRef)(null),v=(0,I.useRef)(0),y=(0,I.useRef)(null),b=(0,I.useRef)(0),x=(0,I.useRef)(void 0),S=(0,I.useRef)(i);S.current=i;let C=(0,I.useRef)(n);C.current=n;let w=(0,I.useCallback)(async()=>{let t=C.current;if(!t||!e||!t.isDirty())return;if(_.current)return _.current;let n=b.current,i=null;return i=(async()=>{l(!0),lc.emit(nc.editorSaveStart,{panelId:r});let a,o=new Promise(e=>{a=setTimeout(()=>e(`timeout`),IJe)});try{let r=await Promise.race([t.save().then(()=>`saved`),o]);if(b.current!==n)return;r===`saved`&&(v.current=Date.now(),d(Date.now()),s(!1),S.current?.(e,!1))}catch{if(b.current!==n)return}finally{if(a&&clearTimeout(a),_.current===i&&(_.current=null),b.current!==n)return;lc.emit(nc.editorSaveEnd,{panelId:r}),l(!1)}})(),_.current=i,i},[e,r]),T=(0,I.useCallback)(()=>{clearTimeout(g.current),g.current=setTimeout(w,PJe)},[w]),E=(0,I.useCallback)(()=>{e&&(s(!0),S.current?.(e,!0),T())},[e,T]),D=(0,I.useCallback)(()=>{clearTimeout(g.current),s(!1),h(!1),e&&S.current?.(e,!1)},[e]),O=(0,I.useCallback)(async()=>{if(clearTimeout(g.current),_.current)return _.current;if(C.current?.isDirty())return w()},[w]),k=(0,I.useCallback)(()=>p(!1),[]),A=(0,I.useCallback)(()=>h(!1),[]),ee=(0,I.useCallback)(e=>{y.current=e,h(!1)},[]);return(0,I.useEffect)(()=>{if(!(a==null||!e)){if(y.current===null){y.current=a;return}if(a!==y.current){if(Date.now()-v.current<FJe){y.current=a;return}y.current=a,o?h(!0):p(!0)}}},[a,e,o]),(0,I.useEffect)(()=>{if(x.current===void 0){x.current=e;return}x.current!==e&&(x.current=e,b.current+=1,clearTimeout(g.current),_.current&&lc.emit(nc.editorSaveEnd,{panelId:r}),_.current=null,y.current=null,v.current=0,s(!1),l(!1),p(!1),h(!1))},[e]),(0,I.useEffect)(()=>()=>clearTimeout(g.current),[]),{isDirty:o,isSaving:c,lastSavedAt:u,markDirty:E,markClean:D,flushSave:O,shouldSync:f,ackSync:k,externalChangeWhileDirty:m,ackExternalChange:A,notifySaved:ee}}function KU(e){return typeof window>`u`?!1:window.innerWidth<e}function qU(e=1024){let[t,n]=(0,I.useState)(()=>KU(e));return(0,I.useEffect)(()=>{let t=()=>{n(KU(e))};return t(),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t)}},[e]),t}function JU({isNarrowViewport:e,isCollapsed:t,setCollapsed:n}){let r=(0,I.useRef)(t),i=(0,I.useRef)(!1),a=(0,I.useRef)(null);return(0,I.useEffect)(()=>{r.current=t},[t]),(0,I.useEffect)(()=>{let t=a.current,o=t!==!0&&e,s=t===!0&&!e;if(a.current=e,e&&o&&!r.current){i.current=!0,n(!0);return}s&&i.current&&(i.current=!1,n(!1))},[e,n]),(0,I.useCallback)(()=>{i.current=!1},[])}function LJe(e){let[t,n]=(0,I.useState)([]),r=(0,I.useRef)(t);return r.current=t,(0,I.useEffect)(()=>{if(!e){n([]);return}function t(){try{let t=e.toJSON(),i=[];if(t&&typeof t==`object`&&`panels`in t){let e=t;if(e.panels)for(let[,t]of Object.entries(e.panels))t.id&&i.push({id:t.id,component:t.contentComponent??t.id,params:t.params})}let a=r.current;(a.length!==i.length||a.some((e,t)=>e.id!==i[t]?.id))&&n(i)}catch{}}t();let i=setInterval(t,500);return()=>clearInterval(i)},[e]),{panels:t,open:(0,I.useCallback)(t=>{e?.addPanel(`artifacts`,{id:t.id,component:t.component,params:t.params})},[e]),close:(0,I.useCallback)(t=>{e?.removePanel(t)},[e]),activate:(0,I.useCallback)(t=>{e?.activatePanel(t)},[e]),isOpen:(0,I.useCallback)(e=>r.current.some(t=>t.id===e),[])}}function RJe(e,t={}){let n=t.toolPanelMap??{},r=(0,I.useCallback)(e=>n[e],[n]);return{openForTool:(0,I.useCallback)((t,r)=>{let i=n[t];if(!i)return;let a=`artifact-${r.path}`;e.isOpen(a)?e.activate(a):e.open({id:a,component:i,params:r})},[n,e]),resolvePanel:r}}function zJe(e,t){let n=e.metaKey||e.ctrlKey;if(t.mod&&!n||!t.mod&&n||t.shift&&!e.shiftKey||!t.shift&&e.shiftKey)return!1;let r=t.key.toLowerCase(),i=e.key.toLowerCase(),a=e.code.toLowerCase();return i===r||a===r||a===`key${r}`}function BJe(e){return e instanceof HTMLElement?e.isContentEditable||e.closest(`[contenteditable='true'], [contenteditable=''], [contenteditable='plaintext-only']`)||e.closest(`[role='textbox'], [role='searchbox'], [role='combobox']`)?!0:!!e.closest(`input, textarea, select`):!1}function YU({shortcuts:e,enabled:t=!0}){let n=(0,I.useRef)(e);n.current=e,(0,I.useEffect)(()=>{if(!t)return;function e(e){let t=BJe(e.target);for(let r of n.current)if(!(t&&!r.allowInEditable)&&zJe(e,r)){e.preventDefault(),e.stopPropagation(),r.handler();return}}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t])}function VJe(e){let t=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent),n=[];return e.mod&&n.push(t?`⌘`:`Ctrl`),e.shift&&n.push(t?`⇧`:`Shift`),n.push({"\\":`\\`,p:`P`,b:`B`,s:`S`,w:`W`}[e.key]??e.key.toUpperCase()),n.join(t?``:`+`)}var HJe=0;function XU(e){let{path:t,panelId:n,initialContent:r=null,createIfMissing:i}=e,a=ba(e.filesystem),o=/\S/.test(t)?t:null,s=o?Sa({filesystem:a,path:o}):null,c=(0,I.useRef)(n??`file-pane:${HJe++}`),l=n??c.current,{data:u,isLoading:d,error:f,refetch:p}=ed(o,i===void 0?{filesystem:a}:{filesystem:a,createIfMissing:i}),m=u?.access===`readonly`,{mutateAsync:h}=rd(),[g,_]=(0,I.useState)(r),v=(0,I.useRef)(``),y=(0,I.useRef)(!1),b=(0,I.useRef)(null),x=(0,I.useRef)(null),S=(0,I.useRef)(null),C=(0,I.useRef)(null),w=(0,I.useRef)(0),[T,E]=(0,I.useState)(null);(0,I.useEffect)(()=>{(b.current!==t||x.current!==s)&&(_(r),v.current=r??``,y.current=!1,S.current=null,w.current+=1,E(null),b.current=t,x.current=s)},[t,s,r]),(0,I.useEffect)(()=>{u?.content!=null&&g===null&&(_(u.content),v.current=u.content,S.current=u.mtimeMs??null)},[u,g]);let D=o&&g!=null&&!m?{isDirty:()=>y.current,save:async()=>{let e=++w.current;try{let t=await h({filesystem:a,path:o,content:v.current,expectedMtimeMs:S.current??void 0});if(w.current!==e)return;typeof t.mtimeMs==`number`&&(S.current=t.mtimeMs,C.current?.(t.mtimeMs)),y.current=!1,E(null)}catch(t){throw w.current===e&&t instanceof Ql?(typeof t.currentMtimeMs==`number`&&(S.current=t.currentMtimeMs),E(t),t):t}},getContent:()=>v.current}:null,O=GU(s,{adapter:D,panelId:l,serverMtime:u?.mtimeMs??null});C.current=O.notifySaved,(0,I.useEffect)(()=>{if(!(!O.shouldSync||u?.content==null)){if(y.current){O.ackSync();return}_(u.content),v.current=u.content,S.current=u.mtimeMs??null,y.current=!1,O.ackSync()}},[O.shouldSync,O,u,_]),(0,I.useEffect)(()=>{m||!O.externalChangeWhileDirty||u?.mtimeMs==null||(E(new Ql(o??t,u.mtimeMs,S.current)),S.current=u.mtimeMs,O.ackExternalChange())},[o,m,O.externalChangeWhileDirty,O,u,t]);let k=o?o.split(`/`).pop()??o:``,[A,ee]=(0,I.useState)(``);(0,I.useEffect)(()=>{let e=k?!m&&O.isDirty?`${k} ●`:k:``;ee(e)},[k,m,O.isDirty]);let te=(0,I.useCallback)(e=>{m||(_(e),v.current=e,y.current=!0,O.markDirty())},[m,_,O]),ne=(0,I.useCallback)(async()=>{if(!o)return;let e=await p();if(e.status!==`success`||e.data==null)return;let t=e.data;_(t.content),v.current=t.content,S.current=t.mtimeMs??null,y.current=!1,O.markClean(),typeof t.mtimeMs==`number`&&C.current?.(t.mtimeMs),E(null)},[o,O,p,_]),j=(0,I.useCallback)(async()=>{if(m)return;let e=++w.current;try{if(!o)return;let t=v.current,n=await h({filesystem:a,path:o,content:t});if(w.current!==e)return;typeof n.mtimeMs==`number`&&(S.current=n.mtimeMs,C.current?.(n.mtimeMs)),y.current=!1,E(null)}catch{}},[o,a,m,h]),M=(0,I.useCallback)(async()=>{m||!D||!y.current||await D.save()},[D,m]),N=(0,I.useCallback)(async()=>{m||await O.flushSave()},[m,O]);return{isLoading:d,error:f,content:g,isDirty:!m&&O.isDirty,isReadonly:m,conflict:m?null:T,onReloadFromServer:ne,onOverwrite:j,setContent:te,save:M,flushSave:N,fileName:k,tabTitle:A}}function UJe({conflict:e,onReload:t,onOverwrite:n}){return(0,L.jsx)(u,{role:`alert`,tone:`accent`,className:`rounded-none border-x-0 border-t-0`,description:(0,L.jsx)(L.Fragment,{children:`This file has been modified outside the editor. Your unsaved changes will be lost if you reload, or will overwrite the latest version on disk if you save.`}),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Se,{type:`button`,variant:`outline`,size:`xs`,onClick:()=>void t(),children:`Reload`}),(0,L.jsx)(Se,{type:`button`,variant:`destructive`,size:`xs`,onClick:()=>void n(),children:`Overwrite`}),(0,L.jsx)(`span`,{className:`sr-only`,children:e.path})]})})}function WJe(e,t){return e!==void 0&&e!==`user`&&(t===403||t===404)}function ZU(e,t,n){return WJe(e,t)?`not found or denied`:n}function QU({path:e,content:t,isLoading:n,error:r,conflict:i,readOnly:a=!1,onChange:o,onReload:s,onOverwrite:c,editorComponent:l,editorProps:u={},loadingFallback:d,errorMessage:p,filesystem:m,className:h}){if(!/\S/.test(e))return(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,L.jsx)(lt,{className:`min-h-0 border-0`,title:`No file selected`,description:`Choose a file from the file tree to open an editor.`})});if(r){let e=r instanceof Zl?ZU(m,r.status,r.message):r.message;return(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,L.jsx)(f,{title:`Failed to load file`,description:p??e})})}let g=d??(0,L.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(ot,{className:`size-3.5`}),(0,L.jsx)(`span`,{children:`Loading file...`})]});return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col ${h??``}`,children:[a&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border bg-muted/40 px-3 py-1.5 text-xs text-muted-foreground`,role:`status`,children:[(0,L.jsx)(`span`,{className:`rounded-sm border border-border bg-background px-1.5 py-0.5 font-medium text-foreground`,children:`Readonly`}),(0,L.jsx)(`span`,{children:m===`company_context`?`Company context is policy-filtered and cannot be edited here.`:`This file is readonly.`})]}),!a&&i&&(0,L.jsx)(UJe,{conflict:i,onReload:s,onOverwrite:c}),(0,L.jsx)(I.Suspense,{fallback:g,children:n||t===null?g:(0,L.jsx)(l,{content:t,className:u.className,...u,onChange:a?()=>{}:o,readOnly:a})})]})}var $U=[],eW=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?eW:$U).push(n+=e[t])})();function GJe(e){if(e<768)return!1;for(let t=0,n=$U.length;;){let r=t+n>>1;if(e<$U[r])n=r;else if(e>=eW[r])t=r+1;else return!0;if(t==n)return!1}}function tW(e){return e>=127462&&e<=127487}var nW=8205;function KJe(e,t,n=!0,r=!0){return(n?rW:qJe)(e,t,r)}function rW(e,t,n){if(t==e.length)return t;t&&aW(e.charCodeAt(t))&&oW(e.charCodeAt(t-1))&&t--;let r=iW(e,t);for(t+=sW(r);t<e.length;){let i=iW(e,t);if(r==nW||i==nW||n&&GJe(i))t+=sW(i),r=i;else if(tW(i)){let n=0,r=t-2;for(;r>=0&&tW(iW(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function qJe(e,t,n){for(;t>1;){let r=rW(e,t-2,n);if(r<t)return r;t--}return 0}function iW(e,t){let n=e.charCodeAt(t);if(!oW(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return aW(r)?(n-55296<<10)+(r-56320)+65536:n}function aW(e){return e>=56320&&e<57344}function oW(e){return e>=55296&&e<56320}function sW(e){return e<65536?1:2}var cW=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=gW(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),uW.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=gW(this,e,t);let n=[];return this.decompose(e,t,n,0),uW.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new pW(this),i=new pW(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new pW(this,e)}iterRange(e,t=this.length){return new mW(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new hW(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new lW(t):uW.from(lW.split(t,[]))}},lW=class e extends cW{constructor(e,t=JJe(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new YJe(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(fW(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=dW(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=gW(this,t,n);let i=dW(this.text,dW(r.text,fW(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):uW.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
639
+ `),s=e.value.length>0&&XUe(e,t),c=o||s,l=c?JUe:0,u=c?e.scrollHeight+l:a,d=Math.min(u,qz);e.style.height=`${d}px`,e.style.overflowY=u>qz?`auto`:`hidden`;let f=e.closest(`[data-boring-agent-part="composer-rail"]`),p=c?Math.max(Kz,d+YUe):Kz;f?.style.setProperty(`--composer-input-group-height`,`${p}px`),f?.setAttribute(`data-composer-multiline`,p>Kz?`true`:`false`)},[]);return(0,I.useLayoutEffect)(()=>{we(_e.current)},[ge,we,_e]),(0,L.jsxs)(`div`,{className:R(`relative z-20`,e?`px-4 pb-4 pt-2 sm:px-6 sm:pb-5`:`px-3 pb-2 pt-1`),children:[(0,L.jsx)(`div`,{"data-boring-agent-part":`chat-working-slot`,className:R(`mx-auto w-full overflow-hidden transition-[margin,max-height,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]`,e?`max-w-3xl`:`max-w-[680px]`,t?`mb-2 max-h-8 opacity-100`:`mb-0 max-h-0 opacity-0`),"aria-hidden":!t,children:(0,L.jsxs)(`div`,{"data-testid":t?`chat-working`:void 0,role:t?`status`:void 0,"aria-live":t?`polite`:void 0,className:`inline-flex items-center gap-2 rounded-full border border-border/50 bg-background/85 px-2.5 py-1 text-[12px] text-muted-foreground/75 shadow-sm backdrop-blur`,children:[(0,L.jsx)(pz.span,{"aria-hidden":`true`,className:`inline-block size-1.5 rounded-full bg-[color:var(--accent)]`,animate:{opacity:[.35,1,.35]},transition:{duration:1.2,repeat:1/0,ease:`easeInOut`}}),(0,L.jsx)(`span`,{children:`Working…`})]})}),l?(0,L.jsx)(nde,{notice:l}):null,o&&!u?(0,L.jsx)(ide,{blocker:d,label:s,onAction:f}):null,p.length>0?(0,L.jsx)(ode,{followUps:p,onEdit:m}):null,h?(0,L.jsx)(TUe,{state:g,onDismiss:_,onRetry:v}):null,(0,L.jsx)(EUe,{state:y,onDismiss:b}),x?(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:qv(`info`,`mx-auto mb-2 w-full max-w-3xl text-xs`),children:x}):null,(0,L.jsxs)(`div`,{className:R(`mx-auto w-full`,e?`max-w-3xl`:`max-w-[680px]`),children:[C?(0,L.jsx)(_se,{mention:C,apiBaseUrl:T,fetch:E,requestHeaders:D,storageScope:O,onSelect:k,onDismiss:A}):null,w===null?null:(0,L.jsx)(WUe,{query:w,commands:ee,onSelect:te,onDismiss:ne}),C===null&&w===null&&j?(0,L.jsx)(Rz,{value:M,onChange:oe,options:N,disabled:t||re,hideDefaultOption:ie,onClose:()=>se(!1)}):null,C===null&&w===null&&le?(0,L.jsx)(PUe,{value:ue,onChange:pe,disabled:t||fe,onClose:()=>me(!1)}):null]}),(0,L.jsx)(`div`,{"data-boring-agent-part":`composer-rail`,"data-composer-multiline":`false`,style:{"--composer-input-group-height":`${Kz}px`},className:R(`relative mx-auto w-full overflow-visible rounded-[28px]`,e?`max-w-3xl bg-transparent shadow-[0_1px_2px_-1px_oklch(0_0_0/0.06),0_6px_18px_-12px_oklch(0_0_0/0.12),inset_0_0_0_1px_oklch(from_var(--border)_l_c_h/0.7)] focus-within:shadow-[0_1px_3px_-1px_oklch(0_0_0/0.08),0_10px_28px_-14px_oklch(0_0_0/0.16),inset_0_0_0_1px_oklch(from_var(--accent)_l_c_h/0.45)]`:`max-w-[680px] bg-transparent shadow-[inset_0_0_0_1px_oklch(from_var(--border)_l_c_h/0.7)] focus-within:shadow-[inset_0_0_0_1px_oklch(from_var(--accent)_l_c_h/0.45)]`,`transition-shadow duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]`,`[&_[data-slot=input-group]]:!h-auto [&_[data-slot=input-group]]:!min-h-[var(--composer-input-group-height)]`,`[&_[data-slot=input-group]]:!flex-col [&_[data-slot=input-group]]:!items-stretch [&_[data-slot=input-group]]:!overflow-hidden`,`[&_[data-slot=input-group]]:!border-0 [&_[data-slot=input-group]]:!rounded-[28px]`,`[&_[data-slot=input-group]]:!bg-transparent [&_[data-slot=input-group]]:!shadow-none`,`[&_[data-slot=input-group]]:dark:!bg-transparent [&_[data-slot=input-group]]:!ring-0`,`[&_[data-slot=input-group]]:has-[:focus]:!ring-0`,`[&[data-composer-multiline=true]_[data-boring-agent-part=composer-submit-addon]]:self-end`,`[&[data-composer-multiline=true]_[data-boring-agent-part=composer-submit-addon]]:mb-2`),children:(0,L.jsxs)(VUe,{"data-boring-state":n,onSubmit:e=>be({text:e.text,files:e.files}),onUploadFile:Ce,multiple:!0,maxFiles:r||t?0:Gz,maxFileSize:qUe,onError:e=>{e.code===`max_files`?S(`Up to ${Gz} attachments per message.`):e.code===`max_file_size`?S(`Files must be under 4 MB each.`):e.code===`accept`?S(`That file type isn't supported here.`):S(e.message||`Attachment rejected.`)},children:[(0,L.jsx)(KUe,{}),(0,L.jsxs)(`div`,{"data-boring-agent-part":`composer-input-row`,className:`flex min-h-[var(--composer-input-group-height)] w-full items-center`,children:[(0,L.jsx)(`div`,{className:`flex h-14 shrink-0 items-center pl-2`,children:(0,L.jsx)(GUe,{disabled:r||t})}),(0,L.jsx)(HUe,{value:ge,placeholder:o?u?s:``:c??`Ask anything…`,disabled:r,readOnly:o,"aria-label":`Agent prompt`,ref:e=>{_e.current=e,we(e)},onChange:ve,onKeyDown:ye,style:{fieldSizing:`fixed`},className:R(`min-w-0 flex-1 !min-h-10 !max-h-40 resize-none overflow-hidden border-0 bg-transparent shadow-none`,`[field-sizing:fixed]`,`px-2 py-2 text-[13px] leading-6`,`placeholder:text-muted-foreground/45`,`focus-visible:ring-0 focus-visible:ring-offset-0`)}),(0,L.jsx)(BUe,{align:`inline-end`,"data-boring-agent-part":`composer-submit-addon`,className:`!order-none !w-auto shrink-0 self-center justify-between border-0 bg-transparent !px-2 !py-0`,children:(0,L.jsx)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:(0,L.jsx)(UUe,{"data-boring-agent-part":`composer-submit`,status:i,onStop:xe,disabled:a,className:R(`h-8 w-8 shrink-0 rounded-full`,`bg-foreground`,`text-background`,`transition-all duration-150 ease-[cubic-bezier(0.22,1,0.36,1)]`,`hover:bg-foreground/90 hover:shadow-[0_0_0_3px_oklch(from_var(--foreground)_l_c_h/0.12)] hover:scale-[1.04]`,`active:scale-[0.93] active:brightness-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/20`,`disabled:pointer-events-none disabled:opacity-40`,`[&>svg]:size-3.5`)})})})]})]})}),ae?null:(0,L.jsxs)(`div`,{"data-boring-agent-part":`composer-settings-row`,className:R(`mx-auto mt-1.5 flex w-full items-center justify-center gap-1.5 text-[10.5px] text-muted-foreground/45`,e?`max-w-3xl`:`max-w-[680px]`),children:[(0,L.jsx)(Lz,{value:M,options:N,disabled:t||re,trigger:`slash`,open:j,onClick:()=>{if(j){se(!1);return}ce()}}),de?(0,L.jsx)(NUe,{value:ue,disabled:t||fe,trigger:`slash`,open:le,onClick:()=>{if(le){me(!1);return}he()}}):null]})]})}function QUe(e,t){if(e)return e[t]??Object.entries(e).find(([e])=>e.toLowerCase()===t.toLowerCase())?.[1]}function $Ue({sessionId:e,workspaceId:t,storageScope:n,apiBaseUrl:r,requestHeaders:i,fetch:a,createRemoteSession:o,remoteSessionOptions:s}){let[c,l]=(0,I.useState)(),u=(0,I.useRef)(s);return u.current=s,(0,I.useEffect)(()=>{if(!e){l(void 0);return}let s=(o??lv)({...u.current,sessionId:e,workspaceId:t,storageScope:n,apiBaseUrl:r,headers:i,fetch:a});return l(s),()=>s.dispose()},[r,o,a,(0,I.useMemo)(()=>tWe(s),[s]),i,e,n,t]),c}var Jz=new WeakMap,eWe=0;function Yz(e){if(typeof e!=`object`&&typeof e!=`function`||e===null)return;let t=e,n=Jz.get(t);return n||(n=++eWe,Jz.set(t,n)),String(n)}function tWe(e){return e?JSON.stringify({autoStart:e.autoStart,requestTimeoutMs:e.requestTimeoutMs,onEvent:Yz(e.onEvent),storeOptions:Yz(e.storeOptions),setTimeoutFn:Yz(e.setTimeoutFn),clearTimeoutFn:Yz(e.clearTimeoutFn),reconnect:e.reconnect?{baseMs:e.reconnect.baseMs,maxMs:e.reconnect.maxMs,jitterRatio:e.reconnect.jitterRatio,random:Yz(e.reconnect.random)}:void 0,debug:e.debug?{largeStateWarningBytes:e.debug.largeStateWarningBytes,largeStateWarningMessages:e.debug.largeStateWarningMessages,onWarning:Yz(e.debug.onWarning)}:void 0}):`{}`}function nWe(e){return(0,I.useSyncExternalStore)((0,I.useCallback)(t=>e?.subscribe(t)??(()=>{}),[e]),(0,I.useCallback)(()=>e?.getState(),[e]),(0,I.useCallback)(()=>e?.getState(),[e]))}function rWe(e){return JSON.stringify(aWe(e).sort(([e],[t])=>e.localeCompare(t)))}function iWe(e){let t=JSON.parse(e);return t.length>0?Object.fromEntries(t):void 0}function aWe(e){return Object.entries(e??{}).filter(e=>typeof e[1]==`string`)}function oWe(e,t){return e?.status??(t?`hydrating`:`idle`)}function Xz(e,t){if(!e)return!0;let n=e.getState();return n.status===`idle`?t===void 0||n.lastSeq<t:!1}function Zz(e){return e===`submitted`||e===`streaming`||e===`aborting`}function sWe(e){return e===`submitted`||e===`hydrating`?`submitted`:e===`streaming`||e===`aborting`?`streaming`:e===`error`?`error`:`ready`}function cWe(e,t){let n=t.filter(e=>e.available),r=e.trim(),i=Number.parseInt(r,10);if(Number.isInteger(i)&&String(i)===r&&i>=1&&i<=n.length)return n[i-1]??null;let a=n.find(e=>`${e.provider}:${e.id}`===r||e.id===r);if(a)return a;let o=r.toLowerCase();return n.find(e=>{let t=e.label?.toLowerCase()??``,n=e.id.toLowerCase(),r=e.provider.toLowerCase();return t.includes(o)||n.includes(o)||`${r}:${n}`.includes(o)})??null}function lWe(e){let t=e.trim().toLowerCase();return t===`med`?`medium`:hd.find(e=>e===t)??null}function uWe(e){return e===`off`?`Off`:e===`low`?`Low`:e===`medium`?`Med`:`High`}function dWe(e){return{id:e.id,role:e.role===`system`?`assistant`:e.role,parts:e.parts.map(t=>t.type===`text`?{type:`text`,text:e.role===`user`?`[redacted user message]`:t.text}:t.type===`file`?{type:`file`,mediaType:t.mediaType??`application/octet-stream`,filename:t.filename?`[redacted attachment filename]`:void 0,url:t.url?`[redacted attachment url]`:``}:t.type===`reasoning`?{type:`reasoning`,text:`[redacted reasoning]`}:{type:`text`,text:t.type===`notice`?t.text:`[tool] ${t.toolName}`})}}function fWe(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.type!=`string`)return null;let n=typeof t.id==`string`?t.id:void 0,r=typeof t.revision==`number`?`revision ${t.revision}`:`updated`;switch(t.type){case`boring.plugin.load`:return{kind:`success`,diagnostic:{source:`browser front reload`,...n?{pluginId:n}:{},message:`front module loaded (${r})`}};case`boring.plugin.unload`:return{kind:`success`,diagnostic:{source:`browser front reload`,...n?{pluginId:n}:{},message:`front module unloaded (${r})`}};case`boring.plugin.error`:case`boring.plugin.front-error`:{let e=typeof t.message==`string`&&t.message.length>0?t.message:`browser front module failed to load`;return{kind:`error`,message:`Plugin front failed${n?` (${n})`:``}: ${e}. Previous live version was kept.`}}default:return null}}function pWe(e){let t=e.trim().split(/\r?\n/).find(e=>e.trim().length>0)?.trim()??``;return/^agent plugins reloaded\.?$/i.test(t)||/^agent plugins will reload on the next message\.?$/i.test(t)?null:e}function mWe(e){return e.type===`agent-end`}function Qz(e,t){return e instanceof Error&&e.message?e.message:t}var hWe=(0,I.lazy)(()=>P(()=>import(`./DebugDrawer-BXDxUqG6.js`).then(e=>({default:e.DebugDrawer})),__vite__mapDeps([283,1,282,284,285]))),gWe=[],_We=[],vWe=[],$z=`run-rejected`;function yWe({sessionId:e,extraCommands:t,apiBaseUrl:n,workspaceId:r,storageScope:i=`default`,requestHeaders:a,storage:o,fetch:s,className:c,chrome:l=!0,debug:u=!1,showSessions:d,hotReloadEnabled:f=!0,suggestions:p=yd,emptyState:m,emptyPlacement:h=`default`,composerPlaceholder:g,initialDraft:_,autoSubmitInitialDraft:v=!1,onDraftRestored:y,onAutoSubmitInitialDraftAccepted:b,onAutoSubmitInitialDraftSettled:x,model:S,defaultModel:C,availableModels:w,hideDefaultModelOption:T=!1,hideComposerSettings:E=!1,suppressPreSubmitCancelledWarning:D=!1,thinkingLevel:O,thinkingControl:k=!0,serverResourcesEnabled:A=!0,mentionedFiles:ee,commands:te=gWe,excludeBuiltinCommands:ne=_We,toolRenderers:j,createRemoteSession:M,remoteSessionOptions:N,hydrateMessages:re=!0,allowPromptDuringInitialHydration:ie=!1,workspaceWarmupStatus:ae,onSessionReset:oe,onBeforeSubmit:se,onReloadAgentPlugins:ce,onCommandResult:le,onComposerWarning:ue,onMentionedFilesConsumed:de,onPromptSubmitStarted:fe,onData:pe,onOpenArtifact:me,composerBlockers:he=vWe,onComposerStop:ge,onComposerBlockerAction:_e,onTurnComplete:ve,renderNoticeAction:ye}){let be=e?.trim()||void 0,xe=d??be===void 0,Se=(0,I.useRef)(pe);Se.current=pe;let Ce=(0,I.useRef)(ve);Ce.current=ve;let we=(0,I.useRef)(void 0),Te=(0,I.useMemo)(()=>rWe(a),[a]),Ee=(0,I.useMemo)(()=>iWe(Te),[Te]),De=(0,I.useMemo)(()=>({...N,...re?{}:{autoStart:!1},onEvent:e=>{N?.onEvent?.(e),Se.current?.(e),e.type===`agent-end`&&!e.willRetry&&Ce.current?.(),mWe(e)&&we.current?.()}}),[re,N]),Oe=Ev({apiBaseUrl:n,workspaceId:r,storageScope:i,requestHeaders:a,storage:o,fetch:s,createRemoteSession:M,remoteSessionOptions:De,enabled:be===void 0});(0,I.useEffect)(()=>{if(be){we.current=void 0;return}let e=()=>{Oe.refresh({background:!0})};return we.current=e,()=>{we.current===e&&(we.current=void 0)}},[be,Oe.refresh]);let ke=$Ue({sessionId:be,workspaceId:r,storageScope:i,apiBaseUrl:n,requestHeaders:Ee,fetch:s,createRemoteSession:M,remoteSessionOptions:De}),Ae=be?ke:Oe.activePiSession,je=nWe(Ae),Me=be??Oe.activeSessionId,Ne=be?[]:Oe.sessions,Pe=!be&&Oe.loading,Fe=be?void 0:Oe.error,Ie=Me&&je?.sessionId!==Me?void 0:je,Le=Ie?Ae:void 0,Re=!!(Me&&je&&je.sessionId!==Me),ze=!!(Me&&!Ie),Be=A&&w===void 0,Ve=Zse({apiBaseUrl:n,defaultModel:C,fetch:s,requestHeaders:Ee,storage:o,storageScope:i,enabled:Be}),He=S===void 0?Ve.model:S,Ue=(0,I.useMemo)(()=>Jse(w??Ve.availableModels,He),[w,Ve.availableModels,He]),We=!Be||!!(He&&Ve.availableModels.some(e=>e.available&&e.provider===He.provider&&e.id===He.id)),Ge=Be&&!Ve.loaded,Ke=Be&&Ve.loaded&&!We,qe=!Ge&&!Ke,[Je,Ye]=(0,I.useState)(()=>k?Kg({storageScope:i,storage:o}).thinkingLevel:md),[Xe,Ze]=(0,I.useState)(()=>Kg({storageScope:i,storage:o}).showThoughts),[Qe,$e]=(0,I.useState)(()=>({storageScope:i,storage:o}));(0,I.useEffect)(()=>{let e=Kg({storageScope:i,storage:o});Ye(k?e.thinkingLevel:md),Ze(e.showThoughts),$e({storageScope:i,storage:o})},[o,i,k]);let et=Qe.storageScope===i&&Qe.storage===o;(0,I.useEffect)(()=>{k&&et&&Kse(Je,{storageScope:i,storage:o})},[et,o,i,Je,k]),(0,I.useEffect)(()=>{et&&qse(Xe,{storageScope:i,storage:o})},[et,Xe,o,i]);let tt=O??Je,nt=k||O!==void 0,[rt,it]=(0,I.useState)(!1),[at,ot]=(0,I.useState)(!1),[st,ct]=(0,I.useState)(()=>_??``),lt=(0,I.useRef)(st);lt.current=st;let P=(0,I.useRef)(new Gse),F=(0,I.useRef)(void 0),ut=(0,I.useRef)(void 0),dt=(0,I.useRef)(!1),ft=(0,I.useRef)(!1),pt=(0,I.useCallback)(e=>{let t=F.current;return!t||e&&t!==e?!1:(F.current=void 0,ut.current===t&&(ut.current=void 0),x?.(),!0)},[x]),mt=(0,I.useRef)(`idle`),ht=(0,I.useRef)(`idle`),gt=(0,I.useRef)(()=>{}),_t=(0,I.useRef)(null),[vt,yt]=(0,I.useState)([]),[bt,xt]=(0,I.useState)(()=>new Set),[St,Ct]=(0,I.useState)(null),[wt,Tt]=(0,I.useState)(null),Et=(0,I.useRef)(0),[Dt,Ot]=(0,I.useState)(0),[kt,At]=(0,I.useState)(),jt=(0,I.useRef)(void 0),{attachmentNotice:Mt,setAttachmentNotice:Nt}=ice(),Pt=(0,I.useCallback)(e=>{jt.current=e,At(e)},[]),Ft=(0,I.useCallback)(e=>{e&&jt.current!==e||(jt.current=void 0,At(void 0))},[]),It=(0,I.useMemo)(()=>{let e=new Set(ne),n=xd(Sd.filter(t=>!f&&t.name===`reload`?!1:!e.has(t.name)));for(let e of t??[])n.register(e);for(let e of te)n.register(e);return n},[n,te,ne,t,f,Ee,A,Dt,i]),Lt=(0,I.useMemo)(()=>It.list(),[It,nce({registry:It,requestHeaders:Ee,sessionId:Me??`default`,apiBaseUrl:n,fetch:s,storageScope:i,refreshKey:Dt,enabled:A})]),Rt=Ie?.sessionId,zt=ace(ae),Bt=oce(ae),Vt=!!zt,Ht=(0,I.useMemo)(()=>he.filter(e=>!e.sessionId||!Me||e.sessionId===Me),[Me,he]),Ut=Ie?xce(Ie):[],Wt=Ie?Sce(Ie):[],Gt=Ut,Kt=(0,I.useMemo)(()=>Wse(Ut),[Ut]),qt=oWe(Ie,Pe||Re||ze)===`hydrating`,Jt=h===`hero`&&Gt.length===0&&Wt.length===0&&!qt,Yt=Le?.getDebugState(),Xt=Vt||Ht.length>0,Zt=Ht[0],Qt=Vt?zt?.title??`Preparing workspace...`:Zt?.label??Zt?.reason??`Complete the pending workspace action to continue.`,$t=zt??Bt,en=(0,I.useMemo)(()=>{let e=Ie?Cce(Ie):[],t=Fe?[{id:`session-navigation-error`,level:`error`,text:Fe.message,dismissible:!0}]:[],n=u&&Yt?.largeStateWarning?[{id:`large-state-warning`,level:`warning`,text:`Large chat state: ${Yt.largeStateWarning.messageCount} messages, approximately ${Yt.largeStateWarning.approxBytes} bytes.`,dismissible:!0}]:[];return[...e,...t,...n,...vt].filter(e=>!bt.has(e.id))},[u,Yt?.largeStateWarning,bt,vt,Ie,Fe]),tn=(0,I.useCallback)(e=>{yt(t=>[...t.filter(t=>t.id!==e.id),e])},[]),nn=(0,I.useCallback)(e=>{xt(t=>new Set(t).add(e)),yt(t=>t.filter(t=>t.id!==e))},[]),rn=(0,I.useCallback)(e=>{xt(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),yt(t=>t.filter(t=>t.id!==e))},[]),an=(0,I.useCallback)(()=>{be||Oe.create().catch(e=>{tn({id:`session-create-error`,level:`error`,text:Qz(e,`Could not create a chat session.`),dismissible:!0})})},[tn,be,Oe.create]);(0,I.useEffect)(()=>{be||Pe||Fe||Me||Ne.length>0||dt.current||ft.current||(ft.current=!0,Oe.create().catch(e=>{ft.current=!1,tn({id:`session-auto-create-error`,level:`error`,text:Qz(e,`Could not create a chat session.`),dismissible:!0})}))},[Me,tn,be,Ne.length,Oe.create,Fe,Pe]),(0,I.useEffect)(()=>{(be||Fe||Me||Ne.length>0)&&(ft.current=!1)},[Me,be,Ne.length,Fe]);let on=(0,I.useCallback)(e=>{be||Oe.delete(e).catch(t=>{tn({id:`session-delete-error:${e}`,level:`error`,text:Qz(t,`Could not delete the chat session.`),dismissible:!0})})},[tn,be,Oe.delete]),sn=(0,I.useCallback)(()=>{let e=Me;if(be){oe?.();return}e&&(async()=>{dt.current=!0,await Oe.delete(e),await Oe.create(),await oe?.()})().catch(e=>{tn({id:`session-reset-error`,level:`error`,text:Qz(e,`Could not reset the chat session.`),dismissible:!0})}).finally(()=>{dt.current=!1})},[Me,tn,be,oe,Oe.create,Oe.delete]),cn=(0,I.useCallback)(async()=>{if(!ce)throw Error(`Agent plugin reload is not configured.`);return await ce()},[ce]),ln=(0,I.useCallback)(async()=>{Ct({kind:`running`});try{let e=await cn(),t=pWe(e);return t?(Ct({kind:`error`,message:t}),`Extension update failed: ${t}`):(Ct({kind:`success`,reloaded:!/will reload on the next message/i.test(e)}),Ot(e=>e+1),e)}catch(e){let t=Qz(e,`Extension reload failed.`);return Ct({kind:`error`,message:t}),`Extension update failed: ${t}`}},[cn]),un=(0,I.useCallback)(()=>Ct(null),[]),dn=(0,I.useCallback)(()=>Tt(null),[]);(0,I.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;if(!t||typeof t.message!=`string`)return;let n=t.tone,r=t.command??``;if(n===`error`)Tt({kind:`error`,command:r,message:t.message});else{let e=++Et.current;Tt({kind:`success`,command:r,detail:t.message,runId:e})}};return window.addEventListener(pd,e),()=>window.removeEventListener(pd,e)},[]),(0,I.useEffect)(()=>{if(!f||typeof window>`u`)return;let e=e=>{let t=fWe(e.detail);t&&(t.kind===`success`&&Ot(e=>e+1),Ct(e=>{if(!e)return e;if(t.kind===`error`)return{kind:`error`,message:t.message};if(e.kind===`error`)return e;let n=e.kind===`success`?e:{kind:`success`,reloaded:!0},r=n.frontEvents??[];return r.some(e=>e.pluginId===t.diagnostic.pluginId&&e.message===t.diagnostic.message)?n:{...n,frontEvents:[...r,t.diagnostic]}}))};return window.addEventListener(fd,e),()=>window.removeEventListener(fd,e)},[f]);let{mentionState:fn,slashQuery:pn,mentionedFiles:mn,clearMentionedFiles:hn,dismissMention:gn,dismissSlash:_n,handleComposerChange:vn,selectMention:yn,selectSlashCommand:bn}=Tse({textareaRef:_t}),xn=ee??mn,Sn=fse({userHistory:Kt,textareaRef:_t,disabled:fn!==null||pn!==null||rt||at}),Cn=(0,I.useCallback)((e,t=!0)=>{lt.current=e,ct(e),_t.current&&(_t.current.value=e,t&&_t.current.focus())},[]),wn=(0,I.useCallback)(e=>{ue?.(e),tn({id:`composer-warning:${Date.now()}`,level:`warning`,text:e,dismissible:!0})},[tn,ue]),Tn=(0,I.useCallback)(()=>Zz(ht.current)?(wn(`Model picker is unavailable while the agent is running.`),!1):S===void 0?(ot(!1),it(!0),!0):(wn(`Model selection is controlled by the host.`),!1),[S,wn]),En=(0,I.useCallback)(()=>Zz(ht.current)?(wn(`Thinking picker is unavailable while the agent is running.`),!1):!k||O!==void 0?(wn(`Thinking level is controlled by the host.`),!1):(it(!1),ot(!0),!0),[k,O,wn]),Dn=(0,I.useCallback)(e=>{if(S!==void 0)return`Model selection is controlled by the host.`;let t=cWe(e,Ue);return t?(Ve.setModel(t),`Model set to ${t.label??t.id}.`):`No model matched "${e}".`},[S,Ve,Ue]),On=(0,I.useCallback)(e=>{if(!k||O!==void 0)return`Thinking level is controlled by the host.`;let t=lWe(e);return t?(Ye(t),`Thinking set to ${uWe(t)}.`):`No thinking level matched "${e}".`},[k,O]),kn=(0,I.useCallback)(e=>{if(e===`model`){_n(),Tn()&&Cn(``);return}if(e===`thinking`||e===`think`){_n(),En()&&Cn(``);return}bn(e)},[_n,bn,Tn,En,Cn]),An=(0,I.useMemo)(()=>{if(!(!Le||!Rt||!qe))return Hse({session:{getState:()=>{let e=Le.getState();return jt.current===Rt&&e.status===`idle`?{...e,status:`submitted`}:e},prompt:Le.prompt.bind(Le),followUp:Le.followUp.bind(Le),clearQueue:Le.clearQueue.bind(Le),interrupt:Le.interrupt.bind(Le),stop:Le.stop.bind(Le)},registry:It,slashContext:{sessionId:Rt,clearMessages:()=>tn({id:`clear-not-supported`,level:`info`,text:`/clear is not available in this chat panel.`,dismissible:!0}),resetSession:sn,listCommands:()=>It.list(),reloadAgentPlugins:cn,pluginUpdate:{run:ln},openModelPicker:Tn,selectComposerModel:Dn,openThinkingPicker:En,selectComposerThinking:On},model:He,thinkingLevel:tt,thinkingControl:nt,composerBlocked:Xt,blockerMessage:Qt,mentionedFiles:xn,getDraft:()=>lt.current,onDraftChange:Cn,allowPromptDuringInitialHydration:ie,onPromptSubmitStarted:()=>{Pt(Rt)},onBeforeSubmit:se?async(e,t)=>await se(e,{...t,sessionId:Rt,source:t.source??`composer`})!==!1:void 0,onCommandResult:e=>{le?.(e),tn({id:`command:${Date.now()}`,level:`info`,text:e,dismissible:!0})},onWarning:e=>{D&&e===`Submit was cancelled before sending.`||(ue?.(e),tn({id:`composer-warning:${Date.now()}`,level:`warning`,text:e,dismissible:!0}))},onMentionedFilesConsumed:()=>{hn(),de?.()}})},[Rt,tn,ie,hn,Xt,Qt,xn,Pt,se,le,ue,de,fe,Tn,En,It,cn,sn,ln,Dn,On,He,Le,tt,qe,Cn,nt,D]),jn=(0,I.useCallback)(e=>{let t=sue(e);rn($z),tn({id:$z,level:`error`,text:Qz(e,`Could not send your message.`),dismissible:!0,...t?{errorCode:t}:{}})},[tn,rn]),Mn=(0,I.useCallback)(async({text:e,files:t,source:n=`composer`})=>{if(!An)return tn({id:`composer-no-session`,level:`warning`,text:`Create or select a chat session before sending.`,dismissible:!0}),!1;let r=e,i=()=>{lt.current===``&&Cn(r)};Cn(``,!1),gt.current();try{let r=await An.submit({text:e,files:t,source:n});if(r.preserveDraft)return i(),!1;(r.type===`prompt`||r.type===`followup`)&&rn($z),r.type===`prompt`&&Rt&&(fe?.({sessionId:Rt,clientNonce:r.clientNonce}),Xz(Le,r.cursor)?Pt(Rt):Ft(Rt));return}catch(e){return Ft(Rt),i(),jn(e),!1}},[Rt,Ft,rn,Pt,fe,An,Le,Cn,jn]),Nn=(0,I.useCallback)(()=>{An&&An.editQueued().then(e=>{e.type===`clear-failed`&&tn({id:`edit-queued-clear-failed`,level:`warning`,text:e.message,dismissible:!0})})},[tn,An]),Pn=(0,I.useCallback)(()=>{ge?.(),Ft(Rt),An?.stop().catch(e=>{tn({id:`stop-error`,level:`error`,text:Qz(e,`Could not stop the chat session.`),dismissible:!0})})},[Rt,tn,Ft,ge,An]),Fn=(0,I.useCallback)(()=>{An?.interrupt().catch(e=>{tn({id:`interrupt-error`,level:`error`,text:Qz(e,`Could not interrupt the chat session.`),dismissible:!0})})},[tn,An]);(0,I.useEffect)(()=>{Ct(null),Tt(null),yt([]),xt(new Set)},[Me]),(0,I.useEffect)(()=>{let e=Me??`__none__`;P.current.shouldRestore(e,_)&&_!==void 0&&(Cn(_,_.length>0),y?.())},[Me,_,y,Cn]);let In=Ie?.status??(Pe||Re||ze?`hydrating`:`idle`),Ln=kt===Me&&In===`idle`?`submitted`:In;(0,I.useEffect)(()=>{if(kt){if(kt!==Me){Ft();return}In!==`idle`&&Ft(kt)}},[Me,Ft,kt,In]),(0,I.useEffect)(()=>{let e=mt.current;ht.current=Ln,mt.current=Ln,F.current&&ut.current===F.current&&(Zz(Ln)||!Zz(e)&&e!==`submitted`||pt())},[pt,Ln]),(0,I.useEffect)(()=>{if(!v||!An||!Me||Xt||!P.current.claimAutoSubmit(Me,_))return;F.current=Me,ut.current=void 0;let e=_??``,t=()=>{lt.current===``&&Cn(e,e.length>0)};Cn(``,!1),An.submit({text:e,files:[],source:`auto-submit`}).then(e=>{if(e.preserveDraft){t(),pt(Me),e.type===`blocked`&&e.reason===`composer-blocked`&&P.current.releaseAutoSubmit(Me);return}(e.type===`prompt`||e.type===`followup`)&&rn($z),e.type===`prompt`&&(fe?.({sessionId:Me,clientNonce:e.clientNonce}),Xz(Le,e.cursor)?Pt(Me):Ft(Me)),ut.current=Me,b?.(),!Zz(ht.current)&&F.current===Me&&pt(Me)}).catch(e=>{Ft(Me),t(),pt(Me),jn(e)})},[Me,v,Ft,Xt,rn,_,Pt,b,fe,An,Le,Cn,pt,jn]),(0,I.useEffect)(()=>{ae?.status===`ready`&&nn(`workspace-warmup`)},[nn,ae?.status]);let Rn=!!(ie&&Ie&&Ie.status===`hydrating`&&!Ie.hydrated&&Ie.history.messageCount===0&&Ie.committedMessages.length===0&&Ie.queue.followUps.length===0&&Object.keys(Ie.optimisticOutbox).length===0&&!Ie.streamingMessage),zn=Be&&Ve.loaded&&Ve.availableModels.every(e=>!e.available),Bn=Ge||Ke||zn,Vn=!An||Pe||Xt,Hn=Zz(Ln),Un=Rn?`ready`:sWe(Ln),Wn=!An||Pe||Bn||Xt&&!Hn,Gn=(0,I.useMemo)(()=>use(j),[j]),Kn=(0,I.useMemo)(()=>Gt.map(dWe),[Gt]),qn=(0,I.useCallback)(e=>{it(!1),ot(!1),ct(e.currentTarget.value),vn(e)},[vn]);(0,I.useEffect)(()=>{Hn&&(it(!1),ot(!1))},[Hn]),(0,I.useEffect)(()=>{typeof window>`u`||!Rt||window.dispatchEvent(new CustomEvent(`boring:chat-session-status`,{detail:{sessionId:Rt,working:Hn}}))},[Rt,Hn]);let Jn=(0,I.useCallback)(e=>{if(e.key===`Escape`&&Hn){if(e.defaultPrevented||fn!==null||pn!==null){Sn(e);return}e.preventDefault(),Fn();return}Sn(e)},[Sn,Fn,Hn,fn,pn]);return(0,L.jsx)(ud,{onOpenArtifact:me,children:(0,L.jsxs)(`div`,{"data-boring-agent":``,"data-boring-agent-part":`chat`,"data-pi-chat-session-id":Me,"data-pi-chat-connection":Yt?.connection??`disconnected`,"data-pi-chat-last-seq":Yt?.lastSeq??0,className:R(`flex h-full min-h-0 overflow-hidden text-foreground antialiased`,u||xe?`flex-row`:`flex-col`,l?`bg-[color:var(--canvas)] text-[13px]`:`bg-transparent text-[13px]`,c),role:`region`,"aria-label":`Agent assistant`,children:[xe?(0,L.jsx)(`aside`,{"data-boring-agent-part":`pi-chat-session-sidebar`,className:`min-h-0 w-64 shrink-0 border-r border-border/60`,children:(0,L.jsx)(jue,{sessions:Ne,activeId:Me,loading:Pe,onCreate:an,onSwitch:Oe.switch,onDelete:on,onLoadMore:Oe.loadMore,hasMore:Oe.hasMore,loadingMore:Oe.loadingMore})}):null,(0,L.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,L.jsxs)(`div`,{className:R(`flex h-full min-h-0 flex-col overflow-hidden`,Jt&&`justify-center`,l&&`mx-3 my-3 rounded-xl bg-[color:var(--surface-chat)] shadow-[0_1px_0_oklch(0_0_0/0.02),0_1px_2px_-1px_oklch(0_0_0/0.04),inset_0_0_0_1px_oklch(from_var(--border)_l_c_h/0.6)]`),children:[(0,L.jsx)(SUe,{chrome:l,emptyHero:Jt,messages:Gt,emptyStateHydrating:qt,emptyState:m,suggestions:p,isStreaming:Hn,showThoughts:Xe,toolRenderers:Gn,runtimeNotices:en,onDismissNotice:nn,renderNoticeAction:ye,onScrollToBottomReady:e=>{gt.current=e},onSuggestionSubmit:({text:e,files:t,source:n})=>Mn({text:e,files:t,source:n}),onRestoreDraft:Cn,windowResetKey:Me}),(0,L.jsx)(ZUe,{chrome:l,isStreaming:Hn,status:Ln,disabled:Vn,submitStatus:Un,submitDisabled:Wn,composerBlocked:Xt,composerBlockerLabel:Qt,composerPlaceholder:g,composerStatusNotice:$t,workspaceWarmupBlocked:Vt,primaryComposerBlocker:Zt,onComposerBlockerAction:_e,queuePreview:Wt,onEditQueued:Nn,hotReloadEnabled:f,pluginUpdateState:St,onDismissPluginUpdate:un,onRunPluginUpdate:ln,commandNotifyState:wt,onDismissCommandNotify:dn,attachmentNotice:Mt,onAttachmentNotice:Nt,mentionState:fn,slashQuery:pn,apiBaseUrl:n,fetch:s,requestHeaders:Ee,storageScope:i,onSelectMention:yn,onDismissMention:gn,commands:Lt,onSelectSlashCommand:kn,onDismissSlash:_n,modelPickerOpen:rt,selectedModel:He,modelOptions:Ue,modelControlled:S!==void 0,hideDefaultModelOption:T,hideComposerSettings:E,onModelChange:Ve.setModel,onSetModelPickerOpen:it,onOpenModelPicker:Tn,thinkingPickerOpen:at,selectedThinking:tt,thinkingControl:k,thinkingControlled:O!==void 0,onThinkingChange:Ye,onSetThinkingPickerOpen:ot,onOpenThinkingPicker:En,draft:st,textareaRef:_t,onTextareaChange:qn,onTextareaKeyDown:Jn,onSubmitMessage:({text:e,files:t})=>Mn({text:e,files:t}),onStop:Pn})]})}),u?(0,L.jsx)(I.Suspense,{fallback:null,children:(0,L.jsx)(`div`,{"aria-label":`Chat debug metadata`,className:`contents`,role:`region`,children:(0,L.jsx)(hWe,{apiBaseUrl:n,fetch:s,sessionId:Me??Rt??`unknown`,messages:Kn,requestHeaders:Ee,storageScope:i,width:440,onWidthChange:()=>{}})})}):null]})})}function bWe(e){let t=Bu(),n=Vu(),[r,i]=(0,I.useState)(0);return{upload:(0,I.useCallback)(async(r,a)=>{i(e=>e+1);try{return await sd(r,{apiBaseUrl:t,workspaceRequestId:n,directory:a?.directory??e?.directory,sourcePath:a?.sourcePath})}finally{i(e=>e-1)}},[t,n,e?.directory]),uploading:r>0}}var eB=(0,I.createContext)({report:()=>void 0});function xWe(e,t){return e?`${e.replace(/\/$/,``)}${t}`:t}function SWe(e){return{"content-type":`application/json`,...e??{}}}function CWe(e){let t=(0,I.useCallback)(t=>{if(!t.panelInstanceId)return;let n=t;fetch(xWe(e.apiBaseUrl,`/api/v1/ui/panels/status`),{method:`PUT`,headers:SWe(e.authHeaders),body:JSON.stringify(n)}).catch(()=>{})},[e.apiBaseUrl,e.authHeaders]);return(0,I.createElement)(eB.Provider,{value:{report:t}},e.children)}function wWe(e){return(0,I.useEffect)(()=>{e.onReady()},[e.onReady]),(0,I.createElement)(I.Fragment,null,e.children)}function TWe(e){return(0,I.useEffect)(()=>{e.onLoading()},[e.onLoading]),(0,I.createElement)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,"data-boring-plugin-suspense-fallback":`true`},`Loading…`)}function EWe(e){let t=(0,I.useContext)(eB),n=e.panelInstanceId,r=(0,I.useCallback)((r,i)=>{n?.startsWith(`self-test:`)&&t.report({pluginId:e.pluginId,panelId:e.panelId,panelInstanceId:n,...e.revision===void 0?{}:{revision:e.revision},state:r,...i?{error:i}:{}})},[n,e.panelId,e.pluginId,e.revision,t]);(0,I.useEffect)(()=>()=>r(`missing`),[r]);let i=(0,I.useCallback)(e=>{r(`error`,{code:`PLUGIN_PANEL_RENDER_ERROR`,message:e.message})},[r]);return(0,I.createElement)(`div`,{className:`h-full min-h-0`,"data-boring-plugin-id":e.pluginId,"data-boring-panel-component-id":e.panelId,...n?{"data-boring-panel-instance-id":n}:{},...e.revision===void 0?{}:{"data-boring-plugin-revision":String(e.revision)}},(0,I.createElement)(oa,{pluginId:e.pluginId,contributionKind:`panel`,contributionId:e.panelId,onError:i,children:(0,I.createElement)(I.Suspense,{fallback:(0,I.createElement)(TWe,{onLoading:()=>r(`loading`)}),children:(0,I.createElement)(wWe,{onReady:()=>r(`ready`),children:e.children})})}))}var tB=class{panels=new Map;registrationOrder=[];capabilities;listeners=new Set;snapshotCache=null;lazyComponentCache=new Map;wrapperComponentCache=new Map;generation=0;constructor(e={}){this.capabilities=new Set(Object.entries(e).filter(([,e])=>e).map(([e])=>e))}register(e,t){let n=this.panels.has(e);this.panels.set(e,{...t,id:e}),n||this.registrationOrder.push(e),this.emit()}unregister(e){this.panels.delete(e)&&(this.lazyComponentCache.delete(e),this.wrapperComponentCache.delete(e),this.registrationOrder=this.registrationOrder.filter(t=>t!==e),this.emit())}replaceByPluginId(e,t){let n=new Set;for(let[t,r]of this.panels)r.pluginId===e&&n.add(t);if(n.size===0&&t.length===0)return;let r=n.size>0;for(let e of n)this.panels.delete(e),this.lazyComponentCache.delete(e),this.wrapperComponentCache.delete(e);n.size>0&&(this.registrationOrder=this.registrationOrder.filter(e=>this.panels.has(e)));for(let n of t){let t=n.id;if(!t)continue;let i=this.panels.get(t);if(i&&i.pluginId!==e){console.warn(`[PanelRegistry] plugin "${e}" tried to register panel "${t}" already owned by "${i.pluginId??`system`}" — skipped`);continue}this.panels.set(t,{...n,id:t,pluginId:e}),this.registrationOrder.includes(t)||this.registrationOrder.push(t),r=!0}r&&(this.generation+=1,this.emit())}get(e){return this.panels.get(e)}has(e){return this.panels.has(e)}list(){return this.filteredPanels()}listAll(){return this.registrationOrder.map(e=>this.panels.get(e))}getComponents(){let e={};for(let t of this.filteredPanels())e[t.id]=this.getWrappedComponent(t.id);return e}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>(this.snapshotCache||=this.filteredPanels(),this.snapshotCache);getWrappedComponent(e){let t=this.wrapperComponentCache.get(e);if(t)return t;let n=this,r=function(t){(0,I.useSyncExternalStore)(n.subscribe,n.getSnapshot,n.getSnapshot);let r=n.get(e),i=n.generation,a=!!(r&&n.satisfiesCapabilities(r)),o=(0,I.useMemo)(()=>!r||!n.satisfiesCapabilities(r)?()=>null:r.lazy?n.getLazyComponent(e,r.component):r.component,[r?.component,r?.lazy,r?.requiresCapabilities,i]);return a?(0,I.createElement)(EWe,{pluginId:r?.pluginId??r?.id??e,panelId:e,panelInstanceId:typeof t?.api?.id==`string`?t.api.id:void 0,revision:r?.pluginRevision,children:(0,I.createElement)(o,t)}):null};return this.wrapperComponentCache.set(e,r),r}getLazyComponent(e,t){let n=this.lazyComponentCache.get(e);if(n?.importer===t)return n.component;let r=(0,I.lazy)(t);return this.lazyComponentCache.set(e,{importer:t,component:r}),r}emit(){this.snapshotCache=null;for(let e of[...this.listeners])e()}filteredPanels(){return this.registrationOrder.map(e=>this.panels.get(e)).filter(e=>this.satisfiesCapabilities(e))}satisfiesCapabilities(e){return!e.requiresCapabilities?.length||e.requiresCapabilities.every(e=>this.capabilities.has(e))}},nB={ts:Vr,tsx:Vr,js:Vr,jsx:Vr,mjs:Vr,cjs:Vr,py:Vr,rb:Vr,go:Vr,rs:Vr,java:Vr,c:Vr,cpp:Vr,h:Vr,cs:Vr,swift:Vr,kt:Vr,sh:Vr,bash:Vr,zsh:Vr,json:Br,jsonl:Br,md:Gr,mdx:Gr,txt:Gr,csv:Gr,tsv:Gr,yaml:Gr,yml:Gr,toml:Gr,ini:Gr,cfg:Gr,conf:Gr,env:Gr,png:ni,jpg:ni,jpeg:ni,gif:ni,svg:ni,webp:ni,ico:ni,bmp:ni};function rB(e){let t=e.split(`.`).pop()?.toLowerCase();return t&&t in nB?nB[t]:Kr}var iB=`workspace.open.path`;function DWe(e){return typeof e.kind!=`string`||e.kind.length===0?null:{id:e.id,kind:e.kind,...e.title===void 0?{}:{title:e.title},...e.description===void 0?{}:{description:e.description},...e.targetHint===void 0?{}:{targetHint:e.targetHint},...e.examples===void 0?{}:{examples:e.examples},...e.metaSchema===void 0?{}:{metaSchema:e.metaSchema},...e.source===void 0?{}:{source:e.source},...e.pluginId===void 0?{}:{pluginId:e.pluginId}}}var aB=class{},oB=class extends aB{constructor(e,t,n,r){super(),this.viewId=e,this.groupId=t,this.panelId=n,this.tabGroupId=r}},sB=class extends aB{constructor(e,t){super(),this.viewId=e,this.paneId=t}},cB=class e{constructor(){}static getInstance(){return e.INSTANCE}hasData(e){return e&&e===this.proto}clearData(e){this.hasData(e)&&(this.proto=void 0,this.data=void 0)}getData(e){if(this.hasData(e))return this.data}setData(e,t){t&&(this.data=e,this.proto=t)}};cB.INSTANCE=new cB;function lB(){let e=cB.getInstance();if(e.hasData(oB.prototype))return e.getData(oB.prototype)[0]}function uB(){let e=cB.getInstance();if(e.hasData(sB.prototype))return e.getData(sB.prototype)[0]}var dB;(function(e){e.NONE={dispose:()=>{}};function t(e){return{dispose:()=>{e()}}}e.from=t})(dB||={});var fB=class{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=new Set(e)}addDisposables(...e){e.forEach(e=>this._disposables.add(e))}removeDisposable(e){this._disposables.delete(e)}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposables.forEach(e=>e.dispose()),this._disposables.clear())}},pB=class{constructor(){this._disposable=dB.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&=(this._disposable.dispose(),dB.NONE)}},mB;(function(e){e.any=(...e)=>t=>{let n=e.map(e=>e(t));return{dispose:()=>{n.forEach(e=>{e.dispose()})}}}})(mB||={});var hB=class{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}},gB=class{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}},OWe=class{constructor(){this.events=new Map}get size(){return this.events.size}add(e,t){this.events.set(e,t)}delete(e){this.events.delete(e)}clear(){this.events.clear()}},_B=class e{static create(){return new e(Error().stack??``)}constructor(e){this.value=e}print(){console.warn(`dockview: stacktrace`,this.value)}},kWe=class{constructor(e,t){this.callback=e,this.stacktrace=t}},Q=class e{static setLeakageMonitorEnabled(t){t!==e.ENABLE_TRACKING&&e.MEMORY_LEAK_WATCHER.clear(),e.ENABLE_TRACKING=t}get value(){return this._last}constructor(e){this.options=e,this._listeners=[],this._disposed=!1,this._pauseTokens=new Set}get event(){return this._event||(this._event=t=>{this.options?.replay&&this._last!==void 0&&t(this._last);let n=new kWe(t,e.ENABLE_TRACKING?_B.create():void 0);return this._listeners.push(n),{dispose:()=>{let t=this._listeners.indexOf(n);t>-1?this._listeners.splice(t,1):e.ENABLE_TRACKING}}},e.ENABLE_TRACKING&&e.MEMORY_LEAK_WATCHER.add(this._event,_B.create())),this._event}fire(e){if(!(this._pauseTokens.size>0)){this.options?.replay&&(this._last=e);for(let t of this._listeners)t.callback(e)}}pause(){let e={};return this._pauseTokens.add(e),dB.from(()=>this._pauseTokens.delete(e))}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(e.ENABLE_TRACKING&&queueMicrotask(()=>{for(let e of this._listeners)console.warn(`dockview: stacktrace`,e.stacktrace?.print())}),this._listeners=[]),e.ENABLE_TRACKING&&this._event&&e.MEMORY_LEAK_WATCHER.delete(this._event))}};Q.ENABLE_TRACKING=!1,Q.MEMORY_LEAK_WATCHER=new OWe;function vB(e,t,n,r){return e.addEventListener(t,n,r),{dispose:()=>{e.removeEventListener(t,n,r)}}}var yB=class{constructor(){this._onFired=new Q,this._currentFireCount=0,this._queued=!1,this.onEvent=e=>{let t=this._currentFireCount;return this._onFired.event(()=>{this._currentFireCount>t&&e()})}}fire(){this._currentFireCount++,!this._queued&&(this._queued=!0,queueMicrotask(()=>{this._queued=!1,this._onFired.fire()}))}dispose(){this._onFired.dispose()}},AWe=class extends fB{constructor(e){super(),this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,bB(e,e=>{let t=e.target.scrollWidth>e.target.clientWidth,n=e.target.scrollHeight>e.target.clientHeight;this._value={hasScrollX:t,hasScrollY:n},this._onDidChange.fire(this._value)}))}};function bB(e,t){let n=new ResizeObserver(e=>{requestAnimationFrame(()=>{let n=e[0];t(n)})});return n.observe(e),{dispose:()=>{n.unobserve(e),n.disconnect()}}}var xB=(e,...t)=>{for(let n of t)e.classList.contains(n)&&e.classList.remove(n)},SB=(e,...t)=>{for(let n of t)e.classList.contains(n)||e.classList.add(n)},CB=(e,t,n)=>{let r=e.classList.contains(t);n&&!r&&e.classList.add(t),!n&&r&&e.classList.remove(t)};function wB(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function TB(e){return new jWe(e)}var jWe=class extends fB{constructor(e){super(),this._onDidFocus=new Q,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new Q,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=wB(document.activeElement,e),n=!1,r=()=>{n=!1,t||(t=!0,this._onDidFocus.fire())},i=()=>{t&&(n=!0,window.setTimeout(()=>{n&&(n=!1,t=!1,this._onDidBlur.fire())},0))};this._refreshStateHandler=()=>{wB(document.activeElement,e)!==t&&(t?i():r())},this.addDisposables(vB(e,`focus`,r,!0)),this.addDisposables(vB(e,`blur`,i,!0))}refreshState(){this._refreshStateHandler()}},EB=`dv-quasiPreventDefault`;function DB(e){e[EB]=!0}function OB(e){return e[EB]}function MWe(e,t,n={}){let r=Array.from(t),{nonce:i}=n,a=typeof i==`function`?i(e):i;for(let t of r){if(t.href){let n=e.createElement(`link`);n.href=t.href,n.type=t.type,n.rel=`stylesheet`,e.head.appendChild(n);continue}let n=[];try{t.cssRules&&(n=Array.from(t.cssRules).map(e=>e.cssText))}catch(e){console.warn(`dockview: failed to access stylesheet rules due to security restrictions`,e)}let r=e.createDocumentFragment();for(let t of n){let n=e.createElement(`style`);a&&n.setAttribute(`nonce`,a),n.appendChild(e.createTextNode(t)),r.appendChild(n)}e.head.appendChild(r)}}function kB(e){let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t+window.scrollX,top:n+window.scrollY,width:r,height:i}}function NWe(e){let t=e;for(;t?.parentNode;)if(t.parentNode===document)return!0;else t=t.parentNode instanceof DocumentFragment?t.parentNode.host:t.parentNode;return!1}function PWe(e,t){e.setAttribute(`data-testid`,t)}function FWe(e,t){let n=[];function r(t){if(t.nodeType===Node.ELEMENT_NODE){e.includes(t.tagName)&&n.push(t),t.shadowRoot&&r(t.shadowRoot);for(let e of t.children)r(e)}}return r(t instanceof Document?t.documentElement:t),n}function AB(e=document){let t=FWe([`IFRAME`,`WEBVIEW`],e),n=new WeakMap;for(let e of t)n.set(e,e.style.pointerEvents),e.style.pointerEvents=`none`;return{release:()=>{for(let e of t)e.style.pointerEvents=n.get(e)??`auto`;t.splice(0,t.length)}}}function IWe(e){function t(e){let t=[];for(let n=0;n<e.classList.length;n++)t.push(e.classList.item(n));return t}let n,r=e;for(;r!==null&&(n=t(r).find(e=>e.startsWith(`dockview-theme-`)),typeof n!=`string`);)r=r.parentElement;return n}var jB=class{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(let e of this._classNames)CB(this.element,e,!1);this._classNames=e.split(` `).filter(e=>e.trim().length>0);for(let e of this._classNames)CB(this.element,e,!0)}},MB=100;function NB(e,t){let n=kB(e),r=kB(t);return!(n.left<r.left||n.left+n.width>r.left+r.width||n.top<r.top||n.top+n.height>r.top+r.height)}function LWe(e){let t=new Q,n=e.screenX,r=e.screenY,i,a=()=>{if(e.closed)return;let o=e.screenX,s=e.screenY;(o!==n||s!==r)&&(clearTimeout(i),i=setTimeout(()=>{t.fire()},MB),n=o,r=s),requestAnimationFrame(a)};return a(),t}function RWe(e,t){let n;return new fB(vB(e,`resize`,()=>{clearTimeout(n),n=setTimeout(()=>{t()},MB)}))}function zWe(e,t,n={buffer:10}){let r=n.buffer,i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=0,s=0,c=i.left-a.left,l=i.top-a.top,u=i.bottom-a.bottom,d=i.right-a.right;c<r?o=r-c:d>r&&(o=-r-d),l<r?s=r-l:u>r&&(s=-u-r),(o!==0||s!==0)&&(e.style.transform=`translate(${o}px, ${s}px)`)}function PB(e){let t=e;for(;t&&(t.style.zIndex===`auto`||t.style.zIndex===``);)t=t.parentElement;return t}function FB(e){if(e.length===0)throw Error(`Invalid tail call`);return[e.slice(0,e.length-1),e[e.length-1]]}function IB(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function LB(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.unshift(t))}function RB(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.push(t))}function BWe(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(t(r))return n}return-1}function zB(e,t){let n=e.findIndex(e=>e===t);return n>-1?(e.splice(n,1),!0):!1}var BB=(e,t,n)=>t>n?t:Math.min(n,Math.max(e,t)),VB=()=>{let e=1;return{next:()=>(e++).toString()}},HB=(e,t)=>{let n=[];if(typeof t!=`number`&&(t=e,e=0),e<=t)for(let r=e;r<t;r++)n.push(r);else for(let r=e;r>t;r--)n.push(r);return n},VWe=class{set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return this._cachedVisibleSize===void 0}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?``:`none`}constructor(e,t,n,r){this.container=e,this.view=t,this.disposable=r,this._cachedVisibleSize=void 0,typeof n==`number`?(this._size=n,this._cachedVisibleSize=void 0,e.classList.add(`visible`)):(this._size=0,this._cachedVisibleSize=n.cachedVisibleSize)}setVisible(e,t){e!==this.visible&&(e?(this.size=BB(this._cachedVisibleSize??0,this.viewMinimumSize,this.viewMaximumSize),this._cachedVisibleSize=void 0):(this._cachedVisibleSize=typeof t==`number`?t:this.size,this.size=0),this.container.classList.toggle(`visible`,e),this.view.setVisible&&this.view.setVisible(e))}dispose(){return this.disposable.dispose(),this.view}},UB;(function(e){e.HORIZONTAL=`HORIZONTAL`,e.VERTICAL=`VERTICAL`})(UB||={});var WB;(function(e){e[e.MAXIMUM=0]=`MAXIMUM`,e[e.MINIMUM=1]=`MINIMUM`,e[e.DISABLED=2]=`DISABLED`,e[e.ENABLED=3]=`ENABLED`})(WB||={});var GB;(function(e){e.Low=`low`,e.High=`high`,e.Normal=`normal`})(GB||={});var KB;(function(e){e.Distribute={type:`distribute`};function t(e){return{type:`split`,index:e}}e.Split=t;function n(e){return{type:`invisible`,cachedVisibleSize:e}}e.Invisible=n})(KB||={});var qB=class{get contentSize(){return this._contentSize}get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;let t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,xB(this.element,`dv-horizontal`,`dv-vertical`),this.element.classList.add(this.orientation==UB.HORIZONTAL?`dv-horizontal`:`dv-vertical`)}get minimumSize(){return this.viewItems.reduce((e,t)=>e+t.minimumSize,0)}get maximumSize(){return this.length===0?1/0:this.viewItems.reduce((e,t)=>e+t.maximumSize,0)}get startSnappingEnabled(){return this._startSnappingEnabled}set startSnappingEnabled(e){this._startSnappingEnabled!==e&&(this._startSnappingEnabled=e,this.updateSashEnablement())}get endSnappingEnabled(){return this._endSnappingEnabled}set endSnappingEnabled(e){this._endSnappingEnabled!==e&&(this._endSnappingEnabled=e,this.updateSashEnablement())}get disabled(){return this._disabled}set disabled(e){this._disabled=e,CB(this.element,`dv-splitview-disabled`,e)}get margin(){return this._margin}set margin(e){this._margin=e,CB(this.element,`dv-splitview-has-margin`,e!==0)}constructor(e,t){this.container=e,this.viewItems=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this._contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._disabled=!1,this._margin=0,this._onDidSashEnd=new Q,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new Q,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new Q,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(e,t,n=this.viewItems.map(e=>e.size),r,i,a=-1/0,o=1/0,s,c)=>{if(e<0||e>this.viewItems.length)return 0;let l=HB(e,-1),u=HB(e+1,this.viewItems.length);if(i)for(let e of i)LB(l,e),LB(u,e);if(r)for(let e of r)RB(l,e),RB(u,e);let d=l.map(e=>this.viewItems[e]),f=l.map(e=>n[e]),p=u.map(e=>this.viewItems[e]),m=u.map(e=>n[e]),h=l.reduce((e,t)=>e+this.viewItems[t].minimumSize-n[t],0),g=l.reduce((e,t)=>e+this.viewItems[t].maximumSize-n[t],0),_=u.length===0?1/0:u.reduce((e,t)=>e+n[t]-this.viewItems[t].minimumSize,0),v=u.length===0?-1/0:u.reduce((e,t)=>e+n[t]-this.viewItems[t].maximumSize,0),y=Math.max(h,v),b=Math.min(_,g),x=!1;if(s){let e=this.viewItems[s.index],n=t>=s.limitDelta;x=n!==e.visible,e.setVisible(n,s.size)}if(!x&&c){let e=this.viewItems[c.index],n=t<c.limitDelta;x=n!==e.visible,e.setVisible(n,c.size)}if(x)return this.resize(e,t,n,r,i,a,o);let S=BB(t,y,b),C=0,w=S;for(let e=0;e<d.length;e++){let t=d[e],n=BB(f[e]+w,t.minimumSize,t.maximumSize),r=n-f[e];C+=r,w-=r,t.size=n}let T=C;for(let e=0;e<p.length;e++){let t=p[e],n=BB(m[e]-T,t.minimumSize,t.maximumSize),r=n-m[e];T+=r,t.size=n}return t},this._orientation=t.orientation??UB.VERTICAL,this.element=this.createContainer(),this.margin=t.margin??0,this.proportionalLayout=t.proportionalLayout===void 0||!!t.proportionalLayout,this.viewContainer=this.createViewContainer(),this.sashContainer=this.createSashContainer(),this.element.appendChild(this.sashContainer),this.element.appendChild(this.viewContainer),this.container.appendChild(this.element),this.style(t.styles),t.descriptor&&(this._size=t.descriptor.size,t.descriptor.views.forEach((e,t)=>{let n=e.visible===void 0||e.visible?e.size:{type:`invisible`,cachedVisibleSize:e.size},r=e.view;this.addView(r,n,t,!0)}),this._contentSize=this.viewItems.reduce((e,t)=>e+t.size,0),this.saveProportions())}style(e){e?.separatorBorder===`transparent`?(xB(this.element,`dv-separator-border`),this.element.style.removeProperty(`--dv-separator-border`)):(SB(this.element,`dv-separator-border`),e?.separatorBorder&&this.element.style.setProperty(`--dv-separator-border`,e.separatorBorder))}isViewVisible(e){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);return this.viewItems[e].visible}setViewVisible(e,t){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);let n=this.viewItems[e];n.setVisible(t,n.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.viewItems.length?-1:this.viewItems[e].size}resizeView(e,t){if(e<0||e>=this.viewItems.length)return;let n=HB(this.viewItems.length).filter(t=>t!==e),r=[...n.filter(e=>this.viewItems[e].priority===GB.Low),e],i=n.filter(e=>this.viewItems[e].priority===GB.High),a=this.viewItems[e];t=Math.round(t),t=BB(t,a.minimumSize,Math.min(a.maximumSize,this._size)),a.size=t,this.relayout(r,i)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(e,t){let n=this.viewItems.indexOf(e);if(n<0||n>=this.viewItems.length)return;t=typeof t==`number`?t:e.size,t=BB(t,e.minimumSize,e.maximumSize),e.size=t;let r=HB(this.viewItems.length).filter(e=>e!==n),i=[...r.filter(e=>this.viewItems[e].priority===GB.Low),n],a=r.filter(e=>this.viewItems[e].priority===GB.High);this.relayout([...i,n],a)}addView(e,t={type:`distribute`},n=this.viewItems.length,r){let i=document.createElement(`div`);i.className=`dv-view`,i.appendChild(e.element);let a;a=typeof t==`number`?t:t.type===`split`?this.getViewSize(t.index)/2:t.type===`invisible`?{cachedVisibleSize:t.cachedVisibleSize}:e.minimumSize;let o=e.onDidChange(e=>this.onDidChange(s,e.size)),s=new VWe(i,e,a,{dispose:()=>{o.dispose(),this.viewContainer.removeChild(i)}});if(n===this.viewItems.length?this.viewContainer.appendChild(i):this.viewContainer.insertBefore(i,this.viewContainer.children.item(n)),this.viewItems.splice(n,0,s),this.viewItems.length>1){let e=document.createElement(`div`);e.className=`dv-sash`;let t=t=>{for(let e of this.viewItems)e.enabled=!1;let n=AB(),r=this._orientation===UB.HORIZONTAL?t.clientX:t.clientY,i=BWe(this.sashes,t=>t.container===e),a=this.viewItems.map(e=>e.size),o,s,c=HB(i,-1),l=HB(i+1,this.viewItems.length),u=c.reduce((e,t)=>e+(this.viewItems[t].minimumSize-a[t]),0),d=c.reduce((e,t)=>e+(this.viewItems[t].viewMaximumSize-a[t]),0),f=l.length===0?1/0:l.reduce((e,t)=>e+(a[t]-this.viewItems[t].minimumSize),0),p=l.length===0?-1/0:l.reduce((e,t)=>e+(a[t]-this.viewItems[t].viewMaximumSize),0),m=Math.max(u,p),h=Math.min(f,d),g=this.findFirstSnapIndex(c),_=this.findFirstSnapIndex(l);if(typeof g==`number`){let e=this.viewItems[g],t=Math.floor(e.viewMinimumSize/2);o={index:g,limitDelta:e.visible?m-t:m+t,size:e.size}}if(typeof _==`number`){let e=this.viewItems[_],t=Math.floor(e.viewMinimumSize/2);s={index:_,limitDelta:e.visible?h+t:h-t,size:e.size}}let v=e=>{let t=(this._orientation===UB.HORIZONTAL?e.clientX:e.clientY)-r;this.resize(i,t,a,void 0,void 0,m,h,o,s),this.distributeEmptySpace(),this.layoutViews()},y=()=>{for(let e of this.viewItems)e.enabled=!0;n.release(),this.saveProportions(),document.removeEventListener(`pointermove`,v),document.removeEventListener(`pointerup`,y),document.removeEventListener(`pointercancel`,y),document.removeEventListener(`contextmenu`,y),this._onDidSashEnd.fire(void 0)};document.addEventListener(`pointermove`,v),document.addEventListener(`pointerup`,y),document.addEventListener(`pointercancel`,y),document.addEventListener(`contextmenu`,y)};e.addEventListener(`pointerdown`,t);let n={container:e,disposable:()=>{e.removeEventListener(`pointerdown`,t),this.sashContainer.removeChild(e)}};this.sashContainer.appendChild(e),this.sashes.push(n)}r||this.relayout([n]),!r&&typeof t!=`number`&&t.type===`distribute`&&this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){let e=[],t=0;for(let n of this.viewItems)n.maximumSize-n.minimumSize>0&&(e.push(n),t+=n.size);let n=Math.floor(t/e.length);for(let t of e)t.size=BB(n,t.minimumSize,t.maximumSize);let r=HB(this.viewItems.length),i=r.filter(e=>this.viewItems[e].priority===GB.Low),a=r.filter(e=>this.viewItems[e].priority===GB.High);this.relayout(i,a)}removeView(e,t,n=!1){let r=this.viewItems.splice(e,1)[0];if(r.dispose(),this.viewItems.length>=1){let t=Math.max(e-1,0);this.sashes.splice(t,1)[0].disposable()}return n||this.relayout(),t&&t.type===`distribute`&&this.distributeViewSizes(),this._onDidRemoveView.fire(r.view),r.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);return this.viewItems[e].cachedVisibleSize}moveView(e,t){let n=this.getViewCachedVisibleSize(e),r=n===void 0?this.getViewSize(e):KB.Invisible(n),i=this.removeView(e,void 0,!0);this.addView(i,r,t)}layout(e,t){let n=Math.max(this.size,this._contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions){let t=0;for(let n=0;n<this.viewItems.length;n++){let r=this.viewItems[n],i=this.proportions[n];typeof i==`number`?t+=i:e-=r.size}for(let n=0;n<this.viewItems.length;n++){let r=this.viewItems[n],i=this.proportions[n];typeof i==`number`&&t>0&&(r.size=BB(Math.round(i*e/t),r.minimumSize,r.maximumSize))}}else{let t=HB(this.viewItems.length),r=t.filter(e=>this.viewItems[e].priority===GB.Low),i=t.filter(e=>this.viewItems[e].priority===GB.High);this.resize(this.viewItems.length-1,e-n,void 0,r,i)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){let n=this.viewItems.reduce((e,t)=>e+t.size,0);this.resize(this.viewItems.length-1,this._size-n,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(e){let t=this.viewItems.reduce((e,t)=>e+t.size,0),n=this.size-t,r=HB(this.viewItems.length-1,-1),i=r.filter(e=>this.viewItems[e].priority===GB.Low),a=r.filter(e=>this.viewItems[e].priority===GB.High);for(let e of a)LB(r,e);for(let e of i)RB(r,e);typeof e==`number`&&RB(r,e);for(let e=0;n!==0&&e<r.length;e++){let t=this.viewItems[r[e]],i=BB(t.size+n,t.minimumSize,t.maximumSize),a=i-t.size;n-=a,t.size=i}}saveProportions(){this.proportionalLayout&&this._contentSize>0&&(this._proportions=this.viewItems.map(e=>e.visible?e.size/this._contentSize:void 0))}layoutViews(){if(this._contentSize=this.viewItems.reduce((e,t)=>e+t.size,0),this.updateSashEnablement(),this.viewItems.length===0)return;let e=this.viewItems.filter(e=>e.visible),t=Math.max(0,e.length-1),n=this.margin*t/Math.max(1,e.length),r=0,i=[],a=this.viewItems.reduce((e,t,n)=>{let r=+!!t.visible;return n===0?e.push(r):e.push(e[n-1]+r),e},[]);this.viewItems.forEach((e,o)=>{r+=this.viewItems[o].size,i.push(r);let s=e.visible?e.size-n:0,c=Math.max(0,a[o]-1),l=o===0||c===0?0:i[o-1]+c/t*n;if(o<this.viewItems.length-1){let t=e.visible?l+s-4/2+this.margin/2:l;this._orientation===UB.HORIZONTAL&&(this.sashes[o].container.style.left=`${t}px`,this.sashes[o].container.style.top=`0px`),this._orientation===UB.VERTICAL&&(this.sashes[o].container.style.left=`0px`,this.sashes[o].container.style.top=`${t}px`)}this._orientation===UB.HORIZONTAL&&(e.container.style.width=`${s}px`,e.container.style.left=`${l}px`,e.container.style.top=``,e.container.style.height=``),this._orientation===UB.VERTICAL&&(e.container.style.height=`${s}px`,e.container.style.top=`${l}px`,e.container.style.width=``,e.container.style.left=``),e.view.layout(e.size-n,this._orthogonalSize)})}findFirstSnapIndex(e){for(let t of e){let e=this.viewItems[t];if(e.visible&&e.snap)return t}for(let t of e){let e=this.viewItems[t];if(e.visible&&e.maximumSize-e.minimumSize>0)return;if(!e.visible&&e.snap)return t}}updateSashEnablement(){let e=!1,t=this.viewItems.map(t=>e=t.size-t.minimumSize>0||e);e=!1;let n=this.viewItems.map(t=>e=t.maximumSize-t.size>0||e),r=[...this.viewItems].reverse();e=!1;let i=r.map(t=>e=t.size-t.minimumSize>0||e).reverse();e=!1;let a=r.map(t=>e=t.maximumSize-t.size>0||e).reverse(),o=0;for(let e=0;e<this.sashes.length;e++){let r=this.sashes[e],s=this.viewItems[e];o+=s.size;let c=!(t[e]&&a[e+1]),l=!(n[e]&&i[e+1]);if(c&&l){let n=HB(e,-1),a=HB(e+1,this.viewItems.length),s=this.findFirstSnapIndex(n),c=this.findFirstSnapIndex(a),l=typeof s==`number`&&!this.viewItems[s].visible,u=typeof c==`number`&&!this.viewItems[c].visible;l&&i[e]&&(o>0||this.startSnappingEnabled)?this.updateSash(r,WB.MINIMUM):u&&t[e]&&(o<this._contentSize||this.endSnappingEnabled)?this.updateSash(r,WB.MAXIMUM):this.updateSash(r,WB.DISABLED)}else c&&!l?this.updateSash(r,WB.MINIMUM):!c&&l?this.updateSash(r,WB.MAXIMUM):this.updateSash(r,WB.ENABLED)}}updateSash(e,t){CB(e.container,`dv-disabled`,t===WB.DISABLED),CB(e.container,`dv-enabled`,t===WB.ENABLED),CB(e.container,`dv-maximum`,t===WB.MAXIMUM),CB(e.container,`dv-minimum`,t===WB.MINIMUM)}createViewContainer(){let e=document.createElement(`div`);return e.className=`dv-view-container`,e}createSashContainer(){let e=document.createElement(`div`);return e.className=`dv-sash-container`,e}createContainer(){let e=document.createElement(`div`);return e.className=`dv-split-view-container ${this._orientation===UB.HORIZONTAL?`dv-horizontal`:`dv-vertical`}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}for(let e of this.viewItems)e.dispose();this.element.remove()}},JB=Object.keys({orientation:void 0,descriptor:void 0,proportionalLayout:void 0,styles:void 0,margin:void 0,disableAutoResizing:void 0,className:void 0}),YB=class extends fB{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._orientation=t.orientation??UB.VERTICAL,this.element=document.createElement(`div`),this.element.className=`dv-pane-container`,e.appendChild(this.element),this.splitview=new qB(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach(e=>{let t=new fB(e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),n={pane:e,disposable:{dispose:()=>{t.dispose()}}};this.paneItems.push(n),e.orthogonalSize=this.splitview.orthogonalSize}),this.addDisposables(this._onDidChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire(void 0)}),this.splitview.onDidAddView(()=>{this._onDidChange.fire()}),this.splitview.onDidRemoveView(()=>{this._onDidChange.fire()}))}setViewVisible(e,t){this.splitview.setViewVisible(e,t)}addPane(e,t,n=this.splitview.length,r=!1){let i=e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}),a={pane:e,disposable:{dispose:()=>{i.dispose()}}};this.paneItems.splice(n,0,a),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,n,r)}getViewSize(e){return this.splitview.getViewSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t={skipDispose:!1}){let n=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t.skipDispose||(n.disposable.dispose(),n.pane.dispose()),n}moveView(e,t){if(e===t)return;let n=this.removePane(e,{skipDispose:!0});this.skipAnimation=!0;try{this.addPane(n.pane,n.pane.size,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&=(clearTimeout(this.animationTimer),void 0),SB(this.element,`dv-animated`),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,xB(this.element,`dv-animated`)},200))}dispose(){super.dispose(),this.animationTimer&&=(clearTimeout(this.animationTimer),void 0),this.paneItems.forEach(e=>{e.disposable.dispose(),e.pane.dispose()}),this.paneItems=[],this.splitview.dispose(),this.element.remove()}},XB=class{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation===UB.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===UB.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===UB.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===UB.HORIZONTAL?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation===UB.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===UB.HORIZONTAL?this.size:this.orthogonalSize}constructor(e,t,n,r=0){this.view=e,this.orientation=t,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._orthogonalSize=n,this._size=r,this._disposable=this.view.onDidChange(e=>{e?this._onDidChange.fire({size:this.orientation===UB.VERTICAL?e.width:e.height,orthogonalSize:this.orientation===UB.VERTICAL?e.height:e.width}):this._onDidChange.fire({})})}setVisible(e){this.view.setVisible&&this.view.setVisible(e)}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}},ZB=class e extends fB{get width(){return this.orientation===UB.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===UB.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return this.children.length===0?0:Math.max(...this.children.map((e,t)=>this.splitview.isViewVisible(t)?e.minimumOrthogonalSize:0))}get maximumSize(){return Math.min(...this.children.map((e,t)=>this.splitview.isViewVisible(t)?e.maximumOrthogonalSize:1/0))}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation===UB.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===UB.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===UB.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===UB.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(this.children.length===0)return GB.Normal;let e=this.children.map(e=>e.priority===void 0?GB.Normal:e.priority);return e.some(e=>e===GB.High)?GB.High:e.some(e=>e===GB.Low)?GB.Low:GB.Normal}get disabled(){return this.splitview.disabled}set disabled(e){this.splitview.disabled=e}get margin(){return this.splitview.margin}set margin(t){this.splitview.margin=t,this.children.forEach(n=>{n instanceof e&&(n.margin=t)})}constructor(e,t,n,r,i,a,o,s){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=n,this._childrenDisposable=dB.NONE,this.children=[],this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new Q,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=i,this._size=r,this.element=document.createElement(`div`),this.element.className=`dv-branch-node`,!s)this.splitview=new qB(this.element,{orientation:this.orientation,proportionalLayout:t,styles:n,margin:o}),this.splitview.layout(this.size,this.orthogonalSize);else{let e={views:s.map(e=>({view:e.node,size:e.node.size,visible:e.node instanceof XB&&e.visible!==void 0?e.visible:!0})),size:this.orthogonalSize};this.children=s.map(e=>e.node),this.splitview=new qB(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t,styles:n,margin:o})}this.disabled=a,this.addDisposables(this._onDidChange,this._onDidVisibilityChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire({})})),this.setupChildrenEvents()}setVisible(e){}isChildVisible(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.isViewVisible(e)}setChildVisible(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);if(this.splitview.isViewVisible(e)===t)return;let n=this.splitview.contentSize===0;this.splitview.setViewVisible(e,t);let r=this.splitview.contentSize===0;(t&&n||!t&&r)&&this._onDidVisibilityChange.fire({visible:t})}moveChild(e,t){if(e===t)return;if(e<0||e>=this.children.length)throw Error(`Invalid from index`);e<t&&t--,this.splitview.moveView(e,t);let n=this._removeChild(e);this._addChild(n,t)}getChildSize(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.getViewSize(e)}resizeChild(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);this.splitview.resizeView(e,t)}layout(e,t){this._size=t,this._orthogonalSize=e,this.splitview.layout(t,e)}addChild(e,t,n,r){if(n<0||n>this.children.length)throw Error(`Invalid index`);this.splitview.addView(e,t,n,r),this._addChild(e,n)}getChildCachedVisibleSize(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.getViewCachedVisibleSize(e)}removeChild(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.removeView(e,t),this._removeChild(e)}_addChild(e,t){this.children.splice(t,0,e),this.setupChildrenEvents()}_removeChild(e){let[t]=this.children.splice(e,1);return this.setupChildrenEvents(),t}setupChildrenEvents(){this._childrenDisposable.dispose(),this._childrenDisposable=new fB(mB.any(...this.children.map(e=>e.onDidChange))(e=>{this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((t,n)=>t instanceof e?t.onDidVisibilityChange(({visible:e})=>{this.setChildVisible(n,e)}):dB.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}};function QB(e,t){if(e instanceof XB)return e;if(e instanceof ZB)return QB(e.children[t?e.children.length-1:0],t);throw Error(`invalid node`)}function $B(e,t,n){if(e instanceof ZB){let r=new ZB(e.orientation,e.proportionalLayout,e.styles,t,n,e.disabled,e.margin);for(let t=e.children.length-1;t>=0;t--){let n=e.children[t];r.addChild($B(n,n.size,n.orthogonalSize),n.size,0,!0)}return r}else return new XB(e.view,e.orientation,n)}function eV(e,t,n){if(e instanceof ZB){let r=new ZB(rV(e.orientation),e.proportionalLayout,e.styles,t,n,e.disabled,e.margin),i=0;for(let a=e.children.length-1;a>=0;a--){let o=e.children[a],s=o instanceof ZB?o.orthogonalSize:o.size,c=e.size===0?0:Math.round(t*s/e.size);i+=c,a===0&&(c+=t-i),r.addChild(eV(o,n,c),c,0,!0)}return r}else return new XB(e.view,rV(e.orientation),n)}function HWe(e){let t=e.parentElement;if(!t)throw Error(`Invalid grid element`);let n=t.firstElementChild,r=0;for(;n!==e&&n!==t.lastElementChild&&n;)n=n.nextElementSibling,r++;return r}function tV(e){let t=e.parentElement;if(!t)throw Error(`Invalid grid element`);if(/\bdv-grid-view\b/.test(t.className))return[];let n=HWe(t),r=t.parentElement.parentElement.parentElement;return[...tV(r),n]}function nV(e,t,n){if(WWe(e,t)===UWe(n)){let[e,r]=FB(t),i=r;return(n===`right`||n===`bottom`)&&(i+=1),[...e,i]}else{let e=+(n===`right`||n===`bottom`);return[...t,e]}}function UWe(e){return e===`top`||e===`bottom`?UB.VERTICAL:UB.HORIZONTAL}function WWe(e,t){return t.length%2==0?rV(e):e}var rV=e=>e===UB.HORIZONTAL?UB.VERTICAL:UB.HORIZONTAL;function GWe(e){return!!e.children}var iV=(e,t)=>{let n=t===UB.VERTICAL?e.box.width:e.box.height;return GWe(e)?{type:`branch`,data:e.children.map(e=>iV(e,rV(t))),size:n}:typeof e.cachedVisibleSize==`number`?{type:`leaf`,data:e.view.toJSON(),size:e.cachedVisibleSize,visible:!1}:{type:`leaf`,data:e.view.toJSON(),size:n}},aV=class{get length(){return this._root?this._root.children.length:0}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;let{size:t,orthogonalSize:n}=this.root;this.root=eV(this.root,n,t),this.root.layout(t,n)}get width(){return this.root.width}get height(){return this.root.height}get minimumWidth(){return this.root.minimumWidth}get minimumHeight(){return this.root.minimumHeight}get maximumWidth(){return this.root.maximumHeight}get maximumHeight(){return this.root.maximumHeight}get locked(){return this._locked}set locked(e){this._locked=e;let t=[this.root];for(;t.length>0;){let n=t.pop();n instanceof ZB&&(n.disabled=e,t.push(...n.children))}}get margin(){return this._margin}set margin(e){this._margin=e,this.root.margin=e}maximizedView(){return this._maximizedNode?.leaf.view}hasMaximizedView(){return this._maximizedNode!==void 0}maximizeView(e){let t=tV(e.element),[n,r]=this.getNode(t);if(!(r instanceof XB)||this._maximizedNode?.leaf===r)return;this.hasMaximizedView()&&this.exitMaximizedView(),iV(this.getView(),this.orientation);let i=[];function a(e,t){for(let n=0;n<e.children.length;n++){let r=e.children[n];r instanceof XB?r!==t&&(e.isChildVisible(n)?e.setChildVisible(n,!1):i.push(r)):a(r,t)}}a(this.root,r),this._maximizedNode={leaf:r,hiddenOnMaximize:i},this._onDidMaximizedNodeChange.fire({view:r.view,isMaximized:!0})}exitMaximizedView(){if(!this._maximizedNode)return;let e=this._maximizedNode.hiddenOnMaximize;function t(n){for(let r=n.children.length-1;r>=0;r--){let i=n.children[r];i instanceof XB?e.includes(i)||n.setChildVisible(r,!0):t(i)}}t(this.root);let n=this._maximizedNode.leaf;this._maximizedNode=void 0,this._onDidMaximizedNodeChange.fire({view:n.view,isMaximized:!1})}serialize(){let e=this.maximizedView(),t;e&&(t=tV(e.element));let n=this._onDidMaximizedNodeChange.pause();try{this.hasMaximizedView()&&this.exitMaximizedView();let n={root:iV(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(n.maximizedNode={location:t}),e&&this.maximizeView(e),n}finally{n.dispose()}}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this._onDidMaximizedNodeChange.dispose(),this._onDidViewVisibilityChange.dispose(),this.root.dispose(),this._maximizedNode=void 0,this.element.remove()}clear(){let e=this.root.orientation;this.root=new ZB(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(e,t){let n=e.orientation,r=n===UB.VERTICAL?e.height:e.width;if(this._deserialize(e.root,n,t,r),this.layout(e.width,e.height),e.maximizedNode){let t=e.maximizedNode.location,[n,r]=this.getNode(t);if(!(r instanceof XB))return;this.maximizeView(r.view)}}_deserialize(e,t,n,r){this.root=this._deserializeNode(e,t,n,r)}_deserializeNode(e,t,n,r){var i;let a;if(e.type===`branch`){let i=e.data.map(r=>({node:this._deserializeNode(r,rV(t),n,e.size),visible:r.visible}));a=new ZB(t,this.proportionalLayout,this.styles,e.size,r,this.locked,this.margin,i)}else{let o=n.fromJSON(e);typeof e.visible==`boolean`&&((i=o.setVisible)==null||i.call(o,e.visible)),a=new XB(o,t,r,e.size)}return a}get root(){return this._root}set root(e){let t=this._root;t&&(t.dispose(),this._maximizedNode=void 0,this.element.removeChild(t.element)),this._root=e,this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}normalize(){if(!this._root||this._root.children.length!==1)return;let e=this.root,t=e.children[0];if(t instanceof XB)return;e.element.remove();let n=e.removeChild(0);e.dispose(),n.dispose(),this._root=$B(t,t.size,t.orthogonalSize),this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;let e=this.root;if(e.element.remove(),this._root=new ZB(rV(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),e.children.length!==0)if(e.children.length===1){let t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(eV(t,t.orthogonalSize,t.size),KB.Distribute,0)}else this._root.addChild(e,KB.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){let t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,n){let r={height:e.height,width:e.width};if(e instanceof XB)return{box:r,view:e.view,cachedVisibleSize:n};let i=[];for(let n=0;n<e.children.length;n++){let r=e.children[n],a=e.getChildCachedVisibleSize(n);i.push(this._getViews(r,rV(t),a))}return{box:r,children:i}}progmaticSelect(e,t=!1){let[n,r]=this.getNode(e);if(!(r instanceof XB))throw Error(`invalid location`);for(let r=n.length-1;r>-1;r--){let i=n[r],a=e[r]||0;if(t?a-1>-1:a+1<i.children.length)return QB(i.children[t?a-1:a+1],t)}return QB(this.root,t)}constructor(e,t,n,r,i){this.proportionalLayout=e,this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new pB,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new Q,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new Q,this.onDidMaximizedNodeChange=this._onDidMaximizedNodeChange.event,this.element=document.createElement(`div`),this.element.className=`dv-grid-view`,this._locked=r??!1,this._margin=i??0,this.root=new ZB(n,e,t,0,0,this.locked,this.margin)}isViewVisible(e){let[t,n]=FB(e),[,r]=this.getNode(t);if(!(r instanceof ZB))throw Error(`Invalid from location`);return r.isChildVisible(n)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();let[n,r]=FB(e),[,i]=this.getNode(n);if(!(i instanceof ZB))throw Error(`Invalid from location`);this._onDidViewVisibilityChange.fire(),i.setChildVisible(r,t)}moveView(e,t,n){this.hasMaximizedView()&&this.exitMaximizedView();let[,r]=this.getNode(e);if(!(r instanceof ZB))throw Error(`Invalid location`);r.moveChild(t,n)}addView(e,t,n){this.hasMaximizedView()&&this.exitMaximizedView();let[r,i]=FB(n),[a,o]=this.getNode(r);if(o instanceof ZB){let n=new XB(e,rV(o.orientation),o.orthogonalSize);o.addChild(n,t,i)}else{let[n,...s]=[...a].reverse(),[c,...l]=[...r].reverse(),u=0,d=n.getChildCachedVisibleSize(c);typeof d==`number`&&(u=KB.Invisible(d)),n.removeChild(c).dispose();let f=new ZB(o.orientation,this.proportionalLayout,this.styles,o.size,o.orthogonalSize,this.locked,this.margin);n.addChild(f,o.size,c);let p=new XB(o.view,n.orientation,o.size);f.addChild(p,u,0),typeof t!=`number`&&t.type===`split`&&(t={type:`split`,index:0});let m=new XB(e,n.orientation,o.size);f.addChild(m,t,i)}}remove(e,t){let n=tV(e.element);return this.removeView(n,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();let[n,r]=FB(e),[i,a]=this.getNode(n);if(!(a instanceof ZB))throw Error(`Invalid location`);let o=a.children[r];if(!(o instanceof XB))throw Error(`Invalid location`);if(a.removeChild(r,t),o.dispose(),a.children.length!==1)return o.view;let s=a.children[0];if(i.length===0)return s instanceof XB?o.view:(a.removeChild(0,t),this.root=s,o.view);let[c,...l]=[...i].reverse(),[u,...d]=[...n].reverse(),f=a.isChildVisible(0);a.removeChild(0,t);let p=c.children.map((e,t)=>c.getChildSize(t));if(c.removeChild(u,t).dispose(),s instanceof ZB){p.splice(u,1,...s.children.map(e=>e.size));for(let e=0;e<s.children.length;e++){let t=s.children[e];c.addChild(t,t.size,u+e)}for(;s.children.length>0;)s.removeChild(0)}else{let e=new XB(s.view,rV(s.orientation),s.size),t=f?s.orthogonalSize:KB.Invisible(s.orthogonalSize);c.addChild(e,t,u)}s.dispose();for(let e=0;e<p.length;e++)c.resizeChild(e,p[e]);return o.view}layout(e,t){let[n,r]=this.root.orientation===UB.HORIZONTAL?[t,e]:[e,t];this.root.layout(n,r)}getNode(e,t=this.root,n=[]){if(e.length===0)return[n,t];if(!(t instanceof ZB))throw Error(`Invalid location`);let[r,...i]=e;if(r<0||r>=t.children.length)throw Error(`Invalid location`);let a=t.children[r];return n.push(t),this.getNode(i,a,n)}},oV=Object.keys({disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0}),sV=class extends fB{get element(){return this._element}get disableResizing(){return this._disableResizing}set disableResizing(e){this._disableResizing=e}constructor(e,t=!1){super(),this._lastWidth=-1,this._lastHeight=-1,this._disableResizing=t,this._element=e,this.addDisposables(bB(this._element,e=>{if(this.isDisposed||this.disableResizing||!this._element.offsetParent||!NWe(this._element))return;let t=Math.round(e.contentRect.width),n=Math.round(e.contentRect.height);t===this._lastWidth&&n===this._lastHeight||(this._lastWidth=t,this._lastHeight=n,this.layout(t,n))}))}},KWe=VB();function cV(e){switch(e){case`left`:return`left`;case`right`:return`right`;case`above`:return`top`;case`below`:return`bottom`;default:return`center`}}var lV=class extends sV{get id(){return this._id}get size(){return this._groups.size}get groups(){return Array.from(this._groups.values()).map(e=>e.value)}get width(){return this.gridview.width}get height(){return this.gridview.height}get minimumHeight(){return this.gridview.minimumHeight}get maximumHeight(){return this.gridview.maximumHeight}get minimumWidth(){return this.gridview.minimumWidth}get maximumWidth(){return this.gridview.maximumWidth}get activeGroup(){return this._activeGroup}get locked(){return this.gridview.locked}set locked(e){this.gridview.locked=e}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._id=KWe.next(),this._groups=new Map,this._onDidRemove=new Q,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new Q,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new Q,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new Q,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new yB,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new yB,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height=`100%`,this.element.style.width=`100%`,this._classNames=new jB(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this.gridview=new aV(!!t.proportionalLayout,t.styles,t.orientation,t.locked,t.margin),this.gridview.locked=!!t.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(e=>{this._onDidMaximizedChange.fire({panel:e.view,isMaximized:e.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.forceRelayout()}),dB.from(()=>{var e;(e=this.element.parentElement)==null||e.removeChild(this.element)}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),mB.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(tV(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(tV(e.element))}updateOptions(e){e.proportionalLayout,e.orientation&&(this.gridview.orientation=e.orientation),`disableResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),`locked`in e&&(this.locked=e.locked??!1),`margin`in e&&(this.gridview.margin=e.margin??0),`className`in e&&this._classNames.setClassNames(e.className??``)}maximizeGroup(e){this.gridview.maximizeView(e),this.doSetGroupActive(e)}isMaximizedGroup(e){return this.gridview.maximizedView()===e}exitMaximizedGroup(){this.gridview.exitMaximizedView()}hasMaximizedGroup(){return this.gridview.hasMaximizedView()}doAddGroup(e,t=[0],n,r=this.gridview){r.addView(e,n??KB.Distribute,t),this._onDidAdd.fire(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw Error(`invalid operation`);let n=this._groups.get(e.id),r=this.gridview.remove(e,KB.Distribute);if(n&&!t?.skipDispose&&(n.disposable.dispose(),n.value.dispose(),this._groups.delete(e.id),this._onDidRemove.fire(e)),!t?.skipActive&&this._activeGroup===e){let e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return r}getPanel(e){return this._groups.get(e)?.value}doSetGroupActive(e){this._activeGroup!==e&&(this._activeGroup&&this._activeGroup.setActive(!1),e&&e.setActive(!0),this._activeGroup=e,this._onDidActiveChange.fire(e))}removeGroup(e){this.doRemoveGroup(e)}moveToNext(e){if(e||={},!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}let t=tV(e.group.element),n=this.gridview.next(t)?.view;this.doSetGroupActive(n)}moveToPrevious(e){if(e||={},!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}let t=tV(e.group.element),n=this.gridview.previous(t)?.view;this.doSetGroupActive(n)}forceRelayout(){this.layout(this.width,this.height,!0)}layout(e,t,n){(n||e!==this.width||t!==this.height)&&(this.gridview.element.style.height=`${t}px`,this.gridview.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){this._onDidActiveChange.dispose(),this._onDidAdd.dispose(),this._onDidRemove.dispose();for(let e of this.groups)e.dispose();this.gridview.dispose(),super.dispose()}},uV=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get length(){return this.component.length}get orientation(){return this.component.orientation}get panels(){return this.component.panels}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}constructor(e){this.component=e}removePanel(e,t){this.component.removePanel(e,t)}focus(){this.component.focus()}getPanel(e){return this.component.getPanel(e)}layout(e,t){return this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},dV=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get panels(){return this.component.panels}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}get onDidDrop(){return this.component.onDidDrop}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}constructor(e){this.component=e}removePanel(e){this.component.removePanel(e)}getPanel(e){return this.component.getPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}focus(){this.component.focus()}layout(e,t){this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},fV=class{get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddPanel(){return this.component.onDidAddGroup}get onDidRemovePanel(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActiveGroupChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get panels(){return this.component.groups}get orientation(){return this.component.orientation}set orientation(e){this.component.updateOptions({orientation:e})}constructor(e){this.component=e}focus(){this.component.focus()}layout(e,t,n=!1){this.component.layout(e,t,n)}addPanel(e){return this.component.addPanel(e)}removePanel(e,t){this.component.removePanel(e,t)}movePanel(e,t){this.component.movePanel(e,t)}getPanel(e){return this.component.getPanel(e)}fromJSON(e){return this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},pV=class{get id(){return this.component.id}get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get size(){return this.component.size}get tabGroupColors(){return this.component.tabGroupColorPalette.entries()}get totalPanels(){return this.component.totalPanels}get onDidActiveGroupChange(){return this.component.onDidActiveGroupChange}get onDidAddGroup(){return this.component.onDidAddGroup}get onDidRemoveGroup(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActivePanelChange}get onDidAddPanel(){return this.component.onDidAddPanel}get onDidRemovePanel(){return this.component.onDidRemovePanel}get onDidMovePanel(){return this.component.onDidMovePanel}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}get onWillDrop(){return this.component.onWillDrop}get onWillMutateLayout(){return this.component.onWillMutateLayout}get onDidMutateLayout(){return this.component.onDidMutateLayout}get onWillShowOverlay(){return this.component.onWillShowOverlay}get onWillDragGroup(){return this.component.onWillDragGroup}get onWillDragPanel(){return this.component.onWillDragPanel}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}get onDidPopoutGroupSizeChange(){return this.component.onDidPopoutGroupSizeChange}get onDidPopoutGroupPositionChange(){return this.component.onDidPopoutGroupPositionChange}get onDidAddPopoutGroup(){return this.component.onDidAddPopoutGroup}get onDidRemovePopoutGroup(){return this.component.onDidRemovePopoutGroup}get onDidOpenPopoutWindowFail(){return this.component.onDidOpenPopoutWindowFail}getPopouts(){return this.component.getPopouts()}get onDidCreateTabGroup(){return this.component.onDidCreateTabGroup}get onDidDestroyTabGroup(){return this.component.onDidDestroyTabGroup}get onDidAddPanelToTabGroup(){return this.component.onDidAddPanelToTabGroup}get onDidRemovePanelFromTabGroup(){return this.component.onDidRemovePanelFromTabGroup}get onDidTabGroupChange(){return this.component.onDidTabGroupChange}get onDidTabGroupCollapsedChange(){return this.component.onDidTabGroupCollapsedChange}get panels(){return this.component.panels}get groups(){return this.component.groups}adjacentGroupInDirection(e,t){return this.component.adjacentGroupInDirection(e,t)}get activePanel(){return this.component.activePanel}get activeGroup(){return this.component.activeGroup}constructor(e){this.component=e}focus(){this.component.focus()}getPanel(e){return this.component.getGroupPanel(e)}layout(e,t,n=!1){this.component.layout(e,t,n)}addPanel(e){return this.component.withOrigin(`api`,()=>this.component.addPanel(e))}removePanel(e){this.component.withOrigin(`api`,()=>this.component.removePanel(e))}addGroup(e){return this.component.addGroup(e)}closeAllGroups(){return this.component.withOrigin(`api`,()=>this.component.closeAllGroups())}removeGroup(e){this.component.withOrigin(`api`,()=>this.component.removeGroup(e))}getGroup(e){return this.component.getPanel(e)}addFloatingGroup(e,t){return this.component.withOrigin(`api`,()=>this.component.addFloatingGroup(e,t))}fromJSON(e,t){this.component.withOrigin(`api`,()=>this.component.fromJSON(e,t))}toJSON(){return this.component.toJSON()}clear(){this.component.withOrigin(`api`,()=>this.component.clear())}moveToNext(e){this.component.moveToNext(e)}moveToPrevious(e){this.component.moveToPrevious(e)}maximizeGroup(e){this.component.maximizeGroup(e.group)}hasMaximizedGroup(){return this.component.hasMaximizedGroup()}exitMaximizedGroup(){this.component.exitMaximizedGroup()}get onDidMaximizedGroupChange(){return this.component.onDidMaximizedGroupChange}addPopoutGroup(e,t){return this.component.withOrigin(`api`,()=>this.component.addPopoutGroup(e,t))}addEdgeGroup(e,t){return this.component.addEdgeGroup(e,t)}getEdgeGroup(e){return this.component.getEdgeGroup(e)}setEdgeGroupVisible(e,t){this.component.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this.component.isEdgeGroupVisible(e)}removeEdgeGroup(e){this.component.removeEdgeGroup(e)}updateOptions(e){this.component.updateOptions(e)}_getGroupModel(e){let t=this.component.getPanel(e);if(!t)throw Error(`dockview: group '${e}' not found`);return t.model}createTabGroup(e){let t=this._getGroupModel(e.groupId);return this.component.withOrigin(`api`,()=>t.createTabGroup({label:e.label,color:e.color,componentParams:e.componentParams}))}dissolveTabGroup(e){let t=this._getGroupModel(e.groupId);this.component.withOrigin(`api`,()=>t.dissolveTabGroup(e.tabGroupId))}addPanelToTabGroup(e){let t=this._getGroupModel(e.groupId);this.component.withOrigin(`api`,()=>t.addPanelToTabGroup(e.tabGroupId,e.panelId,e.index))}removePanelFromTabGroup(e){let t=this._getGroupModel(e.groupId);this.component.withOrigin(`api`,()=>t.removePanelFromTabGroup(e.panelId))}getTabGroups(e){return this._getGroupModel(e.groupId).getTabGroups()}getTabGroupForPanel(e){return this._getGroupModel(e.groupId).getTabGroupForPanel(e.panelId)}moveTabGroup(e){this._getGroupModel(e.groupId).moveTabGroup(e.tabGroupId,e.index)}dispose(){this.component.dispose()}},mV=class extends fB{constructor(e,t){super(),this.element=e,this.callbacks=t,this.target=null,this.registerListeners()}onDragEnter(e){this.target=e.target,this.callbacks.onDragEnter(e)}onDragOver(e){e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}onDragLeave(e){this.target===e.target&&(this.target=null,this.callbacks.onDragLeave(e))}onDragEnd(e){this.target=null,this.callbacks.onDragEnd(e)}onDrop(e){this.callbacks.onDrop(e)}registerListeners(){this.addDisposables(vB(this.element,`dragenter`,e=>{this.onDragEnter(e)},!0)),this.addDisposables(vB(this.element,`dragover`,e=>{this.onDragOver(e)},!0)),this.addDisposables(vB(this.element,`dragleave`,e=>{this.onDragLeave(e)})),this.addDisposables(vB(this.element,`dragend`,e=>{this.onDragEnd(e)})),this.addDisposables(vB(this.element,`drop`,e=>{this.onDrop(e)}))}},qWe={value:50,type:`percentage`},JWe=100,YWe=100;function hV(){let e=document.createElement(`div`);e.className=`dv-drop-target-dropzone`;let t=document.createElement(`div`);return t.className=`dv-drop-target-selection`,e.appendChild(t),{dropzone:e,selection:t}}function gV(e,t,n,r){let i=r?.smallWidthBoundary??JWe,a=r?.smallHeightBoundary??YWe,o=t<i,s=n<a,c=e===`left`,l=e===`right`,u=e===`top`,d=e===`bottom`,f=!o&&l,p=!o&&c,m=!s&&u,h=!s&&d,g=1,_=r?.size??qWe;return _.type===`percentage`?g=BB(_.value,0,100)/100:((f||p)&&(g=BB(0,_.value,t)/t),(m||h)&&(g=BB(0,_.value,n)/n)),{isSmallX:o,isSmallY:s,isLeft:c,isRight:l,isTop:u,isBottom:d,rightClass:f,leftClass:p,topClass:m,bottomClass:h,size:g}}function _V(e,t,n,r,i){let a=gV(t,n,r,i),{rightClass:o,leftClass:s,topClass:c,bottomClass:l,size:u}=a,d={top:`0px`,left:`0px`,width:`100%`,height:`100%`};o?(d.left=`${100*(1-u)}%`,d.width=`${100*u}%`):s?d.width=`${100*u}%`:c?d.height=`${100*u}%`:l&&(d.top=`${100*(1-u)}%`,d.height=`${100*u}%`),a.isSmallX&&a.isLeft&&(d.width=`4px`),a.isSmallX&&a.isRight&&(d.left=`${n-4}px`,d.width=`4px`),a.isSmallY&&a.isTop&&(d.height=`4px`),a.isSmallY&&a.isBottom&&(d.top=`${r-4}px`,d.height=`4px`),e.style.top=d.top,e.style.left=d.left,e.style.width=d.width,e.style.height=d.height,e.style.visibility=`visible`,(!e.style.transform||e.style.transform===``)&&(e.style.transform=`translate3d(0, 0, 0)`);let f=a.isSmallX&&(a.isLeft||a.isRight)||a.isSmallY&&(a.isTop||a.isBottom);CB(e,`dv-drop-target-small-vertical`,a.isSmallY),CB(e,`dv-drop-target-small-horizontal`,a.isSmallX),CB(e,`dv-drop-target-selection-line`,f),CB(e,`dv-drop-target-left`,a.isLeft),CB(e,`dv-drop-target-right`,a.isRight),CB(e,`dv-drop-target-top`,a.isTop),CB(e,`dv-drop-target-bottom`,a.isBottom),CB(e,`dv-drop-target-center`,t===`center`)}function XWe(e,t){let n=`${Math.round(t.top)}px`,r=`${Math.round(t.left)}px`,i=`${Math.round(t.width)}px`,a=`${Math.round(t.height)}px`;return e.style.top!==n||e.style.left!==r||e.style.width!==i||e.style.height!==a}function ZWe(e,t){e.style.top=`${Math.round(t.top)}px`,e.style.left=`${Math.round(t.left)}px`,e.style.width=`${Math.round(t.width)}px`,e.style.height=`${Math.round(t.height)}px`,e.style.visibility=`visible`,(!e.style.transform||e.style.transform===``)&&(e.style.transform=`translate3d(0, 0, 0)`)}function vV(e){let t=gV(e.quadrant,e.width,e.height,e.overlayModel),{rightClass:n,leftClass:r,topClass:i,bottomClass:a,size:o}=t,s=e.outlineElement.getBoundingClientRect(),c=e.targetModel.getElements(void 0,e.outlineElement),l=c.root,u=c.overlay,d=l.getBoundingClientRect(),f=s.top-d.top,p=s.left-d.left,m={top:f,left:p,width:e.width,height:e.height};return n?(m.left=p+e.width*(1-o),m.width=e.width*o):r?m.width=e.width*o:i?m.height=e.height*o:a&&(m.top=f+e.height*(1-o),m.height=e.height*o),t.isSmallX&&t.isLeft&&(m.width=4),t.isSmallX&&t.isRight&&(m.left=p+e.width-4,m.width=4),t.isSmallY&&t.isTop&&(m.height=4),t.isSmallY&&t.isBottom&&(m.top=f+e.height-4,m.height=4),XWe(u,m)?(ZWe(u,m),u.className=`dv-drop-target-anchor${e.className?` ${e.className}`:``}`,CB(u,`dv-drop-target-left`,t.isLeft),CB(u,`dv-drop-target-right`,t.isRight),CB(u,`dv-drop-target-top`,t.isTop),CB(u,`dv-drop-target-bottom`,t.isBottom),CB(u,`dv-drop-target-anchor-line`,t.isSmallX&&(t.isLeft||t.isRight)||t.isSmallY&&(t.isTop||t.isBottom)),CB(u,`dv-drop-target-center`,e.quadrant===`center`),c.changed&&(CB(u,`dv-drop-target-anchor-container-changed`,!0),setTimeout(()=>{CB(u,`dv-drop-target-anchor-container-changed`,!1)},10)),{boundsChanged:!0,targetChanged:c.changed}):{boundsChanged:!1,targetChanged:c.changed}}var yV=class extends hB{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}constructor(e){super(),this.options=e}};function bV(e){switch(e){case`above`:return`top`;case`below`:return`bottom`;case`left`:return`left`;case`right`:return`right`;case`within`:return`center`;default:throw Error(`invalid direction '${e}'`)}}function QWe(e){switch(e){case`top`:return`above`;case`bottom`:return`below`;case`left`:return`left`;case`right`:return`right`;case`center`:return`within`;default:throw Error(`invalid position '${e}'`)}}var $We={value:20,type:`percentage`},xV=class e extends fB{get disabled(){return this._disabled}set disabled(e){this._disabled=e}get state(){return this._state}constructor(t,n){super(),this.element=t,this.options=n,this._onDrop=new Q,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new Q,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new mV(this.element,{onDragEnter:()=>{var e,t;(t=(e=this.options).getOverrideTarget?.call(e))==null||t.getElements()},onDragOver:t=>{var n,r;e.ACTUAL_TARGET=this;let i=(n=this.options).getOverrideTarget?.call(n);if(this._acceptedTargetZonesSet.size===0){if(i)return;this.removeDropTarget();return}let a=(r=this.options).getOverlayOutline?.call(r)??this.element,o=a.offsetWidth,s=a.offsetHeight;if(o===0||s===0)return;let c=t.currentTarget.getBoundingClientRect(),l=(t.clientX??0)-c.left,u=(t.clientY??0)-c.top,d=this.calculateQuadrant(this._acceptedTargetZonesSet,l,u,o,s);if(this.isAlreadyUsed(t)||d===null){this.removeDropTarget();return}if(!this.options.canDisplayOverlay(t,d)){if(i)return;this.removeDropTarget();return}let f=new yV({nativeEvent:t,position:d});if(this._onWillShowOverlay.fire(f),f.defaultPrevented){this.removeDropTarget();return}if(this.markAsUsed(t),!i&&!this.targetElement){let e=hV();this.targetElement=e.dropzone,this.overlayElement=e.selection,this._state=`center`,a.classList.add(`dv-drop-target`),a.append(this.targetElement)}this.toggleClasses(d,o,s),this._state=d},onDragLeave:()=>{var e;(e=this.options).getOverrideTarget?.call(e)||this.removeDropTarget()},onDragEnd:t=>{var n;let r=(n=this.options).getOverrideTarget?.call(n);r&&e.ACTUAL_TARGET===this&&this._state&&(t.stopPropagation(),this._onDrop.fire({position:this._state,nativeEvent:t})),this.removeDropTarget(),r?.clear()},onDrop:e=>{var t,n;e.preventDefault();let r=this._state;this.removeDropTarget(),(n=(t=this.options).getOverrideTarget?.call(t))==null||n.clear(),r&&(e.stopPropagation(),this._onDrop.fire({position:r,nativeEvent:e}))}}),this.addDisposables(this._onDrop,this._onWillShowOverlay,this.dnd)}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this.removeDropTarget(),super.dispose()}markAsUsed(t){t[e.USED_EVENT_ID]=!0}isAlreadyUsed(t){let n=t[e.USED_EVENT_ID];return typeof n==`boolean`&&n}toggleClasses(e,t,n){var r,i;let a=(r=this.options).getOverrideTarget?.call(r);if(a){vV({outlineElement:(i=this.options).getOverlayOutline?.call(i)??this.element,targetModel:a,quadrant:e,width:t,height:n,overlayModel:this.options.overlayModel,className:this.options.className});return}this.overlayElement&&_V(this.overlayElement,e,t,n,this.options.overlayModel)}calculateQuadrant(e,t,n,r,i){let a=this.options.overlayModel?.activationSize??$We;return a.type===`percentage`?SV(e,t,n,r,i,a.value):CV(e,t,n,r,i,a.value)}removeDropTarget(){var e;this.targetElement&&(this._state=void 0,(e=this.targetElement.parentElement)==null||e.classList.remove(`dv-drop-target`),this.targetElement.remove(),this.targetElement=void 0,this.overlayElement=void 0)}showOverlay(e){var t,n;let r=(t=this.options).getOverrideTarget?.call(t),i=(n=this.options).getOverlayOutline?.call(n)??this.element,a=i.offsetWidth,o=i.offsetHeight;if(!r&&!this.targetElement){let e=hV();this.targetElement=e.dropzone,this.overlayElement=e.selection,i.classList.add(`dv-drop-target`),i.append(this.targetElement)}this.toggleClasses(e,a,o),this._state=e}clearOverlay(){var e,t;this.removeDropTarget(),(t=(e=this.options).getOverrideTarget?.call(e))==null||t.clear(),this._state=void 0}};xV.USED_EVENT_ID=`__dockview_droptarget_event_is_used__`;function SV(e,t,n,r,i,a){let o=100*t/r,s=100*n/i;return e.has(`left`)&&o<a?`left`:e.has(`right`)&&o>100-a?`right`:e.has(`top`)&&s<a?`top`:e.has(`bottom`)&&s>100-a?`bottom`:e.has(`center`)?`center`:null}function CV(e,t,n,r,i,a){return e.has(`left`)&&t<a?`left`:e.has(`right`)&&t>r-a?`right`:e.has(`top`)&&n<a?`top`:e.has(`bottom`)&&n>i-a?`bottom`:e.has(`center`)?`center`:null}function eGe(e,t,n){SB(t,`dv-dragged`),t.style.top=`-9999px`,document.body.appendChild(t),e.setDragImage(t,n?.x??0,n?.y??0),setTimeout(()=>{xB(t,`dv-dragged`),t.remove()},0)}var wV=class e extends fB{static getInstance(){return e._instance||=new e,e._instance}constructor(){super(),this._targets=new Set,this._targetByElement=new Map,this._onDragStart=new Q,this.onDragStart=this._onDragStart.event,this._onDragMove=new Q,this.onDragMove=this._onDragMove.event,this._onDragEnd=new Q,this.onDragEnd=this._onDragEnd.event,this.addDisposables(this._onDragStart,this._onDragMove,this._onDragEnd)}get active(){return this._active}registerTarget(e){return this._targets.add(e),this._targetByElement.set(e.element,e),{dispose:()=>{this._targets.delete(e),this._targetByElement.get(e.element)===e&&this._targetByElement.delete(e.element),this._currentTarget===e&&(this._currentTarget=void 0)}}}beginDrag(e){this._active&&this.cancel();let{pointerEvent:t,source:n}=e,r=e.getData();this._active={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,source:n},this._onDragMoveCallback=e.onDragMove,this._onDragEndCallback=e.onDragEnd,this._dataDisposable=r,this._ghost=e.ghost,this._iframeShield=AB(n.ownerDocument??document);let i={clientX:t.clientX,clientY:t.clientY,pointerEvent:t};this._onDragStart.fire(i);let a=n.ownerDocument?.defaultView??window;this._moveListener=vB(a,`pointermove`,e=>{!this._active||e.pointerId!==this._active.pointerId||this._handleMove(e)}),this._upListener=vB(a,`pointerup`,e=>{!this._active||e.pointerId!==this._active.pointerId||this._handleEnd(e,!0)}),this._cancelListener=vB(a,`pointercancel`,e=>{!this._active||e.pointerId!==this._active.pointerId||this._handleEnd(e,!1)})}cancel(){var e,t;this._active&&((e=this._currentTarget)==null||e.handleDragLeave(),this._teardown(),(t=this._dataDisposable)==null||t.dispose(),this._dataDisposable=void 0)}_findTargetUnder(e,t){let n=(this._active?.source.ownerDocument??document).elementsFromPoint(e,t);for(let e of n){let t=e;for(;t;){let e=this._targetByElement.get(t);if(e)return e;t=t.parentElement}}}_handleMove(e){var t,n,r;(t=this._ghost)==null||t.update(e.clientX,e.clientY);let i={clientX:e.clientX,clientY:e.clientY,pointerEvent:e},a=this._findTargetUnder(e.clientX,e.clientY);a!==this._currentTarget&&((n=this._currentTarget)==null||n.handleDragLeave(),this._currentTarget=a),a&&a.handleDragOver(i),(r=this._onDragMoveCallback)==null||r.call(this,i),this._onDragMove.fire(i)}_handleEnd(e,t){var n;let r={clientX:e.clientX,clientY:e.clientY,pointerEvent:e};t&&this._currentTarget?this._currentTarget.handleDrop(r):(n=this._currentTarget)==null||n.handleDragLeave();let i=this._onDragEndCallback,a=this._dataDisposable;this._teardown(),this._dataDisposable=void 0,setTimeout(()=>a?.dispose(),0),i?.(r,t),this._onDragEnd.fire(r)}_teardown(){var e,t,n,r,i;this._currentTarget=void 0,this._active=void 0,this._onDragMoveCallback=void 0,this._onDragEndCallback=void 0,(e=this._ghost)==null||e.dispose(),this._ghost=void 0,(t=this._iframeShield)==null||t.release(),this._iframeShield=void 0,(n=this._moveListener)==null||n.dispose(),(r=this._upListener)==null||r.dispose(),(i=this._cancelListener)==null||i.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}},tGe={value:20,type:`percentage`},nGe=class extends fB{get disabled(){return this._disabled}set disabled(e){this._disabled=e,e&&this._removeOverlay()}get state(){return this._state}constructor(e,t){super(),this.element=e,this.options=t,this._onDrop=new Q,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new Q,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(t.acceptedTargetZones);let n={element:this.element,handleDragOver:e=>this._onDragOver(e),handleDragLeave:()=>this._onDragLeave(),handleDrop:e=>this._onDropEvent(e)};this.addDisposables(this._onDrop,this._onWillShowOverlay,wV.getInstance().registerTarget(n))}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this._removeOverlay(),super.dispose()}_onDragOver(e){var t,n;if(this._disabled){this._removeOverlay();return}let r=(t=this.options).getOverrideTarget?.call(t);if(this._acceptedTargetZonesSet.size===0){if(r)return;this._removeOverlay();return}let i=(n=this.options).getOverlayOutline?.call(n)??this.element,a=i.offsetWidth,o=i.offsetHeight;if(a===0||o===0)return;let s=i.getBoundingClientRect(),c=e.clientX-s.left,l=e.clientY-s.top,u=this._calculateQuadrant(c,l,a,o);if(u===null){this._removeOverlay();return}if(!this.options.canDisplayOverlay(e.pointerEvent,u)){if(r)return;this._removeOverlay();return}let d=new yV({nativeEvent:e.pointerEvent,position:u});if(this._onWillShowOverlay.fire(d),d.defaultPrevented){this._removeOverlay();return}if(r){vV({outlineElement:i,targetModel:r,quadrant:u,width:a,height:o,overlayModel:this.options.overlayModel,className:this.options.className}),this._state=u;return}if(!this._targetElement){let e=hV();this._targetElement=e.dropzone,this._overlayElement=e.selection,this._state=`center`,this.element.classList.add(`dv-drop-target`),this.element.append(this._targetElement)}this._overlayElement&&_V(this._overlayElement,u,a,o,this.options.overlayModel),this._state=u}_onDragLeave(){var e;let t=(e=this.options).getOverrideTarget?.call(e);if(t){this._state=void 0,t.clear();return}this._removeOverlay()}_onDropEvent(e){var t;let n=this._state,r=(t=this.options).getOverrideTarget?.call(t);this._removeOverlay(),r?.clear(),n&&this._onDrop.fire({position:n,nativeEvent:e.pointerEvent})}_calculateQuadrant(e,t,n,r){let i=this.options.overlayModel?.activationSize??tGe;return i.type===`percentage`?SV(this._acceptedTargetZonesSet,e,t,n,r,i.value):CV(this._acceptedTargetZonesSet,e,t,n,r,i.value)}_removeOverlay(){var e;this._targetElement?(this._state=void 0,(e=this._targetElement.parentElement)==null||e.classList.remove(`dv-drop-target`),this._targetElement.remove(),this._targetElement=void 0,this._overlayElement=void 0):this._state=void 0}},rGe=5,iGe=250,aGe=8,oGe=class extends fB{constructor(e,t){super(),this.element=e,this.options=t,this._disabled=!1,this._armed=!1,this._startX=0,this._startY=0,this._touchOnly=t.touchOnly??!0,this.addDisposables(vB(this.element,`pointerdown`,e=>{this._onPointerDown(e)}))}setDisabled(e){this._disabled=e,e&&this._cancelPending()}setTouchOnly(e){this._touchOnly!==e&&(this._touchOnly=e,e&&this._cancelPending())}_shouldHandle(e){var t;return!(this._disabled||this._touchOnly&&e.pointerType!==`touch`&&e.pointerType!==`pen`||(t=this.options).isCancelled?.call(t,e))}_onPointerDown(e){if(!this._shouldHandle(e))return;this._cancelPending(),this._pendingPointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY,this._startEvent=e;let t=e.pointerType===`touch`||e.pointerType===`pen`,n=this.options.touchInitiationDelay,r=(typeof n==`function`?n():n)??iGe;this._armed=!t||r<=0,t&&r>0&&isFinite(r)&&(this._armTimer=setTimeout(()=>{this._armTimer=void 0,this._armed=!0},r));let i=this.options.threshold??rGe,a=this.options.pressTolerance,o=(typeof a==`function`?a():a)??aGe,s=this.element.ownerDocument?.defaultView??window;this._pendingMoveListener=vB(s,`pointermove`,e=>{if(e.pointerId!==this._pendingPointerId)return;let t=e.clientX-this._startX,n=e.clientY-this._startY,r=Math.hypot(t,n);if(this._armed){r>=i&&this._beginDrag(e);return}r>o&&this._beginDrag(e)}),this._pendingUpListener=vB(s,`pointerup`,e=>{e.pointerId===this._pendingPointerId&&this._cancelPending()}),this._pendingCancelListener=vB(s,`pointercancel`,e=>{e.pointerId===this._pendingPointerId&&this._cancelPending()})}cancelPending(){this._cancelPending()}_cancelPending(){var e,t,n;this._pendingPointerId=void 0,this._armTimer!==void 0&&(clearTimeout(this._armTimer),this._armTimer=void 0),this._armed=!1,(e=this._pendingMoveListener)==null||e.dispose(),(t=this._pendingUpListener)==null||t.dispose(),(n=this._pendingCancelListener)==null||n.dispose(),this._pendingMoveListener=void 0,this._pendingUpListener=void 0,this._pendingCancelListener=void 0,this._startEvent=void 0}_beginDrag(e){var t,n,r;let i=this._startEvent??e;this._cancelPending(),(n=(t=this.options).onDragStart)==null||n.call(t,i);let a=(r=this.options).createGhost?.call(r,i);wV.getInstance().beginDrag({pointerEvent:e,source:this.element,getData:()=>this.options.getData(i),ghost:a,onDragMove:this.options.onDragMove,onDragEnd:this.options.onDragEnd})}dispose(){this._cancelPending(),super.dispose()}},sGe=class{constructor(e){this._disposed=!1,this.element=e.element,this.offsetX=e.offsetX??0,this.offsetY=e.offsetY??0,this.element.style.position=`fixed`,this.element.style.left=`0px`,this.element.style.top=`0px`,this.element.style.pointerEvents=`none`,this.element.style.zIndex=`99999`,this.element.style.opacity=String(e.opacity??.8),this.element.style.willChange=`transform`,this.element.style.transform=`translate3d(${e.initialX-this.offsetX}px, ${e.initialY-this.offsetY}px, 0)`,(e.owner?.ownerDocument??document).body.appendChild(this.element)}update(e,t){this._disposed||(this.element.style.transform=`translate3d(${e-this.offsetX}px, ${t-this.offsetY}px, 0)`)}dispose(){this._disposed||(this._disposed=!0,this.element.remove())}},cGe=class extends fB{constructor(e,t){super(),this.el=e,this.opts=t,this._dataDisposable=new pB,this._pointerEventsDisposable=new pB,this._disabled=!!t.disabled,this.addDisposables(this._dataDisposable,this._pointerEventsDisposable,vB(this.el,`dragstart`,e=>{var t,n,r,i;if(e.defaultPrevented||this._disabled||(t=this.opts).isCancelled?.call(t,e)){e.preventDefault();return}let a=AB(this.el.ownerDocument??document);this._pointerEventsDisposable.value={dispose:()=>a.release()},this.el.classList.add(`dv-dragged`),setTimeout(()=>this.el.classList.remove(`dv-dragged`),0),this._dataDisposable.value=this.opts.getData(e);let o=(n=this.opts).createGhost?.call(n,e);if(o&&e.dataTransfer&&(eGe(e.dataTransfer,o.element,{x:o.offsetX??0,y:o.offsetY??0}),o.dispose)){let e=o.dispose;setTimeout(()=>e(),0)}e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.items.length===0&&e.dataTransfer.setData(`text/plain`,``)),(i=(r=this.opts).onDragStart)==null||i.call(r,e)}),vB(this.el,`dragend`,e=>{var t,n;this._pointerEventsDisposable.dispose(),setTimeout(()=>this._dataDisposable.dispose(),0),(n=(t=this.opts).onDragEnd)==null||n.call(t,e)}))}setDisabled(e){this._disabled=e}setTouchOnly(e){}cancelPending(){}},lGe=class{constructor(){this.kind=`html5`}createDropTarget(e,t){return new xV(e,t)}createDragSource(e,t){return new cGe(e,t)}},uGe=class{constructor(){this.kind=`pointer`}createDropTarget(e,t){return new nGe(e,t)}createDragSource(e,t){let n=t.createGhost?n=>{let r=t.createGhost(n);if(!r)return;let i=new sGe({element:r.element,initialX:n.clientX,initialY:n.clientY,offsetX:r.offsetX,offsetY:r.offsetY,owner:e});if(r.dispose){let e=i.dispose.bind(i),t=r.dispose;i.dispose=()=>{e(),t()}}return i}:void 0,r=new oGe(e,{getData:t.getData,isCancelled:t.isCancelled,onDragStart:t.onDragStart,onDragEnd:t.onDragEnd?e=>t.onDragEnd(e.pointerEvent):void 0,createGhost:n,touchOnly:t.touchOnly,touchInitiationDelay:t.touchInitiationDelay,pressTolerance:t.pressTolerance,threshold:t.threshold});return t.disabled&&r.setDisabled(!0),r}},TV=new lGe,EV=new uGe,DV=Object.keys({disableAutoResizing:void 0,disableDnd:void 0,className:void 0}),dGe=class extends gB{constructor(e,t,n,r){super(),this.nativeEvent=e,this.position=t,this.getData=n,this.panel=r}},OV=class extends hB{constructor(){super()}},kV=class extends fB{get isFocused(){return this._isFocused}get isActive(){return this._isActive}get isVisible(){return this._isVisible}get width(){return this._width}get height(){return this._height}constructor(e,t){super(),this.id=e,this.component=t,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this._parameters={},this.panelUpdatesDisposable=new pB,this._onDidDimensionChange=new Q,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new Q,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new Q,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new Q,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new Q,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new Q,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new Q,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new Q,this.onDidParametersChange=this._onDidParametersChange.event,this.addDisposables(this.onDidFocusChange(e=>{this._isFocused=e.isFocused}),this.onDidActiveChange(e=>{this._isActive=e.isActive}),this.onDidVisibilityChange(e=>{this._isVisible=e.isVisible}),this.onDidDimensionsChange(e=>{this._width=e.width,this._height=e.height}),this.panelUpdatesDisposable,this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onWillFocus,this._onActiveChange,this._onWillFocus,this._onWillVisibilityChange,this._onDidParametersChange)}getParameters(){return this._parameters}initialize(e){this.panelUpdatesDisposable.value=this._onDidParametersChange.event(t=>{this._parameters=t,e.update({params:t})})}setVisible(e){this._onWillVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onDidParametersChange.fire(e)}},AV=class extends kV{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new Q,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new Q({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new Q,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},fGe=class extends AV{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new Q({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new Q({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new Q({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;(t=this._pane)==null||t.setExpanded(e)}get isExpanded(){return!!this._pane?.isExpanded()}},jV=class extends fB{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){return this._params?.params}constructor(e,t,n){super(),this.id=e,this.component=t,this.api=n,this._height=0,this._width=0,this._element=document.createElement(`div`),this._element.tabIndex=-1,this._element.style.outline=`none`,this._element.style.height=`100%`,this._element.style.width=`100%`,this._element.style.overflow=`hidden`;let r=TB(this._element);this.addDisposables(this.api,r.onDidFocus(()=>{this.api._onDidChangeFocus.fire({isFocused:!0})}),r.onDidBlur(()=>{this.api._onDidChangeFocus.fire({isFocused:!1})}),r)}focus(){let e=new OV;this.api._onWillFocus.fire(e),!e.defaultPrevented&&this._element.focus()}layout(e,t){this._width=e,this._height=t,this.api._onDidDimensionChange.fire({width:e,height:t}),this.part&&this._params&&this.part.update(this._params.params)}init(e){this._params=e,this.part=this.getComponent()}update(e){var t;this._params=Object.assign(Object.assign({},this._params),{params:Object.assign(Object.assign({},this._params?.params),e.params)});for(let t of Object.keys(e.params))e.params[t]===void 0&&delete this._params.params[t];(t=this.part)==null||t.update({params:this._params.params})}toJSON(){let e=this._params?.params??{};return{id:this.id,component:this.component,params:Object.keys(e).length>0?e:void 0}}dispose(){var e;this.api.dispose(),(e=this.part)==null||e.dispose(),super.dispose()}},pGe=class extends jV{set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){return this.headerSize+(this.isExpanded()?this._minimumBodySize:0)}get maximumSize(){return this.headerSize+(this.isExpanded()?this._maximumBodySize:0)}get size(){return this._size}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get minimumBodySize(){return this._minimumBodySize}set minimumBodySize(e){this._minimumBodySize=typeof e==`number`?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize=typeof e==`number`?e:1/0}get headerVisible(){return this._headerVisible}set headerVisible(e){this._headerVisible=e,this.header.style.display=e?``:`none`}constructor(e){super(e.id,e.component,new fGe(e.id,e.component)),this._onDidChangeExpansionState=new Q({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._orthogonalSize=0,this._size=0,this._isExpanded=!1,this.api.pane=this,this.api.initialize(this),this.headerSize=e.headerSize,this.headerComponent=e.headerComponent,this._minimumBodySize=e.minimumBodySize,this._maximumBodySize=e.maximumBodySize,this._isExpanded=e.isExpanded,this._headerVisible=e.isHeaderVisible,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=e.orientation,this.element.classList.add(`dv-pane`),this.addDisposables(this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}),vB(this.element,`mouseenter`,e=>{this.api._onMouseEnter.fire(e)}),vB(this.element,`mouseleave`,e=>{this.api._onMouseLeave.fire(e)})),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState(e=>{this.api._onDidExpansionChange.fire({isExpanded:e})}),this.api.onDidFocusChange(e=>{this.header&&(e.isFocused?SB(this.header,`focused`):xB(this.header,`focused`))})),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):this.animationTimer=setTimeout(()=>{var e;(e=this.body)==null||e.remove()},200),this._onDidChange.fire(e?{size:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(e,t){this._size=e,this._orthogonalSize=t;let[n,r]=this.orientation===UB.HORIZONTAL?[e,t]:[t,e];super.layout(n,r)}init(e){var t,n;super.init(e),typeof e.minimumBodySize==`number`&&(this.minimumBodySize=e.minimumBodySize),typeof e.maximumBodySize==`number`&&(this.maximumBodySize=e.maximumBodySize),this.bodyPart=this.getBodyComponent(),this.headerPart=this.getHeaderComponent(),this.bodyPart.init(Object.assign(Object.assign({},e),{api:this.api})),this.headerPart.init(Object.assign(Object.assign({},e),{api:this.api})),(t=this.body)==null||t.append(this.bodyPart.element),(n=this.header)==null||n.append(this.headerPart.element),typeof e.isExpanded==`boolean`&&this.setExpanded(e.isExpanded)}toJSON(){let e=this._params;return Object.assign(Object.assign({},super.toJSON()),{headerComponent:this.headerComponent,title:e.title})}renderOnce(){this.header=document.createElement(`div`),this.header.tabIndex=0,this.header.className=`dv-pane-header`,this.header.style.height=`${this.headerSize}px`,this.header.style.lineHeight=`${this.headerSize}px`,this.header.style.minHeight=`${this.headerSize}px`,this.header.style.maxHeight=`${this.headerSize}px`,this.element.appendChild(this.header),this.body=document.createElement(`div`),this.body.className=`dv-pane-body`,this.element.appendChild(this.body)}getComponent(){return{update:e=>{var t,n;(t=this.bodyPart)==null||t.update({params:e}),(n=this.headerPart)==null||n.update({params:e})},dispose:()=>{var e,t;(e=this.bodyPart)==null||e.dispose(),(t=this.headerPart)==null||t.dispose()}}}},mGe=class extends pGe{constructor(e){super({id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,isHeaderVisible:!0,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this._onDidDrop=new Q,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOver=new Q,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.accessor=e.accessor,this.addDisposables(this._onDidDrop,this._onUnhandledDragOver),e.disableDnd||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;let e=this.id,t=this.accessor.id;this.header.draggable=!0;let n={getData:()=>(cB.getInstance().setData([new sB(t,e)],sB.prototype),{dispose:()=>{cB.getInstance().clearData(sB.prototype)}})};this.html5DragSource=TV.createDragSource(this.header,n),this.pointerDragSource=EV.createDragSource(this.header,n);let r={acceptedTargetZones:[`top`,`bottom`],overlayModel:{activationSize:{type:`percentage`,value:50}},canDisplayOverlay:(e,t)=>{let n=uB();if(n&&n.paneId!==this.id&&n.viewId===this.accessor.id)return!0;let r=new dGe(e,t,uB,this);return this._onUnhandledDragOver.fire(r),r.isAccepted}};this.target=TV.createDropTarget(this.element,r),this.pointerTarget=EV.createDropTarget(this.element,r),this.addDisposables(this._onDidDrop,this.html5DragSource,this.pointerDragSource,this.target,this.pointerTarget,this.target.onDrop(e=>{this.onDrop(e)}),this.pointerTarget.onDrop(e=>{this.onDrop(e)}))}onDrop(e){let t=uB();if(!t||t.viewId!==this.accessor.id){this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new dV(this.accessor),getData:uB}));return}let n=this._params.containerApi,r=t.paneId,i=n.getPanel(r);if(!i){this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,getData:uB,api:new dV(this.accessor)}));return}let a=n.panels,o=a.indexOf(i),s=n.panels.indexOf(this);(e.position===`left`||e.position===`top`)&&(s=Math.max(0,s-1)),(e.position===`right`||e.position===`bottom`)&&(o>s&&s++,s=Math.min(a.length-1,s)),n.movePanel(o,s)}},hGe=0,gGe=()=>`dv-tabpanel-${hGe++}`,_Ge=class extends fB{get element(){return this._element}constructor(e,t){var n,r,i;super(),this.accessor=e,this.group=t,this.disposable=new pB,this._onDidFocus=new Q,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new Q,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement(`div`),this._element.className=`dv-content-container`,this._element.tabIndex=-1,this._element.id=gGe(),this._element.setAttribute(`role`,`tabpanel`),this.addDisposables(this._onDidFocus,this._onDidBlur);let a=()=>t.dropTargetContainer?.model,o=(e,t)=>{if(this.group.locked===`no-drop-target`||this.group.locked&&t===`center`)return!1;let n=lB();return!n&&e.shiftKey&&this.group.location.type!==`floating`?!1:n&&n.viewId===this.accessor.id?!0:this.group.canDisplayOverlay(e,t,`content`)};this.dropTarget=new xV(this.element,{getOverlayOutline:()=>e.options.theme?.dndPanelOverlay===`group`?this.element.parentElement:null,className:`dv-drop-target-content`,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],canDisplayOverlay:o,getOverrideTarget:a,overlayModel:(n=this.accessor).resolveDropOverlayModel?.call(n,`content`)}),this.pointerDropTarget=EV.createDropTarget(this.element,{acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],canDisplayOverlay:o,getOverlayOutline:()=>e.options.theme?.dndPanelOverlay===`group`?this.element.parentElement:null,className:`dv-drop-target-content`,getOverrideTarget:a,overlayModel:(r=this.accessor).resolveDropOverlayModel?.call(r,`content`)}),this.addDisposables(this.dropTarget,this.pointerDropTarget,(i=this.accessor).onDidOptionsChange?.call(i,()=>{var e;let t=(e=this.accessor).resolveDropOverlayModel?.call(e,`content`)??{};this.dropTarget.setOverlayModel(t),this.pointerDropTarget.setOverlayModel(t)})??dB.NONE)}show(){this.element.style.display=``}hide(){this.element.style.display=`none`}setLabelledBy(e){e?this._element.setAttribute(`aria-labelledby`,e):this._element.removeAttribute(`aria-labelledby`)}renderPanel(e,t={asActive:!0}){var n,r,i,a;let o=t.asActive||this.panel&&this.group.isPanelActive(this.panel);this.panel&&this.panel.view.content.element.parentElement===this._element&&(this._element.removeChild(this.panel.view.content.element),(r=(n=this.panel.view.content).onHide)==null||r.call(n)),this.panel=e;let s;switch(e.api.renderer){case`onlyWhenVisible`:this.group.renderContainer.detatch(e),this.panel&&o&&(this._element.appendChild(this.panel.view.content.element),(a=(i=this.panel.view.content).onShow)==null||a.call(i)),s=this._element;break;case`always`:e.view.content.element.parentElement===this._element&&this._element.removeChild(e.view.content.element),s=this.group.renderContainer.attach({panel:e,referenceContainer:this});break;default:throw Error(`dockview: invalid renderer type '${e.api.renderer}'`)}if(o){let e=TB(s);this.focusTracker=e;let t=new fB;t.addDisposables(e,e.onDidFocus(()=>this._onDidFocus.fire()),e.onDidBlur(()=>this._onDidBlur.fire())),this.disposable.value=t}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){var e,t,n;this.panel&&this.panel.api.renderer===`onlyWhenVisible`&&((e=this.panel.view.content.element.parentElement)==null||e.removeChild(this.panel.view.content.element),(n=(t=this.panel.view.content).onHide)==null||n.call(t)),this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}refreshFocusState(){this.focusTracker?.refreshState&&this.focusTracker.refreshState()}},vGe=500,yGe=8,MV=class extends fB{constructor(e,t){super(),this.element=e,this.options=t,this._startX=0,this._startY=0,this.addDisposables(vB(this.element,`pointerdown`,e=>{this._onPointerDown(e)}))}_onPointerDown(e){if((this.options.touchOnly??!0)&&e.pointerType!==`touch`&&e.pointerType!==`pen`)return;this._cancelPending(),this._pointerId=e.pointerId,this._startX=e.clientX,this._startY=e.clientY;let t=this.options.delay??vGe,n=this.options.tolerance??yGe,r=this.element.ownerDocument?.defaultView??window;this._timer=setTimeout(()=>{this._timer=void 0,this._cancelPending(),this._installContextMenuGuard(r),this._installClickGuard(r),this.options.onLongPress(e)},t),this._moveListener=vB(r,`pointermove`,e=>{if(e.pointerId!==this._pointerId)return;let t=e.clientX-this._startX,r=e.clientY-this._startY;Math.hypot(t,r)>n&&this._cancelPending()}),this._upListener=vB(r,`pointerup`,e=>{e.pointerId===this._pointerId&&this._cancelPending()}),this._cancelListener=vB(r,`pointercancel`,e=>{e.pointerId===this._pointerId&&this._cancelPending()})}_installContextMenuGuard(e){let t,n=setTimeout(()=>t?.dispose(),500);t=vB(e,`contextmenu`,e=>{e.preventDefault(),clearTimeout(n),t?.dispose()},{capture:!0})}_installClickGuard(e){let t,n=setTimeout(()=>t?.dispose(),500);t=vB(e,`click`,e=>{let r=e.target;r&&this.element.contains(r)&&(e.preventDefault(),e.stopPropagation()),clearTimeout(n),t?.dispose()},{capture:!0})}_cancelPending(){var e,t,n;this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0),this._pointerId=void 0,(e=this._moveListener)==null||e.dispose(),(t=this._upListener)==null||t.dispose(),(n=this._cancelListener)==null||n.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}dispose(){this._cancelPending(),super.dispose()}};function NV(e){if(e.disableDnd)return{html5:!1,pointer:!1,pointerHandlesMouse:!1};switch(e.dndStrategy){case`pointer`:return{html5:!1,pointer:!0,pointerHandlesMouse:!0};case`html5`:return{html5:!0,pointer:!1,pointerHandlesMouse:!1};case`auto`:case void 0:default:return bGe()?{html5:!1,pointer:!0,pointerHandlesMouse:!0}:{html5:!0,pointer:!0,pointerHandlesMouse:!1}}}function bGe(){if(typeof window>`u`||!window.matchMedia)return!1;let e=window.matchMedia(`(pointer: coarse)`).matches,t=window.matchMedia(`(pointer: fine)`).matches;return e&&!t}var xGe=0,SGe=()=>`dv-tab-${xGe++}`,CGe=class extends fB{get element(){return this._element}constructor(e,t,n){super(),this.panel=e,this.accessor=t,this.group=n,this.content=void 0,this.panelTransfer=cB.getInstance(),this._direction=`horizontal`,this._onPointDown=new Q,this.onPointerDown=this._onPointDown.event,this._onTabClick=new Q,this.onTabClick=this._onTabClick.event,this._onDropped=new Q,this.onDrop=this._onDropped.event,this._onDragStart=new Q,this.onDragStart=this._onDragStart.event,this._onDragEnd=new Q,this.onDragEnd=this._onDragEnd.event;let r=NV(this.accessor.options);this._element=document.createElement(`div`),this._element.className=`dv-tab`,this._element.tabIndex=-1,this._element.draggable=r.html5,this._element.id=SGe(),this._element.setAttribute(`role`,`tab`),this._element.setAttribute(`aria-selected`,`false`);let i=this.group?.model?.contentContainerId;i&&this._element.setAttribute(`aria-controls`,i),CB(this.element,`dv-inactive-tab`,!0);let a=(e,t)=>{if(this.group.locked)return!1;let n=lB();return n&&this.accessor.id===n.viewId?this.accessor.options.theme?.tabAnimation!==`smooth`:this.group.model.canDisplayOverlay(e,t,`tab`)};this.dropTarget=TV.createDropTarget(this._element,{acceptedTargetZones:[`left`,`right`],overlayModel:this._buildOverlayModel(),canDisplayOverlay:a,getOverrideTarget:()=>n.model.dropTargetContainer?.model}),this.pointerDropTarget=EV.createDropTarget(this._element,{acceptedTargetZones:[`left`,`right`],overlayModel:this._buildOverlayModel(),canDisplayOverlay:a,getOverrideTarget:()=>n.model.dropTargetContainer?.model});let o={getData:()=>(this.panelTransfer.setData([new oB(this.accessor.id,this.group.id,this.panel.id)],oB.prototype),{dispose:()=>{this.panelTransfer.clearData(oB.prototype)}}),createGhost:()=>({element:this._buildGhostElement(),offsetX:30,offsetY:-10}),onDragStart:e=>{this._onDragStart.fire(e),!(e instanceof PointerEvent)&&this.accessor.options.theme?.tabAnimation===`smooth`&&requestAnimationFrame(()=>{CB(this.element,`dv-tab--dragging`,!0)})},onDragEnd:e=>{this._onDragEnd.fire(e)}};this.html5DragSource=TV.createDragSource(this._element,Object.assign(Object.assign({},o),{disabled:!r.html5})),this.pointerDragSource=EV.createDragSource(this._element,Object.assign(Object.assign({},o),{disabled:!r.pointer,touchOnly:!r.pointerHandlesMouse,isCancelled:()=>!NV(this.accessor.options).pointer})),this.onWillShowOverlay=mB.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this._onPointDown,this._onTabClick,this._onDropped,this._onDragStart,this._onDragEnd,this.accessor.onDidOptionsChange(()=>{let e=this._buildOverlayModel();this.dropTarget.setOverlayModel(e),this.pointerDropTarget.setOverlayModel(e)}),vB(this._element,`dragend`,()=>{CB(this.element,`dv-tab--dragging`,!1)}),this.html5DragSource,vB(this._element,`pointerdown`,e=>{this._onPointDown.fire(e)}),vB(this._element,`click`,e=>{this._onTabClick.fire(e)}),vB(this._element,`contextmenu`,e=>{var t;(t=this.accessor.contextMenuService)==null||t.show(this.panel,this.group,e)}),new MV(this._element,{onLongPress:e=>{var t;this.pointerDragSource.cancelPending(),(t=this.accessor.contextMenuService)==null||t.show(this.panel,this.group,e)}}),this.dropTarget.onDrop(e=>{this._onDropped.fire(e)}),this.pointerDropTarget.onDrop(e=>{this._onDropped.fire(e)}),this.dropTarget,this.pointerDropTarget,this.pointerDragSource)}setActive(e){CB(this.element,`dv-active-tab`,e),CB(this.element,`dv-inactive-tab`,!e),this._element.setAttribute(`aria-selected`,e?`true`:`false`),this._element.tabIndex=e?0:-1}setContent(e){this.content&&this._element.removeChild(this.content.element),this.content=e,this._element.appendChild(this.content.element)}_buildOverlayModel(){var e;let t=(e=this.accessor).resolveDropOverlayModel?.call(e,`tab`,this.group);if(t)return t;let n=this.accessor.options.theme?.dndTabIndicator===`line`?1/0:0;return{activationSize:{value:50,type:`percentage`},smallWidthBoundary:n,smallHeightBoundary:n}}setDirection(e){this._direction=e;let t=e===`vertical`?[`top`,`bottom`]:[`left`,`right`];this.dropTarget.setTargetZones(t),this.pointerDropTarget.setTargetZones(t)}updateDragAndDropState(){let e=NV(this.accessor.options);this._element.draggable=e.html5,this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}_buildGhostElement(){let e=getComputedStyle(this.element),t=this.element.cloneNode(!0),n=this._direction===`vertical`,r=new Set([`writing-mode`,`inline-size`,`block-size`,`min-inline-size`,`min-block-size`,`max-inline-size`,`max-block-size`,`margin-inline`,`margin-inline-start`,`margin-inline-end`,`margin-block`,`margin-block-start`,`margin-block-end`,`padding-inline`,`padding-inline-start`,`padding-inline-end`,`padding-block`,`padding-block-start`,`padding-block-end`]);return Array.from(e).forEach(i=>{n&&r.has(i)||t.style.setProperty(i,e.getPropertyValue(i),e.getPropertyPriority(i))}),n&&(t.style.setProperty(`writing-mode`,`horizontal-tb`),t.style.setProperty(`width`,e.height),t.style.setProperty(`height`,e.width)),t.style.position=`absolute`,t.classList.add(`dv-tab-ghost-drag`),t}},PV=class{get kind(){return this.options.kind}get nativeEvent(){return this.event.nativeEvent}get position(){return this.event.position}get defaultPrevented(){return this.event.defaultPrevented}get panel(){return this.options.panel}get api(){return this.options.api}get group(){return this.options.group}preventDefault(){this.event.preventDefault()}getData(){return this.options.getData()}constructor(e,t){this.event=e,this.options=t}},wGe=500,FV=class extends fB{get group(){return this.groupAccessor()}constructor(e){super(),this.panelTransfer=cB.getInstance(),this._onDragStart=new Q,this.onDragStart=this._onDragStart.event,this._element=e.element,this.accessor=e.accessor;let t=e.group;this.groupAccessor=typeof t==`function`?t:()=>t,this.isFloatingMoveHandle=e.isFloatingMoveHandle??(()=>!0);let n=NV(this.accessor.options);this._element.draggable=n.html5,CB(this._element,`dv-draggable`,n.html5||n.pointer),this.addDisposables(this._onDragStart);let r=()=>{let e=document.createElement(`div`),t=window.getComputedStyle(this._element),n=t.getPropertyValue(`--dv-activegroup-visiblepanel-tab-background-color`),r=t.getPropertyValue(`--dv-activegroup-visiblepanel-tab-color`);return e.style.backgroundColor=n,e.style.color=r,e.style.padding=`2px 8px`,e.style.height=`24px`,e.style.fontSize=`11px`,e.style.lineHeight=`20px`,e.style.borderRadius=`12px`,e.style.whiteSpace=`nowrap`,e.style.boxSizing=`border-box`,e.style.display=`inline-block`,e.textContent=`Multiple Panels (${this.group.size})`,e},i={getData:()=>(this.panelTransfer.setData([new oB(this.accessor.id,this.group.id,null)],oB.prototype),{dispose:()=>{this.panelTransfer.clearData(oB.prototype)}}),createGhost:()=>{var e;return(e=this.accessor).buildGroupDragGhost?.call(e,this.group)||{element:r(),offsetX:30,offsetY:-10}},onDragStart:e=>{this._onDragStart.fire(e)}};this.html5DragSource=TV.createDragSource(this._element,Object.assign(Object.assign({},i),{disabled:!n.html5,isCancelled:e=>!!(this.group.api.location.type===`floating`&&this.isFloatingMoveHandle()&&!e.shiftKey||this.group.api.location.type===`edge`&&this.group.size===0)}));let a=()=>this.group?.api?.location?.type===`floating`&&this.isFloatingMoveHandle();this.pointerDragSource=EV.createDragSource(this._element,Object.assign(Object.assign({},i),{disabled:!n.pointer,touchOnly:!n.pointerHandlesMouse,touchInitiationDelay:()=>a()?wGe:250,pressTolerance:()=>a()?1/0:8,isCancelled:()=>!NV(this.accessor.options).pointer||this.group.api.location.type===`edge`&&this.group.size===0,onDragStart:e=>{var t;(t=this.getFloatingOverlay())==null||t.cancelPendingDrag(),this._onDragStart.fire(e)}}));let o=new pB,s=()=>{let e=this.getFloatingOverlay();o.value=e?e.onDidStartMoving(()=>{this.pointerDragSource.cancelPending()}):dB.NONE};s(),this.addDisposables(o);let c=this.group?.api?.onDidLocationChange;c&&this.addDisposables(c(s)),this.addDisposables(this.html5DragSource,this.pointerDragSource)}updateDragAndDropState(){let e=NV(this.accessor.options);this._element.draggable=e.html5,CB(this._element,`dv-draggable`,e.html5||e.pointer),this.html5DragSource.setDisabled(!e.html5),this.pointerDragSource.setDisabled(!e.pointer),this.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}getFloatingOverlay(){if(this.group)return this.accessor.floatingGroups?.find(e=>e.group===this.group)?.overlay}},TGe=class extends fB{get element(){return this._element}constructor(e,t){var n,r,i;super(),this.accessor=e,this.group=t,this._onDrop=new Q,this.onDrop=this._onDrop.event,this._onDragStart=new Q,this.onDragStart=this._onDragStart.event,this._element=document.createElement(`div`),this._element.className=`dv-void-container`,this.addDisposables(this._onDrop,this._onDragStart,vB(this._element,`pointerdown`,()=>{this.accessor.doSetGroupActive(this.group)}),vB(this._element,`pointerdown`,e=>{e.shiftKey&&DB(e)},!0)),this.dragSource=new FV({element:this._element,accessor:this.accessor,group:this.group,isFloatingMoveHandle:()=>!this._element.closest(`.dv-resize-container-with-titlebar`)});let a=(e,n)=>{if(this.group.api.locked)return!1;let r=lB();return r&&this.accessor.id===r.viewId?!0:t.model.canDisplayOverlay(e,n,`header_space`)};this.dropTarget=TV.createDropTarget(this._element,{acceptedTargetZones:[`center`],canDisplayOverlay:a,getOverrideTarget:()=>t.model.dropTargetContainer?.model,overlayModel:(n=this.accessor).resolveDropOverlayModel?.call(n,`header_space`,this.group)}),this.pointerDropTarget=EV.createDropTarget(this._element,{acceptedTargetZones:[`center`],canDisplayOverlay:a,getOverrideTarget:()=>t.model.dropTargetContainer?.model,overlayModel:(r=this.accessor).resolveDropOverlayModel?.call(r,`header_space`,this.group)}),this.onWillShowOverlay=mB.any(this.dropTarget.onWillShowOverlay,this.pointerDropTarget.onWillShowOverlay),this.addDisposables(this.dragSource,this.dragSource.onDragStart(e=>{this._onDragStart.fire(e)}),this.dropTarget.onDrop(e=>{this._onDrop.fire(e)}),this.pointerDropTarget.onDrop(e=>{this._onDrop.fire(e)}),this.dropTarget,this.pointerDropTarget,(i=this.accessor).onDidOptionsChange?.call(i,()=>{var e;let t=(e=this.accessor).resolveDropOverlayModel?.call(e,`header_space`,this.group)??{};this.dropTarget.setOverlayModel(t),this.pointerDropTarget.setOverlayModel(t)})??dB.NONE)}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}},IV=class e extends fB{get element(){return this._element}get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._scrollOffset=0,this._orientation=e,xB(this._scrollbar,`dv-scrollbar-vertical`,`dv-scrollbar-horizontal`),e===`vertical`?SB(this._scrollbar,`dv-scrollbar-vertical`):SB(this._scrollbar,`dv-scrollbar-horizontal`))}constructor(t){super(),this.scrollableElement=t,this._scrollOffset=0,this._orientation=`horizontal`,this._element=document.createElement(`div`),this._element.className=`dv-scrollable`,this._scrollbar=document.createElement(`div`),this._scrollbar.className=`dv-scrollbar dv-scrollbar-horizontal`,this.element.appendChild(t),this.element.appendChild(this._scrollbar),this.addDisposables(vB(this.element,`wheel`,t=>{this._scrollOffset+=t.deltaY*e.MouseWheelSpeed,this.calculateScrollbarStyles()}),vB(this._scrollbar,`pointerdown`,e=>{e.preventDefault(),CB(this.element,`dv-scrollable-scrolling`,!0);let t=this._orientation===`horizontal`?e.clientX:e.clientY,n=this._scrollOffset,r=e=>{let r=this._orientation===`horizontal`?e.clientX-t:e.clientY-t,i=(this._orientation===`horizontal`?this.element.clientWidth:this.element.clientHeight)/(this._orientation===`horizontal`?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight);this._scrollOffset=n+r/i,this.calculateScrollbarStyles()},i=()=>{CB(this.element,`dv-scrollable-scrolling`,!1),document.removeEventListener(`pointermove`,r),document.removeEventListener(`pointerup`,i),document.removeEventListener(`pointercancel`,i)};document.addEventListener(`pointermove`,r),document.addEventListener(`pointerup`,i),document.addEventListener(`pointercancel`,i)}),vB(this.element,`scroll`,()=>{this.calculateScrollbarStyles()}),vB(this.scrollableElement,`scroll`,()=>{this._scrollOffset=this._orientation===`horizontal`?this.scrollableElement.scrollLeft:this.scrollableElement.scrollTop,this.calculateScrollbarStyles()}),bB(this.element,()=>{CB(this.element,`dv-scrollable-resizing`,!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),CB(this.element,`dv-scrollable-resizing`,!1)},500),this.calculateScrollbarStyles()}))}calculateScrollbarStyles(){let e=this._orientation===`horizontal`?this.element.clientWidth:this.element.clientHeight,t=this._orientation===`horizontal`?this.scrollableElement.scrollWidth:this.scrollableElement.scrollHeight;if(t>e){let n=e/t*e;this._orientation===`horizontal`?(this._scrollbar.style.width=`${n}px`,this._scrollbar.style.height=``):(this._scrollbar.style.height=`${n}px`,this._scrollbar.style.width=``),this._scrollOffset=BB(this._scrollOffset,0,t-e),this._orientation===`horizontal`?this.scrollableElement.scrollLeft=this._scrollOffset:this.scrollableElement.scrollTop=this._scrollOffset;let r=this._scrollOffset/(t-e);this._orientation===`horizontal`?(this._scrollbar.style.left=`${(e-n)*r}px`,this._scrollbar.style.top=``):(this._scrollbar.style.top=`${(e-n)*r}px`,this._scrollbar.style.left=``)}else this._orientation===`horizontal`?(this._scrollbar.style.width=`0px`,this._scrollbar.style.left=`0px`):(this._scrollbar.style.height=`0px`,this._scrollbar.style.top=`0px`),this._scrollOffset=0}};IV.MouseWheelSpeed=1;var LV=[{id:`grey`,value:`var(--dv-tab-group-color-grey)`,label:`Grey`},{id:`blue`,value:`var(--dv-tab-group-color-blue)`,label:`Blue`},{id:`red`,value:`var(--dv-tab-group-color-red)`,label:`Red`},{id:`yellow`,value:`var(--dv-tab-group-color-yellow)`,label:`Yellow`},{id:`green`,value:`var(--dv-tab-group-color-green)`,label:`Green`},{id:`pink`,value:`var(--dv-tab-group-color-pink)`,label:`Pink`},{id:`purple`,value:`var(--dv-tab-group-color-purple)`,label:`Purple`},{id:`cyan`,value:`var(--dv-tab-group-color-cyan)`,label:`Cyan`},{id:`orange`,value:`var(--dv-tab-group-color-orange)`,label:`Orange`}],RV=class{constructor(e,t=!0){this._entries=e.slice(),this._byId=new Map(e.map(e=>[e.id,e])),this._enabled=t}get enabled(){return this._enabled}set enabled(e){this._enabled=e}setEntries(e){this._entries=e.slice(),this._byId=new Map(e.map(e=>[e.id,e]))}entries(){return this._entries}has(e){return this._byId.has(e)}get(e){return this._byId.get(e)}defaultId(){return this._entries[0]?.id}resolveValue(e){if(!this._enabled||!e)return;let t=this._byId.get(e);return t?t.value:e}},zV;function BV(){return zV||=new RV(LV,!0),zV}function VV(e,t,n){let r=(n??BV()).resolveValue(t);r===void 0?e.style.removeProperty(`--dv-tab-group-color`):e.style.setProperty(`--dv-tab-group-color`,r)}function HV(e,t){return(t??BV()).resolveValue(e)}var UV=class extends fB{get element(){return this._element}constructor(e){super(),this._palette=e,this._onClick=new Q,this.onClick=this._onClick.event,this._onContextMenu=new Q,this.onContextMenu=this._onContextMenu.event,this._element=document.createElement(`div`),this._element.className=`dv-tab-group-chip`,this._element.tabIndex=0,this._label=document.createElement(`span`),this._label.className=`dv-tab-group-chip-label`,this._element.appendChild(this._label),this.addDisposables(this._onClick,this._onContextMenu,new MV(this._element,{onLongPress:e=>{this._onContextMenu.fire(e)}}),vB(this._element,`click`,e=>{this._onClick.fire(e)}),vB(this._element,`contextmenu`,e=>{this._onContextMenu.fire(e)}))}init(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed),this.addDisposables(e.tabGroup.onDidChange(()=>{this._tabGroup&&(this.updateColor(this._tabGroup.color),this.updateLabel(this._tabGroup.label))}),e.tabGroup.onDidCollapseChange(e=>{this.updateCollapsed(e)}),this._onClick.event(()=>{var e;(e=this._tabGroup)==null||e.toggle()}))}update(e){this._tabGroup=e.tabGroup,this.updateColor(e.tabGroup.color),this.updateLabel(e.tabGroup.label),this.updateCollapsed(e.tabGroup.collapsed)}updateColor(e){VV(this._element,e,this._palette),CB(this._element,`dv-tab-group-chip--accent-off`,this._palette?.enabled===!1)}updateLabel(e){this._label.textContent=e,CB(this._label,`dv-tab-group-chip-label--empty`,!e)}updateCollapsed(e){CB(this._element,`dv-tab-group-chip--collapsed`,e)}},WV=class{get underlines(){return this._underlines}constructor(e){this._ctx=e,this._underlines=new Map,this._rafId=null}positionUnderlines(){requestAnimationFrame(()=>{this._positionUnderlinesSync()})}trackUnderlines(){this._rafId!==null&&cancelAnimationFrame(this._rafId);let e=performance.now(),t=()=>{this._positionUnderlinesSync(),performance.now()-e<250?this._rafId=requestAnimationFrame(t):this._rafId=null};this._rafId=requestAnimationFrame(t)}syncUnderlineElements(e){for(let t of e)if(!this._underlines.has(t)){let e=document.createElement(`div`);e.className=`dv-tab-group-underline`,this._ctx.tabsList.appendChild(e),this._underlines.set(t,e)}for(let[t,n]of this._underlines)e.has(t)||(n.remove(),this._underlines.delete(t))}getUnderline(e){return this._underlines.get(e)}dispose(){this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null);for(let[,e]of this._underlines)e.remove();this._underlines.clear()}_positionUnderlinesSync(){let e=this._ctx.tabsList.getBoundingClientRect(),t=this._ctx.getTabGroups(),n=this._ctx.getDirection()===`vertical`,r=n?e.width:e.height,i=this._ctx.getActivePanelId(),a=this._ctx.getTabMap();for(let o of t){let t=this._underlines.get(o.id);if(!t)continue;let s=o.panelIds;if(s.length===0){t.style.display=`none`;continue}t.style.display=``;let c=this._ctx.getChipElement(o.id),l;if(c){let t=c.getBoundingClientRect(),r=getComputedStyle(c),i=n?Number.parseFloat(r.marginTop)||0:Number.parseFloat(r.marginLeft)||0;l=n?t.top-e.top-i:t.left-e.left-i}else{let t=s[0],r=a.get(t);if(r){let t=r.value.element.getBoundingClientRect();l=n?t.top-e.top:t.left-e.left}else l=0}let u=s[s.length-1],d=a.get(u);if(!d){n?(t.style.top=`${l}px`,t.style.height=`0px`,t.style.left=``,t.style.width=``):(t.style.left=`${l}px`,t.style.width=`0px`,t.style.top=``,t.style.height=``);continue}let f=d.value.element.getBoundingClientRect(),p=n?f.bottom-e.top:f.right-e.left,m=p-l;if((o.collapsed||o.panelIds.some(e=>{let t=a.get(e);return t&&t.value.element.classList.contains(`dv-tab--group-expanding`)}))&&c){let t=c.getBoundingClientRect(),r=n?t.top+t.height/2-e.top:t.left+t.width/2-e.left,i=0,s=0;for(let e of o.panelIds){let t=a.get(e);if(!t)continue;let r=t.value.element;n?(i+=r.getBoundingClientRect().height,s+=r.scrollHeight):(i+=r.getBoundingClientRect().width,s+=r.scrollWidth)}let u=s>0?Math.min(1,i/s):0;l=r+(l-r)*u,p=r+(p-r)*u,m=Math.max(0,p-l)}n?(t.style.top=`${l}px`,t.style.height=`${Math.max(0,m)}px`,t.style.left=``,t.style.width=``):(t.style.left=`${l}px`,t.style.width=`${Math.max(0,m)}px`,t.style.top=``,t.style.height=``),this.applyShape(t,o,l,m,r,i,e,n)}}},EGe=class extends WV{_applyStraightLine(e,t,n,r,i,a){a?(e.setAttribute(`width`,String(r)),e.setAttribute(`height`,String(i)),n.style.width=`${r}px`,n.style.height=`${i}px`,t.setAttribute(`d`,`M ${r/2},0 L ${r/2},${i}`)):(e.setAttribute(`width`,String(i)),e.setAttribute(`height`,String(r)),n.style.width=`${i}px`,n.style.height=`${r}px`,t.setAttribute(`d`,`M 0,${r/2} L ${i},${r/2}`))}applyShape(e,t,n,r,i,a,o,s){let c=i,l=r,u=HV(t.color,this._ctx.getColorPalette());if(l<=0||c<=0||u===void 0){e.style.display=`none`;return}e.style.display=``;let d;a&&t.panelIds.includes(a)&&(d=this._ctx.getTabMap().get(a));let f=e.firstElementChild,p;if(!f||f.tagName!==`svg`?(e.replaceChildren(),f=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`),f.style.display=`block`,p=document.createElementNS(`http://www.w3.org/2000/svg`,`path`),p.setAttribute(`fill`,`none`),f.appendChild(p),e.appendChild(f)):p=f.firstElementChild,p.setAttribute(`stroke`,u),p.setAttribute(`stroke-width`,`2`),!d){this._applyStraightLine(f,p,e,2,l,s);return}let m=d.value.element.getBoundingClientRect(),h,g;if(s?(h=Math.max(0,m.top-o.top-n),g=Math.min(l,m.bottom-o.top-n)):(h=Math.max(0,m.left-o.left-n),g=Math.min(l,m.right-o.left-n)),g<=h){this._applyStraightLine(f,p,e,2,l,s);return}let _=this._ctx.getHeaderPosition();if(s){let t=c,n=l;f.setAttribute(`width`,String(t)),f.setAttribute(`height`,String(n)),e.style.width=`${t}px`,e.style.height=`${n}px`;let r=_===`right`,i=r?t-1:1,a=r?1:t-1,o=r?-1:1,s=[`M ${i},0`,`L ${i},${h-6}`,`Q ${i},${h} ${i+o*6},${h}`,`L ${a-o*6},${h}`,`Q ${a},${h} ${a},${h+6}`,`L ${a},${g-6}`,`Q ${a},${g} ${a-o*6},${g}`,`L ${i+o*6},${g}`,`Q ${i},${g} ${i},${g+6}`,`L ${i},${n}`].join(` `);p.setAttribute(`d`,s)}else{let t=l,n=c;f.setAttribute(`width`,String(t)),f.setAttribute(`height`,String(n)),e.style.width=`${t}px`,e.style.height=`${n}px`;let r=_===`bottom`,i=r?1:n-1,a=r?n-1:1,o=r?1:-1,s=[`M 0,${i}`,`L ${h-6},${i}`,`Q ${h},${i} ${h},${i+o*6}`,`L ${h},${a-o*6}`,`Q ${h},${a} ${h+6},${a}`,`L ${g-6},${a}`,`Q ${g},${a} ${g},${a-o*6}`,`L ${g},${i+o*6}`,`Q ${g},${i} ${g+6},${i}`,`L ${t},${i}`].join(` `);p.setAttribute(`d`,s)}}},DGe=class extends WV{applyShape(e,t,n,r,i,a,o,s){let c=HV(t.color,this._ctx.getColorPalette());if(r<=0||c===void 0){e.style.display=`none`;return}e.style.display=``,e.firstElementChild&&e.replaceChildren(),e.style.backgroundColor=c,s?(e.style.width=`2px`,e.style.height=`${r}px`):(e.style.width=`${r}px`,e.style.height=`2px`)}},OGe=new Map,kGe=class{get chipRenderers(){return this._chipRenderers}get groupUnderlines(){return this._indicator?.underlines??OGe}get skipNextCollapseAnimation(){return this._skipNextCollapseAnimation}set skipNextCollapseAnimation(e){this._skipNextCollapseAnimation=e}constructor(e,t){this._ctx=e,this._callbacks=t,this._chipRenderers=new Map,this._indicator=null,this._skipNextCollapseAnimation=!1,this._pendingTransitionCleanups=new Map}update(){let e=this._ctx.group.model.getTabGroups(),t=new Set;for(let n of e)t.add(n.id),this._ensureChipForGroup(n),this._positionChipForGroup(n);for(let[e,n]of this._chipRenderers)t.has(e)||(n.chip.element.remove(),n.chip.dispose(),n.disposable.dispose(),this._chipRenderers.delete(e));this._updateTabGroupClasses()}refreshAccents(){var e,t;for(let n of this._ctx.group.model.getTabGroups()){let r=this._chipRenderers.get(n.id);(t=r==null?void 0:(e=r.chip).update)==null||t.call(e,{tabGroup:n})}this._updateTabGroupClasses()}positionAllChips(){if(this._chipRenderers.size!==0)for(let e of this._ctx.group.model.getTabGroups())this._positionChipForGroup(e)}updateDirection(){let e=this._ctx.getDirection()===`vertical`;for(let[,t]of this._chipRenderers)t.dropTarget.setTargetZones(e?[`top`]:[`left`])}snapshotChipWidths(){let e=new Map;for(let[t,n]of this._chipRenderers)e.set(t,n.chip.element.getBoundingClientRect().width);return e}positionUnderlines(){var e;(e=this._indicator)==null||e.positionUnderlines()}trackUnderlines(){var e;(e=this._indicator)==null||e.trackUnderlines()}setGroupDragImage(e,t,n){if(!e.dataTransfer)return;let r=this._ctx.getDirection()===`vertical`,i=this._ctx.tabsList.cloneNode(!0);r?(i.classList.remove(`dv-tabs-container-vertical`,`dv-vertical`),i.classList.add(`dv-horizontal`),i.style.writingMode=`horizontal-tb`,i.style.height=`${this._ctx.tabsList.offsetWidth}px`):i.style.height=`${this._ctx.tabsList.offsetHeight}px`,i.style.width=`auto`,i.style.overflow=`visible`,i.style.pointerEvents=`none`;let a=Array.from(i.children),o=Array.from(this._ctx.tabsList.children);for(let e=a.length-1;e>=0;e--)o[e]!==n&&a[e].remove();let s=document.createElement(`div`);s.className=`dv-groupview dv-active-group`,s.style.position=`fixed`,s.style.top=`-10000px`,s.style.left=`0px`,s.style.height=`auto`,s.style.width=`auto`,s.style.pointerEvents=`none`;let c=document.createElement(`div`);c.className=`dv-tabs-and-actions-container`,c.style.height=`auto`,c.style.width=`auto`,s.appendChild(c),c.appendChild(i),this._ctx.accessor.element.appendChild(s);let l=i.querySelector(`.dv-tab-group-chip`),u=n.getBoundingClientRect(),d=e.clientX-u.left,f=e.clientY-u.top;if(l){let t=l.getBoundingClientRect(),n=s.getBoundingClientRect(),r=t.left-n.left+d,i=t.top-n.top+f;e.dataTransfer.setDragImage(s,r,i)}else e.dataTransfer.setDragImage(s,d,f);requestAnimationFrame(()=>{s.remove()})}cleanupTransition(e){var t;(t=this._pendingTransitionCleanups.get(e))==null||t(),this._pendingTransitionCleanups.delete(e)}updateDragAndDropState(){let e=NV(this._ctx.accessor.options);for(let t of this._chipRenderers.values())t.chip.element.draggable=e.html5,t.html5DragSource.setDisabled(!e.html5),t.pointerDragSource.setDisabled(!e.pointer),t.pointerDragSource.setTouchOnly(!e.pointerHandlesMouse)}disposeChipDrag(e){var t,n;let r=this._chipRenderers.get(e);r&&((t=r.html5DragSource)==null||t.dispose(),(n=r.pointerDragSource)==null||n.dispose())}_buildChipGhostElement(e){let t=getComputedStyle(e),n=e.cloneNode(!0);return Array.from(t).forEach(e=>{n.style.setProperty(e,t.getPropertyValue(e),t.getPropertyPriority(e))}),n.style.position=`absolute`,n}disposeAll(){var e;(e=this._indicator)==null||e.dispose(),this._indicator=null;for(let[,e]of this._pendingTransitionCleanups)e();this._pendingTransitionCleanups.clear();for(let[,e]of this._chipRenderers)e.chip.element.remove(),e.chip.dispose(),e.disposable.dispose();this._chipRenderers.clear()}_ensureIndicator(){let e=(this._ctx.accessor.options.theme?.tabGroupIndicator??`wrap`)===`none`?DGe:EGe;this._indicator&&!(this._indicator instanceof e)&&(this._indicator.dispose(),this._indicator=null),this._indicator||=new e({tabsList:this._ctx.tabsList,getTabGroups:()=>this._ctx.group.model.getTabGroups(),getActivePanelId:()=>this._ctx.group.activePanel?.id,getTabMap:()=>this._ctx.getTabMap(),getChipElement:e=>this._chipRenderers.get(e)?.chip.element,getDirection:()=>this._ctx.getDirection(),getHeaderPosition:()=>this._ctx.group.model.headerPosition,getColorPalette:()=>this._ctx.accessor.tabGroupColorPalette})}_ensureChipForGroup(e){if(this._chipRenderers.has(e.id))return;let t=this._ctx.accessor.options.createTabGroupChipComponent,n=t?t(e):new UV(this._ctx.accessor.tabGroupColorPalette);n.init({tabGroup:e,api:this._ctx.accessor.api});let r=NV(this._ctx.accessor.options);n.element.draggable=r.html5;let i=cB.getInstance(),a=()=>(i.setData([new oB(this._ctx.accessor.id,this._ctx.group.id,null,e.id)],oB.prototype),{dispose:()=>{i.clearData(oB.prototype)}}),o=TV.createDragSource(n.element,{getData:a,disabled:!r.html5,isCancelled:()=>!NV(this._ctx.accessor.options).html5,onDragStart:t=>{`dataTransfer`in t&&t.dataTransfer&&this.setGroupDragImage(t,e,n.element),this._callbacks.onChipDragStart(e,n,t)},onDragEnd:t=>{var r,i;(i=(r=this._callbacks).onChipDragEnd)==null||i.call(r,e,n,t)}});n.element.addEventListener(`dragend`,()=>{i.clearData(oB.prototype)},{once:!0});let s=EV.createDragSource(n.element,{getData:a,disabled:!r.pointer,touchOnly:!r.pointerHandlesMouse,isCancelled:()=>!NV(this._ctx.accessor.options).pointer,createGhost:()=>({element:this._buildChipGhostElement(n.element),offsetX:8,offsetY:8}),onDragStart:t=>{this._callbacks.onChipDragStart(e,n,t)}}),c=[e.onDidChange(()=>{var t;(t=n.update)==null||t.call(n,{tabGroup:e}),this._updateTabGroupClasses()}),e.onDidPanelChange(()=>{this._positionChipForGroup(e),this._updateTabGroupClasses()}),e.onDidCollapseChange(()=>{this._updateTabGroupClasses()}),o,s],l=t=>{s.cancelPending(),this._callbacks.onChipContextMenu(e,t)};n instanceof UV?c.push(n.onContextMenu(l)):c.push(new MV(n.element,{onLongPress:l}),vB(n.element,`contextmenu`,l));let u=this._ctx.getDirection()===`vertical`,d=new xV(n.element,{acceptedTargetZones:u?[`top`]:[`left`],overlayModel:{activationSize:{value:100,type:`percentage`}},canDisplayOverlay:(e,t)=>{if(this._ctx.group.locked||this._ctx.accessor.options.disableDnd)return!1;let n=lB();return n&&this._ctx.accessor.id===n.viewId?this._ctx.accessor.options.theme?.tabAnimation!==`smooth`:this._ctx.group.model.canDisplayOverlay(e,t,`tab`)}});c.push(d,d.onDrop(t=>{this._callbacks.onChipDrop(e,t)}));let f=new fB(...c);this._chipRenderers.set(e.id,{chip:n,html5DragSource:o,pointerDragSource:s,disposable:f,dropTarget:d}),e.collapsed&&(this._skipNextCollapseAnimation=!0)}_positionChipForGroup(e){let t=this._chipRenderers.get(e.id);if(!t)return;let n=t.chip.element,r=e.panelIds;if(r.length===0){n.remove();return}let i=r[0],a=this._ctx.getTabMap().get(i);if(!a){n.remove();return}let o=a.value.element;n.nextSibling!==o&&this._ctx.tabsList.insertBefore(n,o)}_updateTabGroupClasses(){var e;let t=this._ctx.group.model.getTabGroups(),n=this._ctx.getTabs(),r=this._ctx.getTabMap(),i=!1,a=new Map;for(let e of t)for(let t of e.panelIds)a.set(t,e);for(let t of n){let n=t.value,r=n.panel.id,o=a.get(r),s=!!o;if(CB(n.element,`dv-tab--grouped`,s),o){let t=o.panelIds,a=t[0]===r,s=t[t.length-1]===r;CB(n.element,`dv-tab--group-first`,a),CB(n.element,`dv-tab--group-last`,s),VV(n.element,o.color,this._ctx.accessor.tabGroupColorPalette);let c=n.element.classList.contains(`dv-tab--group-collapsed`);if(!o.collapsed&&c){i=!0,n.element.classList.remove(`dv-tab--group-collapsed`),n.element.classList.add(`dv-tab--group-expanding`),(e=this._pendingTransitionCleanups.get(r))==null||e();let t=()=>{n.element.classList.remove(`dv-tab--group-expanding`),n.element.style.removeProperty(`width`),n.element.removeEventListener(`transitionend`,t),clearTimeout(a),this._pendingTransitionCleanups.delete(r)},a=setTimeout(t,300);this._pendingTransitionCleanups.set(r,t),n.element.addEventListener(`transitionend`,t)}}else CB(n.element,`dv-tab--group-first`,!1),CB(n.element,`dv-tab--group-last`,!1),n.element.classList.remove(`dv-tab--group-collapsed`,`dv-tab--group-expanding`),n.element.style.removeProperty(`width`),n.element.style.removeProperty(`--dv-tab-group-color`)}let o=new Set;for(let e of t)if(o.add(e.id),e.collapsed&&e.panelIds.some(e=>{let t=r.get(e);return t&&!t.value.element.classList.contains(`dv-tab--group-collapsed`)}))if(this._skipNextCollapseAnimation){let t=[];for(let n of e.panelIds){let e=r.get(n);e&&(e.value.element.style.transition=`none`,e.value.element.classList.add(`dv-tab--group-collapsed`),t.push(e.value.element))}if(t.length>0){t[0].offsetHeight;for(let e of t)e.style.removeProperty(`transition`)}}else{i=!0;let t=this._ctx.getDirection()===`vertical`;for(let n of e.panelIds){let e=r.get(n);if(e&&!e.value.element.classList.contains(`dv-tab--group-collapsed`)){let n=e.value.element.getBoundingClientRect();t?e.value.element.style.height=`${n.height}px`:e.value.element.style.width=`${n.width}px`,e.value.element.offsetHeight,e.value.element.classList.add(`dv-tab--group-collapsed`)}}}this._skipNextCollapseAnimation=!1,this._ensureIndicator(),this._indicator&&(this._indicator.syncUnderlineElements(o),i?this._indicator.trackUnderlines():this._indicator.positionUnderlines())}},AGe=class extends fB{get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e&&(this._showTabsOverflowControl=e,e)){let e=new AWe(this._tabsList);this._observerDisposable.value=new fB(e,e.onDidChange(e=>{let t=e.hasScrollX||e.hasScrollY;this.toggleDropdown({reset:!t}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}),vB(this._tabsList,`scroll`,()=>{this.toggleDropdown({reset:!1}),this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}))}}get element(){return this._element}set voidContainer(e){var t;(t=this._voidContainerListeners)==null||t.dispose(),this._voidContainerListeners=null,this._voidContainer=e,e&&(this._voidContainerListeners=new fB(vB(e,`dragover`,e=>{this._animState&&e.preventDefault()}),vB(e,`drop`,e=>{this._animState?.sourceTabGroupId&&this._animState.currentInsertionIndex!==null&&(e.preventDefault(),e.stopPropagation(),this.handleVoidDrop())})))}handleVoidDrop(){if(!this._animState?.sourceTabGroupId)return!1;let e=this._animState.sourceTabGroupId,t=this._animState.currentInsertionIndex??this._tabs.length;return this._animState=null,this._commitGroupMove(e,t),!0}get panels(){return this._tabs.map(e=>e.value.panel.id)}get size(){return this._tabs.length}get tabs(){return this._tabs.map(e=>e.value)}get direction(){return this._direction}set direction(e){if(this._direction!==e){this._direction=e,this._tabsList.setAttribute(`aria-orientation`,e===`vertical`?`vertical`:`horizontal`),this._scrollbar&&(this._scrollbar.orientation=e),xB(this._tabsList,`dv-horizontal`,`dv-vertical`),e===`vertical`?SB(this._tabsList,`dv-tabs-container-vertical`,`dv-vertical`):(xB(this._tabsList,`dv-tabs-container-vertical`),SB(this._tabsList,`dv-horizontal`));for(let t of this._tabs)t.value.setDirection(e);this._tabGroupManager.updateDirection()}}constructor(e,t,n){super(),this.group=e,this.accessor=t,this._observerDisposable=new pB,this._scrollbar=null,this._tabs=[],this._tabMap=new Map,this.selectedIndex=-1,this._showTabsOverflowControl=!1,this._direction=`horizontal`,this._animState=null,this._pendingMarginCleanups=new Map,this._pendingCollapse=!1,this._flipTransitionCleanup=null,this._voidContainer=null,this._voidContainerListeners=null,this._extendedDropZone=null,this._pointerInsideTabsList=!1,this._onTabDragStart=new Q,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new Q,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new Q,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new Q,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement(`div`),this._tabsList.className=`dv-tabs-container`,this._tabsList.setAttribute(`role`,`tablist`),this._tabsList.setAttribute(`aria-orientation`,this._direction===`vertical`?`vertical`:`horizontal`),this.showTabsOverflowControl=n.showTabsOverflowControl,t.options.scrollbars===`native`?this._element=this._tabsList:(this._scrollbar=new IV(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new kGe({group:this.group,accessor:this.accessor,tabsList:this._tabsList,getTabs:()=>this._tabs,getTabMap:()=>this._tabMap,getDirection:()=>this._direction},{onChipContextMenu:(e,t)=>{var n;(n=this.accessor.contextMenuService)==null||n.showForChip(e,this.group,t)},onChipDragStart:(e,t,n)=>{this._handleChipDragStart(e,t,n)},onChipDragEnd:()=>{this.resetDragAnimation()},onChipDrop:(e,t)=>{this._handleChipDrop(e,t)}}),this.addDisposables(this._onOverflowTabsChange,this._observerDisposable,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,{dispose:()=>{var e;(e=this._flipTransitionCleanup)==null||e.call(this)}},wV.getInstance().onDragEnd(()=>{this._pointerInsideTabsList=!1,this.resetDragAnimation()}),wV.getInstance().onDragMove(e=>{this._handlePointerDragMove(e.clientX,e.clientY)}),vB(this.element,`pointerdown`,e=>{e.defaultPrevented||e.button===0&&this.accessor.doSetGroupActive(this.group)}),vB(this._tabsList,`wheel`,e=>{let t=this._direction===`vertical`,n=t?e.deltaY||e.deltaX:e.deltaX||e.deltaY;if(n===0)return;let r=t?this._tabsList.scrollHeight-this._tabsList.clientHeight:this._tabsList.scrollWidth-this._tabsList.clientWidth;if(r<=0)return;let i=t?this._tabsList.scrollTop:this._tabsList.scrollLeft;n<0&&i<=0||n>0&&i>=r||(e.preventDefault(),e.stopPropagation(),t?this._tabsList.scrollTop=i+n:this._tabsList.scrollLeft=i+n)},{passive:!1}),vB(this._tabsList,`keydown`,e=>{this._onKeyDown(e)}),vB(this._tabsList,`dragover`,e=>{this._processDragOver(e.clientX)&&e.preventDefault()},!0),vB(this._tabsList,`dragleave`,e=>{this._processDragLeave(e.relatedTarget)},!0),vB(this._tabsList,`dragend`,()=>{this.resetDragAnimation()}),vB(this._tabsList,`drop`,e=>{var t;if(!this._animState||this._animState.currentInsertionIndex===null||this.accessor.options.theme?.tabAnimation!==`smooth`&&!this._animState.sourceTabGroupId)return;e.stopPropagation(),e.preventDefault(),(t=this.group.model.dropTargetContainer?.model)==null||t.clear();let n=this._animState;if(this._animState=null,this._pendingCollapse=!1,n.sourceTabGroupId){this._commitGroupMove(n.sourceTabGroupId,n.currentInsertionIndex);return}let r=n.currentInsertionIndex,i=n.sourceIndex,a=r-+(i!==-1&&i<r),o=this.group.model.getTabGroupForPanel(n.sourceTabId);if(a===i&&!n.targetTabGroupId&&!o){this._uncollapsSourceTab(n.sourceTabId),this.resetTabTransforms();return}this._uncollapsSourceTab(n.sourceTabId);let s=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:e,index:a,targetTabGroupId:n.targetTabGroupId}),this.runFlipAnimation(s,n.sourceTabId,n.sourceIndex===-1,{from:Math.min(i,a),to:Math.max(i,a)})},!0),dB.from(()=>{var e;(e=this._voidContainerListeners)==null||e.dispose(),this.resetDragAnimation(),this._tabGroupManager.disposeAll();for(let{value:e,disposable:t}of this._tabs)t.dispose(),e.dispose();this._tabs=[],this._tabMap.clear()}))}indexOf(e){return this._tabs.findIndex(t=>t.value.panel.id===e)}getTabId(e){return this._tabMap.get(e)?.value.element.id}isActive(e){return this.selectedIndex>-1&&this._tabs[this.selectedIndex].value===e}_onKeyDown(e){let t=this._tabs.findIndex(t=>t.value.element===e.target);if(t===-1)return;let n=this._direction===`vertical`,r=n?`ArrowDown`:`ArrowRight`,i=n?`ArrowUp`:`ArrowLeft`,a=this._tabs.length-1;switch(e.key){case r:e.preventDefault(),this._focusTab(Math.min(t+1,a));break;case i:e.preventDefault(),this._focusTab(Math.max(t-1,0));break;case`Home`:e.preventDefault(),this._focusTab(0);break;case`End`:e.preventDefault(),this._focusTab(a);break;case`Enter`:case` `:e.preventDefault(),this.accessor.withOrigin(`user`,()=>this._tabs[t].value.panel.api.setActive());break;case`Delete`:case`Backspace`:e.preventDefault(),this._closeTab(t);break}}_closeTab(e){let t=this._tabs[e]?.value;if(!t)return;let n=(this._tabs[e+1]?.value??this._tabs[e-1]?.value)?.panel.id;if(t.panel.api.close(),n!==void 0){let e=this._tabs.findIndex(e=>e.value.panel.id===n);e>-1&&this._focusTab(e)}}_focusTab(e){for(let t=0;t<this._tabs.length;t++)this._tabs[t].value.element.tabIndex=t===e?0:-1;this._tabs[e].value.element.focus()}focusActiveTab(){if(this._tabs.length===0)return;let e=this.group.activePanel?.id,t=e?this._tabs.findIndex(t=>t.value.panel.id===e):-1;this._focusTab(t>-1?t:0)}setActivePanel(e){let t=this._direction===`vertical`,n=0;for(let r of this._tabs){let i=e.id===r.value.panel.id;if(r.value.setActive(i),i){let e=r.value.element,i=e.parentElement;t?(n<i.scrollTop||n+e.clientHeight>i.scrollTop+i.clientHeight)&&(i.scrollTop=n):(n<i.scrollLeft||n+e.clientWidth>i.scrollLeft+i.clientWidth)&&(i.scrollLeft=n)}n+=t?r.value.element.clientHeight:r.value.element.clientWidth}this._tabGroupManager.groupUnderlines.size>0&&this._tabGroupManager.positionUnderlines()}openPanel(e,t=this._tabs.length){if(this._tabMap.has(e.id))return;let n=new CGe(e,this.accessor,this.group);n.setContent(e.view.tab),this._direction!==`horizontal`&&n.setDirection(this._direction);let r={value:n,disposable:new fB(n.onDragStart(t=>{if(this._onTabDragStart.fire({nativeEvent:t,panel:e}),this.accessor.options.theme?.tabAnimation===`smooth`){let t=n.element.getBoundingClientRect().width,r=this._tabs.findIndex(e=>e.value===n);this._animState={sourceTabId:e.id,sourceIndex:r,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:t/2,sourceGapWidth:t,containerLeft:this._tabsList.getBoundingClientRect().left},this._pendingCollapse=!0,requestAnimationFrame(()=>{var e;this._pendingCollapse=!1,this._animState&&(n.element.style.transition=`none`,CB(n.element,`dv-tab--dragging`,!0),n.element.offsetHeight,(e=this._animState).currentInsertionIndex??(e.currentInsertionIndex=r),this.applyDragOverTransforms(!0),n.element.style.removeProperty(`transition`))})}}),n.onTabClick(t=>{t.defaultPrevented||this.group.api.location.type===`edge`&&(this.group.activePanel===e?this.group.api.isCollapsed()?this.group.api.expand():this.group.api.collapse():(this.group.model.openPanel(e),this.group.api.isCollapsed()&&this.group.api.expand()))}),n.onPointerDown(t=>{if(t.defaultPrevented)return;let r=!this.accessor.options.disableFloatingGroups,i=this.group.api.location.type===`floating`&&this.size===1;if(r&&!i&&t.shiftKey){t.preventDefault();let e=this.accessor.getGroupPanel(n.panel.id),{top:r,left:i}=n.element.getBoundingClientRect(),{top:a,left:o}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(e,{x:i-o,y:r-a,inDragMode:!0});return}switch(t.button){case 0:this.group.api.location.type===`edge`||this.group.activePanel!==e&&this.group.model.openPanel(e);break}}),n.onDrop(e=>{let t=this._animState;this._animState=null,this._pendingCollapse=!1;let r=this._tabs.findIndex(e=>e.value===n);if(t){let n=e.position===`right`?r+1:r;if(t.sourceTabGroupId){this._commitGroupMove(t.sourceTabGroupId,t.currentInsertionIndex??n);return}this._uncollapsSourceTab(t.sourceTabId);let i=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire({event:e.nativeEvent,index:n,targetTabGroupId:t.targetTabGroupId}),this.accessor.options.theme?.tabAnimation===`smooth`&&this.runFlipAnimation(i,t.sourceTabId,t.sourceIndex===-1,t.sourceIndex===-1?void 0:{from:Math.min(t.sourceIndex,n),to:Math.max(t.sourceIndex,n)})}else{let t=this._direction===`vertical`?`bottom`:`right`,i=e.position===t?r+1:r,a=lB(),o=a?this._tabs.findIndex(e=>e.value.panel.id===a.panelId):-1,s=i-+(o!==-1&&o<i),c=this.group.model.getTabGroupForPanel(n.panel.id)?.id??null;this._onDrop.fire({event:e.nativeEvent,index:s,targetTabGroupId:c})}}),n.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new PV(e,{kind:`tab`,panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:lB}))}))};this.addTab(r,t),this._tabGroupManager.positionAllChips(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}delete(e){this._animState?.sourceTabId===e&&(this.resetTabTransforms(),this._animState=null),this._tabGroupManager.cleanupTransition(e);let t=this.indexOf(e),n=this._tabs.splice(t,1)[0];if(this._tabMap.delete(e),n){let{value:e,disposable:t}=n;t.dispose(),e.dispose(),e.element.remove()}this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipPositions=this._tabGroupManager.snapshotChipWidths(),this.applyDragOverTransforms())}addTab(e,t=this._tabs.length){if(t<0||t>this._tabs.length)throw Error(`invalid location`);let n=t<this._tabs.length?this._tabs[t].value.element:null;this._tabsList.insertBefore(e.value.element,n),this._tabs=[...this._tabs.slice(0,t),e,...this._tabs.slice(t)],this._tabMap.set(e.value.panel.id,e),this.selectedIndex<0&&(this.selectedIndex=t)}toggleDropdown(e){if(e.reset){this._onOverflowTabsChange.fire({tabs:[],tabGroups:[],reset:!0});return}let t=this._tabs.filter(e=>!NB(e.value.element,this._tabsList)).map(e=>e.value.panel.id),n=new Set(t),r=[];for(let e of this.group.model.getTabGroups()){let i=this._tabGroupManager.chipRenderers.get(e.id),a=i&&!NB(i.chip.element,this._tabsList),o=e.panelIds.length>0&&e.panelIds.every(e=>n.has(e));if((a||o)&&(r.push(e.id),e.collapsed))for(let r of e.panelIds)n.has(r)||(n.add(r),t.push(r))}this._onOverflowTabsChange.fire({tabs:t,tabGroups:r,reset:!1})}updateDragAndDropState(){for(let e of this._tabs)e.value.updateDragAndDropState();this._tabGroupManager.updateDragAndDropState()}updateTabGroups(){this._tabGroupManager.update()}refreshTabGroupAccent(){this._tabGroupManager.refreshAccents()}_handleChipDragStart(e,t,n){let r=e.panelIds[0],i=r?this._tabs.findIndex(e=>e.value.panel.id===r):-1,a=t.element.getBoundingClientRect(),o=a.width;for(let t of e.panelIds){let e=this._tabMap.get(t);e&&(o+=e.value.element.getBoundingClientRect().width)}if(this._animState={sourceTabId:``,sourceIndex:i,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.id,sourceGroupPanelIds:new Set(e.panelIds),sourceChipWidth:a.width,cursorOffsetFromDragLeft:n.clientX-a.left,sourceGapWidth:o,containerLeft:this._tabsList.getBoundingClientRect().left},this.accessor.options.theme?.tabAnimation!==`smooth`)return;let s=new Set(e.panelIds);this._pendingCollapse=!0,requestAnimationFrame(()=>{var t;if(this._pendingCollapse=!1,!this._animState)return;for(let e of this._tabs)s.has(e.value.panel.id)&&(e.value.element.style.transition=`none`,CB(e.value.element,`dv-tab--dragging`,!0));let n=this._tabGroupManager.chipRenderers.get(e.id);n&&(n.chip.element.style.transition=`none`,CB(n.chip.element,`dv-tab-group-chip--dragging`,!0)),this._tabsList.offsetHeight;let r=this._tabGroupManager.groupUnderlines.get(e.id);r&&(r.style.display=`none`),(t=this._animState).currentInsertionIndex??(t.currentInsertionIndex=i),this.applyDragOverTransforms(!0);for(let e of this._tabs)s.has(e.value.panel.id)&&e.value.element.style.removeProperty(`transition`);n&&n.chip.element.style.removeProperty(`transition`)})}_handleChipDrop(e,t){let n=e.panelIds[0];if(!n)return;let r=this._tabs.findIndex(e=>e.value.panel.id===n);if(r===-1)return;let i=lB(),a=i&&i.groupId===this.group.id&&i.panelId?this._tabs.findIndex(e=>e.value.panel.id===i.panelId):-1,o=r-+(a!==-1&&a<r);this._onDrop.fire({event:t.nativeEvent,index:o,targetTabGroupId:null})}setExtendedDropZone(e){this._extendedDropZone=e}setExternalInsertionIndex(e){this._animState&&e!==this._animState.currentInsertionIndex&&(this._animState.currentInsertionIndex=e,this.applyDragOverTransforms())}clearExternalAnimState(){this._animState&&(this.resetTabTransforms(),this._animState.sourceIndex===-1?this._animState=null:this._animState.currentInsertionIndex=null)}snapshotTabPositions(){let e=new Map;for(let t of this._tabs)e.set(t.value.panel.id,t.value.element.getBoundingClientRect());return e}getAverageTabWidth(){if(this._tabs.length===0)return 0;let e=this._direction===`vertical`,t=0;for(let n of this._tabs){let r=n.value.element.getBoundingClientRect();t+=e?r.height:r.width}return t/this._tabs.length}_handlePointerDragMove(e,t){let n=(this._tabsList.ownerDocument??document).elementFromPoint(e,t);if(!(n&&(this._tabsList.contains(n)||this._extendedDropZone&&this._extendedDropZone.contains(n)))){this._pointerInsideTabsList&&(this._pointerInsideTabsList=!1,this._processDragLeave(n));return}this._pointerInsideTabsList=!0,this._processDragOver(e)}_processDragOver(e){var t;if(this.accessor.options.disableDnd)return!1;if(this._animState){let e=lB();e?.tabGroupId&&e.groupId!==this.group.id&&this._animState.sourceTabGroupId!==e.tabGroupId&&(this._animState=null)}if(!this._animState){let e=lB();if(this.accessor.options.theme?.tabAnimation==="default"&&!e?.tabGroupId)return!1;if(e&&(e.panelId||e.tabGroupId)&&e.groupId!==this.group.id){let t=this.getAverageTabWidth();if(e.tabGroupId){let n=this.accessor.getPanel(e.groupId)?.model.getTabGroups().find(t=>t.id===e.tabGroupId),r=t*(n?.panelIds.length??1)+t;this._animState={sourceTabId:``,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.tabGroupId,sourceGroupPanelIds:n?new Set(n.panelIds):new Set,sourceChipWidth:t,cursorOffsetFromDragLeft:r/2,sourceGapWidth:r,containerLeft:this._tabsList.getBoundingClientRect().left}}else this._animState={sourceTabId:e.panelId,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipPositions:this._tabGroupManager.snapshotChipWidths(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipWidth:0,cursorOffsetFromDragLeft:t/2,sourceGapWidth:t,containerLeft:this._tabsList.getBoundingClientRect().left}}else return!1}return this._animState.sourceIndex!==-1&&((t=this.group.model.dropTargetContainer?.model)==null||t.clear()),this.handleDragOver({clientX:e}),!0}_processDragLeave(e){var t;if(this._animState&&!(e&&this._tabsList.contains(e))){if(e&&this._extendedDropZone?.contains(e)){this.resetTabTransforms(),this._animState.currentInsertionIndex=null;return}this._voidContainer&&e&&(e===this._voidContainer||this._voidContainer.contains(e))||(this.resetTabTransforms(),this._animState.sourceIndex===-1?((t=this.group.model.dropTargetContainer?.model)==null||t.clear(),this._animState=null):this._animState.currentInsertionIndex=null)}}handleDragOver(e){if(!this._animState)return;let t=e.clientX,n=null,r=null,i=this._animState.sourceGroupPanelIds,a=t-this._animState.cursorOffsetFromDragLeft-this._animState.containerLeft,o=0,s=new Map;if(this._tabGroupManager.chipRenderers.size>0){let e=this.group.model.getTabGroups();for(let t of e)t.id!==this._animState.sourceTabGroupId&&t.panelIds.length>0&&s.set(t.panelIds[0],t.id)}for(let e=0;e<this._tabs.length;e++){let t=this._tabs[e].value;if(t.panel.id===this._animState.sourceTabId||i?.has(t.panel.id))continue;let r=s.get(t.panel.id);if(r){let t=this._animState.chipPositions.get(r)??0;if(o+t>a){n??=e;break}o+=t}let c=this._animState.tabPositions.get(t.panel.id),l=c?c.width:t.element.getBoundingClientRect().width;if(o+l/2<=a)o+=l,n=e+1;else{n??=e;break}}if(n!==null&&this._tabGroupManager.chipRenderers.size>0){let e=!!this._animState.sourceTabGroupId,a=this.group.model.getTabGroups(),o=0;for(let e=0;e<this._tabs.length;e++){let t=this._tabs[e].value;if(t.panel.id===this._animState.sourceTabId||i?.has(t.panel.id))continue;if(e>=n)break;let r=s.get(t.panel.id);r&&(o+=this._animState.chipPositions.get(r)??0);let a=this._animState.tabPositions.get(t.panel.id);o+=a?a.width:t.element.getBoundingClientRect().width}for(let s of a){let a=s.panelIds.filter(e=>e!==this._animState.sourceTabId&&!i?.has(e));if(a.length===0)continue;let c=this._tabs.findIndex(e=>e.value.panel.id===a[0]),l=this._tabs.findIndex(e=>e.value.panel.id===a[a.length-1]);if(c===-1||l===-1)continue;let u=n>=c&&n<=l,d=!u&&n===c-1;if(!(!u&&!d)){if(e&&u){let e=(c+l+1)/2;n=n<e?c:l+1;break}if(e&&d)break;if(d){let e=!0;for(let t=n;t<c;t++){let n=this._tabs[t].value.panel.id;if(n!==this._animState.sourceTabId&&!i?.has(n)){e=!1;break}}if(!e)continue;let a=this._animState.chipPositions.get(s.id)??0;t>=(s.collapsed?this._animState.containerLeft+o+a/2:this._animState.containerLeft+o+a)&&(n=c,r=s.id);break}if(u){let e=this._animState.chipPositions.get(s.id)??0,i=this._animState.containerLeft+o+e;n===c?t>=i&&(r=s.id):r=s.id;break}}}}n===this._animState.currentInsertionIndex&&r===this._animState.targetTabGroupId||(this._animState.currentInsertionIndex=n,this._animState.targetTabGroupId=r,this.accessor.options.theme?.tabAnimation===`smooth`&&this.applyDragOverTransforms())}_removeClassInstantlyBatch(e,t){let n=[];for(let r of e)r.classList.contains(t)&&(r.style.transition=`none`,CB(r,t,!1),n.push(r));if(n.length>0){n[0].offsetHeight;for(let e of n)e.style.removeProperty(`transition`)}}_uncollapsSourceTab(e){let t=this._tabMap.get(e);t&&this._removeClassInstantlyBatch([t.value.element],`dv-tab--dragging`)}applyDragOverTransforms(e=!1){if(!this._animState||this._animState.currentInsertionIndex===null){this.resetTabTransforms();return}if(this._pendingCollapse)return;let t=this._animState.currentInsertionIndex,n,r=this._animState.sourceGroupPanelIds;if(this._animState.sourceTabGroupId&&r)n=this._animState.sourceGapWidth;else{let e=this._animState.tabPositions.get(this._animState.sourceTabId);n=e?e.width:this.getAverageTabWidth()}let i=null;if(this._tabGroupManager.chipRenderers.size>0){let e=this.group.model.getTabGroups();for(let n of e){if(n.id===this._animState.sourceTabGroupId||n.panelIds.includes(this._animState.sourceTabId))continue;let e=n.panelIds.filter(e=>e!==this._animState.sourceTabId&&!r?.has(e));if(e.length===0)continue;let a=this._tabs.findIndex(t=>t.value.panel.id===e[0]);if((!this._animState.targetTabGroupId||this._animState.targetTabGroupId===n.id&&n.collapsed)&&a>=t){let e=!1;for(let n=t;n<a;n++){let t=this._tabs[n].value.panel.id;if(t!==this._animState.sourceTabId&&!r?.has(t)){e=!0;break}}if(!e){let e=this._tabGroupManager.chipRenderers.get(n.id);e&&(i=e.chip.element)}break}}}let a=e=>e.classList.contains(`dv-tab-group-chip`)?`dv-tab-group-chip--shifting`:`dv-tab--shifting`,o=(t,n)=>{e?(t.style.transition=`none`,t.style.marginLeft=n,t.offsetHeight,t.style.removeProperty(`transition`)):t.style.marginLeft=n,CB(t,a(t),!0)},s=t=>{let n=a(t),r=this._pendingMarginCleanups.get(t);if(r&&r(),e||!t.style.marginLeft)t.style.removeProperty(`margin-left`),CB(t,n,!1);else{t.style.marginLeft=`0px`,CB(t,n,!0);let e=()=>{t.style.removeProperty(`margin-left`),CB(t,n,!1),t.removeEventListener(`transitionend`,e),clearTimeout(r),this._pendingMarginCleanups.delete(t)},r=setTimeout(e,300);this._pendingMarginCleanups.set(t,e),t.addEventListener(`transitionend`,e)}},c=!1;for(let[e,t]of this._tabGroupManager.chipRenderers)e!==this._animState.sourceTabGroupId&&s(t.chip.element);i&&(o(i,`${n}px`),c=!0);for(let e=0;e<this._tabs.length;e++){let i=this._tabs[e].value;i.panel.id!==this._animState.sourceTabId&&(r?.has(i.panel.id)||(!c&&e>=t?(o(i.element,`${n}px`),c=!0):s(i.element)))}this._tabGroupManager.trackUnderlines()}resetTabTransforms(){for(let[,e]of this._pendingMarginCleanups)e();this._pendingMarginCleanups.clear();for(let e of this._tabs)e.value.element.style.removeProperty(`margin-left`),e.value.element.style.removeProperty(`margin-right`),e.value.element.style.removeProperty(`margin-top`),e.value.element.style.removeProperty(`margin-bottom`),e.value.element.style.removeProperty(`transform`),CB(e.value.element,`dv-tab--shifting`,!1);for(let[,e]of this._tabGroupManager.chipRenderers)e.chip.element.style.removeProperty(`margin-left`),CB(e.chip.element,`dv-tab-group-chip--shifting`,!1);this._tabGroupManager.positionUnderlines()}_commitGroupMove(e,t){let n=lB();if(this._tabGroupManager.disposeChipDrag(e),this.group.model.getTabGroups().some(t=>t.id===e))if(this.accessor.options.theme?.tabAnimation===`smooth`){this._clearGroupDragClasses(e);let n=this.snapshotTabPositions();this.resetTabTransforms(),this.group.model.moveTabGroup(e,t),this.runFlipAnimation(n,``,!1)}else this._tabGroupManager.skipNextCollapseAnimation=!0,this.group.model.moveTabGroup(e,t);else n&&(this.resetTabTransforms(),this.accessor.moveGroupOrPanel({from:{groupId:n.groupId,tabGroupId:n.tabGroupId??e},to:{group:this.group,position:`center`,index:t}}))}_clearGroupDragClasses(e){let t=this._tabGroupManager.chipRenderers.get(e);t&&this._removeClassInstantlyBatch([t.chip.element],`dv-tab-group-chip--dragging`),this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),`dv-tab--dragging`);let n=this._tabGroupManager.groupUnderlines.get(e);n&&n.style.removeProperty(`display`),this._tabGroupManager.skipNextCollapseAnimation=!0}resetDragAnimation(){if(this._pendingCollapse=!1,this._animState){this.resetTabTransforms(),this._animState.sourceTabGroupId?this._clearGroupDragClasses(this._animState.sourceTabGroupId):this._removeClassInstantlyBatch(this._tabs.map(e=>e.value.element),`dv-tab--dragging`),this._animState=null;for(let[,e]of this._tabGroupManager.groupUnderlines)e.style.removeProperty(`display`)}}runFlipAnimation(e,t,n=!1,r){let i=this._direction===`vertical`,a=!1;for(let o=0;o<this._tabs.length;o++){let s=this._tabs[o],c=s.value.panel.id;if(c===t){if(n){let e=s.value.element.getBoundingClientRect();s.value.element.style.transform=i?`translateY(${e.height}px)`:`translateX(${e.width}px)`,CB(s.value.element,`dv-tab--shifting`,!0),a=!0}continue}if(r!==void 0&&(o<r.from||o>r.to))continue;let l=e.get(c);if(!l)continue;let u=s.value.element.getBoundingClientRect(),d=i?l.top-u.top:l.left-u.left;Math.abs(d)<1||(s.value.element.style.transform=i?`translateY(${d}px)`:`translateX(${d}px)`,CB(s.value.element,`dv-tab--shifting`,!0),a=!0)}a&&requestAnimationFrame(()=>{var e;for(let e of this._tabs)e.value.element.style.transform&&(e.value.element.style.transform=``);this._tabGroupManager.trackUnderlines(),(e=this._flipTransitionCleanup)==null||e.call(this);let t=e=>{if(e.propertyName===`transform`){n();for(let e of this._tabs)CB(e.value.element,`dv-tab--shifting`,!1);this._tabGroupManager.positionUnderlines()}},n=()=>{this._tabsList.removeEventListener(`transitionend`,t),this._flipTransitionCleanup=null};this._flipTransitionCleanup=n,this._tabsList.addEventListener(`transitionend`,t)})}},GV=e=>{let t=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);t.setAttributeNS(null,`height`,e.height),t.setAttributeNS(null,`width`,e.width),t.setAttributeNS(null,`viewBox`,e.viewbox),t.setAttributeNS(null,`aria-hidden`,`false`),t.setAttributeNS(null,`focusable`,`false`),t.classList.add(`dv-svg`);let n=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return n.setAttributeNS(null,`d`,e.path),t.appendChild(n),t},jGe=()=>GV({width:`11`,height:`11`,viewbox:`0 0 28 28`,path:`M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z`}),MGe=()=>GV({width:`11`,height:`11`,viewbox:`0 0 24 15`,path:`M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z`}),KV=()=>GV({width:`11`,height:`11`,viewbox:`0 0 15 25`,path:`M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z`});function NGe(){let e=document.createElement(`div`);e.className=`dv-tabs-overflow-dropdown-default`;let t=document.createElement(`span`);t.textContent=``;let n=KV();return e.appendChild(n),e.appendChild(t),{element:e,update:e=>{t.textContent=`${e.tabs}`}}}var PGe=class extends fB{get onTabDragStart(){return this.tabs.onTabDragStart}get panels(){return this.tabs.panels}get size(){return this.tabs.size}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?`none`:``}get direction(){return this._direction}set direction(e){this._direction=e,e===`vertical`?(SB(this._element,`dv-groupview-header-vertical`),SB(this.rightActionsContainer,`dv-right-actions-container-vertical`),this.tabs.direction=e):(xB(this._element,`dv-groupview-header-vertical`),xB(this.rightActionsContainer,`dv-right-actions-container-vertical`),this.tabs.direction=e)}get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._hidden=!1,this._direction=`horizontal`,this.dropdownPart=null,this._overflowTabs=[],this._overflowTabGroups=[],this._dropdownDisposable=new pB,this._onDrop=new Q,this.onDrop=this._onDrop.event,this._onGroupDragStart=new Q,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new Q,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement(`div`),this._element.className=`dv-tabs-and-actions-container`,CB(this._element,`dv-full-width-single-tab`,this.accessor.options.singleTabMode===`fullwidth`),this.rightActionsContainer=document.createElement(`div`),this.rightActionsContainer.className=`dv-right-actions-container`,this.leftActionsContainer=document.createElement(`div`),this.leftActionsContainer.className=`dv-left-actions-container`,this.preActionsContainer=document.createElement(`div`),this.preActionsContainer.className=`dv-pre-actions-container`,this.tabs=new AGe(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new TGe(this.accessor,this.group),this.tabs.voidContainer=this.voidContainer.element,this._element.appendChild(this.preActionsContainer),this._element.appendChild(this.tabs.element),this._element.appendChild(this.leftActionsContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.rightActionsContainer),this.tabs.setExtendedDropZone(this._element),this.addDisposables(this.tabs.onDrop(e=>this._onDrop.fire(e)),this.tabs.onWillShowOverlay(e=>this._onWillShowOverlay.fire(e)),e.onDidOptionsChange(()=>{this.tabs.showTabsOverflowControl=!e.options.disableTabsOverflowList}),this.tabs.onOverflowTabsChange(e=>{this.toggleDropdown(e)}),this.tabs,this._onWillShowOverlay,this._onDrop,this._onGroupDragStart,this.voidContainer,this.voidContainer.onDragStart(e=>{this._onGroupDragStart.fire({nativeEvent:e,group:this.group})}),this.voidContainer.onDrop(e=>{this.tabs.handleVoidDrop()||this._onDrop.fire({event:e.nativeEvent,index:this.tabs.size})}),this.voidContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new PV(e,{kind:`header_space`,panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:lB}))}),vB(this.leftActionsContainer,`dragleave`,e=>{let t=e.relatedTarget;!this.leftActionsContainer.contains(t)&&!this._element.contains(t)&&this.tabs.clearExternalAnimState()}),vB(this.voidContainer.element,`dragleave`,e=>{let t=e.relatedTarget;this.voidContainer.element.contains(t)||(this._element.contains(t)?this.tabs.setExternalInsertionIndex(null):this.tabs.clearExternalAnimState())}),vB(this.voidContainer.element,`pointerdown`,e=>{if(!e.defaultPrevented&&!this.accessor.options.disableFloatingGroups&&e.shiftKey&&this.group.api.location.type!==`floating`&&this.group.api.location.type!==`edge`){e.preventDefault();let{top:t,left:n}=this.element.getBoundingClientRect(),{top:r,left:i}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:n-i+20,y:t-r+20,inDragMode:!0})}}))}show(){this.hidden||(this.element.style.display=``)}hide(){this._element.style.display=`none`}setRightActionsElement(e){this.rightActions!==e&&(this.rightActions&&=(this.rightActions.remove(),void 0),e&&(this.rightActionsContainer.appendChild(e),this.rightActions=e))}setLeftActionsElement(e){this.leftActions!==e&&(this.leftActions&&=(this.leftActions.remove(),void 0),e&&(this.leftActionsContainer.appendChild(e),this.leftActions=e))}setPrefixActionsElement(e){this.preActions!==e&&(this.preActions&&=(this.preActions.remove(),void 0),e&&(this.preActionsContainer.appendChild(e),this.preActions=e))}isActive(e){return this.tabs.isActive(e)}indexOf(e){return this.tabs.indexOf(e)}getTabId(e){return this.tabs.getTabId(e)}setActive(e){}delete(e){this.tabs.delete(e),this.updateClassnames()}setActivePanel(e){this.tabs.setActivePanel(e)}focusActiveTab(){this.tabs.focusActiveTab()}openPanel(e,t=this.tabs.size){this.tabs.openPanel(e,t),this.updateClassnames()}closePanel(e){this.delete(e.id)}updateClassnames(){CB(this._element,`dv-single-tab`,this.size===1)}toggleDropdown(e){let t=e.reset?[]:e.tabs,n=e.reset?[]:e.tabGroups;this._overflowTabs=t,this._overflowTabGroups=n;let r=this._overflowTabs.length;if(r>0&&this.dropdownPart){this.dropdownPart.update({tabs:r});return}if(r===0){this._dropdownDisposable.dispose();return}let i=document.createElement(`div`);i.className=`dv-tabs-overflow-dropdown-root`;let a=NGe();a.update({tabs:r}),this.dropdownPart=a,i.appendChild(a.element),this.rightActionsContainer.prepend(i),this._dropdownDisposable.value=new fB(dB.from(()=>{var e,t;i.remove(),(t=(e=this.dropdownPart)?.dispose)==null||t.call(e),this.dropdownPart=null}),vB(i,`pointerdown`,e=>{e.preventDefault()},{capture:!0}),vB(i,`click`,e=>{let t=document.createElement(`div`);t.style.overflow=`auto`,t.className=`dv-tabs-overflow-container`;let n=new Set(this._overflowTabGroups),r=this.group.model.getTabGroups(),a=new Map;for(let e of r)if(n.has(e.id))for(let t of e.panelIds)a.set(t,e);let o=new Set;for(let e of this.tabs.tabs.filter(e=>this._overflowTabs.includes(e.panel.id))){let n=a.get(e.panel.id);if(n&&!o.has(n.id)){o.add(n.id);let e=document.createElement(`div`);e.className=`dv-tabs-overflow-group-header`;let r=document.createElement(`span`);r.className=`dv-tabs-overflow-group-color`,VV(r,n.color,this.accessor.tabGroupColorPalette),e.appendChild(r);let i=document.createElement(`span`);if(i.className=`dv-tabs-overflow-group-label`,i.textContent=n.label||n.id,e.appendChild(i),n.collapsed){let t=document.createElement(`span`);t.className=`dv-tabs-overflow-group-collapsed-badge`,t.textContent=`${n.panelIds.length}`,e.appendChild(t)}e.addEventListener(`click`,()=>{this.accessor.getPopupServiceForGroup(this.group).close(),n.collapsed&&n.expand();let e=n.panelIds[0];if(e){let t=this.group.panels.find(t=>t.id===e);this.accessor.withOrigin(`user`,()=>t?.api.setActive())}}),t.appendChild(e)}let r=this.group.panels.find(t=>t===e.panel),i=r.view.createTabRenderer(`headerOverflow`).element,s=document.createElement(`div`);CB(s,`dv-tab`,!0),CB(s,`dv-active-tab`,r.api.isActive),CB(s,`dv-inactive-tab`,!r.api.isActive),n&&CB(s,`dv-tab--grouped`,!0),s.addEventListener(`click`,t=>{this.accessor.getPopupServiceForGroup(this.group).close(),!t.defaultPrevented&&(n?.collapsed&&n.expand(),e.element.scrollIntoView(),this.accessor.withOrigin(`user`,()=>e.panel.api.setActive()))}),s.appendChild(i),t.appendChild(s)}let s=PB(i);this.accessor.getPopupServiceForGroup(this.group).openPopover(t,{x:e.clientX,y:e.clientY,zIndex:s?.style.zIndex?`calc(${s.style.zIndex} * 2)`:void 0})}))}updateDragAndDropState(){this.tabs.updateDragAndDropState(),this.voidContainer.updateDragAndDropState()}updateTabGroups(){this.tabs.updateTabGroups()}refreshTabGroupAccent(){this.tabs.refreshTabGroupAccent()}},qV=class extends gB{constructor(e,t,n,r,i){super(),this.nativeEvent=e,this.target=t,this.position=n,this.getData=r,this.group=i}},JV=Object.keys({disableAutoResizing:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,transformFloatingGroupDrag:void 0,floatingGroupDragHandle:void 0,popoutUrl:void 0,nonce:void 0,defaultRenderer:void 0,defaultHeaderPosition:void 0,debug:void 0,locked:void 0,disableDnd:void 0,dndStrategy:void 0,className:void 0,noPanelsOverlay:void 0,dndEdges:void 0,theme:void 0,disableTabsOverflowList:void 0,scrollbars:void 0,getTabContextMenuItems:void 0,getTabGroupChipContextMenuItems:void 0,createTabGroupChipComponent:void 0,createGroupDragGhostComponent:void 0,dropOverlayModel:void 0,announcements:void 0,getAnnouncement:void 0,announcer:void 0,messages:void 0,keyboardNavigation:void 0,tabGroupColors:void 0,tabGroupAccent:void 0});function FGe(e){return!!e.referencePanel}function IGe(e){return!!e.referenceGroup}function LGe(e){return!!e.referencePanel}function RGe(e){return!!e.referenceGroup}var zGe=class extends fB{get label(){return this._label}get color(){return this._color}get componentParams(){return this._componentParams}setLabel(e){this.isDisposed||this._label===e||(this._label=e,this._onDidChange.fire())}setColor(e){if(this.isDisposed)return;let t=e===``?void 0:e;this._color!==t&&(this._color=t,this._onDidChange.fire())}setComponentParams(e){this.isDisposed||(this._componentParams=e,this._onDidChange.fire())}get collapsed(){return this._collapsed}get panelIds(){return this._panelIds}get size(){return this._panelIds.length}get isEmpty(){return this._panelIds.length===0}constructor(e,t){super(),this.id=e,this._collapsed=!1,this._panelIds=[],this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._onDidPanelChange=new Q,this.onDidPanelChange=this._onDidPanelChange.event,this._onDidCollapseChange=new Q,this.onDidCollapseChange=this._onDidCollapseChange.event,this._onDidDestroy=new Q,this.onDidDestroy=this._onDidDestroy.event,this._label=t?.label??``,this._color=t?.color===``?void 0:t?.color,this._collapsed=t?.collapsed??!1,this._componentParams=t?.componentParams,this.addDisposables(this._onDidChange,this._onDidPanelChange,this._onDidCollapseChange,this._onDidDestroy)}addPanel(e,t){if(this.isDisposed||this._panelIds.includes(e))return;let n=t===void 0?this._panelIds.length:Math.max(0,Math.min(t,this._panelIds.length));this._panelIds.splice(n,0,e),this._onDidPanelChange.fire({panelId:e,type:`add`})}removePanel(e){if(this.isDisposed)return!1;let t=this._panelIds.indexOf(e);return t===-1?!1:(this._panelIds.splice(t,1),this._onDidPanelChange.fire({panelId:e,type:`remove`}),!0)}indexOfPanel(e){return this._panelIds.indexOf(e)}containsPanel(e){return this._panelIds.includes(e)}collapse(){this.isDisposed||this._collapsed||(this._collapsed=!0,this._onDidCollapseChange.fire(!0))}expand(){this.isDisposed||!this._collapsed||(this._collapsed=!1,this._onDidCollapseChange.fire(!1))}toggle(){this._collapsed?this.expand():this.collapse()}toJSON(){let e={id:this.id,collapsed:this._collapsed,panelIds:[...this._panelIds]};return this._label&&(e.label=this._label),this._color!==void 0&&(e.color=this._color),this._componentParams!==void 0&&(e.componentParams=this._componentParams),e}dispose(){this._onDidDestroy.fire(),super.dispose()}},YV=class extends hB{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get panel(){return this.options.panel}get group(){return this.options.group}get api(){return this.options.api}constructor(e){super(),this.options=e}getData(){return this.options.getData()}},XV=class extends YV{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}},BGe=class extends fB{get tabGroups(){return this._tabGroups}get element(){throw Error(`dockview: not supported`)}get activePanel(){return this._activePanel}get contentContainerId(){return this.contentContainer.element.id}get contentDropTarget(){return this.contentContainer.dropTarget}get locked(){return this._locked}set locked(e){this._locked=e,CB(this.container,`dv-locked-groupview`,e===`no-drop-target`||e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return this._panels.length===0}get hasWatermark(){return!!(this.watermark&&this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get isContentFocused(){return document.activeElement?wB(document.activeElement,this.contentContainer.element):!1}get headerPosition(){return this._headerPosition??`top`}set headerPosition(e){this._headerPosition=e,xB(this.container,`dv-groupview-header-top`,`dv-groupview-header-bottom`,`dv-groupview-header-left`,`dv-groupview-header-right`),SB(this.container,`dv-groupview-header-${e}`);let t=e===`top`||e===`bottom`?`horizontal`:`vertical`;this.tabsContainer.direction=t,this.header.direction=t,this._activePanel?.layout&&this._activePanel.layout(this._width,this._height),this.updateHeaderActions()}get location(){return this._location}set location(e){this._location=e,CB(this.container,`dv-groupview-floating`,!1),CB(this.container,`dv-groupview-popout`,!1),CB(this.container,`dv-groupview-edge`,!1);let t=e=>{this.contentContainer.dropTarget.setTargetZones(e),this.contentContainer.pointerDropTarget.setTargetZones(e)};switch(e.type){case`grid`:t([`top`,`bottom`,`left`,`right`,`center`]);break;case`floating`:t([`top`,`bottom`,`left`,`right`,`center`]),CB(this.container,`dv-groupview-floating`,!0);break;case`popout`:t([`top`,`bottom`,`left`,`right`,`center`]),CB(this.container,`dv-groupview-popout`,!0);break;case`edge`:t([`center`]),CB(this.container,`dv-groupview-edge`,!0);break}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,n,r,i){super(),this.container=e,this.accessor=t,this.id=n,this.options=r,this.groupPanel=i,this._isGroupActive=!1,this._locked=!1,this._location={type:`grid`},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._panelDisposables=new Map,this._tabGroupDisposables=new Map,this._pendingMicrotaskDisposables=new Set,this._onMove=new Q,this.onMove=this._onMove.event,this._onDidDrop=new Q,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new Q,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new Q,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new Q,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new Q,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new Q,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new Q,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new Q,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new Q,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new Q,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOver=new Q,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._tabGroups=[],this._tabGroupMap=new Map,this._panelToTabGroup=new Map,this._tabGroupIdCounter=0,this._pendingTabGroupUpdate=!1,this._onDidCreateTabGroup=new Q,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new Q,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new Q,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new Q,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new Q,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new Q,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,CB(this.container,`dv-groupview`,!0),this.container.setAttribute(`role`,`region`),this._api=new pV(this.accessor),this.tabsContainer=new PGe(this.accessor,this.groupPanel),this.contentContainer=new _Ge(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!r.hideHeader,this.locked=r.locked??!1,this.headerPosition=r.headerPosition??t.defaultHeaderPosition,this.addDisposables(this._onDidPanelTitleChange.event(()=>this.updateAccessibleLabel()),this._onTabDragStart,this._onGroupDragStart,this._onWillShowOverlay,this.tabsContainer.onTabDragStart(e=>{this._onTabDragStart.fire(e)}),this.tabsContainer.onGroupDragStart(e=>{this._onGroupDragStart.fire(e)}),this.tabsContainer.onDrop(e=>{let t=lB()?.panelId??null;if(this.handleDropEvent(`header`,e.event,`center`,e.index),t&&e.targetTabGroupId){let n=this._tabGroupMap.get(e.targetTabGroupId),r;if(n){let e=this._panels.findIndex(e=>e.id===t);if(e!==-1){r=0;for(let t of n.panelIds)this._panels.findIndex(e=>e.id===t)<e&&r++}}this.addPanelToTabGroup(e.targetTabGroupId,t,r)}else t&&e.targetTabGroupId===null&&this.removePanelFromTabGroup(t)}),this.contentContainer.onDidFocus(()=>{this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.onDidBlur(()=>{}),this.contentContainer.dropTarget.onDrop(e=>{this.handleDropEvent(`content`,e.nativeEvent,e.position)}),this.contentContainer.pointerDropTarget.onDrop(e=>{this.handleDropEvent(`content`,e.nativeEvent,e.position)}),this.tabsContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(e)}),this.contentContainer.dropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new PV(e,{kind:`content`,panel:this.activePanel,api:this._api,group:this.groupPanel,getData:lB}))}),this.contentContainer.pointerDropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new PV(e,{kind:`content`,panel:this.activePanel,api:this._api,group:this.groupPanel,getData:lB}))}),this._onMove,this._onDidChange,this._onDidDrop,this._onWillDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange,this._onUnhandledDragOver,this._onDidPanelTitleChange,this._onDidPanelParametersChange,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,this._onDidCreateTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidDestroyTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidAddPanelToTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidRemovePanelFromTabGroup.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupChange.event(()=>{this._scheduleTabGroupUpdate()}),this._onDidTabGroupCollapsedChange.event(()=>{this._scheduleTabGroupUpdate()}))}_scheduleTabGroupUpdate(){this._pendingTabGroupUpdate||(this._pendingTabGroupUpdate=!0,queueMicrotask(()=>{this._pendingTabGroupUpdate=!1,this.isDisposed||this.tabsContainer.updateTabGroups()}))}_bracketTabGroupMutation(e){return this.accessor.mutation?this.accessor.mutation(`tab-group`,e):e()}createTabGroup(e){return this._bracketTabGroupMutation(()=>this._doCreateTabGroup(e))}_doCreateTabGroup(e){let t=e?.id??`tg-${this.id}-${this._tabGroupIdCounter++}`,n=new zGe(t,{label:e?.label,color:e?.color,collapsed:e?.collapsed,componentParams:e?.componentParams});return this._tabGroups.push(n),this._tabGroupMap.set(t,n),this._tabGroupDisposables.set(t,new fB(n.onDidChange(()=>{this._onDidTabGroupChange.fire({tabGroup:n})}),n.onDidCollapseChange(e=>{e?this._handleGroupCollapse(n):this._handleGroupExpand(n),this._onDidTabGroupCollapsedChange.fire({tabGroup:n})}),n.onDidDestroy(()=>{this._removeTabGroupInternal(n)}))),this._onDidCreateTabGroup.fire({tabGroup:n}),n}dissolveTabGroup(e){let t=this._tabGroupMap.get(e);t&&this._bracketTabGroupMutation(()=>{let e=[...t.panelIds];for(let n of e)t.removePanel(n),this._panelToTabGroup.delete(n),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:n});t.dispose()})}addPanelToTabGroup(e,t,n){let r=this._tabGroupMap.get(e);if(!r||!this._panels.some(e=>e.id===t))return;let i=this.getTabGroupForPanel(t);i&&i.id===e||this._bracketTabGroupMutation(()=>{i&&this.removePanelFromTabGroup(t),r.addPanel(t,n),this._panelToTabGroup.set(t,r),this._enforceContiguity(r,t),this._onDidAddPanelToTabGroup.fire({tabGroup:r,panelId:t})})}movePanelWithinGroup(e,t,n){let r=this._tabGroupMap.get(e);!r||!r.containsPanel(t)||(r.removePanel(t),r.addPanel(t,n),this._enforceContiguity(r,t),this.tabsContainer.updateTabGroups())}movePanelBetweenGroups(e,t,n){let r=this._findTabGroupForPanel(e),i=this._tabGroupMap.get(t);i&&(r&&(r.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:r,panelId:e}),r.isEmpty&&r.dispose()),i.addPanel(e,n),this._panelToTabGroup.set(e,i),this._enforceContiguity(i,e),this._onDidAddPanelToTabGroup.fire({tabGroup:i,panelId:e}))}moveTabGroup(e,t){let n=this._tabGroupMap.get(e);if(!n||n.panelIds.length===0)return;let r=new Set(n.panelIds),i=n.panelIds.map(e=>this._panels.find(t=>t.id===e)).filter(e=>e!==void 0);if(i.length===0)return;let a=0;for(let e=0;e<Math.min(t,this._panels.length);e++)r.has(this._panels[e].id)&&a++;for(let e of i){let t=this._panels.indexOf(e);t!==-1&&this._panels.splice(t,1)}let o=t-a,s=Math.max(0,Math.min(o,this._panels.length));this._panels.splice(s,0,...i);for(let e of this._panels)this.tabsContainer.delete(e.id);for(let e=0;e<this._panels.length;e++)this.tabsContainer.openPanel(this._panels[e],e);this.tabsContainer.updateTabGroups()}_enforceContiguity(e,t){let n=this._panels.find(e=>e.id===t);if(!n)return;let r=e.indexOfPanel(t),i=this._computeGlobalIndex(e,r),a=this._panels.indexOf(n);if(a===i)return;this._panels.splice(a,1);let o=i>a?i-1:i;this._panels.splice(o,0,n),this.tabsContainer.delete(t),this.tabsContainer.openPanel(n,o)}_computeGlobalIndex(e,t){let n=e.panelIds;if(n.length<=1){let e=this._panels.find(e=>e.id===n[0]);return e?this._panels.indexOf(e):this._panels.length}for(let e=0;e<n.length;e++){if(e===t)continue;let r=this._panels.find(t=>t.id===n[e]);if(r){let n=this._panels.indexOf(r);return Math.max(0,n+(t-e))}}return this._panels.length}removePanelFromTabGroup(e){let t=this._findTabGroupForPanel(e);t&&this._bracketTabGroupMutation(()=>{t.removePanel(e),this._panelToTabGroup.delete(e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:e}),t.isEmpty&&t.dispose()})}getTabGroups(){return this._tabGroups}updateTabGroups(){this.tabsContainer.updateTabGroups()}refreshTabGroupAccent(){this.tabsContainer.refreshTabGroupAccent()}refreshWatermark(){var e,t;this.watermark&&=(this.watermark.element.remove(),(t=(e=this.watermark).dispose)==null||t.call(e),void 0),this.updateContainer()}getTabGroupForPanel(e){return this._findTabGroupForPanel(e)}_findTabGroupForPanel(e){return this._panelToTabGroup.get(e)}_removeTabGroupInternal(e){let t=this._tabGroups.indexOf(e);if(t!==-1){this._tabGroups.splice(t,1),this._tabGroupMap.delete(e.id);for(let t of e.panelIds)this._panelToTabGroup.delete(t);this._onDidDestroyTabGroup.fire({tabGroup:e});let n=this._tabGroupDisposables.get(e.id);this._tabGroupDisposables.delete(e.id),n&&(this._pendingMicrotaskDisposables.add(n),queueMicrotask(()=>{this._pendingMicrotaskDisposables.delete(n),n.dispose()}))}}_handleGroupCollapse(e){if(!this._activePanel||!e.containsPanel(this._activePanel.id))return;let t=this._panels.indexOf(this._activePanel);for(let e=t+1;e<this._panels.length;e++){let t=this._panels[e],n=this._findTabGroupForPanel(t.id);if(!n||!n.collapsed){this.doSetActivePanel(t),this.updateContainer();return}}for(let e=t-1;e>=0;e--){let t=this._panels[e],n=this._findTabGroupForPanel(t.id);if(!n||!n.collapsed){this.doSetActivePanel(t),this.updateContainer();return}}this.contentContainer.closePanel(),this.doSetActivePanel(void 0),this.updateContainer()}_handleGroupExpand(e){if(this._activePanel)return;let t=e.panelIds[0];if(t){let e=this._panels.find(e=>e.id===t);e&&(this.doSetActivePanel(e),this.updateContainer())}}restoreTabGroups(e){for(let t of e){let e=t.id.match(/-(\d+)$/);if(e){let t=parseInt(e[1],10)+1;t>this._tabGroupIdCounter&&(this._tabGroupIdCounter=t)}}for(let t of e){let e=this.createTabGroup({id:t.id,label:t.label,color:t.color,componentParams:t.componentParams}),n=this._tabGroupMap.get(e.id);for(let r of t.panelIds)this._panels.some(e=>e.id===r)&&(e.addPanel(r),this._panelToTabGroup.set(r,n),this._enforceContiguity(n,r));t.collapsed&&e.collapse(),e.isEmpty&&e.dispose()}}focusContent(){this.contentContainer.element.focus()}focusActiveTab(){this.tabsContainer.focusActiveTab()}set renderContainer(e){this.panels.forEach(e=>{this.renderContainer.detatch(e)}),this._overwriteRenderContainer=e,this.panels.forEach(e=>{this.rerender(e)})}get renderContainer(){return this._overwriteRenderContainer??this.accessor.overlayRenderContainer}set dropTargetContainer(e){this._overwriteDropTargetContainer=e}get dropTargetContainer(){return this._overwriteDropTargetContainer??this.accessor.rootDropTargetContainer}initialize(){this.options.panels&&this.options.panels.forEach(e=>{this.doAddPanel(e)}),this.options.activePanel&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0),this.updateContainer(),this.updateHeaderActions()}updateHeaderActions(){var e;(e=this.accessor.headerActionsService)==null||e.refresh(this.groupPanel)}attachHeaderAction(e,t){switch(e){case`left`:this.tabsContainer.setLeftActionsElement(t);break;case`right`:this.tabsContainer.setRightActionsElement(t);break;case`prefix`:this.tabsContainer.setPrefixActionsElement(t);break}}rerender(e){this.contentContainer.renderPanel(e,{asActive:!1})}indexOf(e){return this.tabsContainer.indexOf(e.id)}toJSON(){let e={views:this.tabsContainer.panels,activeView:this._activePanel?.id,id:this.id};return this.locked!==!1&&(e.locked=this.locked),this.header.hidden&&(e.hideHeader=!0),this.headerPosition!==`top`&&(e.headerPosition=this.headerPosition),this._tabGroups.length>0&&(e.tabGroups=this._tabGroups.map(e=>e.toJSON())),e}moveToNext(e){e||={},e.panel||=this.activePanel;let t=e.panel?this.panels.indexOf(e.panel):-1,n;if(t<this.panels.length-1)n=t+1;else if(!e.suppressRoll)n=0;else return;this.openPanel(this.panels[n])}moveToPrevious(e){if(e||={},e.panel||=this.activePanel,!e.panel)return;let t=this.panels.indexOf(e.panel),n;if(t>0)n=t-1;else if(!e.suppressRoll)n=this.panels.length-1;else return;this.openPanel(this.panels[n])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;(e=this._activePanel)==null||e.focus()}openPanel(e,t={}){(typeof t.index!=`number`||t.index>this.panels.length)&&(t.index=this.panels.length);let n=!!t.skipSetActive;if(e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:n}),this._activePanel===e){this.contentContainer.renderPanel(e,{asActive:!0});return}n||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive||this.updateContainer()}removePanel(e,t={skipSetActive:!1}){let n=typeof e==`string`?e:e.id,r=this._panels.find(e=>e.id===n);if(!r)throw Error(`invalid operation`);return this._removePanel(r,t)}closeAllPanels(){if(this.panels.length>0){let e=[...this.panels];for(let t of e)this.doClose(t)}else this.accessor.removeGroup(this.groupPanel)}closePanel(e){this.doClose(e)}doClose(e){let t=this.panels.length===1&&this.accessor.groups.length===1;this.accessor.removePanel(e,t&&this.accessor.options.noPanelsOverlay===`emptyGroup`?{removeEmptyGroup:!1}:void 0)}isPanelActive(e){return this._activePanel===e}updateActions(e){this.tabsContainer.setRightActionsElement(e)}setActive(e,t=!1){if(!(!t&&this.isActive===e)){if(this._isGroupActive=e,CB(this.container,`dv-active-group`,e),CB(this.container,`dv-inactive-group`,!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0){let e=this._panels.find(e=>{let t=this._findTabGroupForPanel(e.id);return!t||!t.collapsed});e&&this.doSetActivePanel(e)}this.updateContainer()}}layout(e,t){this._width=e,this._height=t,this.contentContainer.layout(this._width,this._height),this._activePanel?.layout&&this._activePanel.layout(this._width,this._height)}_removePanel(e,t){let n=this._activePanel===e;if(this.doRemovePanel(e),n&&this.panels.length>0){let e=this.mostRecentlyUsed[0];this.openPanel(e,{skipSetActive:t.skipSetActive,skipSetGroupActive:t.skipSetActiveGroup})}return this._activePanel&&this.panels.length===0&&this.doSetActivePanel(void 0),t.skipSetActive||this.updateContainer(),e}doRemovePanel(e){let t=this.panels.indexOf(e);if(this._activePanel===e&&this.contentContainer.closePanel(),this.tabsContainer.delete(e.id),this._panels.splice(t,1),this.mostRecentlyUsed.includes(e)){let t=this.mostRecentlyUsed.indexOf(e);this.mostRecentlyUsed.splice(t,1)}let n=this._panelDisposables.get(e.id);n&&(n.dispose(),this._panelDisposables.delete(e.id)),this.removePanelFromTabGroup(e.id),this._onDidRemovePanel.fire({panel:e})}doAddPanel(e,t=this.panels.length,n={skipSetActive:!1}){let r=this._panels.indexOf(e)>-1;this.tabsContainer.show(),this.contentContainer.show(),this.tabsContainer.openPanel(e,t),n.skipSetActive?e.api.renderer===`always`&&this.contentContainer.renderPanel(e,{asActive:!1}):this.contentContainer.openPanel(e),!r&&(this.updateMru(e),this.panels.splice(t,0,e),this._panelDisposables.set(e.id,new fB(e.api.onDidTitleChange(e=>this._onDidPanelTitleChange.fire(e)),e.api.onDidParametersChange(e=>this._onDidPanelParametersChange.fire(e)))),this._onDidAddPanel.fire({panel:e}))}doSetActivePanel(e){var t;this._activePanel!==e&&(this._activePanel=e,e&&(this.tabsContainer.setActivePanel(e),this.contentContainer.setLabelledBy(this.tabsContainer.getTabId(e.id)),this.contentContainer.openPanel(e),e.layout(this._width,this._height),this.updateMru(e),this.contentContainer.refreshFocusState(),this._onDidActivePanelChange.fire({panel:e,origin:(t=this.accessor).currentOrigin?.call(t)??`user`})),this.updateAccessibleLabel())}updateAccessibleLabel(){let e=this._activePanel?.title;e?this.container.setAttribute(`aria-label`,e):this.container.removeAttribute(`aria-label`)}updateMru(e){this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this.mostRecentlyUsed=[e,...this.mostRecentlyUsed]}updateContainer(){var e,t;this.panels.forEach(e=>e.runEvents());let n=this.isEmpty||!this._activePanel;if(n&&!this.watermark){let e=this.accessor.createWatermarkComponent();e.init({containerApi:this._api,group:this.groupPanel}),this.watermark=e,vB(this.watermark.element,`pointerdown`,()=>{this.isActive||this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.element.appendChild(this.watermark.element)}!n&&this.watermark&&(this.watermark.element.remove(),(t=(e=this.watermark).dispose)==null||t.call(e),this.watermark=void 0)}canDisplayOverlay(e,t,n){let r=new qV(e,n,t,lB,this.accessor.getPanel(this.id));return this._onUnhandledDragOver.fire(r),r.isAccepted}handleDropEvent(e,t,n,r){if(this.locked===`no-drop-target`)return;function i(){switch(e){case`header`:return typeof r==`number`?`tab`:`header_space`;case`content`:return`content`}}let a=typeof r==`number`?this.panels[r]:void 0,o=new XV({nativeEvent:t,position:n,panel:a,getData:()=>lB(),kind:i(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(o),o.defaultPrevented)return;let s=lB();if(s&&s.viewId===this.accessor.id){if(e===`content`&&s.groupId===this.id&&(n===`center`||s.panelId===null&&!s.tabGroupId)||e===`header`&&s.groupId===this.id&&s.panelId===null&&!s.tabGroupId)return;if(s.panelId===null){let{groupId:e}=s;this._onMove.fire({target:n,groupId:e,index:r,tabGroupId:s.tabGroupId});return}if(this.tabsContainer.indexOf(s.panelId)!==-1&&this.tabsContainer.size===1)return;let{groupId:t,panelId:i}=s;if(this.id===t&&!n&&this.tabsContainer.indexOf(i)===r)return;this._onMove.fire({target:n,groupId:s.groupId,itemId:s.panelId,index:r})}else this._onDidDrop.fire(new YV({nativeEvent:t,position:n,panel:a,getData:()=>lB(),group:this.groupPanel,api:this._api}))}updateDragAndDropState(){this.tabsContainer.updateDragAndDropState()}dispose(){var e,t,n;super.dispose(),(e=this.watermark)==null||e.element.remove(),(n=(t=this.watermark)?.dispose)==null||n.call(t),this.watermark=void 0;for(let e of[...this._tabGroups])e.dispose();for(let e of this._tabGroupDisposables.values())e.dispose();this._tabGroupDisposables.clear();for(let e of this._pendingMicrotaskDisposables)e.dispose();this._pendingMicrotaskDisposables.clear();for(let e of this.panels)e.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}},ZV=class extends kV{constructor(e,t,n){super(e,t),this._onDidConstraintsChangeInternal=new Q,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new Q,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new Q,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),n&&this.initialize(n)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},QV=class extends jV{get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){return this.__minimumWidth()}get minimumHeight(){return this.__minimumHeight()}get maximumHeight(){return this.__maximumHeight()}get maximumWidth(){return this.__maximumWidth()}__minimumWidth(){let e=typeof this._minimumWidth==`function`?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}__maximumWidth(){let e=typeof this._maximumWidth==`function`?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}__minimumHeight(){let e=typeof this._minimumHeight==`function`?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}__maximumHeight(){let e=typeof this._maximumHeight==`function`?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}get isVisible(){return this.api.isVisible}constructor(e,t,n,r){super(e,t,r??new ZV(e,t)),this._evaluatedMinimumWidth=0,this._evaluatedMaximumWidth=2**53-1,this._evaluatedMinimumHeight=0,this._evaluatedMaximumHeight=2**53-1,this._minimumWidth=0,this._minimumHeight=0,this._maximumWidth=2**53-1,this._maximumHeight=2**53-1,this._snap=!1,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,typeof n?.minimumWidth==`number`&&(this._minimumWidth=n.minimumWidth),typeof n?.maximumWidth==`number`&&(this._maximumWidth=n.maximumWidth),typeof n?.minimumHeight==`number`&&(this._minimumHeight=n.minimumHeight),typeof n?.maximumHeight==`number`&&(this._maximumHeight=n.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onActiveChange(()=>{let{accessor:e}=this._params;e.doSetGroupActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{(typeof e.minimumWidth==`number`||typeof e.minimumWidth==`function`)&&(this._minimumWidth=e.minimumWidth),(typeof e.minimumHeight==`number`||typeof e.minimumHeight==`function`)&&(this._minimumHeight=e.minimumHeight),(typeof e.maximumWidth==`number`||typeof e.maximumWidth==`function`)&&(this._maximumWidth=e.maximumWidth),(typeof e.maximumHeight==`number`||typeof e.maximumHeight==`function`)&&(this._maximumHeight=e.maximumHeight)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({height:e.height,width:e.width})}),this._onDidChange)}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}init(e){e.maximumHeight&&(this._maximumHeight=e.maximumHeight),e.minimumHeight&&(this._minimumHeight=e.minimumHeight),e.maximumWidth&&(this._maximumWidth=e.maximumWidth),e.minimumWidth&&(this._minimumWidth=e.minimumWidth),this._priority=e.priority,this._snap=!!e.snap,super.init(e),typeof e.isVisible==`boolean`&&this.setVisible(e.isVisible)}updateConstraints(){this.api._onDidConstraintsChange.fire({minimumWidth:this._evaluatedMinimumWidth,maximumWidth:this._evaluatedMaximumWidth,minimumHeight:this._evaluatedMinimumHeight,maximumHeight:this._evaluatedMaximumHeight})}toJSON(){let e=super.toJSON(),t=e=>e===2**53-1?void 0:e,n=e=>e<=0?void 0:e;return Object.assign(Object.assign({},e),{minimumHeight:n(this.minimumHeight),maximumHeight:t(this.maximumHeight),minimumWidth:n(this.minimumWidth),maximumWidth:t(this.maximumWidth),snap:this.snap,priority:this.priority})}},$V=`dockview: DockviewGroupPanelApiImpl not initialized`,VGe=class extends ZV{get location(){if(!this._group)throw Error($V);return this._group.model.location}get boundingBox(){if(!this._group||this._group.model.location.type===`popout`)return;let e=this.accessor.element.getBoundingClientRect(),t=this._group.element.getBoundingClientRect();return{left:t.left-e.left,top:t.top-e.top,width:t.width,height:t.height}}get locked(){if(!this._group)throw Error($V);return this._group.locked}set locked(e){if(!this._group)throw Error($V);this._group.locked=e}constructor(e,t){super(e,`__dockviewgroup__`),this.accessor=t,this._onDidLocationChange=new Q,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new Q,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidCollapsedChange=new Q,this.onDidCollapsedChange=this._onDidCollapsedChange.event,this.addDisposables(this._onDidLocationChange,this._onDidActivePanelChange,this._onDidCollapsedChange,this._onDidVisibilityChange.event(e=>{e.isVisible&&this._pendingSize&&(super.setSize(this._pendingSize),this._pendingSize=void 0)}))}setSize(e){this._pendingSize=Object.assign({},e),super.setSize(e)}close(){if(this._group)return this.accessor.removeGroup(this._group)}getWindow(){return this.location.type===`popout`?this.location.getWindow():window}setHeaderPosition(e){if(!this._group)throw Error($V);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw Error($V);return this._group.model.headerPosition}moveTo(e){if(!this._group)throw Error($V);let t=e.group??this.accessor.addGroup({direction:QWe(e.position??`right`),skipSetActive:e.skipSetActive??!1});this.accessor.moveGroupOrPanel({from:{groupId:this._group.id},to:{group:t,position:e.group?e.position??`center`:`center`,index:e.index},skipSetActive:e.skipSetActive})}maximize(){if(!this._group)throw Error($V);this.location.type===`grid`&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw Error($V);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw Error($V);this.isMaximized()&&this.accessor.exitMaximizedGroup()}collapse(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!0)}expand(){this._group&&this.accessor.setEdgeGroupCollapsed(this._group,!1)}isCollapsed(){return this._group?this.accessor.isEdgeGroupCollapsed(this._group):!1}initialize(e){this._group=e}},HGe=100,UGe=100,eH=class extends QV{get minimumWidth(){if(typeof this._explicitConstraints.minimumWidth==`number`)return this._explicitConstraints.minimumWidth;let e=this.activePanel?.minimumWidth;return typeof e==`number`?e:super.__minimumWidth()}get minimumHeight(){if(typeof this._explicitConstraints.minimumHeight==`number`)return this._explicitConstraints.minimumHeight;let e=this.activePanel?.minimumHeight;return typeof e==`number`?e:super.__minimumHeight()}get maximumWidth(){if(typeof this._explicitConstraints.maximumWidth==`number`)return this._explicitConstraints.maximumWidth;let e=this.activePanel?.maximumWidth;return typeof e==`number`?e:super.__maximumWidth()}get maximumHeight(){if(typeof this._explicitConstraints.maximumHeight==`number`)return this._explicitConstraints.maximumHeight;let e=this.activePanel?.maximumHeight;return typeof e==`number`?e:super.__maximumHeight()}get panels(){return this._model.panels}get activePanel(){return this._model.activePanel}get size(){return this._model.size}get model(){return this._model}get locked(){return this._model.locked}set locked(e){this._model.locked=e}get header(){return this._model.header}constructor(e,t,n){super(t,`groupview_default`,{minimumHeight:n.constraints?.minimumHeight??UGe,minimumWidth:n.constraints?.minimumWidth??HGe,maximumHeight:n.constraints?.maximumHeight,maximumWidth:n.constraints?.maximumWidth},new VGe(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new BGe(this.element,e,t,n,this),this.addDisposables(this.model.onDidActivePanelChange(e=>{this.api._onDidActivePanelChange.fire(e)}),this.api.onDidConstraintsChangeInternal(e=>{e.minimumWidth!==void 0&&(this._explicitConstraints.minimumWidth=typeof e.minimumWidth==`function`?e.minimumWidth():e.minimumWidth),e.minimumHeight!==void 0&&(this._explicitConstraints.minimumHeight=typeof e.minimumHeight==`function`?e.minimumHeight():e.minimumHeight),e.maximumWidth!==void 0&&(this._explicitConstraints.maximumWidth=typeof e.maximumWidth==`function`?e.maximumWidth():e.maximumWidth),e.maximumHeight!==void 0&&(this._explicitConstraints.maximumHeight=typeof e.maximumHeight==`function`?e.maximumHeight():e.maximumHeight)}))}focus(){this.api.isActive||this.api.setActive(),super.focus()}initialize(){this._model.initialize()}setActive(e){super.setActive(e),this.model.setActive(e)}layout(e,t){super.layout(e,t),this.model.layout(e,t)}getComponent(){return this._model}toJSON(){return this.model.toJSON()}},WGe={name:`abyss`,className:`dockview-theme-abyss`,colorScheme:`dark`,tabGroupIndicator:`none`},GGe=class extends ZV{get location(){return this.group.api.location}get title(){return this.panel.title}get isGroupActive(){return this.group.isActive}get renderer(){return this.panel.renderer}set group(e){let t=this._group;this._group!==e&&(this._group=e,this._onDidGroupChange.fire({}),this.setupGroupEventListeners(t),this._onDidLocationChange.fire({location:this.group.api.location}))}get group(){return this._group}get tabComponent(){return this._tabComponent}constructor(e,t,n,r,i){super(e.id,r),this.panel=e,this.accessor=n,this._onDidTitleChange=new Q,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new Q,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new Q,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new Q,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new Q,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new pB,this._tabComponent=i,this.initialize(e),this._group=t,this.setupGroupEventListeners(),this.addDisposables(this.groupEventsDisposable,this._onDidRendererChange,this._onDidTitleChange,this._onDidGroupChange,this._onDidActiveGroupChange,this._onDidLocationChange)}getWindow(){return this.group.api.getWindow()}setActive(){this.accessor.withOrigin(`api`,()=>super.setActive())}moveTo(e){this.accessor.moveGroupOrPanel({from:{groupId:this._group.id,panelId:this.panel.id},to:{group:e.group??this._group,position:e.group?e.position??`center`:`center`,index:e.index},skipSetActive:e.skipSetActive})}setTitle(e){this.panel.setTitle(e)}setRenderer(e){this.panel.setRenderer(e)}close(){this.group.model.closePanel(this.panel)}maximize(){this.group.api.maximize()}isMaximized(){return this.group.api.isMaximized()}exitMaximized(){this.group.api.exitMaximized()}setupGroupEventListeners(e){let t=e?.isActive??!1;this.groupEventsDisposable.value=new fB(this.group.api.onDidVisibilityChange(e=>{let t=!e.isVisible&&this.isVisible,n=e.isVisible&&!this.isVisible,r=this.group.model.isPanelActive(this.panel);(t||n&&r)&&this._onDidVisibilityChange.fire(e)}),this.group.api.onDidLocationChange(e=>{this.group===this.panel.group&&this._onDidLocationChange.fire(e)}),this.group.api.onDidActiveChange(()=>{this.group===this.panel.group&&t!==this.isGroupActive&&(t=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}},tH=class extends fB{get params(){return this._params}get title(){return this._title}get group(){return this._group}get renderer(){return this._renderer??this.accessor.renderer}get minimumWidth(){return this._minimumWidth}get minimumHeight(){return this._minimumHeight}get maximumWidth(){return this._maximumWidth}get maximumHeight(){return this._maximumHeight}constructor(e,t,n,r,i,a,o,s){super(),this.id=e,this.accessor=r,this.containerApi=i,this.view=o,this._renderer=s.renderer,this._group=a,this._minimumWidth=s.minimumWidth,this._minimumHeight=s.minimumHeight,this._maximumWidth=s.maximumWidth,this._maximumHeight=s.maximumHeight,this.api=new GGe(this,this._group,r,t,n),this.addDisposables(this.api.onActiveChange(()=>{r.setActivePanel(this)}),this.api.onDidSizeChange(e=>{this.group.api.setSize(e)}),this.api.onDidRendererChange(()=>{this.group.model.rerender(this)}))}init(e){this._params=e.params,this.view.init(Object.assign(Object.assign({},e),{api:this.api,containerApi:this.containerApi})),this.setTitle(e.title)}focus(){let e=new OV;this.api._onWillFocus.fire(e),!e.defaultPrevented&&(this.api.isActive||this.api.setActive())}toJSON(){return{id:this.id,contentComponent:this.view.contentComponent,tabComponent:this.view.tabComponent,params:Object.keys(this._params||{}).length>0?this._params:void 0,title:this.title,renderer:this._renderer,minimumHeight:this._minimumHeight,maximumHeight:this._maximumHeight,minimumWidth:this._minimumWidth,maximumWidth:this._maximumWidth}}setTitle(e){e!==this.title&&(this._title=e,this.view.setTitle(e),this.api._onDidTitleChange.fire({title:e}))}setRenderer(e){e!==this.renderer&&(this._renderer=e,this.api._onDidRendererChange.fire({renderer:e}))}update(e){this._params=Object.assign(Object.assign({},this._params??{}),e.params);for(let t of Object.keys(e.params))e.params[t]===void 0&&delete this._params[t];this.view.update({params:this._params})}updateFromStateModel(e){this._maximumHeight=e.maximumHeight,this._minimumHeight=e.minimumHeight,this._maximumWidth=e.maximumWidth,this._minimumWidth=e.minimumWidth,this.update({params:e.params??{}}),this.setTitle(e.title??this.id),this.setRenderer(e.renderer??this.accessor.renderer)}updateParentGroup(e,t){this._group=e,this.api.group=this._group;let n=this._group.model.isPanelActive(this),r=this.group.api.isActive&&n;t?.skipSetActive||this.api.isActive!==r&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&n}),this.api.isVisible!==n&&this.api._onDidVisibilityChange.fire({isVisible:n})}runEvents(){let e=this._group.model.isPanelActive(this),t=this.group.api.isActive&&e;this.api.isActive!==t&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&e}),this.api.isVisible!==e&&this.api._onDidVisibilityChange.fire({isVisible:e})}layout(e,t){this.api._onDidDimensionChange.fire({width:e,height:t}),this.view.layout(e,t)}dispose(){this.api.dispose(),this.view.dispose()}},nH=class extends fB{get element(){return this._element}constructor(){super(),this._element=document.createElement(`div`),this._element.className=`dv-default-tab`,this._content=document.createElement(`div`),this._content.className=`dv-default-tab-content`,this.action=document.createElement(`div`),this.action.className=`dv-default-tab-action`,this.action.appendChild(jGe()),this._element.appendChild(this._content),this._element.appendChild(this.action),this.render()}init(e){this._title=e.title,this.addDisposables(e.api.onDidTitleChange(e=>{this._title=e.title,this.render()}),vB(this.action,`pointerdown`,e=>{e.preventDefault()}),vB(this.action,`click`,t=>{t.defaultPrevented||(t.preventDefault(),e.api.close())})),this.render()}render(){this._content.textContent!==this._title&&(this._content.textContent=this._title??``)}},rH=class{get content(){return this._content}get tab(){return this._tab}constructor(e,t,n,r){this.accessor=e,this.id=t,this.contentComponent=n,this.tabComponent=r,this._content=this.createContentComponent(this.id,n),this._tab=this.createTabComponent(this.id,r)}createTabRenderer(e){var t;let n=this.createTabComponent(this.id,this.tabComponent);return this._params&&n.init(Object.assign(Object.assign({},this._params),{tabLocation:e})),this._updateEvent&&((t=n.update)==null||t.call(n,this._updateEvent)),n}init(e){this._params=e,this.content.init(e),this.tab.init(Object.assign(Object.assign({},e),{tabLocation:`header`}))}setTitle(e){this._params&&(this._params.title=e)}layout(e,t){var n,r;(r=(n=this.content).layout)==null||r.call(n,e,t)}update(e){var t,n,r,i;this._updateEvent=e,(n=(t=this.content).update)==null||n.call(t,e),(i=(r=this.tab).update)==null||i.call(r,e)}dispose(){var e,t,n,r;(t=(e=this.content).dispose)==null||t.call(e),(r=(n=this.tab).dispose)==null||r.call(n)}createContentComponent(e,t){return this.accessor.options.createComponent({id:e,name:t})}createTabComponent(e,t){let n=t??this.accessor.options.defaultTabComponent;if(n){if(this.accessor.options.createTabComponent)return this.accessor.options.createTabComponent({id:e,name:n})||new nH;console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new nH}},KGe=class{constructor(e){this.accessor=e}fromJSON(e,t){let n=e.id,r=e.params,i=e.title,a=e.view,o=a?a.content.id:e.contentComponent??`unknown`,s=a?a.tab?.id:e.tabComponent,c=new rH(this.accessor,n,o,s),l=new tH(n,o,s,this.accessor,new pV(this.accessor),t,c,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return l.init({title:i??n,params:r??{}}),l}},qGe=class extends fB{get element(){return this._element}constructor(){super(),this._element=document.createElement(`div`),this._element.className=`dv-watermark`}init(e){}},iH=new class{constructor(){this._orderedList=[]}push(e){this._orderedList=[...this._orderedList.filter(t=>t!==e),e],this.update()}destroy(e){this._orderedList=this._orderedList.filter(t=>t!==e),this.update()}update(){for(let e=0;e<this._orderedList.length;e++)this._orderedList[e].setAttribute(`aria-level`,`${e}`),this._orderedList[e].style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2})`}},aH=class e extends fB{set minimumInViewportWidth(e){this.options.minimumInViewportWidth=e}set minimumInViewportHeight(e){this.options.minimumInViewportHeight=e}get element(){return this._element}get isVisible(){return this._isVisible}get headerHeight(){return this.options.header?.offsetHeight??0}constructor(e){super(),this.options=e,this._element=document.createElement(`div`),this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new Q,this.onDidChangeEnd=this._onDidChangeEnd.event,this._onDidStartMoving=new Q,this.onDidStartMoving=this._onDidStartMoving.event,this._dragMove=new pB,this._dragCancelled=!1,this.addDisposables(this._onDidChange,this._onDidChangeEnd,this._onDidStartMoving,this._dragMove),this._element.className=`dv-resize-container`,this._element.setAttribute(`role`,`dialog`),this._element.setAttribute(`aria-modal`,`false`),this._isVisible=!0,this.setupResize(`top`),this.setupResize(`bottom`),this.setupResize(`left`),this.setupResize(`right`),this.setupResize(`topleft`),this.setupResize(`topright`),this.setupResize(`bottomleft`),this.setupResize(`bottomright`),this.options.header&&(CB(this._element,`dv-resize-container-with-titlebar`,!0),this._element.appendChild(this.options.header)),this._element.appendChild(this.options.content),this.options.container.appendChild(this._element),this.setBounds(Object.assign(Object.assign(Object.assign(Object.assign({height:this.options.height,width:this.options.width},`top`in this.options&&{top:this.options.top}),`bottom`in this.options&&{bottom:this.options.bottom}),`left`in this.options&&{left:this.options.left}),`right`in this.options&&{right:this.options.right})),iH.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,CB(this.element,`dv-hidden`,!this.isVisible))}bringToFront(){iH.push(this._element)}setBounds(e={}){typeof e.height==`number`&&(this._element.style.height=`${e.height}px`),typeof e.width==`number`&&(this._element.style.width=`${e.width}px`),`top`in e&&typeof e.top==`number`&&(this._element.style.top=`${e.top}px`,this._element.style.bottom=`auto`,this.verticalAlignment=`top`),`bottom`in e&&typeof e.bottom==`number`&&(this._element.style.bottom=`${e.bottom}px`,this._element.style.top=`auto`,this.verticalAlignment=`bottom`),`left`in e&&typeof e.left==`number`&&(this._element.style.left=`${e.left}px`,this._element.style.right=`auto`,this.horiziontalAlignment=`left`),`right`in e&&typeof e.right==`number`&&(this._element.style.right=`${e.right}px`,this._element.style.left=`auto`,this.horiziontalAlignment=`right`);let t=this.options.container.getBoundingClientRect(),n=this._element.getBoundingClientRect(),r=Math.max(0,this.getMinimumWidth(n.width)),i=Math.max(0,this.getMinimumHeight(n.height));if(this.verticalAlignment===`top`){let e=BB(n.top-t.top,-i,Math.max(0,t.height-n.height+i));this._element.style.top=`${e}px`,this._element.style.bottom=`auto`}if(this.verticalAlignment===`bottom`){let e=BB(t.bottom-n.bottom,-i,Math.max(0,t.height-n.height+i));this._element.style.bottom=`${e}px`,this._element.style.top=`auto`}if(this.horiziontalAlignment===`left`){let e=BB(n.left-t.left,-r,Math.max(0,t.width-n.width+r));this._element.style.left=`${e}px`,this._element.style.right=`auto`}if(this.horiziontalAlignment===`right`){let e=BB(t.right-n.right,-r,Math.max(0,t.width-n.width+r));this._element.style.right=`${e}px`,this._element.style.left=`auto`}this._onDidChange.fire()}toJSON(){let e=this.options.container.getBoundingClientRect(),t=this._element.getBoundingClientRect(),n={};return this.verticalAlignment===`top`?n.top=parseFloat(this._element.style.top):this.verticalAlignment===`bottom`?n.bottom=parseFloat(this._element.style.bottom):n.top=t.top-e.top,this.horiziontalAlignment===`left`?n.left=parseFloat(this._element.style.left):this.horiziontalAlignment===`right`?n.right=parseFloat(this._element.style.right):n.left=t.left-e.left,n.width=t.width,n.height=t.height,n}cancelPendingDrag(){this._dragMove.value&&(this._dragCancelled=!0,CB(this._element,`dv-resize-container-dragging`,!1),this._dragMove.value=dB.NONE)}setupDrag(e,t={inDragMode:!1}){let n=(e,t)=>{var n;let r=null,i=!1;this._dragCancelled=!1;let a=this.options.transformDragPosition?(n=this.options).getSiblingBoxes?.call(n)??[]:[],o=AB();if(e&&typeof t==`number`&&typeof e.setPointerCapture==`function`)try{e.setPointerCapture(t)}catch{}let s=()=>{CB(this._element,`dv-resize-container-dragging`,!1),this._dragMove.value=dB.NONE,this._onDidChangeEnd.fire()};this._dragMove.value=new fB({dispose:()=>{if(o.release(),e&&typeof t==`number`&&typeof e.releasePointerCapture==`function`)try{e.releasePointerCapture(t)}catch{}}},vB(window,`pointermove`,e=>{if(this._dragCancelled)return;let t=this.options.container.getBoundingClientRect(),n=e.clientX-t.left,o=e.clientY-t.top;CB(this._element,`dv-resize-container-dragging`,!0);let s=this._element.getBoundingClientRect();r===null&&(r={x:e.clientX-s.left,y:e.clientY-s.top});let c=Math.max(0,this.getMinimumWidth(s.width)),l=Math.max(0,this.getMinimumHeight(s.height)),u=o-r.y,d=n-r.x;if(this.options.transformDragPosition){let e=this.options.transformDragPosition({proposed:{top:u,left:d,width:s.width,height:s.height},container:{width:t.width,height:t.height},others:a});e&&(u=e.top,d=e.left)}let f=Math.max(0,t.height-s.height+l),p=Math.max(0,t.width-s.width+c),m=BB(u,-l,f),h=BB(t.height-s.height-u,-l,f),g=BB(d,-c,p),_=BB(t.width-s.width-d,-c,p),v={};m<=h?v.top=m:v.bottom=h,g<=_?v.left=g:v.right=_,this.setBounds(v),i||(i=!0,this._onDidStartMoving.fire())}),vB(window,`pointerup`,s),vB(window,`pointercancel`,s))};this.addDisposables(vB(e,`pointerdown`,t=>{if(t.defaultPrevented){t.preventDefault();return}OB(t)||n(e,t.pointerId)}),vB(this.options.content,`pointerdown`,e=>{e.defaultPrevented||OB(e)||e.shiftKey&&n(this.options.content,e.pointerId)}),vB(this.options.content,`pointerdown`,()=>{iH.push(this._element)},!0)),t.inDragMode&&n()}setupResize(t){let n=document.createElement(`div`);n.className=`dv-resize-handle-${t}`,this._element.appendChild(n);let r=new pB;this.addDisposables(r,vB(n,`pointerdown`,i=>{i.preventDefault();let a=null,o=AB(),s=i.pointerId;if(typeof n.setPointerCapture==`function`)try{n.setPointerCapture(s)}catch{}let c=()=>{r.dispose(),this._onDidChangeEnd.fire()};r.value=new fB(vB(window,`pointermove`,n=>{let r=this.options.container.getBoundingClientRect(),i=this._element.getBoundingClientRect(),o=n.clientY-r.top,s=n.clientX-r.left;a===null&&(a={originalY:o,originalHeight:i.height,originalX:s,originalWidth:i.width});let c,l,u,d,f,p,m=()=>{let t=a.originalY+a.originalHeight>r.height?Math.max(0,r.height-e.MINIMUM_HEIGHT):Math.max(0,a.originalY+a.originalHeight-e.MINIMUM_HEIGHT);c=BB(o,0,t),u=a.originalY+a.originalHeight-c,l=r.height-c-u},h=()=>{c=a.originalY-a.originalHeight;let t=c<0&&typeof this.options.minimumInViewportHeight==`number`?-c+this.options.minimumInViewportHeight:e.MINIMUM_HEIGHT,n=r.height-Math.max(0,c);u=BB(o-c,t,n),l=r.height-c-u},g=()=>{let t=a.originalX+a.originalWidth>r.width?Math.max(0,r.width-e.MINIMUM_WIDTH):Math.max(0,a.originalX+a.originalWidth-e.MINIMUM_WIDTH);d=BB(s,0,t),p=a.originalX+a.originalWidth-d,f=r.width-d-p},_=()=>{d=a.originalX-a.originalWidth;let t=d<0&&typeof this.options.minimumInViewportWidth==`number`?-d+this.options.minimumInViewportWidth:e.MINIMUM_WIDTH,n=r.width-Math.max(0,d);p=BB(s-d,t,n),f=r.width-d-p};switch(t){case`top`:m();break;case`bottom`:h();break;case`left`:g();break;case`right`:_();break;case`topleft`:m(),g();break;case`topright`:m(),_();break;case`bottomleft`:h(),g();break;case`bottomright`:h(),_();break}let v={};c<=l?v.top=c:v.bottom=l,d<=f?v.left=d:v.right=f,v.height=u,v.width=p,this.setBounds(v)}),{dispose:()=>{if(o.release(),typeof n.releasePointerCapture==`function`)try{n.releasePointerCapture(s)}catch{}}},vB(window,`pointerup`,c),vB(window,`pointercancel`,c))}))}getMinimumWidth(e){return typeof this.options.minimumInViewportWidth==`number`?e-this.options.minimumInViewportWidth:0}getMinimumHeight(e){return typeof this.options.minimumInViewportHeight==`number`?e-this.options.minimumInViewportHeight:0}dispose(){iH.destroy(this._element),this._element.remove(),super.dispose()}};aH.MINIMUM_HEIGHT=20,aH.MINIMUM_WIDTH=20;var JGe=class extends fB{get element(){return this._element}get group(){return this._group}setGroup(e){this._group=e}constructor(e,t){super(),this.accessor=e,this._onDragStart=new Q,this.onDragStart=this._onDragStart.event,this._group=t,this._element=document.createElement(`div`),this._element.className=`dv-floating-titlebar`,this.addDisposables(this._onDragStart,vB(this._element,`pointerdown`,()=>{this.accessor.doSetGroupActive(this._group)}),vB(this._element,`pointerdown`,e=>{e.shiftKey&&DB(e)},!0)),this.dragSource=new FV({element:this._element,accessor:this.accessor,group:()=>this._group}),this.addDisposables(this.dragSource,this.dragSource.onDragStart(e=>{this._onDragStart.fire(e)}))}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}};function oH(e){return{moduleName:e.name,services:{[e.serviceKey]:e.create},init:e.init?(t,n)=>e.init(t,n[e.serviceKey]):void 0,dependsOn:e.dependsOn}}var sH=new Set;function cH(e,t,n){if(e!==void 0)return e;let r=`${t}|${n??``}`;if(sH.has(r))return;sH.add(r);let i=n?` for ${n}`:``;console.error(`dockview: module "${t}" is not registered${i}.`)}var YGe=class{constructor(){this._modules=new Map,this._services={},this._initDisposables=[]}get services(){return this._services}register(e){if(!this._modules.has(e.moduleName)){if(e.dependsOn)for(let t of e.dependsOn)this.register(t);this._modules.set(e.moduleName,e)}}initialize(e){for(let t of this._modules.values())if(t.services)for(let[n,r]of Object.entries(t.services))this._services[n]=r(e)}postConstruct(e){for(let t of this._modules.values())t.init&&this._initDisposables.push(t.init(e,this._services))}has(e){return this._modules.has(e)}dispose(){for(let e of this._initDisposables)e.dispose();this._initDisposables.length=0;for(let e of Object.values(this._services))e!==void 0&&typeof e.dispose==`function`&&e.dispose()}},lH=[];function XGe(e){for(let t of e)lH.some(e=>e.moduleName===t.moduleName)||lH.push(t)}function ZGe(){return[...lH]}var uH=!1;function QGe(){uH=!0}function $Ge(){return uH}var dH=100,fH={left:100,top:100,width:300,height:300},eKe=100,tKe=class extends fB{get group(){return this._group}setTitleBar(e){this._titleBar=e}setAnchorGroup(e){var t;this._group=e,(t=this._titleBar)==null||t.setGroup(e)}constructor(e,t,n){super(),this.overlay=t,this.gridview=n,this._group=e,this.addDisposables(t,{dispose:()=>this.gridview.dispose()})}position(e){this.overlay.setBounds(e)}},nKe=class{get floatingGroups(){return this._floatingGroups}constructor(e){this._floatingGroups=[],this._host=e}add(e,t,n){let r=new tKe(e,t,n),i=new fB(e.api.onDidActiveChange(e=>{e.isActive&&t.bringToFront()}),(()=>{let e=-1,t=-1;return bB(n.element,r=>{let i=Math.round(r.contentRect.width),a=Math.round(r.contentRect.height);i===e&&a===t||(e=i,t=a,n.layout(i,a))})})()),a=()=>{let n=e.activePanel?.title;n?t.element.setAttribute(`aria-label`,n):t.element.removeAttribute(`aria-label`)};return a(),r.addDisposables(e.api.onDidActivePanelChange(()=>a()),t.onDidChange(()=>{n.layout(n.width,n.height)}),t.onDidChangeEnd(()=>{this._host.fireLayoutChange()}),e.onDidChange(e=>{t.setBounds({height:typeof e?.height==`number`?e.height+t.headerHeight:e?.height,width:e?.width})}),{dispose:()=>{i.dispose(),zB(this._floatingGroups,r),e.model.location={type:`grid`}}}),this._floatingGroups.push(r),r}findByGroup(e){return this._floatingGroups.find(t=>t.group===e||t.gridview.element.contains(e.element))}serialize(){return this._floatingGroups.map(e=>{let t=e.gridview.serialize(),n=e.overlay.toJSON(),r=t.root;return r.type===`branch`&&r.data.length===1&&r.data[0].type===`leaf`?{data:r.data[0].data,position:n}:{grid:t,position:n}})}constrainBounds(){for(let e of this._floatingGroups)e.overlay.setBounds()}updateBounds(e){if(`floatingGroupBounds`in e)for(let t of this._floatingGroups){switch(e.floatingGroupBounds){case`boundedWithinViewport`:t.overlay.minimumInViewportHeight=void 0,t.overlay.minimumInViewportWidth=void 0;break;case void 0:t.overlay.minimumInViewportHeight=dH,t.overlay.minimumInViewportWidth=dH;break;default:t.overlay.minimumInViewportHeight=e.floatingGroupBounds?.minimumHeightWithinViewport,t.overlay.minimumInViewportWidth=e.floatingGroupBounds?.minimumWidthWithinViewport}t.overlay.setBounds()}}disposeAll(){for(let e of[...this._floatingGroups])e.dispose()}dispose(){this.disposeAll()}},rKe=oH({name:`FloatingGroup`,serviceKey:`floatingGroupService`,create:e=>new nKe(e)}),iKe=class{constructor(e){this._entries=[],this._popupServices=new Map,this._restorationCleanups=new Set,this._restorationPromise=Promise.resolve(),this._onDidRemove=new Q,this.onDidRemove=this._onDidRemove.event,this._host=e}get entries(){return this._entries}get restorationPromise(){return this._restorationPromise}add(e){this._entries.push(e)}remove(e){zB(this._entries,e)&&!this._host.isDisposed&&this._onDidRemove.fire(e)}findByGroup(e){return this._entries.find(t=>t.popoutGroup===e||t.gridview.element.contains(e.element))}findReferenceGroupId(e){return this._entries.find(t=>t.popoutGroup===e)?.referenceGroup}observeGridviewSize(e,t,n){let r=e.window?.ResizeObserver;if(!r)return;let i=-1,a=-1,o=()=>{let r=e.window;if(this._host.isDisposed||!r||r.closed)return;let o=Math.round(t.element.clientWidth),s=Math.round(t.element.clientHeight);o===i&&s===a||(i=o,a=s,o>0&&s>0&&t.layout(o,s),n.updateAllPositions())},s=new r(()=>{let t=e.window?.requestAnimationFrame;t?t.call(e.window,o):o()});return s.observe(t.element),{dispose:()=>s.disconnect()}}getPopupService(e){return this._popupServices.get(e)}setPopupService(e,t){this._popupServices.set(e,t)}deletePopupService(e){this._popupServices.delete(e)}scheduleRestoration(e,t,n){return new Promise(r=>{let i=()=>{this._restorationCleanups.delete(i),clearTimeout(a),n?.(),r()},a=setTimeout(()=>{if(this._restorationCleanups.delete(i),this._host.isDisposed){r();return}t(),r()},e);this._restorationCleanups.add(i)})}finishRestoration(e){this._restorationPromise=Promise.all(e).then(()=>void 0)}cancelPendingRestorations(){for(let e of[...this._restorationCleanups])e();this._restorationCleanups.clear()}serialize(){return this._entries.map(e=>{let t=e.gridview.serialize(),n=t.root,r=e.popoutGroup.api.location.type===`popout`?e.popoutGroup.api.location.popoutUrl:void 0,i={gridReferenceGroup:e.referenceGroup,position:e.window.dimensions(),url:r};return n.type===`branch`&&n.data.length===1&&n.data[0].type===`leaf`?Object.assign(Object.assign({},i),{data:n.data[0].data}):Object.assign(Object.assign({},i),{grid:t})})}disposeAll(){for(let e of[...this._entries])e.disposable.dispose()}dispose(){this.cancelPendingRestorations(),this.disposeAll(),this._onDidRemove.dispose()}},aKe=oH({name:`PopoutWindow`,serviceKey:`popoutWindowService`,create:e=>new iKe(e)}),oKe=class{constructor(e){this._watermark=null,this._host=e}update(){if(this._host.hasVisibleGridGroup()){this._unmount();return}if(this._watermark)return;this._watermark=this._host.createWatermarkComponent(),this._watermark.init({containerApi:this._host.api});let e=document.createElement(`div`);e.className=`dv-watermark-container`,PWe(e,`watermark-component`),e.appendChild(this._watermark.element),this._host.mountElement.appendChild(e)}refresh(){this._unmount(),this.update()}_unmount(){var e,t;this._watermark&&=(this._watermark.element.parentElement.remove(),(t=(e=this._watermark).dispose)==null||t.call(e),null)}dispose(){this._unmount()}},sKe=oH({name:`Watermark`,serviceKey:`watermarkService`,create:e=>new oKe(e),init:(e,t)=>(t.update(),new fB(mB.any(e.onDidAdd,e.onDidRemove)(()=>{t.update()}),e.onDidViewVisibilityChangeMicroTaskQueue(()=>{t.update()})))}),cKe=class{constructor(){this._edgeGroups=new Map,this._edgeGroupDisposables=new Map}add(e,t,n){this._edgeGroups.set(e,t),this._edgeGroupDisposables.set(e,n)}remove(e){var t;(t=this._edgeGroupDisposables.get(e))==null||t.dispose(),this._edgeGroupDisposables.delete(e),this._edgeGroups.delete(e)}get(e){return this._edgeGroups.get(e)}has(e){return this._edgeGroups.has(e)}hasAny(){return this._edgeGroups.size>0}entries(){return this._edgeGroups.entries()}includes(e){for(let t of this._edgeGroups.values())if(t===e)return!0;return!1}findPositionOf(e){for(let[t,n]of this._edgeGroups)if(n===e)return t}disposeAll(){for(let e of this._edgeGroupDisposables.values())e.dispose();this._edgeGroupDisposables.clear(),this._edgeGroups.clear()}dispose(){this.disposeAll()}},lKe=oH({name:`EdgeGroup`,serviceKey:`edgeGroupService`,create:()=>new cKe}),pH={activationSize:{type:`pixels`,value:10},size:{type:`pixels`,value:20}},uKe=class{constructor(e){let t=(t,n)=>{let r=lB();return r?r.viewId===e.id?n!==`center`||e.isGridEmpty():!1:n===`center`&&!e.isGridEmpty()?!1:e.dispatchUnhandledDragOver(t,n)},n=typeof e.options.dndEdges==`object`&&e.options.dndEdges!==null?e.options.dndEdges:pH;this._html5Target=TV.createDropTarget(e.element,{className:`dv-drop-target-edge`,canDisplayOverlay:t,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],overlayModel:n,getOverrideTarget:()=>e.rootDropTargetOverrideTarget()}),this._pointerTarget=EV.createDropTarget(e.element,{className:`dv-drop-target-edge`,canDisplayOverlay:t,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],overlayModel:n,getOverrideTarget:()=>e.rootDropTargetOverrideTarget()}),this.onWillShowOverlay=mB.any(this._html5Target.onWillShowOverlay,this._pointerTarget.onWillShowOverlay),this.onDrop=mB.any(this._html5Target.onDrop,this._pointerTarget.onDrop),this.setOptions(e.options)}setOptions(e){if(`dndEdges`in e){let t=typeof e.dndEdges==`boolean`&&e.dndEdges===!1;this._html5Target.disabled=t,this._pointerTarget.disabled=t,typeof e.dndEdges==`object`&&e.dndEdges!==null?(this._html5Target.setOverlayModel(e.dndEdges),this._pointerTarget.setOverlayModel(e.dndEdges)):(this._html5Target.setOverlayModel(pH),this._pointerTarget.setOverlayModel(pH))}}dispose(){this._html5Target.dispose(),this._pointerTarget.dispose()}},dKe=oH({name:`RootDropTarget`,serviceKey:`rootDropTargetService`,create:e=>new uKe(e)}),fKe={left:`createLeftHeaderActionComponent`,right:`createRightHeaderActionComponent`,prefix:`createPrefixHeaderActionComponent`},pKe=class{constructor(e){this._perGroup=new Map,this._host=e}refresh(e){if(!e?.model)return;let t=this._ensureState(e);this._refreshSlot(`left`,e,t.left),this._refreshSlot(`right`,e,t.right),this._refreshSlot(`prefix`,e,t.prefix)}refreshAll(){for(let e of this._host.groups)this.refresh(e)}disposeGroup(e){let t=this._perGroup.get(e);t&&(t.left.dispose(),t.right.dispose(),t.prefix.dispose(),this._perGroup.delete(e))}dispose(){for(let e of[...this._perGroup.keys()])this.disposeGroup(e)}_ensureState(e){let t=this._perGroup.get(e);return t||(t={left:new pB,right:new pB,prefix:new pB},this._perGroup.set(e,t)),t}_refreshSlot(e,t,n){let r=this._host.options[fKe[e]];if(r){let i=r(t);n.value=i,i.init({containerApi:this._host.api,api:t.api,group:t}),t.model.attachHeaderAction(e,i.element)}else n.dispose(),t.model.attachHeaderAction(e,void 0)}},mKe=oH({name:`HeaderActions`,serviceKey:`headerActionsService`,create:e=>new pKe(e),init:(e,t)=>new fB(e.onDidRemoveGroup(e=>{t.disposeGroup(e)}))});function hKe(e,t){return e===`center`?`Tab into ${t}`:`Split ${e} of ${t}`}function gKe(e,t){return e===`center`?`docked into ${t}`:`split ${e} of ${t}`}var mH={panelOpened:e=>`${e} opened`,panelClosed:e=>`${e} closed`,groupMaximized:e=>`${e} maximized`,groupRestored:e=>`${e} restored`,groupFloated:e=>`${e} floated`,groupDocked:e=>`${e} docked`,groupPoppedOut:e=>`${e} opened in a new window`,movePickTarget:(e,t,n,r)=>`Moving ${e}. Target ${t}, ${n} of ${r}. Enter to choose where, Escape to cancel.`,movePickEdge:(e,t)=>`${hKe(e,t)}. Arrows to change, Enter to confirm, Escape to go back.`,moveCommitted:(e,t,n)=>`${e} ${gKe(n,t)}.`,moveCancelled:()=>`Move cancelled.`,moveNotAllowed:()=>`That move is not allowed.`};function hH(e){return e?Object.assign(Object.assign({},mH),e):mH}var gH=e=>e===`load`||e===`clear`;function _H(e){let t=document.createElement(`div`);return t.className=e===`assertive`?`dv-live-region-assertive`:`dv-live-region`,t.setAttribute(`role`,e===`assertive`?`alert`:`status`),t.setAttribute(`aria-live`,e),t.setAttribute(`aria-atomic`,`true`),Object.assign(t.style,{position:`absolute`,width:`1px`,height:`1px`,margin:`-1px`,padding:`0`,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(50%)`,whiteSpace:`nowrap`,border:`0`}),t}var _Ke=class extends fB{constructor(e){super(),this._suppressDepth=0,this._locationSubs=new Map,this._host=e,this._polite=_H(`polite`),this._assertive=_H(`assertive`),e.element.appendChild(this._polite),e.element.appendChild(this._assertive),this.addDisposables({dispose:()=>this._polite.remove()},{dispose:()=>this._assertive.remove()},e.onDidAddPanel(e=>this._announce(e,`open`)),e.onDidRemovePanel(e=>this._announce(e,`close`)),e.onWillMutateLayout(e=>{gH(e.kind)&&this._suppressDepth++}),e.onDidMutateLayout(e=>{gH(e.kind)&&(this._suppressDepth=Math.max(0,this._suppressDepth-1))}),e.onDidMaximizedGroupChange(e=>{let t=e.group.activePanel;t&&this._announce(t,e.isMaximized?`maximize`:`restore`)}),e.onDidAddGroup(e=>this._trackLocation(e)),e.onDidRemoveGroup(e=>{var t;(t=this._locationSubs.get(e.id))==null||t.dispose(),this._locationSubs.delete(e.id)}),{dispose:()=>{this._locationSubs.forEach(e=>e.dispose()),this._locationSubs.clear()}})}_trackLocation(e){let t=e.api.location.type,n=e.api.onDidLocationChange(n=>{let r=n.location.type;if(r===t)return;t=r;let i=e.activePanel;if(!i)return;let a=r===`floating`?`float`:r===`popout`?`popout`:`dock`;this._announce(i,a)});this._locationSubs.set(e.id,n)}announce(e,t=`polite`){if(this._host.options.announcements===!1||this._suppressDepth>0||!e)return;let n=this._host.options.announcer;if(n){n({message:e,politeness:t});return}let r=t===`assertive`?this._assertive:this._polite;r.textContent=``,r.textContent=e}_announce(e,t){var n;let r=(n=this._host.options).getAnnouncement?.call(n,{kind:t,panel:e});r===null||r===``||this.announce(r??this._defaultMessage(e,t))}_defaultMessage(e,t){let n=hH(this._host.options.messages),r=e.title??e.id;switch(t){case`open`:return n.panelOpened(r);case`close`:return n.panelClosed(r);case`maximize`:return n.groupMaximized(r);case`restore`:return n.groupRestored(r);case`float`:return n.groupFloated(r);case`dock`:return n.groupDocked(r);case`popout`:return n.groupPoppedOut(r)}}},vH=oH({name:`LiveRegion`,serviceKey:`liveRegionService`,create:e=>new _Ke(e)}),vKe=[rKe,aKe,sKe,lKe,dKe,mKe,vH],yKe=class{constructor(){this.cache=new Map,this.currentFrameId=0,this.rafId=null}getPosition(e){let t=this.cache.get(e);if(t&&t.frameId===this.currentFrameId)return t.rect;this.scheduleFrameUpdate();let n=kB(e);return this.cache.set(e,{rect:n,frameId:this.currentFrameId}),n}invalidate(){this.currentFrameId++}scheduleFrameUpdate(){this.rafId||=requestAnimationFrame(()=>{this.currentFrameId++,this.rafId=null})}};function bKe(){let e=document.createElement(`div`);return e.tabIndex=-1,e}var yH=class extends fB{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this.positionCache=new yKe,this.pendingUpdates=new Set,this.addDisposables(dB.from(()=>{for(let e of Object.values(this.map))e.disposable.dispose(),e.destroy.dispose();this._disposed=!0}))}updateAllPositions(){if(!this._disposed){this.positionCache.invalidate();for(let e of Object.values(this.map))e.panel.api.isVisible&&e.resize&&e.resize()}}detatch(e){if(this.map[e.api.id]){let{disposable:t,destroy:n}=this.map[e.api.id];return t.dispose(),n.dispose(),delete this.map[e.api.id],!0}return!1}attach(e){let{panel:t,referenceContainer:n}=e;if(!this.map[t.api.id]){let e=bKe();e.className=`dv-render-overlay`,e.style.visibility=`hidden`,this.map[t.api.id]={panel:t,disposable:dB.NONE,destroy:dB.NONE,element:e}}let r=this.map[t.api.id].element,i=t.view.content.element;i.parentElement!==r&&r.appendChild(i),r.parentElement!==this.element&&this.element.appendChild(r);let a=()=>{let e=t.api.id;this.pendingUpdates.has(e)||(this.pendingUpdates.add(e),requestAnimationFrame(()=>{if(this.pendingUpdates.delete(e),this.isDisposed||!this.map[e])return;let i=this.positionCache.getPosition(n.element),a=this.positionCache.getPosition(this.element),o=i.left-a.left,s=i.top-a.top,c=i.width,l=i.height;r.style.left=`${o}px`,r.style.top=`${s}px`,r.style.width=`${c}px`,r.style.height=`${l}px`,t.api.isVisible?(r.style.visibility=``,r.style.pointerEvents=``):(r.style.visibility=`hidden`,r.style.pointerEvents=`none`),CB(r,`dv-render-overlay-float`,t.group.api.location.type===`floating`)}))},o=()=>{t.api.isVisible?(this.positionCache.invalidate(),a(),r.style.pointerEvents=``):(r.style.visibility=`hidden`,r.style.pointerEvents=`none`)},s=new pB,c=()=>{t.api.location.type===`floating`?queueMicrotask(()=>{let e=this.accessor.floatingGroups.find(e=>e.group===t.api.group);if(!e)return;let n=e.overlay.element,i=()=>{let e=Number(n.getAttribute(`aria-level`));r.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2+1})`},a=new MutationObserver(()=>{i()});s.value=dB.from(()=>a.disconnect()),a.observe(n,{attributeFilter:[`aria-level`],attributes:!0}),i()}):r.style.zIndex=``},l=new fB(s,new mV(r,{onDragEnd:e=>{n.dropTarget.dnd.onDragEnd(e)},onDragEnter:e=>{n.dropTarget.dnd.onDragEnter(e)},onDragLeave:e=>{n.dropTarget.dnd.onDragLeave(e)},onDrop:e=>{n.dropTarget.dnd.onDrop(e)},onDragOver:e=>{n.dropTarget.dnd.onDragOver(e)}}),t.api.onDidVisibilityChange(()=>{o()}),t.api.onDidDimensionsChange(()=>{t.api.isVisible&&a()}),t.api.onDidLocationChange(()=>{c()}));return this.map[t.api.id].destroy=dB.from(()=>{var e;i.parentElement===r&&r.removeChild(i),(e=r.parentElement)==null||e.removeChild(r)}),c(),queueMicrotask(()=>{this.isDisposed||o()}),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=l,this.map[t.api.id].resize=a,r}};function xKe(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function SKe(e){let t;try{t=new URL(e,window.location.href)}catch{throw Error(`dockview: invalid popout URL: ${e}`)}if(!(t.protocol===`http:`||t.protocol===`https:`)||t.origin!==window.location.origin)throw Error(`dockview: popout URL must be same-origin http(s); got: ${e}`)}var CKe=class extends fB{get window(){return this._window?.value??null}constructor(e,t,n){super(),this.target=e,this.className=t,this.options=n,this._onWillClose=new Q,this.onWillClose=this._onWillClose.event,this._onDidClose=new Q,this.onDidClose=this._onDidClose.event,this._window=null,this.addDisposables(this._onWillClose,this._onDidClose,{dispose:()=>{this.close()}})}dimensions(){if(!this._window)return null;let e=this._window.value.screenX;return{top:this._window.value.screenY,left:e,width:this._window.value.innerWidth,height:this._window.value.innerHeight}}close(){var e,t;this._window&&(this._onWillClose.fire(),(t=(e=this.options).onWillClose)==null||t.call(e,{id:this.target,window:this._window.value}),this._window.disposable.dispose(),this._window=null,this._onDidClose.fire())}open(){return xKe(this,void 0,void 0,function*(){var e,t;if(this._window)throw Error(`instance of popout window is already open`);let n=`${this.options.url}`;SKe(n);let r=Object.entries({top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height}).map(([e,t])=>`${e}=${t}`).join(`,`),i=window.open(n,this.target,r);if(!i)return null;let a=new fB;this._window={value:i,disposable:a},a.addDisposables(dB.from(()=>{i.close()}),vB(window,`beforeunload`,()=>{this.close()}));let o=this.createPopoutWindowContainer();return this.className&&o.classList.add(this.className),(t=(e=this.options).onDidOpen)==null||t.call(e,{id:this.target,window:i}),new Promise((e,t)=>{i.addEventListener(`unload`,e=>{}),i.addEventListener(`load`,()=>{try{let t=i.document;t.title=document.title,t.body.appendChild(o),MWe(t,window.document.styleSheets,{nonce:this.options.nonce}),vB(i,`beforeunload`,()=>{this.close()}),e(o)}catch(e){t(e)}})})})}createPopoutWindowContainer(){let e=document.createElement(`div`);return e.classList.add(`dv-popout-window`),e.id=`dv-popout-window`,e.style.position=`absolute`,e.style.width=`100%`,e.style.height=`100%`,e.style.top=`0px`,e.style.left=`0px`,e}},wKe=class extends fB{constructor(e){super(),this.accessor=e,this.init()}init(){let e=new Set,t=new Set;this.addDisposables(this.accessor.onDidAddPanel(t=>{if(e.has(t.api.id))throw Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${t.api.id} but panel already exists`);e.add(t.api.id)}),this.accessor.onDidRemovePanel(t=>{if(e.has(t.api.id))e.delete(t.api.id);else throw Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${t.api.id} but panel does not exists`)}),this.accessor.onDidAddGroup(e=>{if(t.has(e.api.id))throw Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${e.api.id} but group already exists`);t.add(e.api.id)}),this.accessor.onDidRemoveGroup(e=>{if(t.has(e.api.id))t.delete(e.api.id);else throw Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${e.api.id} but group does not exists`)}))}};function TKe(e){if(!e.matchMedia)return!1;let t=e.matchMedia(`(pointer: coarse)`).matches,n=e.matchMedia(`(pointer: fine)`).matches;return t&&!n}var bH=class extends fB{constructor(e,t=window){super(),this._active=null,this._activeDisposable=new pB,this._root=e,this._window=t,this._element=t.document.createElement(`div`),this._element.className=`dv-popover-anchor`,this._element.style.position=`relative`,this._root.prepend(this._element),this.addDisposables(dB.from(()=>{this.close()}),this._activeDisposable)}updateRoot(e){e.prepend(this._element),this._root=e}openPopover(e,t){this.close();let n=this._window.document.createElement(`div`);n.style.position=`absolute`,n.style.zIndex=t.zIndex??`var(--dv-overlay-z-index)`,n.appendChild(e);let r=this._element.getBoundingClientRect(),i=r.left,a=r.top;n.style.top=`${t.y-a}px`,n.style.left=`${t.x-i}px`,this._element.appendChild(n),this._active=n;let o=Date.now();this._activeDisposable.value=new fB(vB(this._window,`pointerdown`,e=>{if(Date.now()-o<200)return;let t=e.target;if(!(t instanceof HTMLElement))return;let r=t;for(;r&&r!==n;)r=r?.parentElement??null;r||this.close()}),vB(this._window,`keydown`,e=>{(e.key===`Escape`||e.key===`Enter`)&&this.close()}),vB(this._window,`resize`,()=>{TKe(this._window)||this.close()})),this._window.requestAnimationFrame(()=>{zWe(n,this._root)})}close(){this._active&&=(this._active.remove(),this._activeDisposable.dispose(),null)}},xH=class extends fB{get disabled(){return this._disabled}set disabled(e){var t;this.disabled!==e&&(this._disabled=e,e&&((t=this.model)==null||t.clear()))}get model(){if(!this.disabled)return{clear:()=>{var e;this._model&&((e=this._model.root.parentElement)==null||e.removeChild(this._model.root)),this._model=void 0},exists:()=>!!this._model,getElements:(e,t)=>{let n=this._outline!==t;if(this._outline=t,this._model)return this._model.changed=n,this._model;let r=this.createContainer(),i=this.createAnchor();if(this._model={root:r,overlay:i,changed:n},r.appendChild(i),this.element.appendChild(r),e?.target instanceof HTMLElement){let t=e.target.getBoundingClientRect(),n=this.element.getBoundingClientRect();i.style.left=`${t.left-n.left}px`,i.style.top=`${t.top-n.top}px`}return this._model}}}constructor(e,t){super(),this.element=e,this._disabled=!1,this._disabled=t.disabled,this.addDisposables(dB.from(()=>{var e;(e=this.model)==null||e.clear()}))}createContainer(){let e=document.createElement(`div`);return e.className=`dv-drop-target-container`,e}createAnchor(){let e=document.createElement(`div`);return e.className=`dv-drop-target-anchor`,e.style.visibility=`hidden`,e}},EKe=class{get minimumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMinimumSize}get maximumSize(){return this._isCollapsed?this._collapsedSize:this._expandedMaximumSize}get element(){return this._group.element}get isCollapsed(){return this._isCollapsed}get lastExpandedSize(){return this._lastExpandedSize}get collapsedSize(){return this._collapsedSize}constructor(e,t,n){this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority=GB.Low,this._isCollapsed=!1,this._group=t,this._orientation=n,t.element.classList.add(`dv-edge-group`),t.element.dataset.testid=`dv-edge-group-${e.id}`,this._collapsedSize=e.collapsedSize??35,this._expandedMaximumSize=e.maximumSize??1/0,this._expandedMinimumSize=e.minimumSize===void 0?this._collapsedSize+50:e.minimumSize,this._lastExpandedSize=e.initialSize??200,e.collapsed&&(this._isCollapsed=!0,t.element.classList.add(`dv-edge-collapsed`))}layout(e,t){this._isCollapsed||(this._lastExpandedSize=e),this._orientation===`horizontal`?this._group.layout(e,t):this._group.layout(t,e)}setCollapsed(e){this._isCollapsed!==e&&(this._isCollapsed=e,this._group.element.classList.toggle(`dv-edge-collapsed`,e))}setVisible(e){}restoreExpandedSize(e){this._lastExpandedSize=e}updateCollapsedSize(e,t){this._collapsedSize=e,this._expandedMinimumSize=t}dispose(){this._onDidChange.dispose()}},DKe=class{get element(){return this._dockviewElement}constructor(e,t){this._dockviewElement=e,this._layoutDockview=t,this.priority=GB.High,this.minimumSize=100,this.maximumSize=1/0,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event}layout(e,t){this._layoutDockview(t,e)}setVisible(e){}dispose(){this._onDidChange.dispose()}},OKe=class{get element(){return this._element}constructor(e,t=0){this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this.minimumSize=100,this.maximumSize=1/0,this.priority=GB.High,this._element=document.createElement(`div`),this._element.className=`dv-shell-middle-column`,this._element.style.height=`100%`,this._element.style.width=`100%`,this._splitview=new qB(this._element,{orientation:UB.VERTICAL,proportionalLayout:!1,margin:t}),this._centerIndex=0,this._splitview.addView(e,{type:`distribute`},0)}addTopView(e,t){this._splitview.addView(e,t,0),this._topIndex=0,this._centerIndex+=1,this._bottomIndex!==void 0&&(this._bottomIndex+=1)}addBottomView(e,t){let n=this._splitview.length;this._splitview.addView(e,t,n),this._bottomIndex=n}removeView(e){let t=e===`top`?this._topIndex:this._bottomIndex;t!==void 0&&(this._splitview.removeView(t),e===`top`?(this._topIndex=void 0,--this._centerIndex,this._bottomIndex!==void 0&&--this._bottomIndex):this._bottomIndex=void 0)}layout(e,t){this._splitview.layout(t,e)}setVisible(e){}setViewVisible(e,t){let n=e===`top`?this._topIndex:this._bottomIndex;n!==void 0&&this._splitview.setViewVisible(n,t)}isViewVisible(e){let t=e===`top`?this._topIndex:this._bottomIndex;return t!==void 0&&this._splitview.isViewVisible(t)}getViewSize(e){let t=e===`top`?this._topIndex:this._bottomIndex;return t===void 0?0:this._splitview.getViewSize(t)}resizeView(e,t){let n=e===`top`?this._topIndex:this._bottomIndex;n!==void 0&&this._splitview.resizeView(n,t)}updateMargin(e){this._splitview.margin=e}dispose(){this._onDidChange.dispose(),this._splitview.dispose()}};function kKe(e,t,n){let r=(e.collapsedSize??t)+n,i=Object.assign(Object.assign({},e),{collapsedSize:r});return e.minimumSize!==void 0&&(i.minimumSize=e.minimumSize+n),i}var AKe=class{constructor(e,t,n,r=0,i=35){this._disposables=new fB,this._viewConfigs=new Map,this._currentWidth=0,this._currentHeight=0,this._gap=r,this._defaultCollapsedSize=i,this._shellElement=document.createElement(`div`),this._shellElement.className=`dv-shell`,this._shellElement.style.height=`100%`,this._shellElement.style.width=`100%`,this._shellElement.style.position=`relative`,e.appendChild(this._shellElement);let a=new DKe(t,n);this._middleColumn=new OKe(a,r),this._outerSplitview=new qB(this._shellElement,{orientation:UB.HORIZONTAL,proportionalLayout:!1,margin:r}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:`distribute`},0),this._disposables.addDisposables(bB(this._shellElement,e=>{let t=Math.round(e.contentRect.width),n=Math.round(e.contentRect.height);t===this._currentWidth&&n===this._currentHeight||(this._currentWidth=t,this._currentHeight=n,this.layout(t,n))}),this._outerSplitview,this._middleColumn,a)}get element(){return this._shellElement}addEdgeView(e,t,n){if(this.hasEdgeGroup(e))throw Error(`dockview: edge group already registered at position '${e}'`);this._viewConfigs.set(e,t);let r=1+ +!!this._viewConfigs.has(`left`)+ +!!this._viewConfigs.has(`right`),i=1+ +!!this._viewConfigs.has(`top`)+ +!!this._viewConfigs.has(`bottom`),a=r>1?this._gap*(r-1)/r:0,o=i>1?this._gap*(i-1)/i:0,s=e===`left`||e===`right`,c=s?a:o,l=s?`horizontal`:`vertical`,u=new EKe(kKe(Object.assign({collapsedSize:this._defaultCollapsedSize},t),this._defaultCollapsedSize,c),n,l),d=u.isCollapsed?u.collapsedSize:u.lastExpandedSize;switch(e){case`left`:this._outerSplitview.addView(u,d,0),this._leftIndex=0,this._middleIndex+=1,this._rightIndex!==void 0&&(this._rightIndex+=1),this._leftView=u;break;case`right`:{let e=this._outerSplitview.length;this._outerSplitview.addView(u,d,e),this._rightIndex=e,this._rightView=u}break;case`top`:this._middleColumn.addTopView(u,d),this._topView=u;break;case`bottom`:this._middleColumn.addBottomView(u,d),this._bottomView=u;break}return this._disposables.addDisposables(u),this.updateTheme(this._gap,this._defaultCollapsedSize),u}layout(e,t){this._outerSplitview.layout(e,t)}updateTheme(e,t){this._gap=e,this._defaultCollapsedSize=t;let n=1+ +!!this._viewConfigs.has(`left`)+ +!!this._viewConfigs.has(`right`),r=1+ +!!this._viewConfigs.has(`top`)+ +!!this._viewConfigs.has(`bottom`),i=n>1?e*(n-1)/n:0,a=r>1?e*(r-1)/r:0;this._outerSplitview.margin=e,this._middleColumn.updateMargin(e);let o=(e,n,r)=>{let i=(n.collapsedSize??t)+r,a=n.minimumSize,o=a===void 0?i+50:a+r;e.updateCollapsedSize(i,o)},s=this._viewConfigs.get(`top`);this._topView&&s&&o(this._topView,s,a);let c=this._viewConfigs.get(`bottom`);this._bottomView&&c&&o(this._bottomView,c,a);let l=this._viewConfigs.get(`left`);this._leftView&&l&&o(this._leftView,l,i);let u=this._viewConfigs.get(`right`);this._rightView&&u&&o(this._rightView,u,i),this._leftView?.isCollapsed&&this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,this._leftView.collapsedSize),this._rightView?.isCollapsed&&this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,this._rightView.collapsedSize),this._topView?.isCollapsed&&this._middleColumn.resizeView(`top`,this._topView.collapsedSize),this._bottomView?.isCollapsed&&this._middleColumn.resizeView(`bottom`,this._bottomView.collapsedSize),this._currentWidth>0&&this._currentHeight>0&&this.layout(this._currentWidth,this._currentHeight)}removeEdgeView(e){let t=this._getView(e);if(t){switch(e){case`left`:this._outerSplitview.removeView(this._leftIndex),this._leftIndex=void 0,this._leftView=void 0,--this._middleIndex,this._rightIndex!==void 0&&--this._rightIndex;break;case`right`:this._outerSplitview.removeView(this._rightIndex),this._rightIndex=void 0,this._rightView=void 0;break;case`top`:this._middleColumn.removeView(`top`),this._topView=void 0;break;case`bottom`:this._middleColumn.removeView(`bottom`),this._bottomView=void 0;break}this._disposables.removeDisposable(t),t.dispose(),this._viewConfigs.delete(e),this.updateTheme(this._gap,this._defaultCollapsedSize)}}hasEdgeGroup(e){switch(e){case`top`:return this._topView!==void 0;case`bottom`:return this._bottomView!==void 0;case`left`:return this._leftView!==void 0;case`right`:return this._rightView!==void 0}}setEdgeGroupVisible(e,t){switch(e){case`left`:this._leftIndex!==void 0&&this._outerSplitview.setViewVisible(this._leftIndex,t);break;case`right`:this._rightIndex!==void 0&&this._outerSplitview.setViewVisible(this._rightIndex,t);break;case`top`:case`bottom`:this._middleColumn.setViewVisible(e,t);break}}isEdgeGroupVisible(e){switch(e){case`left`:return this._leftIndex!==void 0&&this._outerSplitview.isViewVisible(this._leftIndex);case`right`:return this._rightIndex!==void 0&&this._outerSplitview.isViewVisible(this._rightIndex);case`top`:case`bottom`:return this._middleColumn.isViewVisible(e)}}setEdgeGroupCollapsed(e,t){let n=this._getView(e);if(!n)return;n.setCollapsed(t);let r=t?n.collapsedSize:n.lastExpandedSize;switch(e){case`left`:this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,r);break;case`right`:this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,r);break;case`top`:case`bottom`:this._middleColumn.resizeView(e,r);break}}isEdgeGroupCollapsed(e){return this._getView(e)?.isCollapsed??!1}_getView(e){switch(e){case`top`:return this._topView;case`bottom`:return this._bottomView;case`left`:return this._leftView;case`right`:return this._rightView}}toJSON(){let e={};return this._leftView&&this._leftIndex!==void 0&&(e.left={size:this._leftView.isCollapsed?this._leftView.lastExpandedSize:this._outerSplitview.getViewSize(this._leftIndex),visible:this._outerSplitview.isViewVisible(this._leftIndex),collapsed:this._leftView.isCollapsed||void 0}),this._rightView&&this._rightIndex!==void 0&&(e.right={size:this._rightView.isCollapsed?this._rightView.lastExpandedSize:this._outerSplitview.getViewSize(this._rightIndex),visible:this._outerSplitview.isViewVisible(this._rightIndex),collapsed:this._rightView.isCollapsed||void 0}),this._topView&&(e.top={size:this._topView.isCollapsed?this._topView.lastExpandedSize:this._middleColumn.getViewSize(`top`),visible:this._middleColumn.isViewVisible(`top`),collapsed:this._topView.isCollapsed||void 0}),this._bottomView&&(e.bottom={size:this._bottomView.isCollapsed?this._bottomView.lastExpandedSize:this._middleColumn.getViewSize(`bottom`),visible:this._middleColumn.isViewVisible(`bottom`),collapsed:this._bottomView.isCollapsed||void 0}),e}fromJSON(e){var t,n,r,i,a,o,s,c;e.left&&this._leftIndex!==void 0&&((t=this._leftView)==null||t.restoreExpandedSize(e.left.size),(n=this._leftView)==null||n.setCollapsed(e.left.collapsed??!1),this._outerSplitview.resizeView(this._leftIndex,e.left.collapsed?this._leftView?.collapsedSize??e.left.size:e.left.size),e.left.visible||this._outerSplitview.setViewVisible(this._leftIndex,!1)),e.right&&this._rightIndex!==void 0&&((r=this._rightView)==null||r.restoreExpandedSize(e.right.size),(i=this._rightView)==null||i.setCollapsed(e.right.collapsed??!1),this._outerSplitview.resizeView(this._rightIndex,e.right.collapsed?this._rightView?.collapsedSize??e.right.size:e.right.size),e.right.visible||this._outerSplitview.setViewVisible(this._rightIndex,!1)),e.top&&((a=this._topView)==null||a.restoreExpandedSize(e.top.size),(o=this._topView)==null||o.setCollapsed(e.top.collapsed??!1),this._middleColumn.resizeView(`top`,e.top.collapsed?this._topView?.collapsedSize??e.top.size:e.top.size),e.top.visible||this._middleColumn.setViewVisible(`top`,!1)),e.bottom&&((s=this._bottomView)==null||s.restoreExpandedSize(e.bottom.size),(c=this._bottomView)==null||c.setCollapsed(e.bottom.collapsed??!1),this._middleColumn.resizeView(`bottom`,e.bottom.collapsed?this._bottomView?.collapsedSize??e.bottom.size:e.bottom.size),e.bottom.visible||this._middleColumn.setViewVisible(`bottom`,!1))}dispose(){var e;this._disposables.dispose(),(e=this._shellElement.parentElement)==null||e.removeChild(this._shellElement)}};function jKe(e){return new RV(e.tabGroupColors??LV,e.tabGroupAccent!==`off`)}function SH(e){let t=e.from.activePanel;[...e.from.panels].map(t=>{let n=e.from.model.removePanel(t);return e.from.model.renderContainer.detatch(t),n}).forEach(n=>{e.to.model.openPanel(n,{skipSetActive:t!==n,skipSetGroupActive:!0})})}var CH=!1;function MKe(){typeof process<`u`||CH||$Ge()||(CH=!0,console.warn(`dockview: do not use "dockview-core" directly — it is an internal package. Use the "dockview" package, the JavaScript version of dockview, instead. This notice is shown once.`))}var NKe=class extends lV{fireDidCreateTabGroup(e){this._onDidCreateTabGroup.fire(e)}fireDidDestroyTabGroup(e){this._onDidDestroyTabGroup.fire(e)}fireDidAddPanelToTabGroup(e){this._onDidAddPanelToTabGroup.fire(e)}fireDidRemovePanelFromTabGroup(e){this._onDidRemovePanelFromTabGroup.fire(e)}fireDidTabGroupChange(e){this._onDidTabGroupChange.fire(e)}fireDidTabGroupCollapsedChange(e){this._onDidTabGroupCollapsedChange.fire(e)}get orientation(){return this.gridview.orientation}get totalPanels(){return this.panels.length}get panels(){return this.groups.flatMap(e=>e.panels)}get options(){return this._options}get tabGroupColorPalette(){return this._tabGroupColorPalette}get activePanel(){let e=this.activeGroup;if(e)return e.activePanel}get renderer(){return this.options.defaultRenderer??`onlyWhenVisible`}get defaultHeaderPosition(){return this.options.defaultHeaderPosition??`top`}get api(){return this._api}get floatingGroups(){return this._moduleRegistry?.services.floatingGroupService?.floatingGroups??[]}_gatherFloatingGroupBoxes(e){let t=(this._floatingOverlayHost??this.gridview.element).getBoundingClientRect();return this.floatingGroups.filter(t=>t.group!==e).map(e=>{let n=e.overlay.element.getBoundingClientRect();return{left:n.left-t.left,top:n.top-t.top,width:n.width,height:n.height}})}get _floatingGroupService(){return this._moduleRegistry.services.floatingGroupService}get _popoutWindowService(){return this._moduleRegistry.services.popoutWindowService}get _watermarkService(){return this._moduleRegistry.services.watermarkService}get _edgeGroupService(){return this._moduleRegistry.services.edgeGroupService}get _rootDropTargetService(){return this._moduleRegistry.services.rootDropTargetService}get _advancedDnDService(){return this._moduleRegistry.services.advancedDnDService}get headerActionsService(){return this._moduleRegistry.services.headerActionsService}isGridEmpty(){return this.gridview.length===0}rootDropTargetOverrideTarget(){return this.rootDropTargetContainer?.model}dispatchUnhandledDragOver(e,t){let n=new qV(e,`edge`,t,lB);return this._onUnhandledDragOver.fire(n),n.isAccepted}fireWillDragPanel(e){this._onWillDragPanel.fire(e)}fireWillDragGroup(e){this._onWillDragGroup.fire(e)}fireWillDrop(e){this._onWillDrop.fire(e)}fireWillShowOverlay(e){this._onWillShowOverlay.fire(e)}buildGroupDragGhost(e){return this._advancedDnDService?.buildGroupDragGhost(e)}resolveDropOverlayModel(e,t){return this._advancedDnDService?.resolveOverlayModel(e,t)}get rootElement(){return this._shellManager?.element??this.element}adjacentGroup(e,t){if(e.api.location.type!==`grid`)return;let n=tV(e.element);return(t?this.gridview.previous(n):this.gridview.next(n))?.view}adjacentGroupInDirection(e,t){if(e.api.location.type!==`grid`)return;let n=e.element.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height/2,a,o=1/0;for(let n of this.groups){if(n===e||n.api.location.type!==`grid`)continue;let s=n.element.getBoundingClientRect(),c=s.left+s.width/2-r,l=s.top+s.height/2-i;if(!(t===`left`?c<0&&Math.abs(c)>=Math.abs(l):t===`right`?c>0&&Math.abs(c)>=Math.abs(l):t===`up`?l<0&&Math.abs(l)>=Math.abs(c):l>0&&Math.abs(l)>=Math.abs(c)))continue;let u=c*c+l*l;u<o&&(o=u,a=n)}return a}showDropPreview(e,t){return this._advancedDnDService?.showPreviewOverlay(e,t)??dB.NONE}announce(e){var t;(t=this._moduleRegistry.services.liveRegionService)==null||t.announce(e)}dockPanel(e,t,n){this.moveGroupOrPanel({from:{groupId:e.group.id,panelId:e.id},to:{group:t,position:n}})}get contextMenuService(){return this._moduleRegistry.services.contextMenuService}get mountElement(){return this.gridview.element}hasVisibleGridGroup(){return this.groups.some(e=>e.api.location.type===`grid`&&e.api.isVisible)}fireLayoutChange(){this._bufferOnDidLayoutChange.fire()}get popoutRestorationPromise(){return this._popoutWindowService?.restorationPromise??Promise.resolve()}constructor(e,t){super(e,{proportionalLayout:!0,orientation:UB.HORIZONTAL,styles:t.hideBorders?{separatorBorder:`transparent`}:void 0,disableAutoResizing:t.disableAutoResizing,locked:t.locked,margin:t.theme?.gap??0,className:t.className}),this.nextGroupId=VB(),this._deserializer=new KGe(this),this._moduleRegistry=new YGe,this._onWillDragPanel=new Q,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new Q,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new Q,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new Q,this.onWillDrop=this._onWillDrop.event,this._mutationDepth=0,this._origin=`user`,this._originDepth=0,this._onWillMutateLayout=new Q,this.onWillMutateLayout=this._onWillMutateLayout.event,this._onDidMutateLayout=new Q,this.onDidMutateLayout=this._onDidMutateLayout.event,this._onWillShowOverlay=new Q,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOver=new Q,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this._onDidRemovePanel=new Q,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new Q,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new Q,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new Q,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidAddPopoutGroup=new Q,this.onDidAddPopoutGroup=this._onDidAddPopoutGroup.event,this._onDidRemovePopoutGroup=new Q,this.onDidRemovePopoutGroup=this._onDidRemovePopoutGroup.event,this._onDidOpenPopoutWindowFail=new Q,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidLayoutFromJSON=new Q,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new Q({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidMovePanel=new Q,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidCreateTabGroup=new Q,this.onDidCreateTabGroup=this._onDidCreateTabGroup.event,this._onDidDestroyTabGroup=new Q,this.onDidDestroyTabGroup=this._onDidDestroyTabGroup.event,this._onDidAddPanelToTabGroup=new Q,this.onDidAddPanelToTabGroup=this._onDidAddPanelToTabGroup.event,this._onDidRemovePanelFromTabGroup=new Q,this.onDidRemovePanelFromTabGroup=this._onDidRemovePanelFromTabGroup.event,this._onDidTabGroupChange=new Q,this.onDidTabGroupChange=this._onDidTabGroupChange.event,this._onDidTabGroupCollapsedChange=new Q,this.onDidTabGroupCollapsedChange=this._onDidTabGroupCollapsedChange.event,this._onDidMaximizedGroupChange=new Q,this.onDidMaximizedGroupChange=this._onDidMaximizedGroupChange.event,this._inShellLayout=!1,this._onDidRemoveGroup=new Q,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new Q,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new Q,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new Q,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._moving=!1,this._options=t,this._tabGroupColorPalette=jKe(t);let n=t.modules??[...vKe,...ZGe()];for(let e of n)this._moduleRegistry.register(e);this._moduleRegistry.initialize(this);let r=this._popoutWindowService;r&&this.addDisposables(r.onDidRemove(e=>{this._onDidRemovePopoutGroup.fire({id:e.popoutGroup.id,group:e.popoutGroup,window:e.getWindow()})})),MKe(),this.popupService=new bH(this.element),this._api=new pV(this),this.disableResizing=!0,e.removeChild(this.element),this._shellManager=new AKe(e,this.element,(e,t)=>this._layoutFromShell(e,t),t.theme?.gap??0,t.theme?.edgeGroupCollapsedSize),this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new jB(this._shellManager.element),this.rootDropTargetContainer=new xH(this._shellManager.element,{disabled:!0}),this.overlayRenderContainer=new yH(this._shellManager.element,this),this._floatingOverlayHost=document.createElement(`div`),this._floatingOverlayHost.className=`dv-floating-overlay-host`,this._shellManager.element.appendChild(this._floatingOverlayHost),CB(this.gridview.element,`dv-dockview`,!0),CB(this.element,`dv-debug`,!!t.debug),this.updateTheme(),t.debug&&this.addDisposables(new wKe(this)),this.addDisposables(this.rootDropTargetContainer,this.overlayRenderContainer,this._onWillDragPanel,this._onWillDragGroup,this._onWillShowOverlay,this._onDidActivePanelChange,this._onDidAddPanel,this._onDidRemovePanel,this._onDidLayoutFromJSON,this._onDidDrop,this._onWillDrop,this._onWillMutateLayout,this._onDidMutateLayout,this._onDidMovePanel,this._onDidMovePanel.event(()=>{this.debouncedUpdateAllPositions()}),this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this._onUnhandledDragOver,this._onDidMaximizedGroupChange,this._onDidPopoutGroupSizeChange,this._onDidPopoutGroupPositionChange,this._onDidAddPopoutGroup,this._onDidRemovePopoutGroup,this._onDidOpenPopoutWindowFail,this._onDidCreateTabGroup,this._onDidDestroyTabGroup,this._onDidAddPanelToTabGroup,this._onDidRemovePanelFromTabGroup,this._onDidTabGroupChange,this._onDidTabGroupCollapsedChange,mB.any(this.onDidPopoutGroupSizeChange,this.onDidPopoutGroupPositionChange,this.onDidCreateTabGroup,this.onDidDestroyTabGroup,this.onDidAddPanelToTabGroup,this.onDidRemovePanelFromTabGroup,this.onDidTabGroupChange,this.onDidTabGroupCollapsedChange)(()=>{this.fireLayoutChange()}),this._onDidOptionsChange,this.onDidAdd(e=>{this._moving||this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._moving||this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._moving||this._onDidActiveGroupChange.fire(e)}),this.onDidMaximizedChange(e=>{this._onDidMaximizedGroupChange.fire({group:e.panel,isMaximized:e.isMaximized})}),mB.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidAddGroup,this.onDidRemove,this.onDidRemoveGroup,this.onDidMovePanel,this.onDidActivePanelChange)(()=>{this._bufferOnDidLayoutChange.fire()}),dB.from(()=>{var e;this._moduleRegistry.dispose(),(e=this._shellManager)==null||e.dispose()}));let i=this._rootDropTargetService;i&&this.addDisposables(i.onWillShowOverlay(e=>{this.gridview.length>0&&e.position===`center`||this._onWillShowOverlay.fire(new PV(e,{kind:`edge`,panel:void 0,api:this._api,group:void 0,getData:lB}))}),i.onDrop(e=>{let t=new XV({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:lB,kind:`edge`});if(this._onWillDrop.fire(t),t.defaultPrevented)return;let n=lB();n?this.moveGroupOrPanel({from:{groupId:n.groupId,panelId:n.panelId??void 0},to:{group:this.orthogonalize(e.position),position:`center`}}):this._onDidDrop.fire(new YV({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:lB}))})),this._moduleRegistry.postConstruct(this)}setVisible(e,t){switch(e.api.location.type){case`grid`:super.setVisible(e,t);break;case`floating`:{let n=this.floatingGroups.find(t=>t.group===e);n&&(n.overlay.setVisible(t),e.api._onDidVisibilityChange.fire({isVisible:t}));break}case`popout`:console.warn(`dockview: You cannot hide a group that is in a popout window`);break}}getPopupServiceForGroup(e){return this._popoutWindowService?.getPopupService(e.id)??this.popupService}addPopoutGroup(e,t){return this.mutation(`popout`,()=>this._doAddPopoutGroup(e,t))}getPopouts(){return this._popoutWindowService?.entries.map(e=>({id:e.popoutGroup.id,group:e.popoutGroup,window:e.getWindow()}))??[]}_doAddPopoutGroup(e,t){let n=cH(this._popoutWindowService,`PopoutWindow`,`api.addPopoutGroup`);if(!n||e instanceof eH&&e.model.location.type===`edge`)return Promise.resolve(!1);if(e instanceof tH&&e.group.size===1)return this.addPopoutGroup(e.group,t);let r=IWe(this.gridview.element),i=this.element;function a(){return t?.position?t.position:e instanceof eH?e.element.getBoundingClientRect():e.group?e.group.element.getBoundingClientRect():i.getBoundingClientRect()}let o=a(),s=t?.overridePopoutGroup?.id??this.getNextGroupId(),c=t?.popoutUrl??this.options?.popoutUrl,l=new CKe(`${this.id}-${s}`,r??``,{url:c??`/popout.html`,left:window.screenX+o.left,top:window.screenY+o.top,width:o.width,height:o.height,onDidOpen:t?.onDidOpen,onWillClose:t?.onWillClose,nonce:this.options?.nonce}),u=new fB(l,l.onDidClose(()=>{u.dispose()}));return l.open().then(r=>{if(l.isDisposed)return!1;let i=t?.referenceGroup?t.referenceGroup:e instanceof tH?e.group:e,a=e.api.location.type,o=i.element.parentElement!==null,d;if(t?.overridePopoutGridview?d=t.overridePopoutGroup??i:o?t?.overridePopoutGroup?d=t.overridePopoutGroup:(d=this.createGroup({id:s}),r&&this._onDidAddGroup.fire(d)):d=i,r===null)return this.handleBlockedPopout({group:d,referenceGroup:i,options:t,popoutWindowDisposable:u}),!1;let f=document.createElement(`div`);f.className=`dv-overlay-render-container`;let p=new yH(f,this);d.model.renderContainer=p;let m=t?.overridePopoutGridview??this.createNestedGridview();t?.overridePopoutGridview||m.addView(d,KB.Distribute,[0]),m.element.style.width=`100%`,m.element.style.height=`100%`,m.layout(l.window.innerWidth,l.window.innerHeight);let h=!1,g=()=>{h||(h=!0,m.dispose())},_;if(!t?.overridePopoutGroup&&!t?.overridePopoutGridview&&o)if(e instanceof tH)this.movingLock(()=>{let t=i.model.removePanel(e);d.model.openPanel(t)});else switch(this.movingLock(()=>SH({from:i,to:d})),a){case`grid`:i.api.setVisible(!1);break;case`floating`:case`popout`:_=this.floatingGroups.find(t=>t.group.api.id===e.api.id)?.overlay.toJSON(),this.removeGroup(i);break}r.classList.add(`dv-dockview`),r.style.overflow=`hidden`,r.appendChild(f),r.appendChild(m.element);let v=document.createElement(`div`),y=new xH(v,{disabled:this.rootDropTargetContainer.disabled});r.appendChild(v),d.model.dropTargetContainer=y;let b=new bH(r,l.window);if(n.setPopupService(d.id,b),u.addDisposables(b,dB.from(()=>{n.deletePopupService(d.id)})),d.model.location={type:`popout`,getWindow:()=>l.window,popoutUrl:c},t?.overridePopoutGridview){let e=this.groups.filter(e=>m.element.contains(e.element));for(let t of e)t.model.renderContainer=p,t.model.dropTargetContainer=y,t.model.location={type:`popout`,getWindow:()=>l.window,popoutUrl:c}}o&&e.api.location.type===`grid`&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(d);let x=n.observeGridviewSize(l,m,p);x&&u.addDisposables(x),u.addDisposables(d.api.onDidActiveChange(e=>{var t;e.isActive&&((t=l.window)==null||t.focus())}),d.api.onWillFocus(()=>{var e;(e=l.window)==null||e.focus()}));let S={},C=o&&i&&this.getPanel(i.id),w={window:l,popoutGroup:d,gridview:m,overlayRenderContainer:p,dropTargetContainer:y,getWindow:()=>l.window,popoutUrl:c,referenceGroup:C?i.id:void 0,disposable:{dispose:()=>(u.dispose(),S.returnedGroup)}},T=LWe(l.window);return u.addDisposables(T,RWe(l.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:l.window.innerWidth,height:l.window.innerHeight,group:d})}),T.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:l.window.screenX,screenY:l.window.screenX,group:d})}),vB(l.window,`resize`,()=>{m.layout(l.window.innerWidth,l.window.innerHeight)}),p,dB.from(()=>this.disposePopoutWindow({group:d,referenceGroup:i,popoutGridview:m,isGroupAddedToDom:o,floatingBox:_,disposePopoutGridview:g,closeResult:S}))),n.add(w),this._onDidAddPopoutGroup.fire({id:w.popoutGroup.id,group:w.popoutGroup,window:w.getWindow()}),!0}).catch(e=>(console.error(`dockview: failed to create popout.`,e),!1))}handleBlockedPopout(e){let{group:t,referenceGroup:n,options:r,popoutWindowDisposable:i}=e;if(console.error(`dockview: failed to create popout. perhaps you need to allow pop-ups for this website`),i.dispose(),this._onDidOpenPopoutWindowFail.fire(),r?.overridePopoutGridview){let e=r.overridePopoutGridview,t=this.groups.filter(t=>e.element.contains(t.element));for(let n of t)this.movingLock(()=>{e.remove(n),this.redockGroupToMainGrid(n)});e.dispose(),n&&!n.api.isVisible&&n.api.setVisible(!0);return}t===n?this.gridview.element.contains(t.element)||(this.movingLock(()=>this.doAddGroup(t,[0])),t.model.location={type:`grid`}):(this.movingLock(()=>SH({from:t,to:n})),t.model.size===0&&this._groups.has(t.id)&&(t.dispose(),this._groups.delete(t.id),this._onDidRemoveGroup.fire(t))),n.api.isVisible||n.api.setVisible(!0)}redockGroupToMainGrid(e){e.model.renderContainer=this.overlayRenderContainer,e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location={type:`grid`},this.doAddGroup(e,[0])}disposePopoutWindow(e){let{group:t,referenceGroup:n,popoutGridview:r,isGroupAddedToDom:i,floatingBox:a,disposePopoutGridview:o,closeResult:s}=e;if(this.isDisposed){o();return}let c=!!this._popoutWindowService?.entries.find(e=>e.gridview===r),l=this.groups.filter(e=>r.element.contains(e.element)),u=l.includes(t),d=u&&l.length===1;if(c)for(let e of l)e!==t&&this.movingLock(()=>{this.doRemoveGroup(e,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),this.redockGroupToMainGrid(e)});if(u&&i&&this.getPanel(n.id))this.movingLock(()=>SH({from:t,to:n})),n.api.isVisible||n.api.setVisible(!0),this.getPanel(t.id)&&this.doRemoveGroup(t,{skipPopoutAssociated:!0});else if(u&&this.getPanel(t.id)){if(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,s.returnedGroup=t,!c){o();return}a&&d?this.addFloatingGroup(t,{height:a.height,width:a.width,position:a}):(this.doRemoveGroup(t,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),t.model.location={type:`grid`},this.movingLock(()=>{this.doAddGroup(t,[0])})),this.doSetGroupAndPanelActive(t)}o()}addFloatingGroup(e,t){this.mutation(`float`,()=>this._doAddFloatingGroup(e,t))}_doAddFloatingGroup(e,t){if(!cH(this._floatingGroupService,`FloatingGroup`,`api.addFloatingGroup`)||e instanceof eH&&e.model.location.type===`edge`)return;let n;if(e instanceof tH)n=this.createGroup(),this._onDidAddGroup.fire(n),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0,skipSetActiveGroup:!0})),this.movingLock(()=>n.model.openPanel(e,{skipSetGroupActive:!0}));else{n=e;let r=this._popoutWindowService?.findReferenceGroupId(n),i=r?this.getPanel(r):void 0;typeof t?.skipRemoveGroup==`boolean`&&t.skipRemoveGroup||(i?(this.movingLock(()=>SH({from:e,to:i})),this.doRemoveGroup(e,{skipPopoutReturn:!0,skipPopoutAssociated:!0}),this.doRemoveGroup(i,{skipDispose:!0}),n=i):this.doRemoveGroup(e,{skipDispose:!0,skipPopoutReturn:!0,skipPopoutAssociated:!1}))}function r(){if(t?.position){let e={};return`left`in t.position?e.left=Math.max(t.position.left,0):`right`in t.position?e.right=Math.max(t.position.right,0):e.left=fH.left,`top`in t.position?e.top=Math.max(t.position.top,0):`bottom`in t.position?e.bottom=Math.max(t.position.bottom,0):e.top=fH.top,typeof t.width==`number`?e.width=Math.max(t.width,0):e.width=fH.width,typeof t.height==`number`?e.height=Math.max(t.height,0):e.height=fH.height,e}return{left:typeof t?.x==`number`?Math.max(t.x,0):fH.left,top:typeof t?.y==`number`?Math.max(t.y,0):fH.top,width:typeof t?.width==`number`?Math.max(t.width,0):fH.width,height:typeof t?.height==`number`?Math.max(t.height,0):fH.height}}let i=r(),a=this.createNestedGridview();a.addView(n,KB.Distribute,[0]),this.mountFloatingWindow(a,n,[n],i,{dragHandle:t?.dragHandle,inDragMode:t?.inDragMode,skipActiveGroup:t?.skipActiveGroup})}createNestedGridview(e=UB.HORIZONTAL){return new aV(!0,this.options.hideBorders?{separatorBorder:`transparent`}:void 0,e,!1,this.options.theme?.gap??0)}mountFloatingWindow(e,t,n,r,i){let a=cH(this._floatingGroupService,`FloatingGroup`,`api.addFloatingGroup`);if(!a)return;let o=(i?.dragHandle??this.options.floatingGroupDragHandle??`titlebar`)===`titlebar`?new JGe(this,t):void 0,s=new aH(Object.assign(Object.assign({container:this._floatingOverlayHost??this.gridview.element,content:e.element,header:o?.element},r),{minimumInViewportWidth:this.options.floatingGroupBounds===`boundedWithinViewport`?void 0:this.options.floatingGroupBounds?.minimumWidthWithinViewport??dH,minimumInViewportHeight:this.options.floatingGroupBounds===`boundedWithinViewport`?void 0:this.options.floatingGroupBounds?.minimumHeightWithinViewport??dH,transformDragPosition:this.options.transformFloatingGroupDrag?e=>this.options.transformFloatingGroupDrag({group:t,proposed:e.proposed,container:e.container,others:e.others}):void 0,getSiblingBoxes:()=>this._gatherFloatingGroupBoxes(t)})),c=o?.element??t.element.querySelector(`.dv-void-container`);if(!c)throw Error(`dockview: failed to find drag handle`);s.setupDrag(c,{inDragMode:typeof i?.inDragMode==`boolean`&&i.inDragMode});let l=a.add(t,s,e);o&&(l.setTitleBar(o),l.addDisposables(o,dB.from(()=>l.setTitleBar(void 0)),o.onDragStart(e=>{this._onWillDragGroup.fire({nativeEvent:e,group:l.group})})));for(let e of n)e.model.location={type:`floating`};i?.skipActiveGroup||this.doSetGroupAndPanelActive(t)}orthogonalize(e,t){switch(this.gridview.normalize(),e){case`top`:case`bottom`:this.gridview.orientation===UB.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case`left`:case`right`:this.gridview.orientation===UB.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break}switch(e){case`top`:case`left`:case`center`:return this.createGroupAtLocation([0],void 0,t);case`bottom`:case`right`:return this.createGroupAtLocation([this.gridview.length],void 0,t);default:throw Error(`dockview: unsupported position ${e}`)}}updateOptions(e){var t,n,r,i;super.updateOptions(e),(t=this._floatingGroupService)==null||t.updateBounds(e),(n=this._rootDropTargetService)==null||n.setOptions(e);let a=this.options.disableDnd,o=this.options.dndStrategy;this._options=Object.assign(Object.assign({},this.options),e);let s=this.options.disableDnd,c=this.options.dndStrategy;if((a!==s||o!==c)&&this.updateDragAndDropState(),`theme`in e&&this.updateTheme(),(`createRightHeaderActionComponent`in e||`createLeftHeaderActionComponent`in e||`createPrefixHeaderActionComponent`in e)&&((r=this.headerActionsService)==null||r.refreshAll()),`createWatermarkComponent`in e){(i=this._watermarkService)==null||i.refresh();for(let e of this.groups)e.model.refreshWatermark()}if(`tabGroupColors`in e||`tabGroupAccent`in e){this._tabGroupColorPalette.setEntries(this._options.tabGroupColors??LV),this._tabGroupColorPalette.enabled=this._options.tabGroupAccent!==`off`;for(let e of this.groups)e.model.refreshTabGroupAccent()}this._onDidOptionsChange.fire(),this._layoutFromShell(this.gridview.width,this.gridview.height)}layout(e,t,n){var r;this._shellManager&&!this._inShellLayout?this._shellManager.layout(e,t):super.layout(e,t,n),this._syncFloatingOverlayHost(),(r=this._moduleRegistry?.services.floatingGroupService)==null||r.constrainBounds()}_syncFloatingOverlayHost(){if(!this._floatingOverlayHost||!this._shellManager)return;let e=this._shellManager.element.getBoundingClientRect(),t=this.element.getBoundingClientRect(),n=this._floatingOverlayHost;n.style.left=`${t.left-e.left}px`,n.style.top=`${t.top-e.top}px`,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`}_layoutFromShell(e,t){this._inShellLayout=!0,this.layout(e,t,!0),this._inShellLayout=!1}forceRelayout(){this._shellManager?this._layoutFromShell(this.width,this.height):super.forceRelayout()}addEdgeGroup(e,t){let n=cH(this._edgeGroupService,`EdgeGroup`,`api.addEdgeGroup`);if(!n)throw Error(`dockview: EdgeGroup module is not registered`);if(n.has(e))throw Error(`dockview: edge group already exists at position '${e}'`);return this.mutation(`add`,()=>{let r=this.createGroup({id:t.id});r.model.location={type:`edge`,position:e},r.model.headerPosition=e;let i=r.model.onDidRemovePanel(()=>{r.model.isEmpty&&this.setEdgeGroupCollapsed(r,!0)});return n.add(e,r,i),this._onDidAddGroup.fire(r),this._shellManager.addEdgeView(e,t,r),r.api})}getEdgeGroup(e){return this._edgeGroupService?.get(e)?.api}setEdgeGroupVisible(e,t){this._shellManager.setEdgeGroupVisible(e,t)}isEdgeGroupVisible(e){return this._shellManager.isEdgeGroupVisible(e)}removeEdgeGroup(e){let t=cH(this._edgeGroupService,`EdgeGroup`,`api.removeEdgeGroup`);if(!t)return;let n=t.get(e);if(!n)throw Error(`dockview: no edge group exists at position '${e}'`);this.mutation(`remove`,()=>{for(let e of[...n.panels])this.removePanel(e,{removeEmptyGroup:!1,skipDispose:!1});this._shellManager.removeEdgeView(e),t.remove(e),n.dispose(),this._groups.delete(n.id),this._onDidRemoveGroup.fire(n)})}setEdgeGroupCollapsed(e,t){let n=this._edgeGroupService?.findPositionOf(e);n&&this._shellManager.isEdgeGroupCollapsed(n)!==t&&(this._shellManager.setEdgeGroupCollapsed(n,t),e.api._onDidCollapsedChange.fire({isCollapsed:t}))}isEdgeGroupCollapsed(e){let t=this._edgeGroupService?.findPositionOf(e);return t?this._shellManager.isEdgeGroupCollapsed(t):!1}updateDragAndDropState(){for(let e of this.groups)e.model.updateDragAndDropState()}focus(){var e;(e=this.activeGroup)==null||e.focus()}getGroupPanel(e){return this.panels.find(t=>t.id===e)}setActivePanel(e){e.group.model.openPanel(e),this.doSetGroupAndPanelActive(e.group)}moveToNext(e={}){if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[e.group.panels.length-1]){e.group.model.moveToNext({suppressRoll:!0});return}let t=tV(e.group.element),n=this.gridview.next(t)?.view;this.doSetGroupAndPanelActive(n)}moveToPrevious(e={}){if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[0]){e.group.model.moveToPrevious({suppressRoll:!0});return}let t=tV(e.group.element),n=this.gridview.previous(t)?.view;n&&this.doSetGroupAndPanelActive(n)}toJSON(){let e=this.gridview.serialize(),t=this.panels.reduce((e,t)=>(e[t.id]=t.toJSON(),e),{}),n=this._floatingGroupService?.serialize()??[],r=this._popoutWindowService?.serialize()??[],i={grid:e,panels:t,activeGroup:this.activeGroup?.id};n.length>0&&(i.floatingGroups=n),r.length>0&&(i.popoutGroups=r);let a=this._edgeGroupService?.entries()??[];if(this._edgeGroupService?.hasAny()){let e=this._shellManager.toJSON();for(let[t,n]of a){let r=e[t];r&&(r.group=n.toJSON())}i.edgeGroups=e}return i}fromJSON(e,t){this.mutation(`load`,()=>this._doFromJSON(e,t))}_doFromJSON(e,t){var n,r,i,a,o;(n=this._popoutWindowService)==null||n.cancelPendingRestorations();let s=new Map,c;if(t?.reuseExistingPanels){c=this.createGroup(),this._groups.delete(c.api.id);let t=Object.keys(e.panels);for(let e of this.panels)t.includes(e.api.id)&&s.set(e.api.id,e);this.movingLock(()=>{Array.from(s.values()).forEach(e=>{this.moveGroupOrPanel({from:{groupId:e.api.group.api.id,panelId:e.api.id},to:{group:c,position:`center`},keepEmptyGroups:!0})})})}if(this.clear(),typeof e!=`object`||!e)throw Error(`dockview: serialized layout must be a non-null object`);let{grid:l,panels:u,activeGroup:d}=e;if(l.root.type!==`branch`||!Array.isArray(l.root.data))throw Error(`dockview: root must be of type branch`);try{let t=this.width,n=this.height,o=e=>{let{id:t,locked:n,hideHeader:r,headerPosition:i,views:a,activeView:o}=e;if(typeof t!=`string`)throw Error(`dockview: group id must be of type string`);let l=this.createGroup({id:t,locked:!!n,hideHeader:!!r,headerPosition:i});this._onDidAddGroup.fire(l);let d=[];for(let e of a){let t=s.get(e);if(c&&t)this.movingLock(()=>{c.model.removePanel(t)}),d.push(t),t.updateFromStateModel(u[e]);else{let t=this._deserializer.fromJSON(u[e],l);d.push(t)}}for(let e=0;e<a.length;e++){let t=d[e],n=typeof o==`string`&&o===t.id;s.has(t.api.id)?this.movingLock(()=>{l.model.openPanel(t,{skipSetActive:!n,skipSetGroupActive:!0})}):l.model.openPanel(t,{skipSetActive:!n,skipSetGroupActive:!0})}return e.tabGroups&&e.tabGroups.length>0&&l.model.restoreTabGroups(e.tabGroups),!l.activePanel&&l.panels.length>0&&l.model.openPanel(l.panels[l.panels.length-1],{skipSetGroupActive:!0}),l};this.gridview.deserialize(l,{fromJSON:e=>o(e.data)}),this._layoutFromShell(t,n),e.edgeGroups&&this.deserializeEdgeGroups(e.edgeGroups,u),this.deserializeFloatingWindows(e.floatingGroups??[],o);let f=this.deserializePopoutWindows(e.popoutGroups??[],o);if((r=this._popoutWindowService)==null||r.finishRestoration(f),(i=this._floatingGroupService)==null||i.constrainBounds(),typeof d==`string`){let e=this.getPanel(d);e&&this.doSetGroupAndPanelActive(e)}(a=this._watermarkService)==null||a.update()}catch(e){console.error(`dockview: failed to deserialize layout. Reverting changes`,e);for(let e of this.groups)for(let t of e.panels)this.removePanel(t,{removeEmptyGroup:!1,skipDispose:!1});for(let e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);throw(o=this._floatingGroupService)==null||o.disposeAll(),this.clear(),e}this.debouncedUpdateAllPositions(),this._onDidLayoutFromJSON.fire()}deserializeNestedGridview(e,t){let n=this.createNestedGridview(e.orientation),r=[];return n.deserialize(e,{fromJSON:e=>{let n=t(e.data);return r.push(n),n}}),{gridview:n,members:r}}deserializeEdgeGroups(e,t){let n=cH(this._edgeGroupService,`EdgeGroup`,`fromJSON edge restoration`);if(n){for(let t of[`top`,`bottom`,`left`,`right`]){let r=e[t];if(r&&!n.has(t)){let e=r.group?.id??`${t}-group`;this.addEdgeGroup(t,{id:e})}}for(let[r,i]of n.entries()){let n=e[r]?.group;if(n){let{views:e,activeView:r}=n,a=[];for(let n of e)if(t[n]){let e=this._deserializer.fromJSON(t[n],i);a.push(e)}for(let e=0;e<a.length;e++){let t=a[e],n=r===t.id;i.model.openPanel(t,{skipSetActive:!n,skipSetGroupActive:!0})}n.tabGroups&&n.tabGroups.length>0&&i.model.restoreTabGroups(n.tabGroups),!i.activePanel&&i.panels.length>0&&i.model.openPanel(i.panels[i.panels.length-1],{skipSetGroupActive:!0})}}this._shellManager.fromJSON(e)}}deserializeFloatingWindows(e,t){for(let n of e){let{data:e,grid:r,position:i}=n;if(r){let{gridview:e,members:n}=this.deserializeNestedGridview(r,t);if(n.length===0)continue;this.mountFloatingWindow(e,n[0],n,i,{inDragMode:!1})}else if(e){let n=t(e);this.addFloatingGroup(n,{position:i,width:i.width,height:i.height,skipRemoveGroup:!0,inDragMode:!1})}}}deserializePopoutWindows(e,t){let n=e.length>0?cH(this._popoutWindowService,`PopoutWindow`,`fromJSON popout restoration`):this._popoutWindowService;return n?e.flatMap((e,r)=>{let{data:i,grid:a,position:o,gridReferenceGroup:s,url:c}=e,l,u=[];if(a){let e=this.deserializeNestedGridview(a,t);if(l=e.gridview,u=e.members,u.length===0)return l.dispose(),[]}let d=a?u[0]:t(i);return n.scheduleRestoration(r*eKe,()=>{this.addPopoutGroup(d,{position:o??void 0,overridePopoutGroup:s?d:void 0,overridePopoutGridview:l,referenceGroup:s?this.getPanel(s):void 0,popoutUrl:c})},()=>{for(let e of u.length>0?u:[d])if(!this.isDisposed&&this._groups.has(e.id)&&e.element.parentElement===null){for(let t of[...e.panels])this.removePanel(t,{removeEmptyGroup:!1});e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}})}):[]}clear(){this.mutation(`clear`,()=>this._doClear())}_doClear(){let e=Array.from(this._groups.values()).map(e=>e.value),t=!!this.activeGroup;for(let t of e){if(this._edgeGroupService?.includes(t)){let e=[...t.panels];for(let t of e)this.removePanel(t,{removeEmptyGroup:!1});continue}this.removeGroup(t,{skipActive:!0})}t&&this.doSetGroupAndPanelActive(void 0),this.gridview.clear()}closeAllGroups(){this.mutation(`remove`,()=>{for(let e of this._groups.entries()){let[t,n]=e;n.value.model.closeAllPanels()}})}addPanel(e){return this.mutation(`add`,()=>this._doAddPanel(e))}_doAddPanel(e){if(this.panels.find(t=>t.id===e.id))throw Error(`dockview: panel with id ${e.id} already exists`);let t;if(e.position&&e.floating)throw Error(`dockview: you can only provide one of: position, floating as arguments to .addPanel(...)`);let n={width:e.initialWidth,height:e.initialHeight},r;if(e.position)if(FGe(e.position)){let n=typeof e.position.referencePanel==`string`?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(r=e.position.index,!n)throw Error(`dockview: referencePanel '${e.position.referencePanel}' does not exist`);t=this.findGroup(n)}else if(IGe(e.position)){if(t=typeof e.position.referenceGroup==`string`?this._groups.get(e.position.referenceGroup)?.value:e.position.referenceGroup,r=e.position.index,!t)throw Error(`dockview: referenceGroup '${e.position.referenceGroup}' does not exist`)}else{let t=this.orthogonalize(bV(e.position.direction)),i=this.createPanel(e,t);return t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(t),t.api.setSize({height:n?.height,width:n?.width}),i}else t=this.activeGroup;let i;if(t){let a=cV(e.position?.direction||`within`);if(e.floating){let t=this.createGroup();this._onDidAddGroup.fire(t);let n=typeof e.floating==`object`&&e.floating!==null?e.floating:{};this.addFloatingGroup(t,Object.assign(Object.assign({},n),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),i=this.createPanel(e,t),t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r})}else if(t.api.location.type===`floating`||t.api.location.type===`edge`||a===`center`)i=this.createPanel(e,t),t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),t.api.setSize({width:n?.width,height:n?.height}),e.inactive||this.doSetGroupAndPanelActive(t);else{let o=tV(t.element),s=nV(this.gridview.orientation,o,a),c=this.createGroupAtLocation(s,this.orientationAtLocation(s)===UB.VERTICAL?n?.height:n?.width);i=this.createPanel(e,c),c.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(c)}}else if(e.floating){let t=this.createGroup();this._onDidAddGroup.fire(t);let n=typeof e.floating==`object`&&e.floating!==null?e.floating:{};this.addFloatingGroup(t,Object.assign(Object.assign({},n),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),i=this.createPanel(e,t),t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r})}else{let t=this.createGroupAtLocation([0],this.gridview.orientation===UB.VERTICAL?n?.height:n?.width);i=this.createPanel(e,t),t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(t)}return i}removePanel(e,t={removeEmptyGroup:!0}){this.mutation(`remove`,()=>this._doRemovePanel(e,t))}_doRemovePanel(e,t={removeEmptyGroup:!0}){let n=e.group;if(!n)throw Error(`dockview: cannot remove panel ${e.id}. it's missing a group.`);n.model.removePanel(e,{skipSetActiveGroup:t.skipSetActiveGroup}),t.skipDispose||(e.group.model.renderContainer.detatch(e),e.dispose()),n.size===0&&t.removeEmptyGroup&&this.removeGroup(n,{skipActive:t.skipSetActiveGroup})}createWatermarkComponent(){return this.options.createWatermarkComponent?this.options.createWatermarkComponent():new qGe}addGroup(e){return this.mutation(`add`,()=>this._doAddGroup(e))}_doAddGroup(e){if(e){let t;if(LGe(e)){let n=typeof e.referencePanel==`string`?this.panels.find(t=>t.id===e.referencePanel):e.referencePanel;if(!n)throw Error(`dockview: reference panel ${e.referencePanel} does not exist`);if(t=this.findGroup(n),!t)throw Error(`dockview: reference group for reference panel ${e.referencePanel} does not exist`)}else if(RGe(e)){if(t=typeof e.referenceGroup==`string`?this._groups.get(e.referenceGroup)?.value:e.referenceGroup,!t)throw Error(`dockview: reference group ${e.referenceGroup} does not exist`)}else{let t=this.orthogonalize(bV(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(t),t}let n=cV(e.direction||`within`),r=tV(t.element),i=nV(this.gridview.orientation,r,n),a=this.createGroup(e),o=this.getLocationOrientation(i)===UB.VERTICAL?e.initialHeight:e.initialWidth;return this.doAddGroup(a,i,o),e.skipSetActive||this.doSetGroupAndPanelActive(a),a}else{let t=this.createGroup(e);return this.doAddGroup(t),this.doSetGroupAndPanelActive(t),t}}getLocationOrientation(e){return e.length%2==0&&this.gridview.orientation===UB.HORIZONTAL?UB.HORIZONTAL:UB.VERTICAL}removeGroup(e,t){this.mutation(`remove`,()=>this.doRemoveGroup(e,t))}detachFromNestedWindow(e){let t=this._floatingGroupService?.findByGroup(e);if(t){let n=this.nestedWindowMembers(e);return n.length<=1?!1:(t.gridview.remove(e),t.group===e&&t.setAnchorGroup(n.find(t=>t!==e)),!0)}let n=this._popoutWindowService?.findByGroup(e);if(n){let t=this.nestedWindowMembers(e);return t.length<=1?!1:(n.gridview.remove(e),n.popoutGroup===e&&(n.popoutGroup=t.find(t=>t!==e)),!0)}return!1}disposeGroupRecord(e){e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}activateFallbackGroupIfRemoved(e,t){if(!t&&this._activeGroup===e){let e=Array.from(this._groups.values());this.doSetGroupAndPanelActive(e.length>0?e[0].value:void 0)}}doRemoveGroup(e,t){var n;if(this._edgeGroupService?.includes(e))return e;let r=[...e.panels];if(!t?.skipDispose)for(let e of r)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:t?.skipDispose??!1});let i=this.activePanel;if(e.api.location.type===`floating`){let n=this._floatingGroupService?.findByGroup(e);if(!n)throw Error(`dockview: failed to find floating group`);return this.detachFromNestedWindow(e)?(t?.skipDispose?e.model.location={type:`grid`}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e):(t?.skipDispose||this.disposeGroupRecord(e),n.dispose(),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e)}if(e.api.location.type===`popout`){let r=this._popoutWindowService?.findByGroup(e);if(!r)throw Error(`dockview: failed to find popout group`);if(this.detachFromNestedWindow(e))return t?.skipDispose?e.model.location={type:`grid`}:this.disposeGroupRecord(e),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e;if(!t?.skipDispose){if(!t?.skipPopoutAssociated){let e=r.referenceGroup?this.getPanel(r.referenceGroup):void 0;e&&e.panels.length===0&&this.removeGroup(e)}r.popoutGroup.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}(n=this._popoutWindowService)==null||n.remove(r);let i=r.disposable.dispose();return!t?.skipPopoutReturn&&i&&(this.doAddGroup(i,[0]),this.doSetGroupAndPanelActive(i)),this.activateFallbackGroupIfRemoved(e,t?.skipActive),r.popoutGroup}if(!this.gridview.element.contains(e.element))return t?.skipDispose||(this._groups.get(e.id)?.disposable.dispose(),this.disposeGroupRecord(e)),this.activateFallbackGroupIfRemoved(e,t?.skipActive),e;let a=super.doRemoveGroup(e,t);return t?.skipActive||this.activePanel!==i&&this.fireActivePanelChange(this.activePanel),a}debouncedUpdateAllPositions(){this._updatePositionsFrameId!==void 0&&cancelAnimationFrame(this._updatePositionsFrameId),this._updatePositionsFrameId=requestAnimationFrame(()=>{this._updatePositionsFrameId=void 0,this.overlayRenderContainer.updateAllPositions();for(let e of this._popoutWindowService?.entries??[])e.overlayRenderContainer.updateAllPositions()})}movingLock(e){let t=this._moving;try{return this._moving=!0,e()}finally{this._moving=t}}mutation(e,t){let n=this._mutationDepth===0,r=this._origin;n&&this._onWillMutateLayout.fire({kind:e,origin:r}),this._mutationDepth++;try{return t()}finally{this._mutationDepth--,n&&this._onDidMutateLayout.fire({kind:e,origin:r})}}currentOrigin(){return this._origin}withOrigin(e,t){if(this._originDepth>0||this._mutationDepth>0)return t();let n=this._origin;this._origin=e,this._originDepth++;try{return t()}finally{this._originDepth--,this._origin=n}}fireActivePanelChange(e){this._onDidActivePanelChange.fire({panel:e,origin:this._origin})}moveGroupOrPanel(e){this.mutation(`move`,()=>this._doMoveGroupOrPanel(e))}_doMoveGroupOrPanel(e){let t=e.to.group,n=e.from.groupId,r=e.from.panelId,i=e.to.position,a=e.to.index,o=n?this._groups.get(n)?.value:void 0;if(!o)throw Error(`dockview: Failed to find group id ${n}`);if(r===void 0){e.from.tabGroupId?this.moveTabGroupToGroup({sourceGroup:o,tabGroupId:e.from.tabGroupId,destinationGroup:t,destinationTarget:i,destinationIndex:a,skipSetActive:e.skipSetActive,keepEmptyGroups:e.keepEmptyGroups}):this.moveGroup({from:{group:o},to:{group:t,position:i},skipSetActive:e.skipSetActive});return}if(!i||i===`center`){let n=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!n)throw Error(`dockview: No panel with id ${r}`);!e.keepEmptyGroups&&o.model.size===0&&this.doRemoveGroup(o,{skipActive:!0});let i=t.model.size===0;this.movingLock(()=>t.model.openPanel(n,{index:a,skipSetActive:(e.skipSetActive??!1)&&!i,skipSetGroupActive:!0})),e.skipSetActive||this.doSetGroupAndPanelActive(t),this._onDidMovePanel.fire({panel:n,from:o})}else{let e=this.getGridviewForGroup(t),n=tV(t.element),a=nV(e.orientation,n,i);if(o.size<2){let[n,s]=FB(a);if(o.api.location.type===`grid`&&e===this.gridview){let[e,t]=FB(tV(o.element));if(IB(e,n)){this.gridview.moveView(e,t,s),this._onDidMovePanel.fire({panel:this.getGroupPanel(r),from:o});return}}if(o.api.location.type===`popout`&&this.nestedWindowMembers(o).length<=1){let n=this._popoutWindowService?.findByGroup(o);if(!n)return;let a=this.movingLock(()=>n.popoutGroup.model.removePanel(n.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(o,{skipActive:!0});let s=nV(e.orientation,tV(t.element),i),c=this.createGroupAtLocation(s,void 0,void 0,e);this.movingLock(()=>c.model.openPanel(a,{skipSetActive:!0})),this.doSetGroupAndPanelActive(c),this._onDidMovePanel.fire({panel:this.getGroupPanel(r),from:o});return}if(o.api.location.type===`edge`){let t=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!t)throw Error(`dockview: No panel with id ${r}`);let n=this.createGroupAtLocation(a,void 0,void 0,e);this.movingLock(()=>n.model.openPanel(t,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(n),this._onDidMovePanel.fire({panel:t,from:o});return}let c=this.movingLock(()=>this.doRemoveGroup(o,{skipActive:!0,skipDispose:!0})),l=tV(t.element),u=nV(e.orientation,l,i);this.movingLock(()=>this.doAddGroup(c,u,void 0,e)),this.setGroupLocationForRoot(c,e),this.doSetGroupAndPanelActive(c),this._onDidMovePanel.fire({panel:this.getGroupPanel(r),from:o})}else{let t=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!t)throw Error(`dockview: No panel with id ${r}`);let a=nV(e.orientation,n,i),s=this.createGroupAtLocation(a,void 0,void 0,e);this.movingLock(()=>s.model.openPanel(t,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(s),this._onDidMovePanel.fire({panel:t,from:o})}}}moveTabGroupToGroup(e){let{sourceGroup:t,tabGroupId:n,destinationGroup:r,destinationTarget:i,destinationIndex:a}=e,o=t.model.getTabGroups().find(e=>e.id===n);if(!o||o.panelIds.length===0)return;let s=o.label,c=o.color,l=o.collapsed,u=o.componentParams,d=[...o.panelIds],f=i&&i!==`center`?tV(r.element):void 0,p=this.movingLock(()=>d.map(e=>t.model.removePanel(e,{skipSetActive:!1,skipSetActiveGroup:!0})).filter(e=>e!==void 0));if(p.length===0)return;let m=n=>{this.movingLock(()=>{for(let e of p)n.model.openPanel(e,{index:a,skipSetActive:!0,skipSetGroupActive:!0})});let r=n.model.createTabGroup({label:s,color:c,collapsed:l,componentParams:u});for(let e of p)n.model.addPanelToTabGroup(r.id,e.id);e.skipSetActive||this.doSetGroupAndPanelActive(n);for(let e of p)this._onDidMovePanel.fire({panel:e,from:t})},h;if(!i||i===`center`||!f)h=r;else{let e=nV(this.gridview.orientation,f,i);h=this.createGroupAtLocation(e)}!e.keepEmptyGroups&&t.model.size===0&&t!==h&&this.doRemoveGroup(t,{skipActive:!0}),m(h)}moveGroup(e){this.mutation(`move`,()=>this._doMoveGroup(e))}maximizeGroup(e){this.mutation(`maximize`,()=>super.maximizeGroup(e))}exitMaximizedGroup(){this.mutation(`maximize`,()=>super.exitMaximizedGroup())}_doMoveGroup(e){var t;let n=e.from.group,r=e.to.group,i=e.to.position,a=n;if(i===`center`){let t=n.activePanel,i=n.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),a=this.movingLock(()=>[...n.panels].map(e=>n.model.removePanel(e.id,{skipSetActive:!0})));n?.model.size===0&&this.doRemoveGroup(n,{skipActive:!0}),this.movingLock(()=>{for(let e of a)r.model.openPanel(e,{skipSetActive:e!==t,skipSetGroupActive:!0})});for(let e of i){let t=r.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(let n of e.panelIds)r.model.addPanelToTabGroup(t.id,n)}e.skipSetActive===!0&&this.activePanel||this.doSetGroupAndPanelActive(r)}else{if(n.api.location.type===`edge`){let e=n.activePanel,t=n.model.getTabGroups().map(e=>({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams,panelIds:[...e.panelIds]})),r=this.movingLock(()=>[...n.panels].map(e=>n.model.removePanel(e.id,{skipSetActive:!0})));a=this.createGroup(),this._onDidAddGroup.fire(a),this.movingLock(()=>{for(let t of r)a.model.openPanel(t,{skipSetActive:t!==e,skipSetGroupActive:!0})});for(let e of t){let t=a.model.createTabGroup({label:e.label,color:e.color,collapsed:e.collapsed,componentParams:e.componentParams});for(let n of e.panelIds)a.model.addPanelToTabGroup(t.id,n)}}else switch(n.api.location.type){case`grid`:this.gridview.removeView(tV(n.element));break;case`floating`:{let e=this._floatingGroupService?.findByGroup(n);if(!e)throw Error(`dockview: failed to find floating group`);this.detachFromNestedWindow(n)||e.dispose();break}case`popout`:{let e=this._popoutWindowService?.findByGroup(n);if(!e)throw Error(`dockview: failed to find popout group`);if(this.detachFromNestedWindow(n))break;if((t=this._popoutWindowService)==null||t.remove(e),e.referenceGroup){let t=this.getPanel(e.referenceGroup);t&&!t.api.isVisible&&this.doRemoveGroup(t,{skipActive:!0})}e.window.dispose();break}}if(r.api.location.type===`grid`||r.api.location.type===`floating`||r.api.location.type===`popout`){let e=this.getGridviewForGroup(r),t=tV(r.element),o=nV(e.orientation,t,i),s;switch(e.orientation){case UB.VERTICAL:s=t.length%2==0?n.api.width:n.api.height;break;case UB.HORIZONTAL:s=t.length%2==0?n.api.height:n.api.width;break}e.addView(a,s,o),this.setGroupLocationForRoot(a,e)}}if(a.panels.forEach(e=>{this._onDidMovePanel.fire({panel:e,from:n})}),this.debouncedUpdateAllPositions(),e.skipSetActive===!1){let e=r??n;this.doSetGroupAndPanelActive(e)}else a!==n&&e.skipSetActive!==!0&&this.doSetGroupAndPanelActive(a)}doSetGroupActive(e){super.doSetGroupActive(e);let t=this.activePanel;!this._moving&&t!==this._onDidActivePanelChange.value?.panel&&this.fireActivePanelChange(t)}doSetGroupAndPanelActive(e){super.doSetGroupActive(e);let t=this.activePanel;e&&this.hasMaximizedGroup()&&!this.isMaximizedGroup(e)&&this.exitMaximizedGroup(),!this._moving&&t!==this._onDidActivePanelChange.value?.panel&&this.fireActivePanelChange(t)}getNextGroupId(){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}createGroup(e){e||={};let t=e?.id;if(t&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${e?.id}. reassigning group id to avoid errors`),t=void 0),!t)for(t=this.nextGroupId.next();this._groups.has(t);)t=this.nextGroupId.next();let n=new eH(this,t,e);if(n.init({params:{},accessor:this}),!this._groups.has(n.id)){let e=new fB(n.model.onTabDragStart(e=>{var t;(t=this._advancedDnDService)==null||t.dispatchWillDragPanel(e)}),n.model.onGroupDragStart(e=>{var t;(t=this._advancedDnDService)==null||t.dispatchWillDragGroup(e)}),n.model.onMove(e=>{let{groupId:t,itemId:r,target:i,index:a,tabGroupId:o}=e;this.moveGroupOrPanel({from:{groupId:t,panelId:r,tabGroupId:o},to:{group:n,position:i,index:a}})}),n.model.onDidDrop(e=>{this._onDidDrop.fire(e)}),n.model.onWillDrop(e=>{var t;(t=this._advancedDnDService)==null||t.dispatchWillDrop(e)}),n.model.onWillShowOverlay(e=>{var t;if(this.options.disableDnd){e.preventDefault();return}(t=this._advancedDnDService)==null||t.dispatchWillShowOverlay(e)}),n.model.onUnhandledDragOver(e=>{this._onUnhandledDragOver.fire(e)}),n.model.onDidAddPanel(e=>{this._moving||this._onDidAddPanel.fire(e.panel)}),n.model.onDidRemovePanel(e=>{this._moving||this._onDidRemovePanel.fire(e.panel)}),n.model.onDidActivePanelChange(e=>{this._moving||e.panel===this.activePanel&&this._onDidActivePanelChange.value?.panel!==e.panel&&this.fireActivePanelChange(e.panel)}),mB.any(n.model.onDidPanelTitleChange,n.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(n.id,{value:n,disposable:e})}return n.initialize(),n}createPanel(e,t){let n=e.component,r=e.tabComponent??this.options.defaultTabComponent,i=new rH(this,e.id,n,r),a=new tH(e.id,n,r,this,this._api,t,i,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return a.init({title:e.title??e.id,params:e?.params??{}}),a}createGroupAtLocation(e,t,n,r=this.gridview){let i=this.createGroup(n);return this.doAddGroup(i,e,t,r),this.setGroupLocationForRoot(i,r),i}setGroupLocationForRoot(e,t){let n=this._popoutWindowService?.entries.find(e=>e.gridview===t);if(n){e.model.renderContainer!==n.overlayRenderContainer&&(e.model.renderContainer=n.overlayRenderContainer),e.model.dropTargetContainer=n.dropTargetContainer,e.model.location={type:`popout`,getWindow:n.getWindow,popoutUrl:n.popoutUrl};return}e.model.renderContainer!==this.overlayRenderContainer&&(e.model.renderContainer=this.overlayRenderContainer),e.model.dropTargetContainer=this.rootDropTargetContainer,e.model.location=t===this.gridview?{type:`grid`}:{type:`floating`}}getGridviewForGroup(e){let t=this._floatingGroupService?.findByGroup(e);if(t)return t.gridview;let n=this._popoutWindowService?.findByGroup(e);return n?n.gridview:this.gridview}nestedWindowMembers(e){let t=this.getGridviewForGroup(e);return t===this.gridview?[]:this.groups.filter(e=>t.element.contains(e.element))}findGroup(e){return Array.from(this._groups.values()).find(t=>t.value.model.containsPanel(e))?.value}orientationAtLocation(e){let t=this.gridview.orientation;return e.length%2==1?t:rV(t)}updateTheme(){var e,t,n,r;let i=this._options.theme??WGe;(e=this._shellThemeClassnames)==null||e.setClassNames(i.className);let a=i.gap??0;this.gridview.margin=a;for(let e of this.floatingGroups)e.gridview.margin=a;for(let e of this._popoutWindowService?.entries??[])e.gridview.margin=a;switch((t=this._shellManager)==null||t.updateTheme(a,i.edgeGroupCollapsedSize??35),i.dndOverlayBorder===void 0?(this.element.style.removeProperty(`--dv-drag-over-border`),(r=this._shellManager)==null||r.element.style.removeProperty(`--dv-drag-over-border`)):(this.element.style.setProperty(`--dv-drag-over-border`,i.dndOverlayBorder),(n=this._shellManager)==null||n.element.style.setProperty(`--dv-drag-over-border`,i.dndOverlayBorder)),i.dndOverlayMounting){case`absolute`:this.rootDropTargetContainer.disabled=!1;break;default:this.rootDropTargetContainer.disabled=!0;break}let o=(i.tabGroupIndicator??`wrap`)===`none`;CB(this.element,`dv-tab-group-indicator-none`,o),this._shellManager&&CB(this._shellManager.element,`dv-tab-group-indicator-none`,o);for(let e of this.groups)e.model.updateTabGroups()}},PKe=class extends lV{get orientation(){return this.gridview.orientation}set orientation(e){this.gridview.orientation=e}get options(){return this._options}get deserializer(){return this._deserializer}set deserializer(e){this._deserializer=e}constructor(e,t){super(e,{proportionalLayout:t.proportionalLayout??!0,orientation:t.orientation,styles:t.hideBorders?{separatorBorder:`transparent`}:void 0,disableAutoResizing:t.disableAutoResizing,className:t.className}),this._onDidLayoutfromJSON=new Q,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new Q,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new Q,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new Q,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._options=t,this.addDisposables(this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this.onDidAdd(e=>{this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._onDidActiveGroupChange.fire(e)}))}updateOptions(e){super.updateOptions(e);let t=typeof e.orientation==`string`&&this.gridview.orientation!==e.orientation;this._options=Object.assign(Object.assign({},this.options),e),t&&(this.gridview.orientation=e.orientation),this.layout(this.gridview.width,this.gridview.height,!0)}removePanel(e){this.removeGroup(e)}toJSON(){return{grid:this.gridview.serialize(),activePanel:this.activeGroup?.id}}setVisible(e,t){this.gridview.setViewVisible(tV(e.element),t)}setActive(e){this._groups.forEach((t,n)=>{t.value.setActive(e===t.value)})}focus(){var e;(e=this.activeGroup)==null||e.focus()}fromJSON(e){this.clear();let{grid:t,activePanel:n}=e;try{let e=[],r=this.width,i=this.height;if(this.gridview.deserialize(t,{fromJSON:t=>{let{data:n}=t,r=this.options.createComponent({id:n.id,name:n.component});return e.push(()=>r.init({params:n.params,minimumWidth:n.minimumWidth,maximumWidth:n.maximumWidth,minimumHeight:n.minimumHeight,maximumHeight:n.maximumHeight,priority:n.priority,snap:!!n.snap,accessor:this,isVisible:t.visible})),this._onDidAddGroup.fire(r),this.registerPanel(r),r}}),this.layout(r,i,!0),e.forEach(e=>e()),typeof n==`string`){let e=this.getPanel(n);e&&this.doSetGroupActive(e)}}catch(e){for(let e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);throw this.clear(),e}this._onDidLayoutfromJSON.fire()}clear(){let e=this.activeGroup,t=Array.from(this._groups.values());for(let e of t)e.disposable.dispose(),this.doRemoveGroup(e.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){let n,r=this.gridview.remove(e),i=this._groups.get(t.reference)?.value;if(!i)throw Error(`reference group ${t.reference} does not exist`);let a=cV(t.direction);if(a===`center`)throw Error(`${a} not supported as an option`);{let e=tV(i.element);n=nV(this.gridview.orientation,e,a)}this.doAddGroup(r,n,t.size)}addPanel(e){let t=e.location??[0];if(e.position?.referencePanel){let n=this._groups.get(e.position.referencePanel)?.value;if(!n)throw Error(`reference group ${e.position.referencePanel} does not exist`);let r=cV(e.position.direction);if(r===`center`)throw Error(`${r} not supported as an option`);{let e=tV(n.element);t=nV(this.gridview.orientation,e,r)}}let n=this.options.createComponent({id:e.id,name:e.component});return n.init({params:e.params??{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.doAddGroup(n,t,e.size),this.registerPanel(n),this.doSetGroupActive(n),n}registerPanel(e){let t=new fB(e.api.onDidFocusChange(t=>{t.isFocused&&this._groups.forEach(t=>{let n=t.value;n===e?n.setActive(!0):n.setActive(!1)})}));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,n){let r=this.getPanel(t);if(!r)throw Error(`invalid operation`);let i=tV(e.element),[a,o]=FB(nV(this.gridview.orientation,i,n)),[s,c]=FB(tV(r.element));if(IB(s,a)){this.gridview.moveView(s,c,o);return}let l=this.doRemoveGroup(r,{skipActive:!0,skipDispose:!0}),u=tV(e.element),d=nV(this.gridview.orientation,u,n);this.doAddGroup(l,d)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}},FKe=class extends sV{get panels(){return this.splitview.getViews()}get options(){return this._options}get length(){return this._panels.size}get orientation(){return this.splitview.orientation}get splitview(){return this._splitview}set splitview(e){this._splitview&&this._splitview.dispose(),this._splitview=e,this._splitviewChangeDisposable.value=new fB(this._splitview.onDidSashEnd(()=>{this._onDidLayoutChange.fire(void 0)}),this._splitview.onDidAddView(e=>this._onDidAddView.fire(e)),this._splitview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===UB.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===UB.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._splitviewChangeDisposable=new pB,this._panels=new Map,this._onDidLayoutfromJSON=new Q,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new Q,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new Q,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new Q,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height=`100%`,this.element.style.width=`100%`,this._classNames=new jB(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this._options=t,this.splitview=new qB(this.element,t),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}updateOptions(e){`className`in e&&this._classNames.setClassNames(e.className??``),`disableResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),typeof e.orientation==`string`&&(this.splitview.orientation=e.orientation),this._options=Object.assign(Object.assign({},this.options),e),this.splitview.layout(this.splitview.size,this.splitview.orthogonalSize)}focus(){var e;(e=this._activePanel)==null||e.focus()}movePanel(e,t){this.splitview.moveView(e,t)}setVisible(e,t){let n=this.panels.indexOf(e);this.splitview.setViewVisible(n,t)}setActive(e,t){this._activePanel=e,this.panels.filter(t=>t!==e).forEach(e=>{e.api._onDidActiveChange.fire({isActive:!1}),t||e.focus()}),e.api._onDidActiveChange.fire({isActive:!0}),t||e.focus()}removePanel(e,t){let n=this._panels.get(e.id);if(!n)throw Error(`unknown splitview panel ${e.id}`);n.dispose(),this._panels.delete(e.id);let r=this.panels.findIndex(t=>t===e);this.splitview.removeView(r,t).dispose();let i=this.panels;i.length>0&&this.setActive(i[i.length-1])}getPanel(e){return this.panels.find(t=>t.id===e)}addPanel(e){if(this._panels.has(e.id))throw Error(`panel ${e.id} already exists`);let t=this.options.createComponent({id:e.id,name:e.component});t.orientation=this.splitview.orientation,t.init({params:e.params??{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});let n=typeof e.size==`number`?e.size:KB.Distribute,r=typeof e.index==`number`?e.index:void 0;return this.splitview.addView(t,n,r),this.doAddView(t),this.setActive(t),t}layout(e,t){let[n,r]=this.splitview.orientation===UB.HORIZONTAL?[e,t]:[t,e];this.splitview.layout(n,r)}doAddView(e){let t=e.api.onDidFocusChange(t=>{t.isFocused&&this.setActive(e,!0)});this._panels.set(e.id,t)}toJSON(){return{views:this.splitview.getViews().map((e,t)=>({size:this.splitview.getViewSize(t),data:e.toJSON(),snap:!!e.snap,priority:e.priority})),activeView:this._activePanel?.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();let{views:t,orientation:n,size:r,activeView:i}=e,a=[],o=this.width,s=this.height;if(this.splitview=new qB(this.element,{orientation:n,proportionalLayout:this.options.proportionalLayout,descriptor:{size:r,views:t.map(e=>{let t=e.data;if(this._panels.has(t.id))throw Error(`panel ${t.id} already exists`);let r=this.options.createComponent({id:t.id,name:t.component});return a.push(()=>{r.init({params:t.params??{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:e.snap,priority:e.priority,accessor:this})}),r.orientation=n,this.doAddView(r),setTimeout(()=>{this._onDidAddView.fire(r)},0),{size:e.size,view:r}})}}),this.layout(o,s),a.forEach(e=>e()),typeof i==`string`){let e=this.getPanel(i);e&&this.setActive(e)}this._onDidLayoutfromJSON.fire()}clear(){for(let e of this._panels.values())e.dispose();for(this._panels.clear();this.splitview.length>0;)this.splitview.removeView(0,KB.Distribute,!0).dispose()}dispose(){for(let e of this._panels.values())e.dispose();this._panels.clear();let e=this.splitview.getViews();this._splitviewChangeDisposable.dispose(),this.splitview.dispose();for(let t of e)t.dispose();this.element.remove(),super.dispose()}},wH=class extends fB{get element(){return this._element}constructor(){super(),this._expandedIcon=MGe(),this._collapsedIcon=KV(),this.disposable=new pB,this.apiRef={api:null},this._element=document.createElement(`div`),this.element.className=`dv-default-header`,this._content=document.createElement(`span`),this._expander=document.createElement(`div`),this._expander.className=`dv-pane-header-icon`,this.element.appendChild(this._expander),this.element.appendChild(this._content),this.addDisposables(vB(this._element,`click`,()=>{var e;(e=this.apiRef.api)==null||e.setExpanded(!this.apiRef.api.isExpanded)}))}init(e){this.apiRef.api=e.api,this._content.textContent=e.title,this.updateIcon(),this.disposable.value=e.api.onDidExpansionChange(()=>{this.updateIcon()})}updateIcon(){let e=!!this.apiRef.api?.isExpanded;CB(this._expander,`collapsed`,!e),e?(this._expander.contains(this._collapsedIcon)&&this._collapsedIcon.remove(),this._expander.contains(this._expandedIcon)||this._expander.appendChild(this._expandedIcon)):(this._expander.contains(this._expandedIcon)&&this._expandedIcon.remove(),this._expander.contains(this._collapsedIcon)||this._expander.appendChild(this._collapsedIcon))}update(e){}dispose(){this.disposable.dispose(),super.dispose()}},IKe=VB(),TH=22,EH=0,DH=2**53-1,OH=class extends mGe{constructor(e){super({accessor:e.accessor,id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,disableDnd:e.disableDnd,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}},LKe=class extends sV{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new fB(this._paneview.onDidChange(()=>{this._onDidLayoutChange.fire(void 0)}),this._paneview.onDidAddView(e=>this._onDidAddView.fire(e)),this._paneview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===UB.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===UB.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._id=IKe.next(),this._disposable=new pB,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new Q,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new Q,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new Q,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new Q,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new Q,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOver=new Q,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.element.style.height=`100%`,this.element.style.width=`100%`,this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView,this._onUnhandledDragOver),this._classNames=new jB(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this._options=t,this.paneview=new YB(this.element,{orientation:UB.VERTICAL}),this.addDisposables(this._disposable)}setVisible(e,t){let n=this.panels.indexOf(e);this.paneview.setViewVisible(n,t)}focus(){}updateOptions(e){`className`in e&&this._classNames.setClassNames(e.className??``),`disableResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),this._options=Object.assign(Object.assign({},this.options),e)}addPanel(e){let t=this.options.createComponent({id:e.id,name:e.component}),n;e.headerComponent&&this.options.createHeaderComponent&&(n=this.options.createHeaderComponent({id:e.id,name:e.headerComponent})),n||=new wH;let r=new OH({id:e.id,component:e.component,headerComponent:e.headerComponent,header:n,body:t,orientation:UB.VERTICAL,isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:e.headerSize??TH,minimumBodySize:EH,maximumBodySize:DH});this.doAddPanel(r);let i=typeof e.size==`number`?e.size:KB.Distribute,a=typeof e.index==`number`?e.index:void 0;return r.init({params:e.params??{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new dV(this),accessor:this}),this.paneview.addPane(r,i,a),r.orientation=this.paneview.orientation,r}removePanel(e){let t=this.panels.findIndex(t=>t===e);this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find(t=>t.id===e)}layout(e,t){let[n,r]=this.paneview.orientation===UB.HORIZONTAL?[e,t]:[t,e];this.paneview.layout(n,r)}toJSON(){let e=e=>e===2**53-1||e===1/0?void 0:e,t=e=>e<=0?void 0:e;return{views:this.paneview.getPanes().map((n,r)=>({size:this.paneview.getViewSize(r),data:n.toJSON(),minimumSize:t(n.minimumBodySize),maximumSize:e(n.maximumBodySize),headerSize:n.headerSize,expanded:n.isExpanded()})),size:this.paneview.size}}fromJSON(e){this.clear();let{views:t,size:n}=e,r=[],i=this.width,a=this.height;this.paneview=new YB(this.element,{orientation:UB.VERTICAL,descriptor:{size:n,views:t.map(e=>{let t=e.data,n=this.options.createComponent({id:t.id,name:t.component}),i;t.headerComponent&&this.options.createHeaderComponent&&(i=this.options.createHeaderComponent({id:t.id,name:t.headerComponent})),i||=new wH;let a=new OH({id:t.id,component:t.component,headerComponent:t.headerComponent,header:i,body:n,orientation:UB.VERTICAL,isExpanded:!!e.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:e.headerSize??TH,minimumBodySize:e.minimumSize??EH,maximumBodySize:e.maximumSize??DH});return this.doAddPanel(a),r.push(()=>{a.init({params:t.params??{},minimumBodySize:e.minimumSize,maximumBodySize:e.maximumSize,title:t.title,isExpanded:!!e.expanded,containerApi:new dV(this),accessor:this}),a.orientation=this.paneview.orientation}),setTimeout(()=>{this._onDidAddView.fire(a)},0),{size:e.size,view:a}})}}),this.layout(i,a),r.forEach(e=>e()),this._onDidLayoutfromJSON.fire()}clear(){for(let[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.paneview.dispose()}doAddPanel(e){let t=new fB(e.onDidDrop(e=>{this._onDidDrop.fire(e)}),e.onUnhandledDragOver(e=>{this._onUnhandledDragOver.fire(e)}));this._viewDisposables.set(e.id,t)}doRemovePanel(e){let t=this._viewDisposables.get(e.id);t&&(t.dispose(),this._viewDisposables.delete(e.id))}dispose(){super.dispose();for(let[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.element.remove(),this.paneview.dispose()}},RKe=class extends jV{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){let e=typeof this._minimumSize==`function`?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){let e=typeof this._maximumSize==`function`?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}constructor(e,t){super(e,t,new AV(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=1/0,this._minimumSize=0,this._maximumSize=1/0,this._snap=!1,this._onDidChange=new Q,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onActiveChange(()=>{let{accessor:e}=this._params;e.setActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{(typeof e.minimumSize==`number`||typeof e.minimumSize==`function`)&&(this._minimumSize=e.minimumSize),(typeof e.maximumSize==`number`||typeof e.maximumSize==`function`)&&(this._maximumSize=e.maximumSize),this.updateConstraints()}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(e,t){let[n,r]=this.orientation===UB.HORIZONTAL?[e,t]:[t,e];super.layout(n,r)}init(e){super.init(e),this._priority=e.priority,e.minimumSize&&(this._minimumSize=e.minimumSize),e.maximumSize&&(this._maximumSize=e.maximumSize),e.snap&&(this._snap=e.snap)}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{minimumSize:(e=>e<=0?void 0:e)(this.minimumSize),maximumSize:(e=>e===2**53-1||e===1/0?void 0:e)(this.maximumSize)})}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}};function zKe(e,t){return new NKe(e,t).api}function BKe(e,t){return new uV(new FKe(e,t))}function VKe(e,t){return new fV(new PKe(e,t))}function HKe(e,t){return new dV(new LKe(e,t))}var UKe=class{constructor(e){this._host=e}attachToGroup(e){return new fB(e.model.onDidCreateTabGroup(e=>{this._host.fireDidCreateTabGroup(e)}),e.model.onDidDestroyTabGroup(e=>{this._host.fireDidDestroyTabGroup(e)}),e.model.onDidAddPanelToTabGroup(e=>{this._host.fireDidAddPanelToTabGroup(e)}),e.model.onDidRemovePanelFromTabGroup(e=>{this._host.fireDidRemovePanelFromTabGroup(e)}),e.model.onDidTabGroupChange(e=>{this._host.fireDidTabGroupChange(e)}),e.model.onDidTabGroupCollapsedChange(e=>{this._host.fireDidTabGroupCollapsedChange(e)}))}dispose(){}},WKe=oH({name:`TabGroupChips`,serviceKey:`tabGroupChipsService`,create:e=>new UKe(e),init:(e,t)=>{let n=new Map;return new fB(e.onDidAddGroup(e=>{n.set(e,t.attachToGroup(e))}),e.onDidRemoveGroup(e=>{var t;(t=n.get(e))==null||t.dispose(),n.delete(e)}),{dispose:()=>{for(let e of n.values())e.dispose();n.clear()}})}});function kH(e){if(!(e instanceof HTMLElement))return;let t=PB(e);return t?.style.zIndex?`calc(${t.style.zIndex} * 2)`:void 0}var GKe=0,KKe=()=>`dv-ctx-menu-item-${GKe++}`;function AH(e){return typeof e==`object`}function jH(e,t,n,r){let i=document.createElement(`div`);return i.className=`dv-context-menu-item`,i.setAttribute(`role`,`menuitem`),r&&(i.classList.add(`dv-context-menu-item--disabled`),i.setAttribute(`aria-disabled`,`true`)),i.textContent=e,r||i.addEventListener(`click`,()=>{n(),t()}),i}function MH(){let e=document.createElement(`div`);return e.className=`dv-context-menu-separator`,e.setAttribute(`role`,`separator`),e}function qKe(){if(typeof window>`u`||!window.matchMedia)return!1;let e=window.matchMedia(`(pointer: coarse)`).matches,t=window.matchMedia(`(pointer: fine)`).matches;return e&&!t}function JKe(e){let t=document.createElement(`div`);t.className=`dv-context-menu-rename`;let n=document.createElement(`input`);return n.className=`dv-context-menu-rename-input`,n.type=`text`,n.placeholder=`Name This Group`,n.value=e.label,n.addEventListener(`input`,()=>{e.setLabel(n.value)}),n.addEventListener(`keydown`,e=>{e.key!==`Escape`&&e.key!==`Enter`&&e.stopPropagation()}),n.addEventListener(`click`,e=>{e.stopPropagation()}),t.appendChild(n),qKe()||requestAnimationFrame(()=>{n.focus(),n.select()}),t}function YKe(e,t){let n=document.createElement(`div`);if(n.className=`dv-context-menu-color-picker`,!t.enabled)return n;for(let r of t.entries()){let t=document.createElement(`div`);t.className=`dv-context-menu-color-swatch`,t.style.setProperty(`--dv-tab-group-color`,r.value),r.label&&(t.title=r.label),e.color===r.id&&t.classList.add(`dv-context-menu-color-swatch--selected`),t.addEventListener(`click`,()=>{e.setColor(r.id)}),n.appendChild(t)}return n}var XKe=class{constructor(e){this.accessor=e}show(e,t,n){var r;if(!this.accessor.options.getTabContextMenuItems)return;let i=this.accessor.options.getTabContextMenuItems({panel:e,group:t,api:this.accessor.api,event:n});if(i.length===0)return;n.preventDefault();let a=this.accessor.getPopupServiceForGroup(t),o=()=>a.close(),s=document.createElement(`div`);s.className=`dv-context-menu`,s.setAttribute(`role`,`menu`);for(let n of i)if(n===`separator`)s.appendChild(MH());else if(n===`close`)s.appendChild(jH(`Close`,o,()=>e.api.close()));else if(n===`closeOthers`)s.appendChild(jH(`Close Others`,o,()=>{t.panels.filter(t=>t!==e).forEach(e=>e.api.close())}));else if(n===`closeAll`)s.appendChild(jH(`Close All`,o,()=>{[...t.panels].forEach(e=>e.api.close())}));else if(AH(n)&&n.element)s.appendChild(n.element);else if(AH(n)&&n.component){let i=(r=this.accessor.options).createContextMenuItemComponent?.call(r,{id:KKe(),component:n.component});i&&(i.init({panel:e,group:t,api:this.accessor.api,close:o,componentProps:n.componentProps}),s.appendChild(i.element))}else AH(n)&&n.label&&s.appendChild(jH(n.label,o,()=>n.action?.call(n),n.disabled));a.openPopover(s,{x:n.clientX,y:n.clientY,zIndex:kH(n.target)})}showForChip(e,t,n){if(!this.accessor.options.getTabGroupChipContextMenuItems)return;let r=this.accessor.options.getTabGroupChipContextMenuItems({tabGroup:e,group:t,api:this.accessor.api,event:n});if(r.length===0)return;n.preventDefault();let i=this.accessor.getPopupServiceForGroup(t),a=()=>i.close(),o=document.createElement(`div`);o.className=`dv-context-menu`,o.setAttribute(`role`,`menu`);for(let t of r)t===`separator`?o.appendChild(MH()):t===`rename`?o.appendChild(JKe(e)):t===`colorPicker`?o.appendChild(YKe(e,this.accessor.tabGroupColorPalette)):AH(t)&&t.element?o.appendChild(t.element):AH(t)&&t.label&&o.appendChild(jH(t.label,a,()=>t.action?.call(t),t.disabled));i.openPopover(o,{x:n.clientX,y:n.clientY,zIndex:kH(n.target)})}},ZKe=oH({name:`ContextMenu`,serviceKey:`contextMenuService`,create:e=>new XKe(e)}),QKe=30,$Ke=-10,eqe=class{constructor(e){this.host=e}dispatchWillDragPanel(e){this.host.fireWillDragPanel(e)}dispatchWillDragGroup(e){this.host.fireWillDragGroup(e)}dispatchWillDrop(e){this.host.fireWillDrop(e)}dispatchWillShowOverlay(e){this.host.fireWillShowOverlay(e)}buildGroupDragGhost(e){let t=this.host.options.createGroupDragGhostComponent;if(!t)return;let n=t(e);return n.init({group:e,api:this.host.api}),{element:n.element,offsetX:QKe,offsetY:$Ke,dispose:n.dispose?()=>n.dispose?.call(n):void 0}}resolveOverlayModel(e,t){var n;return(n=this.host.options).dropOverlayModel?.call(n,{location:e,group:t})}showPreviewOverlay(e,t){let n=e.model.contentDropTarget;return n.showOverlay(t),dB.from(()=>n.clearOverlay())}dispose(){}},NH=oH({name:`AdvancedDnD`,serviceKey:`advancedDnDService`,create:e=>new eqe(e)}),PH=`data-dv-kbd-moving`;function FH(e,t){let n=t.toLowerCase().split(`+`),r=n[n.length-1],i=n.slice(0,-1);return e.ctrlKey===i.includes(`ctrl`)&&e.shiftKey===i.includes(`shift`)&&e.altKey===i.includes(`alt`)&&e.metaKey===(i.includes(`meta`)||i.includes(`cmd`))&&e.key.toLowerCase()===r}function IH(e){let t=e.keyboardNavigation;if(t)return t===!0?{}:t}var tqe={nextTab:`ctrl+]`,prevTab:`ctrl+[`,focusNextGroup:`f6`,focusPrevGroup:`shift+f6`,focusTabs:`ctrl+shift+\\`},nqe=class extends fB{constructor(e){super(),this.host=e,this._focusWasInside=!1;let t=e.rootElement.ownerDocument,n=e=>this._onKeyDown(e);t.addEventListener(`keydown`,n,!0);let r=e=>{let t=e.target;t instanceof HTMLElement&&this.host.rootElement.contains(t)&&!t.closest(`[role="dialog"]`)&&(this._lastNonFloatFocus=t)};t.addEventListener(`focusin`,r,!0);let i=e=>this._onFloatingEscape(e);t.addEventListener(`keydown`,i,!1),this.addDisposables({dispose:()=>t.removeEventListener(`keydown`,n,!0)},{dispose:()=>t.removeEventListener(`focusin`,r,!0)},{dispose:()=>t.removeEventListener(`keydown`,i,!1)},e.onWillMutateLayout(e=>{e.kind===`remove`&&this._nav&&(this._focusWasInside=this._isFocusInside())}),e.onDidMutateLayout(e=>{e.kind===`remove`&&this._nav&&this._focusWasInside&&!this._isFocusInside()&&this._restoreFocus()}))}get _moveActive(){return this.host.rootElement.hasAttribute(PH)}_isFocusInside(){let e=this.host.rootElement.ownerDocument.activeElement;return e instanceof Node&&this.host.rootElement.contains(e)}_onFloatingEscape(e){if(!this._nav||this._moveActive||e.defaultPrevented||e.key!==`Escape`)return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[role="dialog"]`);!n||!this.host.rootElement.contains(n)||(e.preventDefault(),e.stopPropagation(),this._returnFocusFromFloat())}_trapFloatTab(e){let t=e.target;if(!(t instanceof Element))return!1;let n=t.closest(`[role="dialog"]`);if(!n||!this.host.rootElement.contains(n))return!1;e.preventDefault();let r=this._tabbables(n);if(r.length===0)return!0;let i=n.ownerDocument.activeElement,a=i instanceof HTMLElement?r.indexOf(i):-1,o=r.length;return r[a===-1?e.shiftKey?o-1:0:(a+(e.shiftKey?-1:1)+o)%o].focus(),!0}_tabbables(e){let t=e.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]`);return Array.from(t).filter(e=>e.tabIndex>=0)}_returnFocusFromFloat(){var e;let t=this._lastNonFloatFocus;if(t&&t.isConnected&&this.host.rootElement.contains(t)&&!t.closest(`[role="dialog"]`)){t.focus();return}(e=this.host.groups.find(e=>e.api.location.type===`grid`))==null||e.model.focusContent()}get _nav(){return IH(this.host.options)}get _keymap(){return Object.assign(Object.assign({},tqe),this._nav?.keymap)}_onKeyDown(e){if(!this._nav||this._moveActive||!(e.target instanceof Node)||!this.host.rootElement.contains(e.target)||e.key===`Tab`&&this._trapFloatTab(e))return;let t=this._keymap;FH(e,t.nextTab)?(this._consume(e),this._switchTab(!1)):FH(e,t.prevTab)?(this._consume(e),this._switchTab(!0)):FH(e,t.focusNextGroup)?(this._consume(e),this._cycleGroup(!1)):FH(e,t.focusPrevGroup)?(this._consume(e),this._cycleGroup(!0)):FH(e,t.focusTabs)&&(this._consume(e),this._focusTabs())}_focusTabs(){var e;(e=this.host.activeGroup)==null||e.model.focusActiveTab()}_switchTab(e){let t=this.host.activeGroup;t&&(e?t.model.moveToPrevious():t.model.moveToNext(),t.model.focusContent())}_cycleGroup(e){let t=this.host.activeGroup,n=t?this.host.adjacentGroup(t,e):this.host.groups[0];this._focusGroup(n)}_focusGroup(e){e&&(e.api.setActive(),e.model.focusContent())}_restoreFocus(){var e;(e=this.host.activeGroup)==null||e.model.focusContent()}_consume(e){e.preventDefault(),e.stopPropagation()}},rqe=oH({name:`Accessibility`,serviceKey:`accessibilityService`,create:e=>new nqe(e)}),iqe={ArrowLeft:`left`,ArrowRight:`right`,ArrowUp:`top`,ArrowDown:`bottom`},LH={focusGroupLeft:`ctrl+shift+arrowleft`,focusGroupRight:`ctrl+shift+arrowright`,focusGroupUp:`ctrl+shift+arrowup`,focusGroupDown:`ctrl+shift+arrowdown`,dock:`ctrl+m`},aqe=class extends fB{constructor(e){super(),this.host=e,this._move=null;let t=e.rootElement.ownerDocument,n=e=>this._onKeyDown(e);t.addEventListener(`keydown`,n,!0),this.addDisposables({dispose:()=>this._exit()},{dispose:()=>t.removeEventListener(`keydown`,n,!0)})}get _enabled(){return!!IH(this.host.options)}get _keymap(){let e=IH(this.host.options)?.keymap??{};return{focusGroupLeft:e.focusGroupLeft??LH.focusGroupLeft,focusGroupRight:e.focusGroupRight??LH.focusGroupRight,focusGroupUp:e.focusGroupUp??LH.focusGroupUp,focusGroupDown:e.focusGroupDown??LH.focusGroupDown,dock:e.dock??LH.dock}}get _messages(){return hH(this.host.options.messages)}_onKeyDown(e){if(!this._enabled)return;if(this._move){this._onMoveKey(e);return}if(!(e.target instanceof Node)||!this.host.rootElement.contains(e.target))return;let t=this._keymap;FH(e,t.dock)?this._enterMoveMode(e):FH(e,t.focusGroupLeft)?(this._consume(e),this._focusGroupInDirection(`left`)):FH(e,t.focusGroupRight)?(this._consume(e),this._focusGroupInDirection(`right`)):FH(e,t.focusGroupUp)?(this._consume(e),this._focusGroupInDirection(`up`)):FH(e,t.focusGroupDown)&&(this._consume(e),this._focusGroupInDirection(`down`))}_focusGroupInDirection(e){let t=this.host.activeGroup;t&&this._focusGroup(this.host.adjacentGroupInDirection(t,e))}_focusGroup(e){e&&(e.api.setActive(),e.model.focusContent())}_restoreFocus(){var e;(e=this.host.activeGroup)==null||e.model.focusContent()}_enterMoveMode(e){let t=this.host.activePanel,n=this.host.groups;if(!t||n.length===0)return;e.preventDefault(),e.stopPropagation();let r=Math.max(0,n.indexOf(t.group));this._move={source:t,groups:n,groupIndex:r,phase:`target`,position:`center`},this.host.rootElement.setAttribute(PH,``),this._render()}_onMoveKey(e){let t=this._move;if(e.key===`Escape`){this._consume(e),t.phase===`edge`?(t.phase=`target`,t.position=`center`,this._render()):(this._exit(),this.host.announce(this._messages.moveCancelled()),this._restoreFocus());return}if(e.key===`Enter`){this._consume(e),t.phase===`target`?(t.phase=`edge`,t.position=`center`,this._render()):this._commit();return}if(t.phase===`target`){let n=t.groups.length;e.key===`ArrowRight`||e.key===`ArrowDown`?(this._consume(e),t.groupIndex=(t.groupIndex+1)%n,this._render()):(e.key===`ArrowLeft`||e.key===`ArrowUp`)&&(this._consume(e),t.groupIndex=(t.groupIndex-1+n)%n,this._render());return}let n=iqe[e.key];n?(this._consume(e),t.position=n,this._render()):(e.key===` `||e.key===`c`||e.key===`C`)&&(this._consume(e),t.position=`center`,this._render())}_render(){let e=this._move,t=e.groups[e.groupIndex];this._clearPreview(),this._preview=this.host.showDropPreview(t,e.position);let n=t.activePanel?.title??t.id,r=this._messages;e.phase===`target`?this.host.announce(r.movePickTarget(this._label(e.source),n,e.groupIndex+1,e.groups.length)):this.host.announce(r.movePickEdge(e.position,n))}_commit(){let e=this._move,t=e.groups[e.groupIndex],n=e.position,r=e.source,i=t.activePanel?.title??t.id,a=this._messages;this._exit();try{this.host.dockPanel(r,t,n),this.host.announce(a.moveCommitted(this._label(r),i,n))}catch{this.host.announce(a.moveNotAllowed())}this._restoreFocus()}_exit(){this._clearPreview(),this._move=null,this.host.rootElement.removeAttribute(PH)}_clearPreview(){var e;(e=this._preview)==null||e.dispose(),this._preview=void 0}_consume(e){e.preventDefault(),e.stopPropagation()}_label(e){return e.title??e.id}};oH({name:`KeyboardDocking`,serviceKey:`keyboardDockingService`,create:e=>new aqe(e),dependsOn:[NH,vH]}),XGe([WKe,ZKe,NH,rqe]),QGe();var RH=(e,t)=>{let[,n]=I.useState(0),r=I.useRef(e.componentProps);return I.useImperativeHandle(t,()=>({update:e=>{r.current=Object.assign(Object.assign({},r.current),e),n(e=>e+1)}}),[]),I.createElement(e.component,r.current)};RH.displayName=`DockviewReactJsBridge`;var oqe=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),sqe=I.createContext({}),zH=class{constructor(e,t,n,r,i){this.parent=e,this.portalStore=t,this.component=n,this.parameters=r,this.context=i,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw Error(`invalid operation: resource is already disposed`);this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw Error(`invalid operation: resource is already disposed`);if(!cqe(this.component))throw Error(`Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components`);let e=I.createElement(I.forwardRef(RH),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?I.createElement(sqe.Provider,{value:this.context},e):e,n=Pn.createPortal(t,this.parent,oqe.next());this.ref={portal:n,disposable:this.portalStore.addPortal(n)}}dispose(){var e;(e=this.ref)==null||e.disposable.dispose(),this.disposed=!0}},BH=()=>{let[e,t]=I.useState([]);return I.useDebugValue(`Portal count: ${e.length}`),[e,I.useCallback(e=>{t(t=>[...t,e]);let n=!1;return dB.from(()=>{if(n)throw Error(`invalid operation: resource already disposed`);n=!0,t(t=>t.filter(t=>t!==e))})},[])]};function cqe(e){return typeof e==`function`||!!e?.$$typeof}var VH=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._onDidFocus=new Q,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new Q,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}focus(){}init(e){this.part=new zH(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;(t=this.part)==null||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),(e=this.part)==null||e.dispose()}},HH=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}focus(){}init(e){this.part=new zH(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;(t=this.part)==null||t.update({params:e.params})}layout(e,t){}dispose(){var e;(e=this.part)==null||e.dispose()}},UH=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new zH(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t;this.parameters&&(this.parameters.params=e.params),(t=this.part)==null||t.update({params:this.parameters?.params??{}})}layout(e,t){}dispose(){var e;(e=this.part)==null||e.dispose()}},lqe=class{get element(){return this._element}get part(){return this._part}constructor(e,t,n){this.component=e,this.reactPortalStore=t,this._group=n,this.mutableDisposable=new pB,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.mutableDisposable.value=new fB(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()}),e.api.onDidLocationChange(e=>{this.updateLocation(e.location)})),this._part=new zH(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:e.api.location})}dispose(){var e;this.mutableDisposable.dispose(),(e=this._part)==null||e.dispose()}update(e){var t;(t=this._part)==null||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}},uqe=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new zH(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;(e=this.part)==null||e.dispose()}},WH=class{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.display=`inline-flex`}init(e){this.part=new zH(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;(t=this.part)==null||t.update({tabGroup:e.tabGroup})}dispose(){var e;(e=this.part)==null||e.dispose()}},GH=class{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.display=`inline-flex`}init(e){this.part=new zH(this._element,this.reactPortalStore,this.component,{group:e.group,api:e.api})}dispose(){var e;(e=this.part)==null||e.dispose()}};function KH(e,t){return e?n=>new lqe(e,t,n):void 0}var qH=`props.defaultTabComponent`;function dqe(e){return JV.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var JH=I.forwardRef((e,t)=>{let n=I.useRef(null),r=I.useRef(void 0),[i,a]=BH();I.useImperativeHandle(t,()=>n.current,[]);let o=I.useRef({});return I.useEffect(()=>{let t={};JV.forEach(n=>{let r=n,i=e[r];r in e&&i!==o.current[r]&&(t[r]=i)}),r.current&&r.current.updateOptions(t),o.current=e},JV.map(t=>e[t])),I.useEffect(()=>{if(!n.current)return;let t=e.tabComponents??{};e.defaultTabComponent&&(t[qH]=e.defaultTabComponent);let i={createLeftHeaderActionComponent:KH(e.leftHeaderActionsComponent,{addPortal:a}),createRightHeaderActionComponent:KH(e.rightHeaderActionsComponent,{addPortal:a}),createPrefixHeaderActionComponent:KH(e.prefixHeaderActionsComponent,{addPortal:a}),createComponent:t=>new VH(t.id,e.components[t.name],{addPortal:a}),createTabComponent(e){return new HH(e.id,t[e.name],{addPortal:a})},createWatermarkComponent:e.watermarkComponent?()=>new UH(`watermark`,e.watermarkComponent,{addPortal:a}):void 0,defaultTabComponent:e.defaultTabComponent?qH:void 0,createContextMenuItemComponent:e=>{if(e.component)return new uqe(e.id,e.component,{addPortal:a})}},o=dqe(e);if(e.tabGroupChipComponent){let t=e.tabGroupChipComponent;o.createTabGroupChipComponent=()=>new WH(t,{addPortal:a})}if(e.groupDragGhostComponent){let t=e.groupDragGhostComponent;o.createGroupDragGhostComponent=()=>new GH(t,{addPortal:a})}let s=zKe(n.current,Object.assign(Object.assign({},o),i)),{clientWidth:c,clientHeight:l}=n.current;return s.layout(c,l),e.onReady&&e.onReady({api:s}),r.current=s,()=>{r.current=void 0,s.dispose()}},[]),I.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),I.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onWillDrop(t=>{e.onWillDrop&&e.onWillDrop(t)});return()=>{t.dispose()}},[e.onWillDrop]),I.useEffect(()=>{r.current&&r.current.updateOptions({createTabGroupChipComponent:e.tabGroupChipComponent?()=>new WH(e.tabGroupChipComponent,{addPortal:a}):void 0})},[e.tabGroupChipComponent]),I.useEffect(()=>{r.current&&r.current.updateOptions({createGroupDragGhostComponent:e.groupDragGhostComponent?()=>new GH(e.groupDragGhostComponent,{addPortal:a}):void 0})},[e.groupDragGhostComponent]),I.useEffect(()=>{r.current&&r.current.updateOptions({createComponent:t=>new VH(t.id,e.components[t.name],{addPortal:a})})},[e.components]),I.useEffect(()=>{if(!r.current)return;let t=e.tabComponents??{};e.defaultTabComponent&&(t[qH]=e.defaultTabComponent),r.current.updateOptions({defaultTabComponent:e.defaultTabComponent?qH:void 0,createTabComponent(e){return new HH(e.id,t[e.name],{addPortal:a})}})},[e.tabComponents,e.defaultTabComponent]),I.useEffect(()=>{r.current&&r.current.updateOptions({createWatermarkComponent:e.watermarkComponent?()=>new UH(`watermark`,e.watermarkComponent,{addPortal:a}):void 0})},[e.watermarkComponent]),I.useEffect(()=>{r.current&&r.current.updateOptions({createRightHeaderActionComponent:KH(e.rightHeaderActionsComponent,{addPortal:a})})},[e.rightHeaderActionsComponent]),I.useEffect(()=>{r.current&&r.current.updateOptions({createLeftHeaderActionComponent:KH(e.leftHeaderActionsComponent,{addPortal:a})})},[e.leftHeaderActionsComponent]),I.useEffect(()=>{r.current&&r.current.updateOptions({createPrefixHeaderActionComponent:KH(e.prefixHeaderActionsComponent,{addPortal:a})})},[e.prefixHeaderActionsComponent]),I.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});JH.displayName=`DockviewComponent`;var YH=class extends RKe{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){return new zH(this.element,this.reactPortalStore,this.reactComponent,{params:this._params?.params??{},api:this.api,containerApi:new uV(this._params.accessor)})}};function fqe(e){return JB.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var pqe=I.forwardRef((e,t)=>{let n=I.useRef(null),r=I.useRef(void 0),[i,a]=BH();I.useImperativeHandle(t,()=>n.current,[]);let o=I.useRef({});return I.useEffect(()=>{let t={};JB.forEach(n=>{let r=n,i=e[r];r in e&&i!==o.current[r]&&(t[r]=i)}),r.current&&r.current.updateOptions(t),o.current=e},JB.map(t=>e[t])),I.useEffect(()=>{if(!n.current)return()=>{};let t=BKe(n.current,Object.assign(Object.assign({},fqe(e)),{createComponent:t=>new YH(t.id,t.name,e.components[t.name],{addPortal:a})})),{clientWidth:i,clientHeight:o}=n.current;return t.layout(i,o),e.onReady&&e.onReady({api:t}),r.current=t,()=>{r.current=void 0,t.dispose()}},[]),I.useEffect(()=>{r.current&&r.current.updateOptions({createComponent:t=>new YH(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),I.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});pqe.displayName=`SplitviewComponent`;var XH=class extends QV{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){return new zH(this.element,this.reactPortalStore,this.reactComponent,{params:this._params?.params??{},api:this.api,containerApi:new fV(this._params.accessor)})}};function mqe(e){return oV.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var hqe=I.forwardRef((e,t)=>{let n=I.useRef(null),r=I.useRef(void 0),[i,a]=BH();I.useImperativeHandle(t,()=>n.current,[]);let o=I.useRef({});return I.useEffect(()=>{let t={};oV.forEach(n=>{let r=n,i=e[r];r in e&&i!==o.current[r]&&(t[r]=i)}),r.current&&r.current.updateOptions(t),o.current=e},oV.map(t=>e[t])),I.useEffect(()=>{if(!n.current)return()=>{};let t=VKe(n.current,Object.assign(Object.assign({},mqe(e)),{createComponent:t=>new XH(t.id,t.name,e.components[t.name],{addPortal:a})})),{clientWidth:i,clientHeight:o}=n.current;return t.layout(i,o),e.onReady&&e.onReady({api:t}),r.current=t,()=>{r.current=void 0,t.dispose()}},[]),I.useEffect(()=>{r.current&&r.current.updateOptions({createComponent:t=>new XH(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),I.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});hqe.displayName=`GridviewComponent`;var ZH=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new zH(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;(t=this.part)==null||t.update(e.params)}dispose(){var e;(e=this.part)==null||e.dispose()}};function gqe(e){return DV.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var _qe=I.forwardRef((e,t)=>{let n=I.useRef(null),r=I.useRef(void 0),[i,a]=BH();I.useImperativeHandle(t,()=>n.current,[]);let o=I.useRef({});return I.useEffect(()=>{let t={};DV.forEach(n=>{let r=n,i=e[r];r in e&&i!==o.current[r]&&(t[r]=i)}),r.current&&r.current.updateOptions(t),o.current=e},DV.map(t=>e[t])),I.useEffect(()=>{if(!n.current)return()=>{};let t=e.headerComponents??{},i=HKe(n.current,Object.assign(Object.assign({},gqe(e)),{createComponent:t=>new ZH(t.id,e.components[t.name],{addPortal:a}),createHeaderComponent:e=>new ZH(e.id,t[e.name],{addPortal:a})})),{clientWidth:o,clientHeight:s}=n.current;return i.layout(o,s),e.onReady&&e.onReady({api:i}),r.current=i,()=>{r.current=void 0,i.dispose()}},[]),I.useEffect(()=>{r.current&&r.current.updateOptions({createComponent:t=>new ZH(t.id,e.components[t.name],{addPortal:a})})},[e.components]),I.useEffect(()=>{if(!r.current)return;let t=e.headerComponents??{};r.current.updateOptions({createHeaderComponent:e=>new ZH(e.id,t[e.name],{addPortal:a})})},[e.headerComponents]),I.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),I.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});_qe.displayName=`PaneviewComponent`;var QH=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},vqe=(e=>e?QH(e):QH),yqe=e=>e;function $H(e,t=yqe){let n=I.useSyncExternalStore(e.subscribe,I.useCallback(()=>t(e.getState()),[e,t]),I.useCallback(()=>t(e.getInitialState()),[e,t]));return I.useDebugValue(n),n}var eU=e=>{let t=vqe(e),n=e=>$H(t,e);return Object.assign(n,t),n},bqe=(e=>e?eU(e):eU),tU=null;function nU(e){tU=e}function rU(){if(!tU)throw Error(`Workspace store not initialized. Wrap your app in WorkspaceProvider.`);return tU}function xqe(){return $H(rU(),e=>e.activeFile)}function Sqe(){return $H(rU(),e=>e.activePanel)}function iU(){return $H(rU(),e=>e.sidebar)}function aU(){return $H(rU(),e=>e.setSidebar)}function Cqe(){return $H(rU(),e=>e.panels)}function wqe(){return $H(rU(),e=>e.dirtyFiles)}function oU(){return $H(rU(),e=>e.preferences.theme)}function sU(){return $H(rU(),e=>e.hydrationComplete)}function Tqe(){return $H(rU(),e=>e.resetLayout)}var cU=`-`,Eqe=e=>{let t=Oqe(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{let n=e.split(cU);return n[0]===``&&n.length!==1&&n.shift(),lU(n,t)||Dqe(e)},getConflictingClassGroupIds:(e,t)=>{let i=n[e]||[];return t&&r[e]?[...i,...r[e]]:i}}},lU=(e,t)=>{if(e.length===0)return t.classGroupId;let n=e[0],r=t.nextPart.get(n),i=r?lU(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;let a=e.join(cU);return t.validators.find(({validator:e})=>e(a))?.classGroupId},uU=/^\[(.+)\]$/,Dqe=e=>{if(uU.test(e)){let t=uU.exec(e)[1],n=t?.substring(0,t.indexOf(`:`));if(n)return`arbitrary..`+n}},Oqe=e=>{let{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return Aqe(Object.entries(e.classGroups),n).forEach(([e,n])=>{dU(n,r,e,t)}),r},dU=(e,t,n,r)=>{e.forEach(e=>{if(typeof e==`string`){let r=e===``?t:fU(t,e);r.classGroupId=n;return}if(typeof e==`function`){if(kqe(e)){dU(e(r),t,n,r);return}t.validators.push({validator:e,classGroupId:n});return}Object.entries(e).forEach(([e,i])=>{dU(i,fU(t,e),n,r)})})},fU=(e,t)=>{let n=e;return t.split(cU).forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},kqe=e=>e.isThemeGetter,Aqe=(e,t)=>t?e.map(([e,n])=>[e,n.map(e=>typeof e==`string`?t+e:typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,n])=>[t+e,n])):e)]):e,jqe=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=new Map,r=new Map,i=(i,a)=>{n.set(i,a),t++,t>e&&(t=0,r=n,n=new Map)};return{get(e){let t=n.get(e);if(t!==void 0)return t;if((t=r.get(e))!==void 0)return i(e,t),t},set(e,t){n.has(e)?n.set(e,t):i(e,t)}}},pU=`!`,Mqe=e=>{let{separator:t,experimentalParseClassName:n}=e,r=t.length===1,i=t[0],a=t.length,o=e=>{let n=[],o=0,s=0,c;for(let l=0;l<e.length;l++){let u=e[l];if(o===0){if(u===i&&(r||e.slice(l,l+a)===t)){n.push(e.slice(s,l)),s=l+a;continue}if(u===`/`){c=l;continue}}u===`[`?o++:u===`]`&&o--}let l=n.length===0?e:e.substring(s),u=l.startsWith(pU);return{modifiers:n,hasImportantModifier:u,baseClassName:u?l.substring(1):l,maybePostfixModifierPosition:c&&c>s?c-s:void 0}};return n?e=>n({className:e,parseClassName:o}):o},Nqe=e=>{if(e.length<=1)return e;let t=[],n=[];return e.forEach(e=>{e[0]===`[`?(t.push(...n.sort(),e),n=[]):n.push(e)}),t.push(...n.sort()),t},Pqe=e=>({cache:jqe(e.cacheSize),parseClassName:Mqe(e),...Eqe(e)}),Fqe=/\s+/,Iqe=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,a=[],o=e.trim().split(Fqe),s=``;for(let e=o.length-1;e>=0;--e){let t=o[e],{modifiers:c,hasImportantModifier:l,baseClassName:u,maybePostfixModifierPosition:d}=n(t),f=!!d,p=r(f?u.substring(0,d):u);if(!p){if(!f){s=t+(s.length>0?` `+s:s);continue}if(p=r(u),!p){s=t+(s.length>0?` `+s:s);continue}f=!1}let m=Nqe(c).join(`:`),h=l?m+pU:m,g=h+p;if(a.includes(g))continue;a.push(g);let _=i(p,f);for(let e=0;e<_.length;++e){let t=_[e];a.push(h+t)}s=t+(s.length>0?` `+s:s)}return s};function Lqe(){let e=0,t,n,r=``;for(;e<arguments.length;)(t=arguments[e++])&&(n=mU(t))&&(r&&(r+=` `),r+=n);return r}var mU=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=mU(e[r]))&&(n&&(n+=` `),n+=t);return n};function Rqe(e,...t){let n,r,i,a=o;function o(o){return n=Pqe(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)}function s(e){let t=r(e);if(t)return t;let a=Iqe(e,n);return i(e,a),a}return function(){return a(Lqe.apply(null,arguments))}}var hU=e=>{let t=t=>t[e]||[];return t.isThemeGetter=!0,t},gU=/^\[(?:([a-z-]+):)?(.+)\]$/i,zqe=/^\d+\/\d+$/,Bqe=new Set([`px`,`full`,`screen`]),Vqe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Hqe=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Uqe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Wqe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Gqe=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_U=e=>yU(e)||Bqe.has(e)||zqe.test(e),vU=e=>TU(e,`length`,$qe),yU=e=>!!e&&!Number.isNaN(Number(e)),bU=e=>TU(e,`number`,yU),xU=e=>!!e&&Number.isInteger(Number(e)),Kqe=e=>e.endsWith(`%`)&&yU(e.slice(0,-1)),SU=e=>gU.test(e),CU=e=>Vqe.test(e),qqe=new Set([`length`,`size`,`percentage`]),Jqe=e=>TU(e,qqe,EU),Yqe=e=>TU(e,`position`,EU),Xqe=new Set([`image`,`url`]),Zqe=e=>TU(e,Xqe,tJe),Qqe=e=>TU(e,``,eJe),wU=()=>!0,TU=(e,t,n)=>{let r=gU.exec(e);return r?r[1]?typeof t==`string`?r[1]===t:t.has(r[1]):n(r[2]):!1},$qe=e=>Hqe.test(e)&&!Uqe.test(e),EU=()=>!1,eJe=e=>Wqe.test(e),tJe=e=>Gqe.test(e),nJe=Rqe(()=>{let e=hU(`colors`),t=hU(`spacing`),n=hU(`blur`),r=hU(`brightness`),i=hU(`borderColor`),a=hU(`borderRadius`),o=hU(`borderSpacing`),s=hU(`borderWidth`),c=hU(`contrast`),l=hU(`grayscale`),u=hU(`hueRotate`),d=hU(`invert`),f=hU(`gap`),p=hU(`gradientColorStops`),m=hU(`gradientColorStopPositions`),h=hU(`inset`),g=hU(`margin`),_=hU(`opacity`),v=hU(`padding`),y=hU(`saturate`),b=hU(`scale`),x=hU(`sepia`),S=hU(`skew`),C=hU(`space`),w=hU(`translate`),T=()=>[`auto`,`contain`,`none`],E=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],D=()=>[`auto`,SU,t],O=()=>[SU,t],k=()=>[``,_U,vU],A=()=>[`auto`,yU,SU],ee=()=>[`bottom`,`center`,`left`,`left-bottom`,`left-top`,`right`,`right-bottom`,`right-top`,`top`],te=()=>[`solid`,`dashed`,`dotted`,`double`,`none`],ne=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],j=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`],M=()=>[``,`0`,SU],N=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],re=()=>[yU,SU];return{cacheSize:500,separator:`:`,theme:{colors:[wU],spacing:[_U,vU],blur:[`none`,``,CU,SU],brightness:re(),borderColor:[e],borderRadius:[`none`,``,`full`,CU,SU],borderSpacing:O(),borderWidth:k(),contrast:re(),grayscale:M(),hueRotate:re(),invert:M(),gap:O(),gradientColorStops:[e],gradientColorStopPositions:[Kqe,vU],inset:D(),margin:D(),opacity:re(),padding:O(),saturate:re(),scale:re(),sepia:M(),skew:re(),space:O(),translate:O()},classGroups:{aspect:[{aspect:[`auto`,`square`,`video`,SU]}],container:[`container`],columns:[{columns:[CU]}],"break-after":[{"break-after":N()}],"break-before":[{"break-before":N()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:[...ee(),SU]}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:[h]}],"inset-x":[{"inset-x":[h]}],"inset-y":[{"inset-y":[h]}],start:[{start:[h]}],end:[{end:[h]}],top:[{top:[h]}],right:[{right:[h]}],bottom:[{bottom:[h]}],left:[{left:[h]}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[`auto`,xU,SU]}],basis:[{basis:D()}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`wrap`,`wrap-reverse`,`nowrap`]}],flex:[{flex:[`1`,`auto`,`initial`,`none`,SU]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:[`first`,`last`,`none`,xU,SU]}],"grid-cols":[{"grid-cols":[wU]}],"col-start-end":[{col:[`auto`,{span:[`full`,xU,SU]},SU]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[wU]}],"row-start-end":[{row:[`auto`,{span:[xU,SU]},SU]}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":[`auto`,`min`,`max`,`fr`,SU]}],"auto-rows":[{"auto-rows":[`auto`,`min`,`max`,`fr`,SU]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:[`normal`,...j()]}],"justify-items":[{"justify-items":[`start`,`end`,`center`,`stretch`]}],"justify-self":[{"justify-self":[`auto`,`start`,`end`,`center`,`stretch`]}],"align-content":[{content:[`normal`,...j(),`baseline`]}],"align-items":[{items:[`start`,`end`,`center`,`baseline`,`stretch`]}],"align-self":[{self:[`auto`,`start`,`end`,`center`,`stretch`,`baseline`]}],"place-content":[{"place-content":[...j(),`baseline`]}],"place-items":[{"place-items":[`start`,`end`,`center`,`baseline`,`stretch`]}],"place-self":[{"place-self":[`auto`,`start`,`end`,`center`,`stretch`]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[C]}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":[C]}],"space-y-reverse":[`space-y-reverse`],w:[{w:[`auto`,`min`,`max`,`fit`,`svw`,`lvw`,`dvw`,SU,t]}],"min-w":[{"min-w":[SU,t,`min`,`max`,`fit`]}],"max-w":[{"max-w":[SU,t,`none`,`full`,`min`,`max`,`fit`,`prose`,{screen:[CU]},CU]}],h:[{h:[SU,t,`auto`,`min`,`max`,`fit`,`svh`,`lvh`,`dvh`]}],"min-h":[{"min-h":[SU,t,`min`,`max`,`fit`,`svh`,`lvh`,`dvh`]}],"max-h":[{"max-h":[SU,t,`min`,`max`,`fit`,`svh`,`lvh`,`dvh`]}],size:[{size:[SU,t,`auto`,`min`,`max`,`fit`]}],"font-size":[{text:[`base`,CU,vU]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`,bU]}],"font-family":[{font:[wU]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`,SU]}],"line-clamp":[{"line-clamp":[`none`,yU,bU]}],leading:[{leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`,_U,SU]}],"list-image":[{"list-image":[`none`,SU]}],"list-style-type":[{list:[`none`,`disc`,`decimal`,SU]}],"list-style-position":[{list:[`inside`,`outside`]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[_]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[_]}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...te(),`wavy`]}],"text-decoration-thickness":[{decoration:[`auto`,`from-font`,_U,vU]}],"underline-offset":[{"underline-offset":[`auto`,_U,SU]}],"text-decoration-color":[{decoration:[e]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:O()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,SU]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,SU]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-opacity":[{"bg-opacity":[_]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:[...ee(),Yqe]}],"bg-repeat":[{bg:[`no-repeat`,{repeat:[``,`x`,`y`,`round`,`space`]}]}],"bg-size":[{bg:[`auto`,`cover`,`contain`,Jqe]}],"bg-image":[{bg:[`none`,{"gradient-to":[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},Zqe]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[s]}],"border-w-x":[{"border-x":[s]}],"border-w-y":[{"border-y":[s]}],"border-w-s":[{"border-s":[s]}],"border-w-e":[{"border-e":[s]}],"border-w-t":[{"border-t":[s]}],"border-w-r":[{"border-r":[s]}],"border-w-b":[{"border-b":[s]}],"border-w-l":[{"border-l":[s]}],"border-opacity":[{"border-opacity":[_]}],"border-style":[{border:[...te(),`hidden`]}],"divide-x":[{"divide-x":[s]}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":[s]}],"divide-y-reverse":[`divide-y-reverse`],"divide-opacity":[{"divide-opacity":[_]}],"divide-style":[{divide:te()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:[``,...te()]}],"outline-offset":[{"outline-offset":[_U,SU]}],"outline-w":[{outline:[_U,vU]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:k()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[_]}],"ring-offset-w":[{"ring-offset":[_U,vU]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:[``,`inner`,`none`,CU,Qqe]}],"shadow-color":[{shadow:[wU]}],opacity:[{opacity:[_]}],"mix-blend":[{"mix-blend":[...ne(),`plus-lighter`,`plus-darker`]}],"bg-blend":[{"bg-blend":ne()}],filter:[{filter:[``,`none`]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":[``,`none`,CU,SU]}],grayscale:[{grayscale:[l]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[y]}],sepia:[{sepia:[x]}],"backdrop-filter":[{"backdrop-filter":[``,`none`]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[l]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[_]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[x]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[`none`,`all`,``,`colors`,`opacity`,`shadow`,`transform`,SU]}],duration:[{duration:re()}],ease:[{ease:[`linear`,`in`,`out`,`in-out`,SU]}],delay:[{delay:re()}],animate:[{animate:[`none`,`spin`,`ping`,`pulse`,`bounce`,SU]}],transform:[{transform:[``,`gpu`,`none`]}],scale:[{scale:[b]}],"scale-x":[{"scale-x":[b]}],"scale-y":[{"scale-y":[b]}],rotate:[{rotate:[xU,SU]}],"translate-x":[{"translate-x":[w]}],"translate-y":[{"translate-y":[w]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:[`center`,`top`,`top-right`,`right`,`bottom-right`,`bottom`,`bottom-left`,`left`,`top-left`,SU]}],accent:[{accent:[`auto`,e]}],appearance:[{appearance:[`none`,`auto`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,SU]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":[`none`,`auto`]}],resize:[{resize:[`none`,`y`,`x`,``]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,SU]}],fill:[{fill:[e,`none`]}],"stroke-w":[{stroke:[_U,vU,bU]}],stroke:[{stroke:[e,`none`]}],sr:[`sr-only`,`not-sr-only`],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-s`,`border-w-e`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-s`,`border-color-e`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]}}});function DU(...e){return nJe(s(e))}function rJe(e){return`api`in e&&e.api?e.api:e}function iJe(e){let t=rJe(e);return{id:t.id??(`id`in e?e.id:void 0),close:t.close?()=>t.close?.():void 0}}function aJe(e){let t=e.api.group?.panels;if(Array.isArray(t))return t;let n=e.containerApi.panels;return Array.isArray(n)?n:[]}function oJe(e,t){if(!e||typeof e!=`object`)return null;let n=e[t];return typeof n==`string`&&n.length>0?n:null}function sJe(e){if(!e)return null;if(e.startsWith(`file:`)){let t=e.slice(5);return t.length>0?t:null}let t=`surface:${iB}:`;if(e.startsWith(t)){let n=e.slice(t.length);return n.length>0?n:null}return null}async function cJe(e){if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(typeof document>`u`)throw Error(`Clipboard not available`);let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.left=`-9999px`,document.body.appendChild(t);let n=!1;try{t.focus(),t.select(),n=document.execCommand?.(`copy`)??!1}finally{t.remove()}if(!n)throw Error(`Clipboard not available`)}function lJe(){typeof document>`u`||document.body.dispatchEvent(new PointerEvent(`pointerdown`,{bubbles:!0,cancelable:!0}))}function uJe(e){let{api:t}=e,n=e.tabLocation===`headerOverflow`,[r,i]=(0,I.useState)(t.title??t.id),[a,o]=(0,I.useState)(null),s=(0,I.useRef)(null);(0,I.useEffect)(()=>{let e=()=>i(t.title??t.id);e();let n=t.onDidTitleChange?.(e);return()=>n?.dispose?.()},[t]),(0,I.useEffect)(()=>{if(!a)return;function e(e){s.current&&!s.current.contains(e.target)&&o(null)}return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]);let c=r.endsWith(` ●`),l=c?r.slice(0,-2):r,u=rB(l),d=oJe(e.params,`path`)??sJe(t.id),f=aJe(e).map(iJe).filter(e=>e.close),p=f.filter(e=>e.id!==t.id),[m,h]=(0,I.useState)(!1);oc(nc.editorSaveStart,e=>{e.panelId===t.id&&h(!0)}),oc(nc.editorSaveEnd,e=>{e.panelId===t.id&&h(!1)});let g=e=>{e.preventDefault(),e.stopPropagation(),n&&e.nativeEvent.stopImmediatePropagation(),t.close(),n&&lJe()},_=e=>{!d&&p.length===0||(e.preventDefault(),e.stopPropagation(),o({x:e.clientX,y:e.clientY}))},v=e=>{o(null),cJe(e)},y=a&&typeof document<`u`?(0,Pn.createPortal)((0,L.jsxs)(`div`,{ref:s,role:`menu`,className:`fixed z-[1000] min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md`,style:{left:a.x,top:a.y},onPointerDown:e=>e.stopPropagation(),onContextMenu:e=>{e.preventDefault(),e.stopPropagation()},children:[d?(0,L.jsx)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center rounded-sm px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground`,onClick:()=>v(d),children:`Copy path`}):null,p.length>0?(0,L.jsx)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center rounded-sm px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground`,onClick:()=>{o(null),t.setActive?.();for(let e of p)e.close?.()},children:`Close other tabs`}):null,f.length>0?(0,L.jsx)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center rounded-sm px-2 py-1.5 text-left text-xs hover:bg-accent hover:text-accent-foreground`,onClick:()=>{o(null),t.setActive?.();for(let e of f)e.close?.()},children:`Close all`}):null]}),document.body):null;return(0,L.jsxs)(I.Fragment,{children:[(0,L.jsxs)(`div`,{className:DU(`group relative flex h-full w-full min-w-0 items-center gap-2 px-3 select-none`,`text-[12.5px] leading-none tracking-tight`,`cursor-pointer transition-colors`),title:c?`${l} (unsaved changes)`:l,onPointerDown:e=>{e.button===2&&_(e)},onContextMenu:_,children:[(0,L.jsx)(u,{className:DU(`h-3.5 w-3.5 shrink-0 text-muted-foreground/70`,`[.dv-active-tab_&]:text-[color:var(--accent)] [.active-tab_&]:text-[color:var(--accent)]`),strokeWidth:1.5}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap`,children:l}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[c||m?(0,L.jsx)(`span`,{"data-testid":`tab-dirty-dot`,"aria-hidden":`true`,className:DU(`h-1.5 w-1.5 shrink-0 rounded-full bg-foreground/35`,`[.dv-active-tab_&]:bg-foreground/45 [.active-tab_&]:bg-foreground/45`)}):null,(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,className:DU(`h-5 w-5 shrink-0 text-muted-foreground/80 opacity-0`,`focus-visible:opacity-100 group-hover:opacity-100`,`[.dv-active-tab_&]:opacity-55 [.active-tab_&]:opacity-55`,`[.dv-active-tab_&]:hover:opacity-100 [.active-tab_&]:hover:opacity-100`),...n?{onClickCapture:g}:{onClick:g},"aria-label":`Close ${l}`,children:(0,L.jsx)(ea,{className:`h-3 w-3`,strokeWidth:2.25})})]})]}),y]})}var dJe=300,OU=(0,I.createContext)(null);function fJe(e,t){if(`id`in t)return e.id===t.id;let n=e.params;if(`paramPrefix`in t){let e=n?.[t.paramPrefix],r=typeof e==`string`&&e.startsWith(t.value),i=!t.params||Object.entries(t.params).every(([e,t])=>n?.[e]===t);return r&&i}return`params`in t?Object.entries(t.params).every(([e,t])=>n?.[e]===t):n?.[t.param]===t.value}function kU(e,t){let n=Array.isArray(t)?t:[t],r=new Set,i=[];for(let t of e.panels)n.some(e=>fJe(t,e))&&(r.has(t.id)||(r.add(t.id),i.push(t)));return i}function pJe(){let e=(0,I.useContext)(OU);if(!e)throw Error(`useDockviewApi must be used within a DockviewShell`);return e}function mJe(e){switch(e){case`left`:return`left`;case`right`:return`right`;case`bottom`:return`below`;default:return`within`}}function hJe(e){function t(){if(!e.current)throw Error(`DockviewShell not initialized`);return e.current}return{addPanel(e,n){let r=t(),i=r.groups.find(t=>t.id===e);r.addPanel({id:n.id,component:n.component,title:n.title,params:n.params,position:i?{referenceGroup:i}:void 0})},removePanel(e){let n=t(),r=n.getPanel(e);r&&n.removePanel(r)},activatePanel(e){let n=t().getPanel(e);n&&n.api.setActive()},movePanel(e,n){let r=t(),i=r.getPanel(e);if(!i)return;let a=i.view.contentComponent,o=i.params,s=i.title;r.removePanel(i);let c={id:e,component:a,params:o,title:s};if(`groupId`in n){let e=r.groups.find(e=>e.id===n.groupId);r.addPanel({...c,position:e?{referenceGroup:e}:void 0})}else{let e=r.getPanel(n.referencePanelId);r.addPanel({...c,position:e?{referencePanel:e,direction:n.direction}:void 0})}},updatePanelParams(e,n){let r=t().getPanel(e);r&&r.api.updateParameters({...r.params??{},...n})},setPanelTitle(e,n){let r=t().getPanel(e);r&&r.api.setTitle(n)},findPanelsByParam(e,n){return t().panels.filter(t=>t.params?.[e]===n).map(e=>e.id)},getActivePanel(){return t().activePanel?.id??null},toJSON(){return t().toJSON()}}}function gJe(e){if(!e.constraints)return null;let t=e.constraints.maxWidth,n=e.constraints.maxWidthViewportRatio;if(typeof n==`number`&&n>0&&typeof window<`u`){let e=Math.floor(window.innerWidth*n);t=typeof t==`number`?Math.min(t,e):e}return{minimumWidth:e.constraints.minWidth,maximumWidth:t,minimumHeight:e.constraints.minHeight,maximumHeight:e.constraints.maxHeight}}function AU(e,t){let n=e.getPanel(t.panel??t.id);if(!n?.group)return;let r=gJe(t);r&&n.group.api.setConstraints(r)}function _Je(e,t,n,r,i,a){let o=e.api;a.current=o;let s=!0;if(n)try{o.fromJSON(n),s=!1}catch(e){console.warn(`[DockviewShell] Ignoring invalid persisted layout`,e)}if(s){let e=!1;for(let n of t.groups)if(n.panel){if(!r.has(n.panel)){console.error(`[DockviewShell] Panel "${n.panel}" not found in registry. Available: ${r.list().map(e=>e.id).join(`, `)}`);continue}o.addPanel({id:n.panel,component:n.panel,params:n.params,position:e?{direction:mJe(n.position)}:void 0}),e=!0}}for(let e of t.groups){let t=o.getPanel(e.panel??e.id);t?.group&&(e.locked&&(t.group.locked=`no-drop-target`),e.hideHeader&&(t.group.header.hidden=!0),AU(o,e))}let c=t.groups.filter(e=>typeof e.constraints?.maxWidthViewportRatio==`number`),l;if(c.length>0){let e=()=>{for(let e of c)AU(o,e)};window.addEventListener(`resize`,e),l=()=>window.removeEventListener(`resize`,e)}let u;if(i){let e=null,t=o.onDidLayoutChange(()=>{e&&clearTimeout(e),e=setTimeout(()=>{i(o.toJSON())},dJe)}),n=()=>{e&&(clearTimeout(e),i(o.toJSON()))};window.addEventListener(`beforeunload`,n),u=()=>{n(),t.dispose(),window.removeEventListener(`beforeunload`,n),l?.()}}else u=()=>{l?.()};return u}function jU({layout:e,persistedLayout:t,onReady:n,onLayoutChange:r,allowedPanels:i,className:a,prefixHeaderActions:o,rightHeaderActions:s,watermarkComponent:c}){let l=ir(),u=(0,I.useSyncExternalStore)(l.subscribe,l.getSnapshot,l.getSnapshot),d=sU(),f=(0,I.useRef)(null),p=(0,I.useRef)(null),m=(0,I.useRef)(void 0),h=(0,I.useRef)(null),g=(0,I.useMemo)(()=>{let e=l.getComponents(),t=i?Object.fromEntries(Object.entries(e).filter(([e])=>i.includes(e))):e,n=h.current;if(n){let e=Object.keys(n),r=Object.keys(t);if(e.length===r.length&&r.every(e=>n[e]===t[e]))return n}return h.current=t,t},[l,u,i]),_=(0,I.useMemo)(()=>hJe(f),[]),v=(0,I.useCallback)(i=>{m.current?.(),m.current=_Je(i,e,t,l,r,f),n?.(i.api)},[e,t,l,r,n]);(0,I.useEffect)(()=>()=>m.current?.(),[]),(0,I.useEffect)(()=>{let e=lc.on(nc.panelUpdate,({match:e,params:t,title:n})=>{let r=f.current;if(r)for(let i of kU(r,e))t&&i.api.updateParameters({...i.params??{},...t}),n&&i.api.setTitle(n)}),t=lc.on(nc.panelClose,({match:e})=>{let t=f.current;if(t)for(let n of kU(t,e))t.removePanel(n)});return()=>{e(),t()}},[]);let y=(0,I.useCallback)(e=>{if(!d){p.current=e;return}v(e)},[d,v]);return(0,I.useEffect)(()=>{d&&p.current&&(v(p.current),p.current=null)},[d,v]),d?(0,L.jsx)(OU.Provider,{value:_,children:(0,L.jsx)(JH,{className:`dv-shell ${a??``}`,components:g,defaultTabComponent:uJe,prefixHeaderActionsComponent:o,rightHeaderActionsComponent:s,watermarkComponent:c,onReady:y})}):(0,L.jsx)(vJe,{})}function vJe(){return(0,L.jsx)(N,{centered:!0,className:`bg-background`,label:`Loading workspace...`})}function yJe(e){return{get panelId(){return e.id},get title(){return e.title??e.id},setTitle(t){e.setTitle(t)},close(){e.close()},focus(){e.setActive()},get isActive(){return e.isActive}}}function MU({title:e,icon:t,essential:n,children:r,className:i,panelApi:a}){return(0,I.useMemo)(()=>a?yJe(a):null,[a]),(0,L.jsxs)(`div`,{className:DU(`flex h-full flex-col overflow-hidden`,i),children:[(0,L.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border bg-muted/50 px-3`,children:[t&&(0,L.jsx)(t,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e}),(0,L.jsx)(`div`,{className:`flex-1`}),!n&&a&&(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`h-5 w-5 text-muted-foreground`,onClick:()=>a.close(),"aria-label":`Close ${e}`,children:(0,L.jsx)(`svg`,{className:`h-3 w-3`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,L.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}),(0,L.jsx)(`div`,{className:`flex-1 overflow-auto`,children:r})]})}var bJe=[`node_modules`,`.git`,`.worktrees`,`.boring-agent`,`dist`,`test-results`,/^\.tsbuildinfo/,`.vite`,`.turbo`,`.next`,`.cache`];function NU(e,t){for(let n of t)if(typeof n==`string`?n===e:n.test(e))return!0;return!1}function xJe(e,t){return t.length===0?e:e?.filter(e=>!NU(e.name,t))}function PU(e){let t=e.trim();return t&&SJe(/[*?\[\]{}]/.test(t)?t:`*${t}*`)}function SJe(e){let t=``,n=!1,r=!1;for(let i of e){if(r){t+=i,r=!1;continue}if(i===`\\`){t+=i,r=!0;continue}if(i===`[`&&!n){n=!0,t+=i;continue}if(i===`]`&&n){n=!1,t+=i;continue}if(!n&&/[a-z]/i.test(i)){let e=i.toLowerCase(),n=i.toUpperCase();t+=e===n?i:`[${n}${e}]`;continue}t+=i}return t}async function FU(e){if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(typeof document>`u`)throw Error(`Clipboard not available`);let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-9999px`,t.style.left=`-9999px`,t.style.opacity=`0`,document.body.appendChild(t);let n=!1;try{t.focus(),t.select(),n=!!document.execCommand?.(`copy`)}finally{document.body.removeChild(t)}if(!n)throw Error(`Clipboard not available`)}var IU=()=>P(()=>Promise.resolve().then(()=>Agt).then(e=>({default:e.FileTree})),void 0);function CJe(){IU()}var wJe=(0,I.lazy)(IU),LU=8,TJe=250;function EJe(e,t,n,r,i){return{x:Math.max(LU,Math.min(e,r-n.width-LU)),y:Math.max(LU,Math.min(t,i-n.height-LU))}}function RU(e){return e.trim().replace(/\\/g,`/`).replace(/^\.\/+/,``).replace(/^\/+/,``).replace(/\/+/g,`/`).replace(/\/+$/,``)||`.`}function zU(e){let t=RU(e).split(`/`).filter(Boolean),n=[];for(let e=1;e<t.length;e++)n.push(t.slice(0,e).join(`/`));return n}function DJe(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function BU(e,t){return!e||t.size===0?e:e.filter(e=>!t.has(e.path))}function VU({rootDir:e=`.`,searchQuery:t,bridge:n,revealFileTreeRequest:r,filesystem:i=`user`,access:a=`readwrite`,ignoreNames:o=bJe,className:s}){let c=zu(),l=a!==`readonly`,u=ba(i),d=u===`user`?void 0:u,p=(0,I.useCallback)(e=>d?c.getTree(e,void 0,d):c.getTree(e),[c,d]),{data:m,error:h,isLoading:g}=td(e,d),[_,v]=(0,I.useState)(new Map),[y,b]=(0,I.useState)(new Set),x=hu(e),S=(0,I.useMemo)(()=>BU(gu(m,_.get(x)),y),[m,_,x,y]),C=(0,I.useMemo)(()=>xJe(S,o),[S,o]),{mutateAsync:w}=rd(),{mutateAsync:T}=see(),{mutateAsync:E}=id(),{mutateAsync:D}=ad(),[O,k]=(0,I.useState)(new Map),A=(0,I.useMemo)(()=>{if(_.size===0&&y.size===0)return O;let e=new Map;for(let[t,n]of O)e.set(t,BU(n,y)??n);for(let[t,n]of _){if(t===x)continue;let r=BU(gu(e.get(t),n),y);r&&e.set(t,r)}return e},[O,_,x,y]),ee=(0,I.useRef)(null),[te,ne]=(0,I.useState)(400),[j,M]=(0,I.useState)(null),{data:N}=nd(j&&!j.isBackground&&j.node.kind===`file`?j.node.path:null),[re,ae]=(0,I.useState)(null),oe=(0,I.useRef)(null),[se,ce]=(0,I.useState)(n?.getActiveFile?.()??null),[le,ue]=(0,I.useState)(null),[de,fe]=(0,I.useState)(null),pe=(0,I.useRef)(0),me=(0,I.useRef)(0),he=(0,I.useRef)(0),_e=(t?.trim().length??0)>0,{data:ve}=oee(_e&&i===`user`?PU(t??``):``,50);(0,I.useEffect)(()=>{if(!j)return;function e(e){oe.current&&!oe.current.contains(e.target)&&M(null)}return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[j]),(0,I.useLayoutEffect)(()=>{if(!j||!oe.current)return;let{x:e,y:t}=EJe(j.x,j.y,oe.current.getBoundingClientRect(),window.innerWidth,window.innerHeight);e===j.x&&t===j.y||M(n=>!n||n.x===e&&n.y===t?n:{...n,x:e,y:t})},[j]),(0,I.useEffect)(()=>{let e=ee.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&ne(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[]);let xe=_u((_e&&ve?ve.map(e=>({name:e.split(`/`).pop()??e,kind:`file`,path:e})):void 0)??pu(C??[],A),le,e),Ce=(0,I.useCallback)(e=>{ce(e),n?.openFile(e,{mode:`edit`,...d?{filesystem:d}:{}})},[n,d]),we=(0,I.useCallback)(async e=>{try{let t=await p(e),n=o.length===0?t:t.filter(e=>!NU(e.name,o));k(t=>new Map(t).set(e,n))}catch{}},[p,o]),Te=(0,I.useCallback)(async(t,n)=>{let r=Array.from(new Set(t)).filter(t=>t&&t!==e&&t!==`.`);if(r.length===0)return;let i=await Promise.all(r.map(async e=>{try{let t=await p(e);return[e,o.length===0?t:t.filter(e=>!NU(e.name,o))]}catch{return null}}));k(e=>{let t=new Map(e);for(let e of i){if(!e)continue;let[r,i]=e;(n?.force||t.has(r))&&t.set(r,i)}return t})},[p,e,o]),Ee=(0,I.useRef)(new Set);(0,I.useLayoutEffect)(()=>{Ee.current=new Set(O.keys())},[O]),(0,I.useEffect)(()=>{let e=new Set,t=e=>Array.from(new Set(e.map(mu))).filter(e=>Ee.current.has(e)),n=e=>ba(e)===u,r=t=>{if(!t.length)return;Te(t);let n=setTimeout(()=>{e.delete(n),Te(t)},TJe);e.add(n)},i=lc.on(eu.created,e=>{e.cause===`user`||!n(e.filesystem)||r(t([e.path]))}),a=lc.on(eu.deleted,e=>{e.cause===`user`||!n(e.filesystem)||r(t([e.path]))}),o=lc.on(eu.moved,e=>{e.cause===`user`||!n(e.filesystem)||r(t([e.from,e.to]))});return()=>{i(),a(),o();for(let t of e)clearTimeout(t);e.clear()}},[u,Te]);let De=(0,I.useCallback)(async(e,t)=>{if(!e)return;let n=RU(e),r=++pe.current;ce(n);let i=t?.refreshTargetDir?[...zU(n),n]:zU(n);await Te([...new Set(i)],{force:!0}),pe.current===r&&fe(n)},[Te]),Oe=(0,I.useCallback)(e=>{fe(t=>t===e?null:t)},[]),ke=(0,I.useCallback)(async e=>{let t=++me.current;try{await De(e,{refreshTargetDir:!0})}finally{me.current===t&&(me.current=0)}},[De]);(0,I.useEffect)(()=>{r&&ke(r.path)},[r,ke]),(0,I.useEffect)(()=>{let e=n?.getActiveFile?.()??null;e&&me.current===0&&De(e);let t=[];return n?.select&&t.push(n.select(e=>e.activeFile,e=>{e?me.current===0&&De(e):ce(null)})),n?.subscribe&&t.push(n.subscribe(`tree:expand`,({path:e})=>{ke(e)})),()=>{for(let e of t)e()}},[n,ke,De]);let Ae=(0,I.useCallback)((e,t)=>{v(n=>{let r=hu(e),i=new Map(n),a=gu(i.get(r),[t])??[t];return i.set(r,a),i})},[]),Me=(0,I.useCallback)((e,t)=>{v(n=>{let r=hu(e),i=n.get(r);if(!i?.length)return n;let a=i.filter(e=>e.path!==t),o=new Map(n);return a.length>0?o.set(r,a):o.delete(r),o})},[]),Ne=(0,I.useCallback)(e=>{b(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),Pe=(0,I.useCallback)(e=>{b(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]);(0,I.useEffect)(()=>{let e=e=>e===x||Ee.current.has(e),t=e=>ba(e)===u,n=lc.on(eu.created,n=>{if(!t(n.filesystem)||(Pe(n.path),n.cause===`user`))return;let r=mu(n.path);e(r)&&Ae(r,{name:DJe(n.path),kind:n.kind,path:n.path})}),r=lc.on(eu.deleted,e=>{e.cause===`user`||!t(e.filesystem)||(Ne(e.path),Me(mu(e.path),e.path))}),i=lc.on(eu.moved,e=>{e.cause===`user`||!t(e.filesystem)||(Ne(e.from),Pe(e.to),Me(mu(e.from),e.from))});return()=>{n(),r(),i()}},[u,Ae,Ne,Me,x,Pe]);let[Fe,Ie]=(0,I.useState)(new Set),Re=(0,I.useCallback)(e=>{Ie(t=>{let n=new Set(t);return n.add(e),n})},[]),ze=(0,I.useCallback)(e=>{Ie(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),Be=(0,I.useCallback)((e,t)=>{M({node:t,x:e.clientX,y:e.clientY})},[]),He=(0,I.useCallback)(t=>{let n=t.target;n.closest(`[role=treeitem]`)||n.closest(`[data-path]`)||(t.preventDefault(),M({node:{name:e,kind:`dir`,path:e},x:t.clientX,y:t.clientY,isBackground:!0}))},[e]),We=(0,I.useCallback)(async(t,n)=>{let r=t.split(`/`).pop()??t,i=n===`.`?e:n,a=i===`.`?r:`${i}/${r}`;if(a!==t){Re(t);try{if(!l)return;await E({from:t,to:a,...d?{filesystem:d}:{}}),await Te([mu(t),mu(a)]),ie.success({title:`Moved`,description:`${t} → ${a}`})}catch(e){ie.error({title:`Move failed`,description:e instanceof Error?e.message:String(e)})}finally{ze(t)}}},[l,d,E,Te,e,Re,ze]);function Ge(e){return()=>{M(null),(async()=>{try{await e()}catch(e){ie.error({title:`Action failed`,description:e instanceof Error?e.message:String(e)})}})()}}let Ke=t=>{let n=j?.node;M(null);let r=n?.kind===`dir`?n.path:n?mu(n.path):e,i=`__draft__:${++he.current}`;ue({kind:t,parentDir:r,path:i})},qe=()=>Ke(`create-file`),Ye=()=>Ke(`create-folder`),Ze=()=>{let e=j?.node;M(null),e&&ue({kind:`rename`,path:e.path,initialValue:e.name})},Qe=(0,I.useCallback)(async(e,t)=>{let n=le;if(ue(null),!n)return;let r=t.trim();if(!r||!l)return;let i=n.kind===`rename`?mu(n.path):n.parentDir,a=n.kind===`rename`?n.path:i===`.`||i===``?r:`${i}/${r}`,o=n.kind===`rename`?n.path:a;Re(o);let s=null;try{if(n.kind===`rename`){if(r===n.initialValue)return;let e=n.path.split(`/`);e[e.length-1]=r;let t=e.join(`/`);await E({from:n.path,to:t,...d?{filesystem:d}:{}}),await Te([mu(n.path)]),ie.success({title:`Renamed`,description:`${n.path} → ${t}`})}else{let e={name:r,kind:n.kind===`create-file`?`file`:`dir`,path:a,filesystem:d};Ae(i,e),s=a,n.kind===`create-file`?(await w({path:a,content:``,returnMtimeMs:!1,...d?{filesystem:d}:{}}),lc.emit(eu.created,{...rc(),path:a,filesystem:d,kind:`file`}),Ce(a),ie.success({title:`File created`,description:a})):(await T({path:a,...d?{filesystem:d}:{}}),ie.success({title:`Folder created`,description:a})),await Te([i],{force:!0}),fe(a)}}catch(e){s&&Me(i,s);let t=e instanceof Error?e.message:String(e);ie.error({title:n.kind===`rename`?`Rename failed`:n.kind===`create-file`?`Create file failed`:`Create folder failed`,description:t})}finally{ze(o)}},[le,l,d,E,w,T,Te,Re,ze,Ae,Me,Ce]),$e=(0,I.useCallback)(()=>{ue(null)},[]),et=Ge(async()=>{j?.node&&(await FU(j.node.path),ie.success({title:`Path copied`,description:j.node.path}))}),tt=Ge(async()=>{if(!N?.enabled||!N.url)throw Error(N?.reason??`Git URL unavailable`);await FU(N.url),ie.success({title:`Git URL copied`,description:N.url})}),nt=(0,I.useCallback)(async()=>{if(!re)return;let e=re;ae(null),Re(e.path);try{if(!l)return;await D({path:e.path,...d?{filesystem:d}:{}}),Me(mu(e.path),e.path),e.kind===`dir`&&k(t=>{let n=new Map(t);for(let t of n.keys())(t===e.path||t.startsWith(`${e.path}/`))&&n.delete(t);return n}),await Te([mu(e.path)]),ie.success({title:`Deleted`,description:e.path})}catch(e){ie.error({title:`Delete failed`,description:e instanceof Error?e.message:String(e)})}finally{ze(e.path)}},[re,D,Te,Re,ze,Me,l,d]),rt=(!_e||i!==`user`)&&(t?.length??0)>0?t:void 0;return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[h&&(0,L.jsx)(f,{className:`m-2 rounded-md p-3`,title:`Failed to load files`,description:h.message}),(0,L.jsx)(`div`,{ref:ee,className:`min-h-0 flex-1 overflow-hidden`,onContextMenu:He,children:g?(0,L.jsx)(`div`,{className:`space-y-1 p-2`,"data-testid":`tree-skeleton`,children:Array.from({length:8}).map((e,t)=>(0,L.jsx)(ye,{className:`h-5`,style:{width:`${60+t*13%30}%`}},t))}):(0,L.jsx)(I.Suspense,{fallback:(0,L.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(ot,{className:`size-3.5`}),(0,L.jsx)(`span`,{children:`Loading...`})]}),children:(0,L.jsx)(wJe,{files:xe,selectedPath:se,searchQuery:rt,editing:le?{path:le.path,isDraft:le.kind!==`rename`,initialValue:le.kind===`rename`?le.initialValue:void 0}:null,revealPath:de,onRevealHandled:Oe,pendingPaths:Fe,onSelect:Ce,onExpand:we,onContextMenu:Be,onSubmitEdit:Qe,onCancelEdit:$e,onDragDrop:l?We:void 0,height:te,className:DU(s)})})}),j&&(0,Pn.createPortal)((0,L.jsxs)(`div`,{ref:oe,role:`menu`,className:`fixed z-50 min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md`,style:{left:j.x,top:j.y},children:[l&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Se,{type:`button`,role:`menuitem`,variant:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:qe,children:`New file`}),(0,L.jsx)(Se,{type:`button`,role:`menuitem`,variant:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:Ye,children:`New folder`})]}),!j.isBackground&&(0,L.jsxs)(L.Fragment,{children:[l&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Se,{type:`button`,role:`menuitem`,variant:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:Ze,children:`Rename`}),(0,L.jsx)(Se,{type:`button`,role:`menuitem`,variant:`ghost`,size:`sm`,className:`w-full justify-start text-destructive hover:bg-destructive/10 hover:text-destructive`,onClick:()=>{ae(j.node),M(null)},children:`Delete`})]}),(0,L.jsx)(Se,{type:`button`,role:`menuitem`,variant:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:et,children:`Copy path`}),N?.enabled?(0,L.jsx)(Se,{type:`button`,role:`menuitem`,variant:`ghost`,size:`sm`,className:`w-full justify-start`,onClick:tt,children:`Copy Git URL`}):N?.reason?(0,L.jsx)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,"aria-live":`polite`,children:N.reason}):null]})]}),document.body),(0,L.jsx)(Ve,{open:re!==null,onOpenChange:e=>{e||ae(null)},children:(0,L.jsxs)(ge,{children:[(0,L.jsxs)(be,{children:[(0,L.jsxs)(Le,{children:[`Delete `,re?.name,`?`]}),(0,L.jsx)(Ue,{children:`This action cannot be undone.`})]}),(0,L.jsxs)(Xe,{children:[(0,L.jsx)(je,{children:`Cancel`}),(0,L.jsx)(Je,{onClick:nt,children:`Delete`})]})]})})]})}function HU({params:e,rootDir:t=`.`,searchQuery:n,panelApi:r,bridge:i,api:a,chromeless:o=!1,filesystem:s=`user`,access:c=`readwrite`,roots:l,className:u}){let d=e?.rootDir??t,f=e?.bridge??i,p=e?.chromeless??o,m=e?.filesystem??s,h=e?.access??c,g=e?.roots??l,_=e?.revealFileTreeRequest??null,v=e?.searchQuery??e?.query??n,y=r??a,[b,x]=(0,I.useState)(``),[S,C]=(0,I.useState)(``),w=(0,I.useMemo)(()=>g?.length?g:[{filesystem:m,label:m===`user`?`Workspace`:m,rootDir:m===`user`?d:`/`,access:h}],[h,m,d,g]),[E,D]=(0,I.useState)(w[0]?.filesystem??`user`);(0,I.useEffect)(()=>{let e=w.some(e=>e.filesystem===m)?m:w[0]?.filesystem??`user`;D(e)},[m,w]);let O=w.find(e=>e.filesystem===E)??w[0],k=O?.filesystem??`user`,A=O?.rootDir??(k===`user`?d:`/`),ee=O?.access??h,te=(0,I.useRef)(void 0);(0,I.useEffect)(()=>(clearTimeout(te.current),te.current=setTimeout(()=>C(b),200),()=>clearTimeout(te.current)),[b]);let ne=v===void 0?S||void 0:v||void 0;return p?w.length<=1?(0,L.jsx)(VU,{rootDir:A,searchQuery:ne,bridge:f,filesystem:k,access:ee,revealFileTreeRequest:_,className:DU(`px-1 pt-1 [&_[role=treeitem]]:!indent-0`,u)},`${k}:${A}`):(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsx)(`div`,{className:`shrink-0 px-1 pt-1`,children:(0,L.jsxs)(tt,{value:k,onValueChange:e=>D(e),children:[(0,L.jsx)(Ke,{size:`sm`,className:`h-7 w-full text-xs`,"aria-label":`File root`,children:(0,L.jsx)(Be,{})}),(0,L.jsx)(Ce,{children:w.map(e=>(0,L.jsx)(Ee,{value:e.filesystem,className:`text-xs`,children:e.label},e.filesystem))})]})}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,L.jsx)(VU,{rootDir:A,searchQuery:ne,bridge:f,filesystem:k,access:ee,revealFileTreeRequest:_,className:DU(`px-1 pt-1 [&_[role=treeitem]]:!indent-0`,u)},`${k}:${A}`)})]}):(0,L.jsx)(MU,{title:`Files`,panelApi:y,children:(0,L.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,L.jsxs)(`div`,{className:`space-y-1.5 border-b border-border px-2 py-1.5`,children:[w.length>1&&(0,L.jsxs)(tt,{value:k,onValueChange:e=>D(e),children:[(0,L.jsx)(Ke,{size:`sm`,className:`h-7 w-full text-xs`,"aria-label":`File root`,children:(0,L.jsx)(Be,{})}),(0,L.jsx)(Ce,{children:w.map(e=>(0,L.jsx)(Ee,{value:e.filesystem,className:`text-xs`,children:e.label},e.filesystem))})]}),(0,L.jsx)(T,{placeholder:O?.searchPlaceholder??`Search files...`,value:v??b,onChange:e=>x(e.target.value),className:`h-7 text-xs`,"aria-label":`Search files`})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,L.jsx)(VU,{rootDir:A,searchQuery:ne,bridge:f,filesystem:k,access:ee,revealFileTreeRequest:_,className:u},`${k}:${A}`)})]})})}function OJe(e){return e.split(`/`).pop()??e}function kJe(){return(0,I.useEffect)(()=>{let e=lc.on(eu.moved,({filesystem:e,from:t,to:n,...r})=>{let i=ba(e);lc.emit(nc.panelUpdate,{...r,match:[{id:`file:${Sa({filesystem:i,path:t})}`},{params:{path:t,filesystem:i}}],params:{path:n,filesystem:i},title:OJe(n)})}),t=lc.on(eu.deleted,({filesystem:e,path:t,...n})=>{let r=ba(e);lc.emit(nc.panelClose,{...n,match:[{id:`file:${Sa({filesystem:r,path:t})}`},{params:{path:t,filesystem:r}},{paramPrefix:`path`,value:`${t}/`,params:{filesystem:r}}]})});return()=>{e(),t()}},[]),null}var AJe=new Set([`write`,`edit`,`unlink`,`rename`,`mkdir`]);function jJe(e){if(typeof e!=`object`||!e)return null;let t=e;if(t.type!==`data-file-changed`)return null;let n=t.data;if(typeof n!=`object`||!n)return null;let r=n;return typeof r.op!=`string`||!AJe.has(r.op)||typeof r.path!=`string`||r.path.length===0||typeof r.toolCallId!=`string`||r.toolCallId.length===0||r.oldPath!==void 0&&(typeof r.oldPath!=`string`||r.oldPath.length===0)?null:r}function UU(e){let t=jJe(e);if(!t)return;let n=ic(t.toolCallId);switch(t.op){case`rename`:t.oldPath&&lc.emit(eu.moved,{...n,from:t.oldPath,to:t.path});return;case`unlink`:lc.emit(eu.deleted,{...n,path:t.path});return;case`mkdir`:lc.emit(eu.created,{...n,path:t.path,kind:`dir`});return;case`write`:t.existsBefore===!1?lc.emit(eu.created,{...n,path:t.path,kind:`file`}):lc.emit(eu.changed,{...n,path:t.path});return;case`edit`:lc.emit(eu.changed,{...n,path:t.path});return}}function WU(e,t={}){let{skip:n,filesOnly:r=!0}=t;oc(eu.created,t=>{t.cause===`agent`&&(r&&t.kind!==`file`||n?.(t.path)||e(t.path))})}function MJe(e){return lc.on(eu.changed,e)}function NJe(){return(0,I.useEffect)(()=>lc.on(nc.agentData,({part:e})=>{UU(e)}),[]),WU(e=>{dc({kind:`openFile`,params:{path:e}})}),null}var PJe=250,FJe=3e3,IJe=3e4;function GU(e,t){let{adapter:n,panelId:r,onDirtyChange:i,serverMtime:a}=t,[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(!1),[m,h]=(0,I.useState)(!1),g=(0,I.useRef)(void 0),_=(0,I.useRef)(null),v=(0,I.useRef)(0),y=(0,I.useRef)(null),b=(0,I.useRef)(0),x=(0,I.useRef)(void 0),S=(0,I.useRef)(i);S.current=i;let C=(0,I.useRef)(n);C.current=n;let w=(0,I.useCallback)(async()=>{let t=C.current;if(!t||!e||!t.isDirty())return;if(_.current)return _.current;let n=b.current,i=null;return i=(async()=>{l(!0),lc.emit(nc.editorSaveStart,{panelId:r});let a,o=new Promise(e=>{a=setTimeout(()=>e(`timeout`),IJe)});try{let r=await Promise.race([t.save().then(()=>`saved`),o]);if(b.current!==n)return;r===`saved`&&(v.current=Date.now(),d(Date.now()),s(!1),S.current?.(e,!1))}catch{if(b.current!==n)return}finally{if(a&&clearTimeout(a),_.current===i&&(_.current=null),b.current!==n)return;lc.emit(nc.editorSaveEnd,{panelId:r}),l(!1)}})(),_.current=i,i},[e,r]),T=(0,I.useCallback)(()=>{clearTimeout(g.current),g.current=setTimeout(w,PJe)},[w]),E=(0,I.useCallback)(()=>{e&&(s(!0),S.current?.(e,!0),T())},[e,T]),D=(0,I.useCallback)(()=>{clearTimeout(g.current),s(!1),h(!1),e&&S.current?.(e,!1)},[e]),O=(0,I.useCallback)(async()=>{if(clearTimeout(g.current),_.current)return _.current;if(C.current?.isDirty())return w()},[w]),k=(0,I.useCallback)(()=>p(!1),[]),A=(0,I.useCallback)(()=>h(!1),[]),ee=(0,I.useCallback)(e=>{y.current=e,h(!1)},[]);return(0,I.useEffect)(()=>{if(!(a==null||!e)){if(y.current===null){y.current=a;return}if(a!==y.current){if(Date.now()-v.current<FJe){y.current=a;return}y.current=a,o?h(!0):p(!0)}}},[a,e,o]),(0,I.useEffect)(()=>{if(x.current===void 0){x.current=e;return}x.current!==e&&(x.current=e,b.current+=1,clearTimeout(g.current),_.current&&lc.emit(nc.editorSaveEnd,{panelId:r}),_.current=null,y.current=null,v.current=0,s(!1),l(!1),p(!1),h(!1))},[e]),(0,I.useEffect)(()=>()=>clearTimeout(g.current),[]),{isDirty:o,isSaving:c,lastSavedAt:u,markDirty:E,markClean:D,flushSave:O,shouldSync:f,ackSync:k,externalChangeWhileDirty:m,ackExternalChange:A,notifySaved:ee}}function KU(e){return typeof window>`u`?!1:window.innerWidth<e}function qU(e=1024){let[t,n]=(0,I.useState)(()=>KU(e));return(0,I.useEffect)(()=>{let t=()=>{n(KU(e))};return t(),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t)}},[e]),t}function JU({isNarrowViewport:e,isCollapsed:t,setCollapsed:n}){let r=(0,I.useRef)(t),i=(0,I.useRef)(!1),a=(0,I.useRef)(null);return(0,I.useEffect)(()=>{r.current=t},[t]),(0,I.useEffect)(()=>{let t=a.current,o=t!==!0&&e,s=t===!0&&!e;if(a.current=e,e&&o&&!r.current){i.current=!0,n(!0);return}s&&i.current&&(i.current=!1,n(!1))},[e,n]),(0,I.useCallback)(()=>{i.current=!1},[])}function LJe(e){let[t,n]=(0,I.useState)([]),r=(0,I.useRef)(t);return r.current=t,(0,I.useEffect)(()=>{if(!e){n([]);return}function t(){try{let t=e.toJSON(),i=[];if(t&&typeof t==`object`&&`panels`in t){let e=t;if(e.panels)for(let[,t]of Object.entries(e.panels))t.id&&i.push({id:t.id,component:t.contentComponent??t.id,params:t.params})}let a=r.current;(a.length!==i.length||a.some((e,t)=>e.id!==i[t]?.id))&&n(i)}catch{}}t();let i=setInterval(t,500);return()=>clearInterval(i)},[e]),{panels:t,open:(0,I.useCallback)(t=>{e?.addPanel(`artifacts`,{id:t.id,component:t.component,params:t.params})},[e]),close:(0,I.useCallback)(t=>{e?.removePanel(t)},[e]),activate:(0,I.useCallback)(t=>{e?.activatePanel(t)},[e]),isOpen:(0,I.useCallback)(e=>r.current.some(t=>t.id===e),[])}}function RJe(e,t={}){let n=t.toolPanelMap??{},r=(0,I.useCallback)(e=>n[e],[n]);return{openForTool:(0,I.useCallback)((t,r)=>{let i=n[t];if(!i)return;let a=`artifact-${r.path}`;e.isOpen(a)?e.activate(a):e.open({id:a,component:i,params:r})},[n,e]),resolvePanel:r}}function zJe(e,t){let n=e.metaKey||e.ctrlKey;if(t.mod&&!n||!t.mod&&n||t.shift&&!e.shiftKey||!t.shift&&e.shiftKey)return!1;let r=t.key.toLowerCase(),i=e.key.toLowerCase(),a=e.code.toLowerCase();return i===r||a===r||a===`key${r}`}function BJe(e){return e instanceof HTMLElement?e.isContentEditable||e.closest(`[contenteditable='true'], [contenteditable=''], [contenteditable='plaintext-only']`)||e.closest(`[role='textbox'], [role='searchbox'], [role='combobox']`)?!0:!!e.closest(`input, textarea, select`):!1}function YU({shortcuts:e,enabled:t=!0}){let n=(0,I.useRef)(e);n.current=e,(0,I.useEffect)(()=>{if(!t)return;function e(e){let t=BJe(e.target);for(let r of n.current)if(!(t&&!r.allowInEditable)&&zJe(e,r)){e.preventDefault(),e.stopPropagation(),r.handler();return}}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t])}function VJe(e){let t=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.userAgent),n=[];return e.mod&&n.push(t?`⌘`:`Ctrl`),e.shift&&n.push(t?`⇧`:`Shift`),n.push({"\\":`\\`,p:`P`,b:`B`,s:`S`,w:`W`}[e.key]??e.key.toUpperCase()),n.join(t?``:`+`)}var HJe=0;function XU(e){let{path:t,panelId:n,initialContent:r=null,createIfMissing:i}=e,a=ba(e.filesystem),o=/\S/.test(t)?t:null,s=o?Sa({filesystem:a,path:o}):null,c=(0,I.useRef)(n??`file-pane:${HJe++}`),l=n??c.current,{data:u,isLoading:d,error:f,refetch:p}=ed(o,i===void 0?{filesystem:a}:{filesystem:a,createIfMissing:i}),m=u?.access===`readonly`,{mutateAsync:h}=rd(),[g,_]=(0,I.useState)(r),v=(0,I.useRef)(``),y=(0,I.useRef)(!1),b=(0,I.useRef)(null),x=(0,I.useRef)(null),S=(0,I.useRef)(null),C=(0,I.useRef)(null),w=(0,I.useRef)(0),[T,E]=(0,I.useState)(null);(0,I.useEffect)(()=>{(b.current!==t||x.current!==s)&&(_(r),v.current=r??``,y.current=!1,S.current=null,w.current+=1,E(null),b.current=t,x.current=s)},[t,s,r]),(0,I.useEffect)(()=>{u?.content!=null&&g===null&&(_(u.content),v.current=u.content,S.current=u.mtimeMs??null)},[u,g]);let D=o&&g!=null&&!m?{isDirty:()=>y.current,save:async()=>{let e=++w.current;try{let t=await h({filesystem:a,path:o,content:v.current,expectedMtimeMs:S.current??void 0});if(w.current!==e)return;typeof t.mtimeMs==`number`&&(S.current=t.mtimeMs,C.current?.(t.mtimeMs)),y.current=!1,E(null)}catch(t){throw w.current===e&&t instanceof Ql?(typeof t.currentMtimeMs==`number`&&(S.current=t.currentMtimeMs),E(t),t):t}},getContent:()=>v.current}:null,O=GU(s,{adapter:D,panelId:l,serverMtime:u?.mtimeMs??null});C.current=O.notifySaved,(0,I.useEffect)(()=>{if(!(!O.shouldSync||u?.content==null)){if(y.current){O.ackSync();return}_(u.content),v.current=u.content,S.current=u.mtimeMs??null,y.current=!1,O.ackSync()}},[O.shouldSync,O,u,_]),(0,I.useEffect)(()=>{m||!O.externalChangeWhileDirty||u?.mtimeMs==null||(E(new Ql(o??t,u.mtimeMs,S.current)),S.current=u.mtimeMs,O.ackExternalChange())},[o,m,O.externalChangeWhileDirty,O,u,t]);let k=o?o.split(`/`).pop()??o:``,[A,ee]=(0,I.useState)(``);(0,I.useEffect)(()=>{let e=k?!m&&O.isDirty?`${k} ●`:k:``;ee(e)},[k,m,O.isDirty]);let te=(0,I.useCallback)(e=>{m||(_(e),v.current=e,y.current=!0,O.markDirty())},[m,_,O]),ne=(0,I.useCallback)(async()=>{if(!o)return;let e=await p();if(e.status!==`success`||e.data==null)return;let t=e.data;_(t.content),v.current=t.content,S.current=t.mtimeMs??null,y.current=!1,O.markClean(),typeof t.mtimeMs==`number`&&C.current?.(t.mtimeMs),E(null)},[o,O,p,_]),j=(0,I.useCallback)(async()=>{if(m)return;let e=++w.current;try{if(!o)return;let t=v.current,n=await h({filesystem:a,path:o,content:t});if(w.current!==e)return;typeof n.mtimeMs==`number`&&(S.current=n.mtimeMs,C.current?.(n.mtimeMs)),y.current=!1,E(null)}catch{}},[o,a,m,h]),M=(0,I.useCallback)(async()=>{m||!D||!y.current||await D.save()},[D,m]),N=(0,I.useCallback)(async()=>{m||await O.flushSave()},[m,O]);return{isLoading:d,error:f,content:g,isDirty:!m&&O.isDirty,isReadonly:m,conflict:m?null:T,onReloadFromServer:ne,onOverwrite:j,setContent:te,save:M,flushSave:N,fileName:k,tabTitle:A}}function UJe({conflict:e,onReload:t,onOverwrite:n}){return(0,L.jsx)(u,{role:`alert`,tone:`accent`,className:`rounded-none border-x-0 border-t-0`,description:(0,L.jsx)(L.Fragment,{children:`This file has been modified outside the editor. Your unsaved changes will be lost if you reload, or will overwrite the latest version on disk if you save.`}),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Se,{type:`button`,variant:`outline`,size:`xs`,onClick:()=>void t(),children:`Reload`}),(0,L.jsx)(Se,{type:`button`,variant:`destructive`,size:`xs`,onClick:()=>void n(),children:`Overwrite`}),(0,L.jsx)(`span`,{className:`sr-only`,children:e.path})]})})}function WJe(e,t){return e!==void 0&&e!==`user`&&(t===403||t===404)}function ZU(e,t,n){return WJe(e,t)?`not found or denied`:n}function QU({path:e,content:t,isLoading:n,error:r,conflict:i,readOnly:a=!1,onChange:o,onReload:s,onOverwrite:c,editorComponent:l,editorProps:u={},loadingFallback:d,errorMessage:p,filesystem:m,className:h}){if(!/\S/.test(e))return(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,L.jsx)(lt,{className:`min-h-0 border-0`,title:`No file selected`,description:`Choose a file from the file tree to open an editor.`})});if(r){let e=r instanceof Zl?ZU(m,r.status,r.message):r.message;return(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,L.jsx)(f,{title:`Failed to load file`,description:p??e})})}let g=d??(0,L.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(ot,{className:`size-3.5`}),(0,L.jsx)(`span`,{children:`Loading file...`})]});return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col ${h??``}`,children:[a&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border bg-muted/40 px-3 py-1.5 text-xs text-muted-foreground`,role:`status`,children:[(0,L.jsx)(`span`,{className:`rounded-sm border border-border bg-background px-1.5 py-0.5 font-medium text-foreground`,children:`Readonly`}),(0,L.jsx)(`span`,{children:m===`company_context`?`Company context is policy-filtered and cannot be edited here.`:`This file is readonly.`})]}),!a&&i&&(0,L.jsx)(UJe,{conflict:i,onReload:s,onOverwrite:c}),(0,L.jsx)(I.Suspense,{fallback:g,children:n||t===null?g:(0,L.jsx)(l,{content:t,className:u.className,...u,onChange:a?()=>{}:o,readOnly:a})})]})}var $U=[],eW=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?eW:$U).push(n+=e[t])})();function GJe(e){if(e<768)return!1;for(let t=0,n=$U.length;;){let r=t+n>>1;if(e<$U[r])n=r;else if(e>=eW[r])t=r+1;else return!0;if(t==n)return!1}}function tW(e){return e>=127462&&e<=127487}var nW=8205;function KJe(e,t,n=!0,r=!0){return(n?rW:qJe)(e,t,r)}function rW(e,t,n){if(t==e.length)return t;t&&aW(e.charCodeAt(t))&&oW(e.charCodeAt(t-1))&&t--;let r=iW(e,t);for(t+=sW(r);t<e.length;){let i=iW(e,t);if(r==nW||i==nW||n&&GJe(i))t+=sW(i),r=i;else if(tW(i)){let n=0,r=t-2;for(;r>=0&&tW(iW(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function qJe(e,t,n){for(;t>1;){let r=rW(e,t-2,n);if(r<t)return r;t--}return 0}function iW(e,t){let n=e.charCodeAt(t);if(!oW(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return aW(r)?(n-55296<<10)+(r-56320)+65536:n}function aW(e){return e>=56320&&e<57344}function oW(e){return e>=55296&&e<56320}function sW(e){return e<65536?1:2}var cW=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=gW(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),uW.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=gW(this,e,t);let n=[];return this.decompose(e,t,n,0),uW.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new pW(this),i=new pW(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new pW(this,e)}iterRange(e,t=this.length){return new mW(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new hW(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new lW(t):uW.from(lW.split(t,[]))}},lW=class e extends cW{constructor(e,t=JJe(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new YJe(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(fW(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=dW(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=gW(this,t,n);let i=dW(this.text,dW(r.text,fW(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):uW.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
640
640
  `){[e,t]=gW(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},uW=class e extends cW{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=gW(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
641
641
  `){[e,t]=gW(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new lW(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof lW&&c&&(n=u[u.length-1])instanceof lW&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new lW(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};cW.empty=new lW([``],0);function JJe(e){let t=-1;for(let n of e)t+=n.length+1;return t}function dW(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function fW(e,t,n){return dW(e,[``],t,n)}var pW=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof lW?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof lW?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
642
642
  `,this;e--}else if(r instanceof lW){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof lW?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},mW=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new pW(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},hW=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(cW.prototype[Symbol.iterator]=function(){return this.iter()},pW.prototype[Symbol.iterator]=mW.prototype[Symbol.iterator]=hW.prototype[Symbol.iterator]=function(){return this});var YJe=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function gW(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function _W(e,t,n=!0,r=!0){return KJe(e,t,n,r)}function XJe(e){return e>=56320&&e<57344}function ZJe(e){return e>=55296&&e<56320}function vW(e,t){let n=e.charCodeAt(t);if(!ZJe(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return XJe(r)?(n-55296<<10)+(r-56320)+65536:n}function QJe(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function yW(e){return e<65536?1:2}var bW=/\r\n?|\n/,xW=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(xW||={}),SW=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){EW(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:OW(this,e)}mapDesc(e,t=!1){return e.empty?this:DW(this,e,t)}mapPos(e,t=-1,n=xW.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=xW.Simple&&c>=e&&(n==xW.TrackDel&&r<e&&c>e||n==xW.TrackBefore&&r<e||n==xW.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},CW=class e extends SW{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return EW(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return DW(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(cW.empty);r.push(a?t.slice(i,i+a):cW.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:OW(this,e,!0)}map(e,t=!1){return e.empty?this:DW(this,e,t,!0)}iterChanges(e,t=!1){EW(this,e,t)}get desc(){return SW.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new kW(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);wW(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;wW(n,e,t),t>0&&TW(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);wW(n,e,-1),wW(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:SW.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&wW(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?cW.of(l.split(r||bW)):l:cW.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&wW(i,e-o,-1),wW(i,s-e,d),TW(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(cW.empty);r[e]=cW.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function wW(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function TW(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(cW.empty);e.push(n)}}function EW(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=cW.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function DW(e,t,n,r=!1){let i=[],a=r?[]:null,o=new kW(e),s=new kW(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);wW(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(wW(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(wW(i,0,o.ins),a&&TW(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;wW(i,t,e<o.i?o.ins:0),a&&e<o.i&&TW(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?CW.createSet(i,a):SW.create(i);else throw Error(`Mismatched change set lengths`)}function OW(e,t,n=!1){let r=[],i=n?[]:null,a=new kW(e),o=new kW(t);for(let e=!1;;)if(a.done&&o.done)return i?CW.createSet(r,i):SW.create(r);else if(a.ins==0)wW(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)wW(r,0,o.ins,e),i&&TW(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;wW(r,t,n,e),i&&n&&TW(i,r,o.text)}else o.ins==-1?(wW(r,a.off?0:a.len,t,e),i&&TW(i,r,a.textBit(t))):(wW(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&TW(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var kW=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?cW.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?cW.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},AW=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return jW.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return jW.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return jW.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},jW=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>AW.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return AW.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n)),r)}static range(e,t,n,r,i){let a=r==null?7:Math.min(6,r);return!i&&e!=t&&(i=t<e?1:-1),i&&(a|=i<0?8:16),t<e?AW.create(t,e,a|32,n):AW.create(e,t,a,n)}static undirectionalRange(e,t){return AW.create(e,t,64,void 0)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function MW(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var NW=0,PW=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=NW++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:FW),!!t.static,t.enables)}of(e){return new IW([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new IW(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new IW(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function FW(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var IW=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=NW++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||RW(e,c)){let r=t(e);if(a?!LW(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=YW(o,c);if(this.dependencies.every(t=>t instanceof PW?o.facet(t)===e.facet(t):t instanceof BW?o.field(t,!1)==e.field(t,!1):!0)||(a?LW(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}get extension(){return this}};function LW(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function RW(e,t){let n=!1;for(let r of t)JW(e,r)&1&&(n=!0);return n}function $Je(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=YW(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)JW(e,t);return e.values[o]=s(e),1},update(e,n){if(!RW(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=RW(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&FW(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var zW=PW.define({static:!0}),BW=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(NW++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(zW).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(zW),i=n.facet(zW),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,zW.of({field:this,create:e})]}get extension(){return this}},VW={lowest:4,low:3,default:2,high:1,highest:0};function HW(e){return t=>new WW(t,e)}var UW={highest:HW(VW.highest),high:HW(VW.high),default:HW(VW.default),low:HW(VW.low),lowest:HW(VW.lowest)},WW=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},GW=class e{of(e){return new KW(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},KW=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},qW=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of eYe(t,n,o))e instanceof BW?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,FW(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>$Je(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function eYe(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof KW&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof KW){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof WW)a(e.inner,e.prec);else if(e instanceof BW)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof IW)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,VW.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,VW.default),r.reduce((e,t)=>e.concat(t))}function JW(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function YW(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var XW=PW.define(),ZW=PW.define({combine:e=>e.some(e=>e),static:!0}),QW=PW.define({combine:e=>e.length?e[0]:void 0,static:!0}),$W=PW.define(),eG=PW.define(),tG=PW.define(),nG=PW.define({combine:e=>e.length?e[0]:!1}),rG=class{constructor(e,t){this.type=e,this.value=t}static define(){return new tYe}},tYe=class{of(e){return new rG(this,e)}},nYe=class{constructor(e){this.map=e}of(e){return new iG(this,e)}},iG=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new nYe(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};iG.reconfigure=iG.define(),iG.appendConfig=iG.define();var aG=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&MW(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};aG.time=rG.define(),aG.userEvent=rG.define(),aG.addToHistory=rG.define(),aG.remote=rG.define();function rYe(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function oG(e,t,n){let r,i,a;return n?(r=t.changes,i=CW.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:iG.mapEffects(e.effects,r).concat(iG.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function sG(e,t,n){let r=t.selection,i=lG(t.annotations);return t.userEvent&&(i=i.concat(aG.userEvent.of(t.userEvent))),{changes:t.changes instanceof CW?t.changes:CW.of(t.changes||[],n,e.facet(QW)),selection:r&&(r instanceof jW?r:jW.single(r.anchor,r.head)),effects:lG(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function cG(e,t,n){let r=sG(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=oG(r,sG(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=aG.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return aYe(n?iYe(i):i)}function iYe(e){let t=e.startState,n=!0;for(let r of t.facet($W)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:rYe(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=CW.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=aG.create(t,r,e.selection&&e.selection.map(i),iG.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(eG);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof aG?i:Array.isArray(i)&&i.length==1&&i[0]instanceof aG?i[0]:cG(t,lG(i),!1)}return e}function aYe(e){let t=e.startState,n=t.facet(tG),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=oG(r,sG(t,a,e.changes.newLength),!0))}return r==e?e:aG.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var oYe=[];function lG(e){return e==null?oYe:Array.isArray(e)?e:[e]}var uG=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(uG||={}),sYe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,dG;try{dG=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function cYe(e){if(dG)return dG.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>`€`&&(n.toUpperCase()!=n.toLowerCase()||sYe.test(n)))return!0}return!1}function lYe(e){return t=>{if(!/\S/.test(t))return uG.Space;if(cYe(t))return uG.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return uG.Word;return uG.Other}}var fG=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)JW(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return JW(this,n),YW(this,n)}update(...e){return cG(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(GW.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(iG.reconfigure)?(n=null,r=e.value):e.is(iG.appendConfig)&&(n=null,r=lG(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=qW.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(ZW)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:jW.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=lG(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=iG.mapEffects(a,c).concat(iG.mapEffects(lG(o.effects),l))}return{changes:r,selection:jW.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof CW?t:CW.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return cW.of(t.split(this.facet(e.lineSeparator)||bW))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(JW(this,t),YW(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof BW&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:jW.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=qW.resolve(t.extensions||[],new Map),r=t.doc instanceof cW?t.doc:cW.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||bW)),i=t.selection?t.selection instanceof jW?t.selection:jW.single(t.selection.anchor,t.selection.head):jW.single(0);return MW(i,r.length),n.staticFacet(ZW)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
@@ -864,7 +864,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
864
864
  `).map(e=>e.trim()).filter(Boolean).map(e=>e.replace(/^-\s+/,``)).join(`, `))}function q7(e){let t=e.replace(/^\uFEFF/,``),n=t.match(/^---[ \t]*\r?\n([\s\S]*?)\r?\n(?:---|\.\.\.)[ \t]*(?:\r?\n|$)/);if(!n||n.index!==0)return null;let r=n[1]??``,i=t.slice(n[0].length),a=[],o=null,s=()=>{if(!o)return;let e=yFt(o.lines.join(`
865
865
  `));e&&a.push({key:o.key,value:e}),o=null};for(let e of r.split(/\r?\n/)){if(!e.trim()||e.trimStart().startsWith(`#`))continue;let t=e.match(/^([A-Za-z0-9_-]+):(?:\s*(.*))?$/);if(t){s(),o={key:t[1],lines:[t[2]??``]};continue}o&&/^\s+/.test(e)&&o.lines.push(e)}return s(),a.length>0?{entries:a,block:n[0],raw:r,body:i}:null}function bFt(e,t){if(!e)return t;let n=e.block.endsWith(`
866
866
  `)||t.length===0?``:`
867
- `;return`${e.block}${n}${t}`}function xFt(e,t,n,r=!1){return TFt(e,t,r)?bFt(n,e):null}function SFt(e){return(q7(e)?.body??e).replace(/```[\s\S]*?```/g,` `).replace(/`[^`]*`/g,` `).replace(/^\s{0,3}#{1,6}\s+/gm,``).replace(/!\[[^\]]*\]\([^)]*\)/g,` `).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/<[^>]+>/g,` `).replace(/^\s{0,3}[-*_]{3,}\s*$/gm,` `).replace(/^\s{0,3}(?:[-*+]\s+|\d+[.)]\s+|>\s?)/gm,``).replace(/^\s{0,3}\|?(?:\s*:?-+:?\s*\|)+\s*$/gm,` `).replace(/\|/g,` `).replace(/[*_~>#]/g,` `).match(/\b[\p{L}\p{N}']+\b/gu)?.length??0}function CFt(e){return`${e} word${e===1?``:`s`}`}function wFt(e){return/^(?:[a-z][a-z0-9+.-]*:|\/|#)/i.test(e)}function TFt(e,t,n=!1){return t||n}function EFt(e,t){let n=e.match(/^([^?#]*)([?#].*)?$/),r=n?.[1]??e,i=n?.[2]??``,a=t?.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)):``,o=`${a?`${a}/`:``}${r}`.split(`/`),s=[];for(let e of o)!e||e===`.`||(e===`..`?s.pop():s.push(e));return`${s.join(`/`)}${i}`}function DFt(e,t,n,r,i){if(!e)return e;let a=ba(i),o=a!==`user`;if(wFt(e)&&!(o&&e.startsWith(`/`)&&!e.startsWith(`//`)))return e;let s=o&&e.startsWith(`/`)?e:o&&t?.startsWith(`/`)?`/${EFt(e,t)}`:EFt(e,t),c=n.replace(/\/$/,``),l=new URLSearchParams({path:s});return r&&l.set(`workspaceId`,r),a!==`user`&&l.set(`filesystem`,a),`${c}/api/v1/files/raw?${l.toString()}`}function OFt(e){return/^(?:[a-z][a-z0-9+.-]*:|\/\/|\/|#|\?)/i.test(e)}function J7(e,t){let n=e.trim();if(!n||OFt(n))return null;let r=n.split(/[?#]/,1)[0];if(!r)return null;let i=t?.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)):``,a=`${i?`${i}/`:``}${r}`.split(`/`),o=[];for(let e of a)if(!(!e||e===`.`)){if(e===`..`){if(o.length===0)return null;o.pop();continue}o.push(e)}return o.join(`/`)||null}function kFt(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey}var AFt=[ijt.configure({codeBlock:!1,link:!1,underline:!1}),lAt,ckt.configure({openOnClick:!0,autolink:!0,linkOnPaste:!0,defaultProtocol:`https`,isAllowedUri:(e,t)=>Z7(e)&&(J7(e)!==null||t.defaultValidate(e)),HTMLAttributes:{rel:`noopener noreferrer nofollow`,target:`_blank`}}),ajt.configure({placeholder:`Start writing...`}),ojt,sjt.configure({nested:!0}),cjt.configure({types:[`heading`,`paragraph`]}),djt,GMt.configure({resizable:!0}),PMt,NMt,MMt,QMt.configure({inline:!1,allowBase64:!0}),sNt.configure({lowlight:hFt}),pFt.configure({markedOptions:{gfm:!0,breaks:!1,pedantic:!1}})];function Y7({onClick:e,active:t,disabled:n,title:r,children:i}){return(0,L.jsx)(Ie,{type:`button`,size:`icon-xs`,onClick:e,disabled:n,title:r,"aria-pressed":t,className:DU(`text-muted-foreground/70`,t&&`bg-[color:var(--accent-soft)] text-[color:var(--accent)]`),children:i})}function X7(){return(0,L.jsx)(Pe,{className:`mx-2 h-3.5`})}function Z7(e){let t=e.trim().toLowerCase();return!t.startsWith(`javascript:`)&&!t.startsWith(`data:text/html`)}function jFt(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error??Error(`Read failed`)),r.readAsDataURL(e)})}function MFt(e){if(!e)return null;for(let t of Array.from(e.files??[]))if(t.type.startsWith(`image/`))return t;for(let t of Array.from(e.items??[])){if(t.kind!==`file`||!t.type.startsWith(`image/`))continue;let e=t.getAsFile();if(e)return e}return null}function NFt({editor:e,onInsertImage:t,rawMode:n,onToggleRawMode:r,uploading:i,allowImageUpload:a}){let o=t=>{if(e){if(e.isActive(`image`)){e.chain().focus().updateAttributes(`image`,{align:t}).run();return}e.chain().focus().setTextAlign(t).run()}},s=(0,I.useRef)(null),c=AEt({editor:e,selector:({editor:e})=>e?{bold:e.isActive(`bold`),italic:e.isActive(`italic`),underline:e.isActive(`underline`),strike:e.isActive(`strike`),h1:e.isActive(`heading`,{level:1}),h2:e.isActive(`heading`,{level:2}),h3:e.isActive(`heading`,{level:3}),bulletList:e.isActive(`bulletList`),orderedList:e.isActive(`orderedList`),taskList:e.isActive(`taskList`),blockquote:e.isActive(`blockquote`),codeBlock:e.isActive(`codeBlock`),link:e.isActive(`link`),highlight:e.isActive(`highlight`),alignLeft:e.isActive(`image`)?(e.getAttributes(`image`).align??`left`)===`left`:e.isActive({textAlign:`left`}),alignCenter:e.isActive(`image`)?e.getAttributes(`image`).align===`center`:e.isActive({textAlign:`center`}),alignRight:e.isActive(`image`)?e.getAttributes(`image`).align===`right`:e.isActive({textAlign:`right`})}:null});if(!e||!c)return null;let l=()=>{let t=window.prompt(`URL:`);t&&Z7(t)&&e.chain().focus().extendMarkRange(`link`).setLink({href:t}).run()},u=()=>{let t=window.prompt(`Image URL:`);t&&Z7(t)&&e.chain().focus().setImage({src:t}).run()};return(0,L.jsxs)(ne,{className:`border-b border-border/60 bg-background px-3 py-1.5`,"aria-label":`Formatting toolbar`,children:[(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleBold().run(),active:c.bold,title:`Bold`,children:(0,L.jsx)(gr,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleItalic().run(),active:c.italic,title:`Italic`,children:(0,L.jsx)(ai,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleUnderline().run(),active:c.underline,title:`Underline`,children:(0,L.jsx)(Xi,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleStrike().run(),active:c.strike,title:`Strikethrough`,children:(0,L.jsx)(Hi,{className:`h-4 w-4`})}),(0,L.jsx)(X7,{}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleHeading({level:1}).run(),active:c.h1,title:`Heading 1`,children:(0,L.jsx)(Qr,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleHeading({level:2}).run(),active:c.h2,title:`Heading 2`,children:(0,L.jsx)($r,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleHeading({level:3}).run(),active:c.h3,title:`Heading 3`,children:(0,L.jsx)(ei,{className:`h-4 w-4`})}),(0,L.jsx)(X7,{}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleBulletList().run(),active:c.bulletList,title:`Bullet list`,children:(0,L.jsx)(ui,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleOrderedList().run(),active:c.orderedList,title:`Ordered list`,children:(0,L.jsx)(ci,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleTaskList().run(),active:c.taskList,title:`Task list`,children:(0,L.jsx)(eee,{className:`h-4 w-4`})}),(0,L.jsx)(X7,{}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleBlockquote().run(),active:c.blockquote,title:`Quote`,children:(0,L.jsx)(Ni,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleCodeBlock().run(),active:c.codeBlock,title:`Code block`,children:(0,L.jsx)(Nr,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:l,active:c.link,title:`Link`,children:(0,L.jsx)(si,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:e=>{if(e?.shiftKey){u();return}a&&s.current?.click()},disabled:!a,title:a?`Image (click to upload, Shift+click for URL)`:`Image upload unavailable for this filesystem`,children:(0,L.jsx)(ni,{className:`h-4 w-4`})}),(0,L.jsx)(T,{ref:s,"data-testid":`image-file-input`,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let n=e.target.files?.[0];e.target.value=``,!(!n||!n.type.startsWith(`image/`))&&await t(n)}}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleHighlight().run(),active:c.highlight,title:`Highlight`,children:(0,L.jsx)(ti,{className:`h-4 w-4`})}),(0,L.jsx)(X7,{}),(0,L.jsx)(Y7,{onClick:()=>o(`left`),active:c.alignLeft,title:`Align left`,children:(0,L.jsx)(qi,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>o(`center`),active:c.alignCenter,title:`Center align`,children:(0,L.jsx)(Gi,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>o(`right`),active:c.alignRight,title:`Align right`,children:(0,L.jsx)(Ki,{className:`h-4 w-4`})}),(0,L.jsx)(X7,{}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().setHorizontalRule().run(),title:`Horizontal rule`,children:(0,L.jsx)(vi,{className:`h-4 w-4`})}),(0,L.jsx)(X7,{}),i&&(0,L.jsxs)(`span`,{role:`status`,"aria-live":`polite`,className:`ml-auto flex items-center gap-1.5 text-[11px] text-muted-foreground/80`,children:[(0,L.jsx)(di,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),`Uploading…`]}),(0,L.jsx)(Y7,{onClick:r,active:n,title:n?`Rich text`:`Raw markdown`,children:(0,L.jsx)(`span`,{className:`font-mono text-[10px] font-semibold leading-none tracking-[-0.02em]`,children:`MD`})})]})}function PFt({summary:e}){return(0,L.jsx)(`section`,{"aria-label":`Frontmatter`,className:`border-b border-border/60 bg-transparent px-6 py-5`,"data-testid":`markdown-frontmatter-summary`,children:(0,L.jsxs)(`div`,{className:`rounded-xl border border-[#3a3a3a] bg-[#262626] px-6 py-5 shadow-sm`,children:[(0,L.jsx)(`h2`,{className:`mb-5 text-base font-medium text-[#c9c9c9]`,children:`Metadata`}),(0,L.jsx)(`dl`,{className:`grid gap-x-10 gap-y-4 text-sm sm:grid-cols-[minmax(9rem,17rem)_minmax(0,1fr)]`,children:e.entries.map((e,t)=>(0,L.jsxs)(`div`,{className:`contents`,children:[(0,L.jsx)(`dt`,{className:`font-mono text-[#b8b8b8]`,children:e.key}),(0,L.jsx)(`dd`,{className:`min-w-0 whitespace-pre-wrap break-words font-mono text-[#f5f5f5]`,children:e.value})]},`${e.key}-${t}`))})]})})}function FFt({content:e,onChange:t,readOnly:n=!1,placeholder:r,className:i,documentPath:a,filesystem:o}){let s=ba(o),c=Bu(),l=Vu(),u=s===`user`,{upload:d,uploading:f}=bWe(),[p,m]=(0,I.useState)(!1),h=(0,I.useMemo)(()=>{let e=QMt.configure({inline:!1,allowBase64:!0,resizable:!n,resolveSrc:e=>DFt(e,a,c,l,s)}),t=AFt.map(t=>t.name===`image`?e:t);return r?[...t.filter(e=>e.name!==`placeholder`),ajt.configure({placeholder:r})]:t},[c,a,s,r,n,l]),g=(0,I.useRef)(t);g.current=t;let _=(0,I.useRef)(!1),v=(0,I.useRef)(!1),y=(0,I.useRef)(e),b=(0,I.useRef)(null),x=(0,I.useMemo)(()=>SFt(e),[e]),S=(0,I.useMemo)(()=>q7(e),[e]),C=S?.body??e,w=(0,I.useRef)(async()=>{}),T=(0,I.useRef)(S);T.current=S,w.current=async e=>{v.current=!0;let t=b.current;if(!t||!u)return;let n;try{n=await jFt(e)}catch{return}let r=typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`pending-${Date.now()}-${Math.random().toString(36).slice(2)}`,i={src:n,alt:e.name,pendingUploadId:r};t.chain().focus().setImage(i).run();try{let{url:t}=await d(e,{sourcePath:a}),n=b.current;if(!n||n.isDestroyed)return;n.commands.command(({tr:e,state:n})=>(n.doc.descendants((n,i)=>(n.type.name===`image`&&n.attrs.pendingUploadId===r&&e.setNodeMarkup(i,void 0,{...n.attrs,src:t,pendingUploadId:null}),!0)),!0))}catch{let e=b.current;if(!e||e.isDestroyed)return;e.commands.command(({tr:e,state:t})=>(t.doc.descendants((t,n)=>(t.type.name===`image`&&t.attrs.pendingUploadId===r&&e.setNodeMarkup(n,void 0,{...t.attrs,pendingUploadId:null}),!0)),!0))}};let E=(0,I.useMemo)(()=>C||{type:`doc`,content:[{type:`paragraph`}]},[C]),D=C?`markdown`:`json`,O=PEt({extensions:h,content:E,contentType:D,editable:!n,editorProps:{attributes:{class:`tiptap-prose max-w-[68ch] px-8 py-6 focus:outline-none min-h-[200px]`},transformPastedHTML:_Ft,handlePaste:(e,t)=>{if(n)return!1;let r=MFt(t.clipboardData);return r?(t.preventDefault(),w.current(r),!0):!1}},onUpdate:({editor:e})=>{if(_.current)return;let t=xFt(e.getMarkdown?.()??e.getHTML(),e.isFocused,T.current,v.current);t!==null&&(y.current=t,g.current?.(t))}});return b.current=O,(0,I.useEffect)(()=>{!O||O.isDestroyed||O.setEditable(!n)},[O,n]),(0,I.useEffect)(()=>{!O||O.isDestroyed||e!==y.current&&(O.getMarkdown?.()??O.getHTML())!==C&&(_.current=!0,O.commands.setContent(E,{contentType:D}),_.current=!1,y.current=e)},[O,e,E,D,C]),(0,L.jsxs)(`div`,{className:DU(`flex h-full min-h-0 flex-col overflow-hidden`,i),onPointerDownCapture:()=>{v.current=!0},onClickCapture:()=>{v.current=!0},onKeyDownCapture:()=>{v.current=!0},children:[!n&&(0,L.jsx)(NFt,{editor:O,onInsertImage:e=>w.current(e),rawMode:p,onToggleRawMode:()=>m(e=>!e),uploading:f,allowImageUpload:u}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onClickCapture:e=>{if(!kFt(e.nativeEvent))return;let t=(e.target instanceof Element?e.target.closest(`a[href]`):null)?.getAttribute(`href`);if(!t)return;let n=ba(s),r=n!==`user`,i=J7(t,a)??(r&&t.startsWith(`/`)&&!t.startsWith(`//`)?t.split(/[?#]/,1)[0]:null);i&&(e.preventDefault(),e.stopPropagation(),dc({kind:`openFile`,params:{path:r&&a?.startsWith(`/`)&&!i.startsWith(`/`)?`/${i}`:i,...n===`user`?{}:{filesystem:n}}}))},children:p&&!n?(0,L.jsx)(`textarea`,{"aria-label":`Raw markdown`,"data-testid":`markdown-raw-editor`,className:`h-full min-h-[200px] w-full resize-none bg-background px-8 py-6 font-mono text-[13px] leading-6 text-foreground outline-none placeholder:text-muted-foreground/70`,value:e,placeholder:r,spellCheck:!1,onChange:e=>g.current?.(e.target.value)}):(0,L.jsxs)(L.Fragment,{children:[S&&(0,L.jsx)(PFt,{summary:S}),(0,L.jsx)(DEt,{editor:O})]})}),(0,L.jsx)(`div`,{className:`border-t border-border/60 px-4 py-2 text-right text-xs text-muted-foreground`,"data-testid":`markdown-word-count`,children:CFt(x)})]})}function IFt({sessions:e,activeId:t,onSwitch:n,onCreate:r,onDelete:i,className:a}){let[o,s]=(0,I.useState)(null),c=(0,I.useRef)({}),l=(0,I.useMemo)(()=>e.map(e=>e.id),[e]);(0,I.useEffect)(()=>{if(l.length===0){s(null);return}s(e=>e&&l.includes(e)?e:t&&l.includes(t)?t:l[0]??null)},[l,t]);let u=(0,I.useCallback)(e=>{s(e),c.current[e]?.focus()},[]),d=(0,I.useCallback)((e,t)=>{if(e.target!==e.currentTarget)return;if(e.key===`Enter`||e.key===` `){e.preventDefault(),n?.(t);return}let r=l.indexOf(t);if(r<0)return;let i=r;if(e.key===`ArrowDown`)i=Math.min(r+1,l.length-1);else if(e.key===`ArrowUp`)i=Math.max(r-1,0);else if(e.key===`Home`)i=0;else if(e.key===`End`)i=l.length-1;else return;e.preventDefault();let a=l[i];a&&u(a)},[u,n,l]);return(0,L.jsxs)(`div`,{"data-boring-workspace-part":`session-list`,className:DU(`flex h-full flex-col`,a),role:`navigation`,"aria-label":`Sessions`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`Sessions`}),r&&(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:r,"aria-label":`New session`,children:(0,L.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,L.jsx)(`path`,{d:`M8 3v10M3 8h10`})})})]}),(0,L.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,role:`list`,"aria-label":`Session list`,children:[e.length===0&&(0,L.jsx)(`div`,{className:`px-3 py-6 text-center text-sm text-muted-foreground`,children:`No sessions`}),e.map(e=>(0,L.jsx)(RFt,{session:e,isActive:e.id===t,isFocused:e.id===o,onSwitch:n,onDelete:i,onFocus:()=>s(e.id),onKeyDown:d,rowRef:t=>{c.current[e.id]=t}},e.id))]})]})}async function LFt(e){if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}if(typeof document>`u`)return!1;let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-9999px`,t.style.left=`-9999px`,t.style.opacity=`0`,t.style.pointerEvents=`none`,document.body.appendChild(t);try{return t.focus(),t.select(),document.execCommand?.(`copy`)??!1}catch{return!1}finally{document.body.removeChild(t)}}function RFt({session:e,isActive:t,isFocused:n,onSwitch:r,onDelete:i,onFocus:a,onKeyDown:o,rowRef:s}){let[c,l]=(0,I.useState)(!1),u=(0,I.useCallback)(t=>{t.stopPropagation(),LFt(e.id).then(e=>{e&&(l(!0),window.setTimeout(()=>l(!1),1200))})},[e.id]);return(0,L.jsxs)(`div`,{ref:s,role:`listitem`,"data-boring-workspace-part":`session-row`,"data-boring-state":t?`selected`:void 0,"data-focused":n?`true`:`false`,className:DU(`group flex items-center gap-2 border-b border-border px-3 py-2 text-sm cursor-pointer transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1`,t?`bg-accent text-accent-foreground`:`text-foreground hover:bg-accent/50`),onClick:()=>r?.(e.id),onFocus:a,onKeyDown:t=>o(t,e.id),tabIndex:n?0:-1,"aria-current":t?`true`:void 0,children:[(0,L.jsx)(`span`,{className:`flex-1 truncate`,children:e.title}),(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`hidden shrink-0 text-muted-foreground hover:text-foreground group-hover:inline-flex group-data-[focused=true]:inline-flex`,onClick:u,tabIndex:n?0:-1,"aria-label":`Copy Pi session id for ${e.title}`,title:`Copy Pi session id`,children:c?(0,L.jsx)(br,{className:`h-3.5 w-3.5`}):(0,L.jsx)(Fr,{className:`h-3.5 w-3.5`})}),t&&(0,L.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`,"aria-label":`Active`}),i&&(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`hidden shrink-0 text-muted-foreground hover:text-destructive group-hover:inline-flex group-data-[focused=true]:inline-flex`,onClick:t=>{t.stopPropagation(),i(e.id)},tabIndex:n?0:-1,"aria-label":`Delete ${e.title}`,children:(0,L.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,L.jsx)(`path`,{d:`M3.5 3.5l7 7M10.5 3.5l-7 7`})})})]})}var zFt=r({ArtifactSurfacePane:()=>g$,CatalogRegistry:()=>$n,ChatLayout:()=>Fst,CodeEditor:()=>lrt,CodeEditorPane:()=>kQ,CommandPalette:()=>Kit,CommandRegistry:()=>Hrt,DockviewShell:()=>jU,EmptyPane:()=>Gst,FileTree:()=>Lgt,FileTreePane:()=>HU,FileTreeView:()=>VU,IdeLayout:()=>eit,MAX_PANELS:()=>50,MarkdownEditor:()=>FFt,MarkdownEditorPane:()=>frt,PanelChrome:()=>MU,PanelErrorBoundary:()=>Kst,PanelRegistry:()=>tB,PluginError:()=>Ln,PluginErrorBoundary:()=>oa,PluginErrorProvider:()=>ia,RegistryProvider:()=>rr,ResponsiveDockviewShell:()=>Zrt,SessionBrowser:()=>$at,SessionList:()=>IFt,SurfaceResolverRegistry:()=>tr,SurfaceShell:()=>Mot,ThemeProvider:()=>hst,Toaster:()=>h,TopBar:()=>Hst,UI_COMMAND_EVENT:()=>uc,WORKSPACE_ATTENTION_ACTION_EVENT:()=>n$,WORKSPACE_COMPOSER_STOP_EVENT:()=>XQ,WORKSPACE_COMPOSER_STOP_REASONS:()=>ZQ,WORKSPACE_OPEN_PATH_SURFACE_KIND:()=>iB,WORKSPACE_SURFACE_OPEN_SKIPPED_EVENT:()=>zs,WorkbenchLeftPane:()=>m$,WorkspaceFilesProvider:()=>Hu,WorkspaceLink:()=>hc,WorkspaceLoadingState:()=>Wst,WorkspacePluginClientProvider:()=>_a,WorkspaceProvider:()=>Dst,WorkspaceSourceRegistry:()=>er,agentMeta:()=>ic,bindStore:()=>nU,bootstrap:()=>Zn,buildChatLayout:()=>Pst,buildFullPagePanelHref:()=>sit,buildIdeLayout:()=>$rt,closePanelSchema:()=>Os,cn:()=>DU,createBridge:()=>Ms,createBridgeClient:()=>Ls,createShadcnTheme:()=>OQ,createWorkspacePluginClient:()=>ga,createWorkspaceStore:()=>WQ,definePanel:()=>iot,dismissToast:()=>D,emitAgentData:()=>sc,emitFilesystemAgentFileChange:()=>UU,emitWorkspaceAttentionAction:()=>r$,emitWorkspaceComposerStop:()=>QQ,events:()=>lc,expandToFileSchema:()=>js,filesystemEvents:()=>eu,filesystemPlugin:()=>IQ,formatShortcut:()=>VJe,getFileIcon:()=>rB,isWorkspaceComposerStopDetail:()=>$Q,isWorkspaceComposerStopReason:()=>gat,navigateToLineSchema:()=>As,notificationSchema:()=>ks,onFilesystemChanged:()=>MJe,openFileSchema:()=>Es,openPanelSchema:()=>Ds,postUiCommand:()=>dc,readFileRecords:()=>Ku,toast:()=>ie,useActiveFile:()=>xqe,useActivePanel:()=>Sqe,useActivePanels:()=>ur,useApiBaseUrl:()=>Bu,useAppLeftOverlayChrome:()=>LQ,useArtifactPanels:()=>LJe,useArtifactRouting:()=>RJe,useAutoOpenAgentFiles:()=>WU,useCatalogRegistry:()=>sr,useCatalogs:()=>dr,useCommandRegistry:()=>or,useCommands:()=>lr,useDirtyFiles:()=>wqe,useDockviewApi:()=>pJe,useEditorLifecycle:()=>GU,useEvent:()=>oc,useFilePane:()=>XU,useFullPagePanelHref:()=>cit,useHasWorkspaceFilesProvider:()=>aee,useHydrationComplete:()=>sU,useIsFullPagePanel:()=>uit,useKeyboardShortcuts:()=>YU,useOpenPanels:()=>Cqe,usePanelRenderMode:()=>lit,usePluginErrors:()=>aa,useRegistry:()=>ir,useResetLayout:()=>Tqe,useResponsiveSidebarCollapse:()=>JU,useSetSidebar:()=>aU,useSidebarState:()=>iU,useSurfaceResolverRegistry:()=>cr,useTheme:()=>mst,useThemePreference:()=>oU,useViewportBreakpoint:()=>qU,useWorkspaceAttention:()=>a$,useWorkspaceBridge:()=>_st,useWorkspaceChatPanel:()=>yst,useWorkspaceContext:()=>j$,useWorkspaceContextOptional:()=>vst,useWorkspaceLeftPaneActions:()=>oot,useWorkspacePluginClient:()=>va,useWorkspaceRequestId:()=>Vu,useWorkspaceShellCapabilities:()=>RQ,useWorkspaceSourceRegistry:()=>ar,userMeta:()=>rc,workspaceAttentionSessionBadgeForBlocker:()=>i$,workspaceComposerStopAppliesToSession:()=>t$,workspaceComposerStopTargetSessionId:()=>e$,workspaceEvents:()=>nc,workspaceLinkCommand:()=>fc,workspaceLinkHref:()=>pc}),BFt=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/,VFt=/^[A-Za-z0-9][A-Za-z0-9._:-]*$/;function HFt(e){return typeof e==`string`&&e.length>0&&VFt.test(e)}function Q7(e){return typeof e==`string`&&e.length>0&&e!==`.`&&!e.includes(`\0`)&&!e.includes(`\\`)&&!e.startsWith(`/`)&&!e.startsWith(`//`)&&!/^[A-Za-z]:[\\/]/.test(e)&&!e.split(`/`).includes(`..`)}function $7(e,t,n){return{code:e,field:t,message:n}}function e9(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function UFt(e,t,n,r){if(t!==void 0){if(!Array.isArray(t)){e.push($7(`INVALID_FIELD`,n,`${n} must be an array`));return}t.forEach((t,i)=>{let a=`${n}[${i}]`;if(typeof t!=`string`||t.length===0){e.push($7(`INVALID_FIELD`,a,`${a} must be a non-empty string`));return}r&&!Q7(t)&&e.push($7(`INVALID_PATH`,a,`${a} must be a safe relative path`))})}}var WFt=[`outputs`,`panels`,`commands`,`leftTabs`,`surfaceResolvers`,`providers`,`bindings`,`catalogs`];function GFt(e,t){if(t===void 0)return;if(!e9(t)){e.push($7(`INVALID_FIELD`,`boring`,`boring must be an object when provided`));return}for(let n of WFt)t[n]!==void 0&&e.push($7(`INVALID_FIELD`,`boring.${n}`,`boring.${n} is not supported; declare front contributions in boring.front via definePlugin({ ... })`));t.id!==void 0&&(typeof t.id!=`string`||!HFt(t.id))&&e.push($7(`INVALID_ID`,`boring.id`,`boring.id must start with a letter or number and use only letters, numbers, dot, underscore, colon, or dash`));let n=t.front;n!==void 0&&(typeof n!=`string`||!Q7(n))&&e.push($7(`INVALID_PATH`,`boring.front`,`boring.front must be a safe relative path`));let r=t.server;return r!==void 0&&r!==!1&&(typeof r!=`string`||!Q7(r))&&e.push($7(`INVALID_PATH`,`boring.server`,`boring.server must be a safe relative path or false`)),t.label!==void 0&&typeof t.label!=`string`&&e.push($7(`INVALID_FIELD`,`boring.label`,`boring.label must be a string when provided`)),{...typeof t.id==`string`?{id:t.id}:{},...typeof t.front==`string`?{front:t.front}:{},...typeof t.server==`string`||t.server===!1?{server:t.server}:{},...typeof t.label==`string`?{label:t.label}:{}}}var KFt=[`npm:`,`git:`,`github:`,`http:`,`https:`,`ssh:`];function qFt(e){return KFt.some(t=>e.startsWith(t))}function JFt(e){if(e.length===0)return!1;if(qFt(e))return!0;let t=e.startsWith(`file:`)?e.slice(5):e;return t===`.`||t===`./`||Q7(t.startsWith(`./`)?t.slice(2):t)}function YFt(e,t){if(t!==void 0){if(!Array.isArray(t)){e.push($7(`INVALID_FIELD`,`pi.packages`,`pi.packages must be an array when provided`));return}t.forEach((t,n)=>{let r=`pi.packages[${n}]`;if(typeof t==`string`){JFt(t)||e.push($7(`INVALID_PATH`,r,`${r} must be a safe package source`));return}if(!e9(t)){e.push($7(`INVALID_FIELD`,r,`${r} must be a string or package source object`));return}typeof t.source!=`string`||t.source.length===0?e.push($7(`INVALID_FIELD`,`${r}.source`,`${r}.source must be a non-empty string`)):JFt(t.source)||e.push($7(`INVALID_PATH`,`${r}.source`,`${r}.source must be a safe package source`))})}}function XFt(e,t){if(t!==void 0){if(!e9(t)){e.push($7(`INVALID_FIELD`,`pi`,`pi must be an object when provided`));return}return UFt(e,t.extensions,`pi.extensions`,!0),UFt(e,t.skills,`pi.skills`,!0),YFt(e,t.packages),t.systemPrompt!==void 0&&typeof t.systemPrompt!=`string`&&e.push($7(`INVALID_FIELD`,`pi.systemPrompt`,`pi.systemPrompt must be a string when provided`)),t}}function ZFt(e){let t=[];if(!e9(e))return{valid:!1,issues:[$7(`INVALID_FIELD`,`<root>`,`package.json manifest must be an object`)]};e.name!==void 0&&typeof e.name!=`string`&&t.push($7(`INVALID_FIELD`,`name`,`name must be a string when provided`)),e.version!==void 0&&typeof e.version!=`string`?t.push($7(`INVALID_VERSION`,`version`,`version must be a string when provided`)):typeof e.version==`string`&&e.version.length>0&&!BFt.test(e.version)&&t.push($7(`INVALID_VERSION`,`version`,`version must be a valid semver string`));let n=GFt(t,e.boring),r=XFt(t,e.pi);return!n&&!r&&t.push($7(`MISSING_REQUIRED_FIELD`,`boring|pi`,`package.json must include boring and/or pi plugin metadata`)),t.length>0?{valid:!1,issues:t}:{valid:!0,packageJson:{...typeof e.name==`string`?{name:e.name}:{},...typeof e.version==`string`?{version:e.version}:{},...n?{boring:n}:{},...r?{pi:r}:{}}}}var QFt=Symbol.for(`@hachej/boring-workspace:active-ui-bridge`);function $Ft(){return globalThis}function eIt(){return $Ft()[QFt]}var tIt=class extends Error{constructor(){super(`No workspace UI bridge is active. This plugin command must run inside a boring-ui workspace agent (it cannot open panels from a bare Pi CLI).`),this.name=`NoWorkspaceUiBridgeError`}};function nIt(){let e=eIt();if(!e)throw new tIt;return e}async function t9(e){return nIt().postCommand(e)}async function rIt(e){return t9({kind:`openPanel`,params:{id:e.id,component:e.component,params:e.params}})}async function iIt(e,t=`info`){return t9({kind:`showNotification`,params:{msg:e,level:t}})}var aIt=r({NoWorkspaceUiBridgeError:()=>tIt,WORKSPACE_OPEN_PATH_SURFACE_KIND:()=>iB,captureFrontPlugin:()=>Un,createCapturingBoringFrontAPI:()=>Hn,definePlugin:()=>zn,execWorkspaceUi:()=>t9,getWorkspaceUiBridge:()=>eIt,isSafePluginRelativePath:()=>Q7,isValidBoringPluginId:()=>HFt,notify:()=>iIt,openPanel:()=>rIt,useAppLeftOverlayChrome:()=>LQ,useWorkspaceShellCapabilities:()=>RQ,validateBoringPluginManifest:()=>ZFt}),n9=`ask-user`,r9=`ask-user.questions`,i9=`Questions`,a9=`questions`,oIt={PENDING:`questions.pending`},o9={request:`ask-user.v1.request`,answer:`ask-user.v1.answer`,cancel:`ask-user.v1.cancel`,pending:`ask-user.v1.pending`,transcript:`ask-user.v1.transcript`},s9={PENDING_EXISTS:`ASK_USER_PENDING_EXISTS`,QUESTION_NOT_FOUND:`ASK_USER_QUESTION_NOT_FOUND`,QUESTION_ABANDONED:`ASK_USER_QUESTION_ABANDONED`,QUESTION_NOT_READY:`ASK_USER_QUESTION_NOT_READY`,SCHEMA_INVALID:`ASK_USER_SCHEMA_INVALID`,ANSWER_INVALID:`ASK_USER_ANSWER_INVALID`,SESSION_MISMATCH:`ASK_USER_SESSION_MISMATCH`,UI_UNAVAILABLE:`ASK_USER_UI_UNAVAILABLE`,ALREADY_ANSWERED:`ASK_USER_ALREADY_ANSWERED`,ALREADY_CANCELLED:`ASK_USER_ALREADY_CANCELLED`,UNAUTHORIZED:`ASK_USER_UNAUTHORIZED`,UI_ACK_TIMEOUT:`ASK_USER_UI_ACK_TIMEOUT`,RATE_LIMITED:`ASK_USER_RATE_LIMITED`,RUNTIME_UNAVAILABLE:`ASK_USER_RUNTIME_UNAVAILABLE`};Object.values(s9);var sIt=(0,I.createContext)(null),cIt=`space-y-1.5`,c9=`mt-0.5`;function l9(){let e=(0,I.useContext)(sIt);if(!e)throw Error(`useQuestionForm must be used inside QuestionFormProvider`);return e}function lIt({schema:e,status:t=`ready`,disabled:n=!1,submitting:r,initialValues:i,rendererRegistry:a={},onSubmit:o,onCancel:s,children:c}){let[l,u]=(0,I.useState)(()=>vIt(e,i)),[d,f]=(0,I.useState)({}),[p,m]=(0,I.useState)(!1),[h,g]=(0,I.useState)(!1),_={},v=(0,I.useRef)(null);(0,I.useEffect)(()=>{u(t=>{let n=vIt(e,i);for(let r of e?.fields??[])d[r.name]&&t[r.name]!==void 0&&(n[r.name]=t[r.name]);return n})},[e,i,d]);let y=(0,I.useMemo)(()=>{if(!e)return{};let t=d9(e,l).errors;return h?t:Object.fromEntries(Object.entries(t).filter(([e])=>d[e]))},[e,l,h,d]),b=(0,I.useCallback)((e,t)=>{f(t=>({...t,[e]:!0})),u(n=>({...n,[e]:t}))},[]),x=(0,I.useCallback)(e=>f(t=>({...t,[e]:!0})),[]),S=(0,I.useCallback)(async()=>{if(!e||t!==`ready`||n)return;let r=d9(e,l);if(!r.valid){g(!0);let e=Object.keys(r.errors)[0];v.current?.querySelector(`[name="${yIt(e)}"]`)?.focus();return}m(!0);try{await o?.(l)}finally{m(!1)}},[e,t,n,l,o]),C=(0,I.useCallback)(()=>{Object.keys(d).length>0&&!window.confirm(`Discard your answer?`)||s?.()},[s,d]),w={schema:e,status:t,values:l,touched:d,errors:y,submitting:r??p,disabled:n,dirtyHints:_,setValue:b,touch:x,submit:S,cancel:C,rendererRegistry:a,formRef:v};return(0,L.jsx)(sIt.Provider,{value:w,children:c})}function uIt({children:e,"aria-label":t=`Question form`,className:n}){let{submit:r,cancel:i,status:a,formRef:o}=l9();return(0,L.jsxs)(`form`,{ref:o,"data-question-form":!0,"aria-label":t,className:n,onSubmit:e=>{e.preventDefault(),r()},onKeyDown:e=>{e.key===`Enter`&&dIt(e)&&(e.preventDefault(),r()),e.key===`Escape`&&(e.preventDefault(),i())},children:[(0,L.jsx)(`div`,{"aria-live":`polite`,className:`sr-only`,children:a===`ready`?`Question ready`:`Question ${a}`}),e]})}function dIt(e){if(e.metaKey||e.ctrlKey)return!0;if(e.shiftKey)return!1;let t=e.target;if(!t)return!0;let n=t.tagName.toLowerCase();return!(n===`textarea`||n===`button`||n===`a`||t.isContentEditable)}function fIt(){let{schema:e}=l9();return e?(0,L.jsx)(L.Fragment,{children:e.fields.map(e=>(0,L.jsx)(pIt,{field:e},e.name))}):null}function pIt({field:e}){let{values:t,errors:n,disabled:r,submitting:i,setValue:a,touch:o,rendererRegistry:s,dirtyHints:c}=l9(),l=n[e.name],u=`${e.name}-help`,d=`${e.name}-error`,f=`${e.name}-hint`,p=[e.helpText?u:void 0,l?d:void 0,c[e.name]?f:void 0].filter(Boolean).join(` `),m=s[e.type]??gIt[e.type]??s.unsupported??_It;return(0,L.jsxs)(ce,{"data-field":e.name,className:cIt,children:[m({field:e,value:t[e.name],error:l,disabled:r||i,describedBy:p,onChange:t=>a(e.name,t),onBlur:()=>o(e.name)}),e.helpText?(0,L.jsx)(x,{id:u,children:e.helpText}):null,c[e.name]?(0,L.jsx)(x,{id:f,children:c[e.name]}):null,l?(0,L.jsx)(se,{id:d,role:`alert`,children:l}):null]})}function mIt(e){let{status:t,submitting:n,disabled:r}=l9();return(0,L.jsx)(`button`,{...e,type:`submit`,disabled:r||n||t!==`ready`,children:e.children??`Submit`})}function hIt(e){let{cancel:t,disabled:n,submitting:r}=l9();return(0,L.jsx)(`button`,{...e,type:`button`,disabled:n||r,onClick:n=>{e.onClick?.(n),n.defaultPrevented||t()},children:e.children??`Cancel`})}var gIt={text:({field:e,value:t,disabled:n,describedBy:r,error:i,onChange:a,onBlur:o})=>e.type===`text`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ue,{htmlFor:e.name,children:u9(e)}),(0,L.jsx)(T,{id:e.name,name:e.name,value:typeof t==`string`?t:``,placeholder:e.placeholder,minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,disabled:n,"aria-describedby":r||void 0,"aria-invalid":!!i,"aria-errormessage":i?`${e.name}-error`:void 0,onChange:e=>a(e.target.value),onBlur:o})]}),textarea:({field:e,value:t,disabled:n,describedBy:r,error:i,onChange:a,onBlur:o})=>e.type===`textarea`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ue,{htmlFor:e.name,children:u9(e)}),(0,L.jsx)(_,{id:e.name,name:e.name,value:typeof t==`string`?t:``,placeholder:e.placeholder,minLength:e.minLength,maxLength:e.maxLength,disabled:n,"aria-describedby":r||void 0,"aria-invalid":!!i,"aria-errormessage":i?`${e.name}-error`:void 0,onChange:e=>a(e.target.value),onBlur:o})]}),select:({field:e,value:t,disabled:n,describedBy:r,error:i,onChange:a,onBlur:o})=>(e.type===`select`||e.type===`radio`)&&(0,L.jsxs)(Ge,{"aria-describedby":e.type===`radio`&&r||void 0,"aria-invalid":e.type===`radio`?!!i:void 0,"aria-errormessage":e.type===`radio`&&i?`${e.name}-error`:void 0,children:[(0,L.jsx)(ze,{children:u9(e)}),e.options.map(r=>e.type===`select`?null:(0,L.jsxs)(ke,{children:[(0,L.jsx)(xe,{className:c9,name:e.name,checked:t===r.value,disabled:n,onChange:()=>a(r.value),onBlur:o}),(0,L.jsxs)(De,{children:[(0,L.jsx)(nt,{children:r.label}),r.description?(0,L.jsx)(me,{children:r.description}):null]})]},r.value)),e.type===`select`?(0,L.jsxs)(tt,{name:e.name,value:typeof t==`string`?t:``,disabled:n,onValueChange:e=>a(e),children:[(0,L.jsx)(Ke,{className:`w-full`,"aria-describedby":r||void 0,"aria-invalid":!!i,"aria-errormessage":i?`${e.name}-error`:void 0,onBlur:o,children:(0,L.jsx)(Be,{placeholder:`Select…`})}),(0,L.jsx)(Ce,{children:e.options.map(e=>(0,L.jsx)(Ee,{value:e.value,children:e.label},e.value))})]}):null]}),radio:e=>gIt.select?.(e),multiselect:({field:e,value:t,disabled:n,describedBy:r,error:i,onChange:a,onBlur:o})=>e.type===`multiselect`&&(0,L.jsxs)(Ge,{"aria-describedby":r||void 0,"aria-invalid":!!i,"aria-errormessage":i?`${e.name}-error`:void 0,children:[(0,L.jsx)(ze,{children:u9(e)}),e.options.map(r=>{let i=Array.isArray(t)?t:[];return(0,L.jsxs)(ke,{children:[(0,L.jsx)(Te,{className:c9,name:e.name,checked:i.includes(r.value),disabled:n,onCheckedChange:e=>a(e?[...i,r.value]:i.filter(e=>e!==r.value)),onBlur:o}),(0,L.jsxs)(De,{children:[(0,L.jsx)(nt,{children:r.label}),r.description?(0,L.jsx)(me,{children:r.description}):null]})]},r.value)})]}),checkbox:({field:e,value:t,disabled:n,describedBy:r,error:i,onChange:a,onBlur:o})=>e.type===`checkbox`&&(0,L.jsxs)(ke,{children:[(0,L.jsx)(Te,{className:c9,name:e.name,checked:t===!0,disabled:n,"aria-describedby":r||void 0,"aria-invalid":!!i,"aria-errormessage":i?`${e.name}-error`:void 0,onCheckedChange:e=>a(e===!0),onBlur:o}),(0,L.jsx)(nt,{children:e.label})]}),number:({field:e,value:t,disabled:n,describedBy:r,error:i,onChange:a,onBlur:o})=>e.type===`number`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ue,{htmlFor:e.name,children:u9(e)}),(0,L.jsx)(T,{id:e.name,type:`number`,name:e.name,value:typeof t==`number`?String(t):``,min:e.min,max:e.max,step:e.integer?1:e.step,disabled:n,"aria-describedby":r||void 0,"aria-invalid":!!i,"aria-errormessage":i?`${e.name}-error`:void 0,onChange:e=>a(e.target.value===``?null:Number(e.target.value)),onBlur:o})]}),unsupported:_It};function _It({field:e}){return(0,L.jsxs)(x,{role:`note`,children:[`Unsupported question field: `,e.type]})}function u9(e){return(0,L.jsxs)(L.Fragment,{children:[e.label,`required`in e&&e.required?(0,L.jsx)(`span`,{className:`text-destructive`,"aria-hidden":`true`,children:` *`}):null]})}function vIt(e,t){let n={...t??{}};for(let t of e?.fields??[])n[t.name]===void 0&&`defaultValue`in t&&(n[t.name]=t.defaultValue);return n}function d9(e,t){let n={};for(let r of e.fields){let e=t[r.name],i=e==null||e===``||Array.isArray(e)&&e.length===0;if(`required`in r&&r.required&&i){n[r.name]=`This field is required.`;continue}i||(r.type===`text`||r.type===`textarea`?typeof e==`string`?r.minLength!==void 0&&e.length<r.minLength?n[r.name]=`Must be at least ${r.minLength} characters.`:r.maxLength!==void 0&&e.length>r.maxLength?n[r.name]=`Must be at most ${r.maxLength} characters.`:r.type===`text`&&r.pattern&&!new RegExp(r.pattern).test(e)&&(n[r.name]=`Invalid format.`):n[r.name]=`Enter text.`:(r.type===`select`||r.type===`radio`)&&(typeof e!=`string`||!r.options.some(t=>t.value===e))?n[r.name]=`Choose a valid option.`:r.type===`multiselect`?Array.isArray(e)?r.minSelections!==void 0&&e.length<r.minSelections?n[r.name]=`Choose at least ${r.minSelections}.`:r.maxSelections!==void 0&&e.length>r.maxSelections?n[r.name]=`Choose at most ${r.maxSelections}.`:e.some(e=>!r.options.some(t=>t.value===e))&&(n[r.name]=`Choose valid options.`):n[r.name]=`Choose valid options.`:r.type===`checkbox`&&typeof e!=`boolean`?n[r.name]=`Must be checked or unchecked.`:r.type===`number`&&(typeof e!=`number`||!Number.isFinite(e)?n[r.name]=`Enter a number.`:r.integer&&!Number.isInteger(e)?n[r.name]=`Enter a whole number.`:r.min!==void 0&&e<r.min?n[r.name]=`Must be at least ${r.min}.`:r.max!==void 0&&e>r.max&&(n[r.name]=`Must be at most ${r.max}.`)))}return{valid:Object.keys(n).length===0,errors:n}}function yIt(e){return globalThis.CSS?.escape?.(e)??e.replace(/[^A-Za-z0-9_-]/g,`\\$&`)}var f9=class extends Error{code;statusCode;constructor(e,t,n=0){super(t),this.code=e,this.statusCode=n}};function bIt(e){let t=e?.[oIt.PENDING];if(!t||typeof t!=`object`)return[];let n=new Map,r=t,i=p9(r.hint)??p9(r.question);if(i&&n.set(i.sessionId,i),r.hintsBySession&&typeof r.hintsBySession==`object`&&!Array.isArray(r.hintsBySession))for(let[e,t]of Object.entries(r.hintsBySession)){let r=p9(t);r&&r.sessionId===e&&n.set(e,r)}return[...n.values()]}function p9(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.questionId!=`string`||typeof t.sessionId!=`string`)return null;let n=wIt(t.status);return{questionId:t.questionId,sessionId:t.sessionId,...n===`abandoned`&&t.status===void 0?{}:{status:n}}}function m9(e={}){async function t(t,n,r,i){let a=await fetch(`${e.apiBaseUrl??``}/api/v1/workspace-bridge/call`,{method:`POST`,headers:{"Content-Type":`application/json`,...e.headers??{},...r?{"x-boring-session-id":r}:{}},body:JSON.stringify({op:t,input:n,...i?{idempotencyKey:i}:{}})}),o=await a.json().catch(()=>({}));if(!a.ok){let e=`error`in o?o.error:void 0;throw new f9(e?.code??s9.UI_UNAVAILABLE,e?.message??`Question bridge call failed`,a.status)}if(!o.ok)throw new f9(o.error?.code??s9.UI_UNAVAILABLE,o.error?.message??`Question bridge call failed`,a.status);return o.output}return{async pending(e){return xIt((await t(o9.pending,{sessionId:e},e)).pending)},async cancel(e){return TIt(e),await t(o9.cancel,{questionId:e.questionId,sessionId:e.sessionId,answerToken:e.answerToken},e.sessionId,await SIt(o9.cancel,{questionId:e.questionId,sessionId:e.sessionId,answerToken:e.answerToken}))},async submit(e,n){if(TIt(e),!e.schema)throw new f9(s9.QUESTION_NOT_READY,`Question is not ready`);let r=d9(e.schema,n);if(!r.valid)throw new f9(s9.ANSWER_INVALID,EIt(r));return await t(o9.answer,{questionId:e.questionId,sessionId:e.sessionId,answerToken:e.answerToken,values:n},e.sessionId,await SIt(o9.answer,{questionId:e.questionId,sessionId:e.sessionId,answerToken:e.answerToken,values:n}))}}}function xIt(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.questionId!=`string`||typeof t.sessionId!=`string`)return null;let n=DIt(t.schema)?t.schema:void 0;return{questionId:t.questionId,sessionId:t.sessionId,ownerPrincipalId:typeof t.ownerPrincipalId==`string`?t.ownerPrincipalId:`anonymous`,status:wIt(t.status),title:typeof t.title==`string`?t.title:void 0,context:typeof t.context==`string`?t.context:void 0,schema:n,answerToken:typeof t.answerToken==`string`?t.answerToken:``,createdAt:typeof t.createdAt==`string`?t.createdAt:new Date(0).toISOString(),updatedAt:typeof t.updatedAt==`string`?t.updatedAt:new Date(0).toISOString()}}async function SIt(e,t){let n=`${e}:${h9(t)}`,r=globalThis.crypto?.subtle;if(r&&typeof r.digest==`function`){let e=new TextEncoder().encode(n),t=await r.digest(`SHA-256`,e);return`ask-user-idem:${Array.from(new Uint8Array(t),e=>e.toString(16).padStart(2,`0`)).join(``)}`}return`ask-user-idem:${CIt(n)}`}function CIt(e){let t=3735928559^e.length,n=1103547991^e.length,r=3235826430^e.length,i=2654435769^e.length;for(let a=0;a<e.length;a+=1){let o=e.charCodeAt(a);t=Math.imul(t^o,2654435761),n=Math.imul(n^o,1597334677),r=Math.imul(r^o,2246822507),i=Math.imul(i^o,3266489909)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),[t,n,r,i].map(e=>(e>>>0).toString(16).padStart(8,`0`)).join(``)}function h9(e){return typeof e!=`object`||!e?JSON.stringify(e):Array.isArray(e)?`[${e.map(h9).join(`,`)}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${h9(e[t])}`).join(`,`)}}`}function wIt(e){return e===`pending`||e===`ready`?`ready`:e===`answered`||e===`cancelled`||e===`abandoned`?e:`abandoned`}function TIt(e){if(!e.answerToken)throw new f9(s9.QUESTION_NOT_READY,`Question answer token is missing`)}function EIt(e){return Object.values(e.errors)[0]??`Invalid answer`}function DIt(e){return!!e&&typeof e==`object`&&e.wireVersion===1&&Array.isArray(e.fields)}function OIt(){let e=new Set,t=new Map,n=new Map,r=()=>{for(let t of[...e])t()};return{getPending(e){return e?t.get(e)??null:null},setPending(e,i){e?(t.set(e.sessionId,e),n.set(e.sessionId,{questionId:e.questionId,sessionId:e.sessionId,status:e.status})):i?(t.delete(i),n.delete(i)):(t.clear(),n.clear()),r()},getPendingHints(){return[...n.values()]},getHydratedPendingKeys(){return[...t.values()].map(e=>`${e.sessionId}:${e.questionId}:${e.status}`)},setPendingHints(e){n.clear();let i=new Map;for(let t of e)n.set(t.sessionId,t),i.set(t.sessionId,t);for(let[e,n]of[...t.entries()]){let r=i.get(e);(!r||r.questionId!==n.questionId||r.status&&r.status!==n.status)&&t.delete(e)}r()},subscribe(t){return e.add(t),()=>e.delete(t)}}}var kIt=OIt(),AIt=(0,I.createContext)(null);function jIt(){let e=(0,I.useContext)(AIt);if(!e)throw Error(`askUserPlugin QuestionsPane must be rendered under AskUserProvider`);return e}function MIt(e){let t=e.getPendingHints().map(e=>`${e.sessionId}:${e.questionId}:${e.status??`ready`}`).sort(),n=e.getHydratedPendingKeys().sort();return`${t.length?t.join(`|`):`none`}#hydrated=${n.join(`|`)}`}function g9(e,t){return e.openSessionIds?e.openSessionIds.includes(t):e.activeSessionId===t}function NIt(e,t){let{addBlocker:n,removeBlocker:r}=a$();(0,I.useEffect)(()=>{let t=[];for(let r of e.getPendingHints()){if(r.status&&r.status!==`ready`)continue;let i=`${n9}:${r.sessionId}:${r.questionId}`;t.push(i);let a=e.getPending(r.sessionId),o=e.activeSessionId===r.sessionId&&g9(e,r.sessionId),s=a?[{id:`open`,label:`Open Questions`},{id:`cancel`,label:`Cancel question`}]:o?[{id:`open`,label:`Open Questions`}]:void 0;n({id:i,reason:`ask-user.question`,surfaceKind:a9,target:r.questionId,label:a?.title??`Answer the question in Questions to continue`,sessionId:r.sessionId,sessionBadge:{kind:`question`,label:`question`,tone:`attention`,priority:10},pruneWhenSessionMissing:!0,focus:{closeWorkbenchLeftPane:!0},inbox:{kind:`question`,sourceLabel:`question`,createdAt:a?.createdAt,updatedAt:a?.updatedAt??a?.createdAt,priority:10},actions:s})}return()=>{for(let e of t)r(e)}},[n,r,e,t])}function PIt(e,t,n){let r=(0,I.useRef)(new Set);(0,I.useEffect)(()=>{for(let t of e.getPendingHints())g9(e,t.sessionId)||r.current.delete(`${t.sessionId}:${t.questionId}`);if(!t||!g9(e,t))return;let n=e.getPendingHints().find(e=>e.sessionId===t);if(!n||n.status&&n.status!==`ready`)return;let i=e.getPending(t);if(!i||i.questionId!==n.questionId||i.status!==`ready`)return;let a=`${n.sessionId}:${n.questionId}`;r.current.has(a)||(r.current.add(a),dc({kind:`openSurface`,params:{kind:a9,target:n.questionId,meta:{sessionId:n.sessionId,openOnlyWhenSessionOpen:!0}}}))},[t,e,n])}function FIt(e){(0,I.useEffect)(()=>{let t=t=>{let n=t.detail;if(!n||n.actionId!==`cancel`||n.blocker.reason!==`ask-user.question`)return;let r=n.blocker.sessionId??n.sessionId??e.activeSessionId,i=e.getPending(r);!i||n.blocker.target&&i.questionId!==n.blocker.target||(e.setPending(null,i.sessionId),m9({apiBaseUrl:e.apiBaseUrl,headers:e.authHeaders}).cancel(i).catch(()=>void 0))};return window.addEventListener(n$,t),()=>window.removeEventListener(n$,t)},[e])}function IIt(e){(0,I.useEffect)(()=>{let t=t=>{let n=t.detail,r=e$(n,e.activeSessionId),i=e.getPending(r);!i||!t$(n,i.sessionId,{fallbackSessionId:e.activeSessionId})||(e.setPending(null,i.sessionId),m9({apiBaseUrl:e.apiBaseUrl,headers:e.authHeaders}).cancel(i).catch(()=>void 0))};return window.addEventListener(XQ,t),()=>window.removeEventListener(XQ,t)},[e])}function LIt(e,t){let{activeSessionId:n,apiBaseUrl:r,authHeaders:i}=t;(0,I.useEffect)(()=>{let t=!1;async function a(){let a=[];try{let n=await(await fetch(`${r}/api/v1/ui/state`,{headers:i})).json().catch(()=>null);a=bIt(n),!t&&RIt(n)&&e.setPendingHints(a)}catch{}let o=new Set;n&&o.add(n);for(let e of a)o.add(e.sessionId);await Promise.all([...o].map(async n=>{try{await e.refreshPending(n)}catch{t||e.setPending(null,n)}}))}let o=()=>{document.visibilityState===`visible`&&a()},s=()=>{a()},c=e=>{e.detail?.kind===`questions`&&a()},l=null,u=lc.on(nc.agentData,()=>{l||=setTimeout(()=>{l=null,a()},1200)}),d=lc.on(nc.uiCommand,s);return a(),window.addEventListener(`focus`,a),document.addEventListener(`visibilitychange`,o),window.addEventListener(uc,s),window.addEventListener(zs,c),()=>{t=!0,l&&clearTimeout(l),u(),d(),window.removeEventListener(`focus`,a),document.removeEventListener(`visibilitychange`,o),window.removeEventListener(uc,s),window.removeEventListener(zs,c)}},[n,r,i,e])}function RIt(e){return!!e&&Object.prototype.hasOwnProperty.call(e,oIt.PENDING)}var zIt=`1970-01-01T00:00:00.000Z`;function _9(e){if(e==null)return null;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()}function BIt(e){return _9(e.inbox?.updatedAt)??_9(e.inbox?.createdAt)??zIt}function VIt(e){if(e.inbox?.kind)return e.inbox.kind;let t=i$(e);return t?.kind===`question`||t?.kind===`review`||t?.kind===`approval`||t?.kind===`notice`?t.kind:`notice`}function HIt(e){return e.label||e.reason||`Workspace item`}function UIt(e){return e.inbox?.sourceLabel??i$(e)?.label??`workspace`}function WIt(e){return!!e.inbox}function GIt(e){let t=BIt(e);return{id:e.id,kind:VIt(e),status:`open`,title:HIt(e),description:e.reason,source:{type:`plugin`,pluginId:e.reason,label:UIt(e)},sessionId:e.sessionId??null,chatAvailable:e.pruneWhenSessionMissing===!0&&!!e.sessionId,targetLabel:e.target??``,artifact:e.surfaceKind?{type:`surface`,surfaceKind:e.surfaceKind,target:e.target,params:e.sessionId?{sessionId:e.sessionId}:void 0}:null,createdAt:_9(e.inbox?.createdAt)??t,updatedAt:t,priority:e.inbox?.priority??i$(e)?.priority??0,actions:e.actions?.map(e=>({id:e.id,label:e.label}))??[]}}function KIt({filter:e,counts:t,onFilterChange:n}){return(0,L.jsx)(`div`,{className:`flex shrink-0 gap-1 border-b border-border/60 bg-[color:oklch(from_var(--background)_calc(l-0.012)_c_h)] px-4 py-2`,children:[[`all`,`All`,t.all],[`questions`,`Questions`,t.questions],[`reviews`,`Reviews`,t.reviews]].map(([t,r,i])=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>n(t),className:DU(`rounded-full px-2.5 py-1 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,e===t?`bg-[color:oklch(from_var(--accent)_l_c_h/0.14)] text-[color:var(--accent)]`:`bg-transparent text-muted-foreground hover:bg-foreground/[0.06] hover:text-foreground`),children:[r,` `,(0,L.jsx)(`span`,{className:`ml-1 opacity-70`,children:i})]},t))})}function v9(e){let t=new Date(e.updatedAt||e.createdAt);return Number.isNaN(t.getTime())?new Date(0):t}function qIt(e,t=Date.now()){let n=v9(e),r=t-n.getTime();if(r<6e4)return`now`;let i=Math.floor(r/6e4);if(i<60)return`${i}m`;let a=Math.floor(i/60);if(a<24)return`${a}h`;let o=Math.floor(a/24);return o<7?`${o}d`:n.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function JIt(e){return e.source.label||e.source.type}function y9(e,t){return t===`all`?[...e]:e.filter(e=>t===`questions`?e.kind===`question`:e.kind===`review`)}function YIt(e){return[...e].sort((e,t)=>{let n=v9(t).getTime()-v9(e).getTime();if(n!==0)return n;let r=t.priority-e.priority;return r===0?e.title.localeCompare(t.title):r})}function XIt(e,t){return e.map(e=>({...e,pinned:t.has(e.id)}))}function ZIt(e){switch(e){case`review`:return`bg-amber-500/12 text-amber-700 dark:text-amber-300`;case`approval`:return`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`;case`notice`:return`bg-foreground/[0.07] text-muted-foreground`;default:return`bg-[color:var(--accent)]/12 text-[color:var(--accent)]`}}function QIt({item:e,onTogglePinned:t,onOpenArtifact:n,onOpenChat:r}){let i=[e.sessionId?`Session ${e.sessionId}`:null,e.targetLabel||null].filter(Boolean).join(` · `);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`div`,{role:`button`,tabIndex:0,className:`group flex h-11 w-full items-center gap-2 overflow-hidden px-4 text-left text-[12px] transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,onClick:()=>n(e),onKeyDown:t=>{t.currentTarget===t.target&&(t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),n(e)))},children:[(0,L.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[color:var(--accent)]`}),(0,L.jsx)(`span`,{className:`max-w-28 shrink-0 truncate font-semibold text-foreground`,children:JIt(e)}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-hidden whitespace-nowrap text-foreground`,children:[(0,L.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,L.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`—`}),(0,L.jsx)(`span`,{className:`truncate text-muted-foreground`,children:i||e.description})]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:DU(`rounded-full px-2 py-0.5 text-[10px] font-medium`,ZIt(e.kind)),children:e.kind}),(0,L.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,title:v9(e).toLocaleString(),children:qIt(e)})]}),e.sessionId&&e.chatAvailable?(0,L.jsx)(`button`,{type:`button`,"aria-label":`Open chat session ${e.sessionId}`,title:`Open chat session`,className:`grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:bg-foreground/[0.06] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 group-hover:opacity-100 group-focus-visible:opacity-100`,onClick:t=>{t.stopPropagation(),r(e)},children:(0,L.jsx)(gi,{className:`size-3.5`,strokeWidth:1.75})}):null,(0,L.jsx)(`button`,{type:`button`,"aria-label":`${e.pinned?`Unpin`:`Pin`} ${e.title}`,title:e.pinned?`Unpin`:`Pin`,className:DU(`grid size-6 shrink-0 place-items-center rounded-md transition-colors hover:bg-foreground/[0.06] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,e.pinned?`text-[color:var(--accent)] opacity-100`:`text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100`),onClick:n=>{n.stopPropagation(),t(e.id)},children:(0,L.jsx)(Vi,{className:DU(`size-3.5`,e.pinned&&`fill-current`),strokeWidth:1.75})})]})})}function $It({title:e,items:t,onTogglePinned:n,onOpenArtifact:r,onOpenChat:i}){return t.length===0?null:(0,L.jsxs)(`section`,{className:`py-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70`,children:[e===`Pinned`?(0,L.jsx)(Di,{className:`size-3`,strokeWidth:1.75}):null,e]}),(0,L.jsx)(`ul`,{role:`list`,className:`divide-y divide-border/60 bg-card/80`,children:t.map(e=>(0,L.jsx)(QIt,{item:e,onTogglePinned:n,onOpenArtifact:r,onOpenChat:i},e.id))})]})}function eLt(){let e=RQ();return(0,I.useMemo)(()=>({openInboxArtifact:t=>e.openArtifact(t.artifact,{sessionId:null,title:t.title,instanceId:t.id}),openDetachedChat:e.openDetachedChat}),[e])}function tLt(e){if(!e)return new Set;try{let t=globalThis.localStorage?.getItem(e),n=t?JSON.parse(t):null;return new Set(Array.isArray(n?.ids)?n.ids.filter(e=>typeof e==`string`&&e.length>0):[])}catch{return new Set}}function nLt(e,t){if(e)try{let n=Array.from(t);n.length===0?globalThis.localStorage?.removeItem(e):globalThis.localStorage?.setItem(e,JSON.stringify({ids:n}))}catch{}}function rLt({onClose:e,pinStorageKey:t}){let{headerInsetStart:n,headerInsetEnd:r}=LQ(),{blockers:i}=a$(),a=eLt(),[o,s]=(0,I.useState)(`all`),[c,l]=(0,I.useState)(null),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(()=>tLt(t));(0,I.useEffect)(()=>{p(tLt(t))},[t]);let m=(0,I.useMemo)(()=>YIt(i.filter(WIt).map(GIt)),[i]),h=(0,I.useMemo)(()=>y9(m,o),[o,m]),g=(0,I.useMemo)(()=>XIt(h,f),[h,f]),_=(0,I.useMemo)(()=>g.filter(e=>e.pinned),[g]),v=(0,I.useMemo)(()=>g.filter(e=>!e.pinned),[g]),y=(0,I.useMemo)(()=>g.find(e=>e.id===u)??null,[g,u]),x=(0,I.useMemo)(()=>y?i.find(e=>e.id===y.id):void 0,[i,y]),S=(0,I.useMemo)(()=>({all:m.length,questions:y9(m,`questions`).length,reviews:y9(m,`reviews`).length}),[m]),C=(0,I.useCallback)(e=>{p(n=>{let r=new Set(n);return r.has(e)?r.delete(e):r.add(e),nLt(t,r),r})},[t]),w=(0,I.useCallback)(e=>{l(e.success?null:e.message)},[]),T=(0,I.useCallback)(e=>{if(!e.artifact){d(e.id),l(null);return}let t=a.openInboxArtifact(e);w(t),d(t.success?null:e.id)},[w,a]),E=(0,I.useCallback)(e=>{e.sessionId&&w(a.openDetachedChat(e.sessionId,{title:e.title}))},[w,a]),D=(0,I.useCallback)(e=>{!y||!x||(r$({blockerId:x.id,actionId:e,blocker:x,sessionId:y.sessionId??void 0}),e===`open`&&(y.artifact?T(y):l(`This inbox item has no artifact target.`)))},[T,x,y]);return(0,L.jsxs)(`div`,{"data-boring-workspace-part":`inbox-overlay`,className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,L.jsxs)(`header`,{className:DU(`flex h-12 shrink-0 items-center justify-between border-b border-border/60`,n?`pl-12`:`pl-4`,r?`pr-16`:`pr-4`),children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`grid size-7 place-items-center rounded-lg bg-[color:oklch(from_var(--accent)_l_c_h/0.14)] text-[color:var(--accent)]`,children:(0,L.jsx)(ri,{className:`h-4 w-4`,strokeWidth:1.75,"aria-hidden":`true`})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h2`,{className:`truncate text-sm font-semibold tracking-tight text-foreground`,children:`Inbox`}),(0,L.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:`Questions, reviews, and owner decisions`})]})]}),(0,L.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:e,"aria-label":`Close inbox`,title:`Close`,className:`text-muted-foreground hover:text-foreground`,children:(0,L.jsx)(ea,{className:`size-3`,strokeWidth:1.75})})})]}),(0,L.jsx)(KIt,{filter:o,counts:S,onFilterChange:s}),c?(0,L.jsx)(`div`,{className:`border-b border-border/60 bg-destructive/10 px-4 py-2 text-xs text-destructive`,children:c}):null,y?(0,L.jsxs)(`div`,{className:`border-b border-border/60 bg-background px-4 py-3 text-xs`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`truncate font-medium text-foreground`,children:y.title}),(0,L.jsx)(`div`,{className:`mt-1 line-clamp-2 text-muted-foreground`,children:y.description})]}),(0,L.jsx)(`button`,{type:`button`,className:`shrink-0 text-muted-foreground hover:text-foreground`,onClick:()=>d(null),children:`Close`})]}),y.actions.length>0&&x?(0,L.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:y.actions.map(e=>(0,L.jsx)(`button`,{type:`button`,className:`rounded-md border border-border/80 bg-background px-2 py-1 text-[11px] font-medium hover:bg-muted/60`,onClick:()=>D(e.id),children:e.label},e.id))}):null]}):null,(0,L.jsx)(`div`,{className:`boring-scrollbar-discreet min-h-0 flex-1 overflow-y-auto bg-[color:oklch(from_var(--background)_calc(l-0.012)_c_h)] py-2`,"aria-live":`polite`,children:g.length===0?(0,L.jsx)(`div`,{className:`flex h-full min-h-[180px] items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(fi,{className:`mx-auto mb-3 size-8 text-muted-foreground/70`,strokeWidth:1.75}),(0,L.jsx)(`div`,{className:`font-medium text-foreground/80`,children:`Inbox zero`}),(0,L.jsx)(`p`,{className:`mt-1 max-w-xs`,children:`When plugins or external harnesses ask for a decision, it appears here.`})]})}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)($It,{title:`Pinned`,items:_,onTogglePinned:C,onOpenArtifact:T,onOpenChat:E}),(0,L.jsx)($It,{title:`Inbox`,items:v,onTogglePinned:C,onOpenArtifact:T,onOpenChat:E})]})})]})}function iLt({apiBaseUrl:e,authHeaders:t,activeSessionId:n,openSessionIds:r,children:i}){let a=(0,I.useMemo)(()=>({...kIt,apiBaseUrl:e,authHeaders:t,activeSessionId:n,openSessionIds:r,async refreshPending(n){let r=await m9({apiBaseUrl:e,headers:t}).pending(n);return kIt.setPending(r,n),r}}),[n,e,t,r]),o=(0,I.useSyncExternalStore)(a.subscribe,()=>MIt(a),()=>`none`);return NIt(a,o),PIt(a,n,o),FIt(a),IIt(a),LIt(a,{activeSessionId:n,apiBaseUrl:e,authHeaders:t}),(0,L.jsx)(AIt.Provider,{value:a,children:i})}function aLt(e,t){let n=e.activeSessionId??null;return n&&b9(e,n)&&x9(e,n)?n:t?.sessionId&&x9(e,t.sessionId)?t.sessionId:e.getPendingHints().find(e=>!e.status||e.status===`ready`)?.sessionId||(t?.sessionId&&b9(e,t.sessionId)?t.sessionId:n&&b9(e,n)?n:null)}function b9(e,t){return!e.openSessionIds||g9(e,t)}function oLt(e,t){return!!e.openSessionIds&&!g9(e,t)}function x9(e,t){return e.getPending(t)?.status===`ready`||e.getPendingHints().some(e=>e.sessionId===t&&(!e.status||e.status===`ready`))}function sLt(){let{blockers:e}=a$(),t=e.filter(WIt).length;if(t===0)return null;let n=t>99?`99+`:String(t);return(0,L.jsx)(`span`,{"data-boring-workspace-part":`app-left-inbox-count`,"aria-label":`${t} inbox item${t===1?``:`s`}`,className:`inline-flex min-w-5 items-center justify-center rounded-full bg-[color:var(--accent)] px-1.5 py-0.5 text-[10px] font-semibold leading-none text-white shadow-sm`,children:n})}function cLt({onClose:e}){let{workspaceId:t}=j$();return(0,L.jsx)(rLt,{onClose:e,pinStorageKey:`boring-workspace:inbox-pins:${t??`workspace`}`})}function lLt({api:e,params:t,className:n}){let r=jIt();(0,I.useSyncExternalStore)(r.subscribe,()=>MIt(r),()=>`none`);let i=aLt(r,t),a=(0,I.useSyncExternalStore)(r.subscribe,()=>r.getPending(i),()=>r.getPending(i)),[o,s]=(0,I.useState)(null),c=(0,I.useRef)(null),[l,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(!1),m=a?.questionId===o?null:a,h=(0,I.useMemo)(()=>m9({apiBaseUrl:r.apiBaseUrl,headers:r.authHeaders}),[r.apiBaseUrl,r.authHeaders]);return(0,I.useEffect)(()=>{if(!t?.sessionId||!oLt(r,t.sessionId)||x9(r,t.sessionId)||r.getPendingHints().length===0)return;let n=r.activeSessionId??null;n&&b9(r,n)&&x9(r,n)||e.close()},[e,t?.sessionId,r]),(0,I.useEffect)(()=>{let t=t=>{let n=t.detail;!m||!t$(n,m.sessionId)||(s(m.questionId),r.setPending(null,m.sessionId),e.close())};return window.addEventListener(XQ,t),()=>window.removeEventListener(XQ,t)},[e,m,r]),(0,I.useEffect)(()=>{if(!i)return;let e=t?.questionId;if(!a){c.current=null,r.refreshPending(i).catch(()=>void 0);return}if(!e||a.questionId===e){c.current=null;return}let n=`${i}:${e}`;c.current!==n&&(c.current=n,r.refreshPending(i).catch(()=>void 0))},[i,t?.questionId,a,r]),(0,L.jsx)(`div`,{className:n?`${n} min-h-0 overflow-hidden`:`h-full min-h-0 overflow-hidden`,children:(0,L.jsxs)(we,{className:`h-full min-h-0 overflow-hidden border-0 bg-background text-sm`,children:[(0,L.jsx)(Ye,{className:`border-b bg-background/95`,children:(0,L.jsx)(`div`,{children:(0,L.jsxs)(Me,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Dr,{className:`h-4 w-4 text-muted-foreground`}),` Agent needs input`]})})}),m?null:(0,L.jsx)($e,{className:`overflow-auto p-4`,children:(0,L.jsx)(lt,{icon:(0,L.jsx)(Dr,{className:`h-5 w-5`}),title:`No pending questions`,description:`When the agent needs a decision, the form will appear here.`,className:`border border-dashed bg-muted/20`})}),m?.status===`ready`&&m.schema?(0,L.jsx)(lIt,{schema:m.schema,submitting:f,onSubmit:async n=>{p(!0),d(null);try{await h.submit(m,n),s(m.questionId),r.setPending(null,m.sessionId),e.close(),t?.__closeWorkbenchOnDone?.()}catch(e){d(e instanceof f9?e.message:String(e))}finally{p(!1)}},onCancel:async()=>{p(!0),d(null);try{await h.cancel(m),s(m.questionId),r.setPending(null,m.sessionId),e.close(),t?.__closeWorkbenchOnDone?.()}catch(e){d(e instanceof f9?e.message:String(e))}finally{p(!1)}},children:(0,L.jsxs)(uIt,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsx)($e,{className:`overflow-auto p-4`,children:(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`section`,{className:`rounded-md border border-border/60 bg-muted/30 p-4`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Waiting for answer`}),(0,L.jsx)(`h2`,{className:`mt-2 text-balance text-sm font-semibold leading-5 text-foreground`,children:m.title??`Question`}),m.context?(0,L.jsx)(`p`,{className:`mt-2 max-w-prose text-sm leading-6 text-muted-foreground`,children:m.context}):null]}),(0,L.jsx)(`div`,{className:`space-y-4`,children:(0,L.jsx)(fIt,{})}),l?(0,L.jsx)(u,{tone:`destructive`,role:`alert`,children:l}):null]})}),(0,L.jsxs)(He,{className:`justify-between border-t bg-background px-4 py-3`,children:[(0,L.jsx)(`p`,{className:`min-w-0 text-xs text-muted-foreground`,children:`Sends answers and closes the pane.`}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(Se,{asChild:!0,variant:`outline`,size:`sm`,children:(0,L.jsx)(hIt,{children:`Cancel`})}),(0,L.jsx)(Se,{asChild:!0,size:`sm`,children:(0,L.jsx)(mIt,{children:m.schema.submitLabel??`Send answers`})})]})]})]})},m.questionId):null,m&&m.status!==`ready`?(0,L.jsx)($e,{className:`p-5`,children:(0,L.jsx)(u,{children:(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Or,{className:`h-4 w-4 text-muted-foreground`}),`Question `,m.status]})})}):null]})})}function uLt(e={}){return zn({id:n9,label:i9,providers:[{id:`${n9}.provider`,component:iLt}],panels:[{id:r9,label:i9,icon:Dr,component:lLt,placement:`center`,source:`builtin`,chromeless:!0}],appLeftActions:e.appLeftInbox?[{id:`inbox`,label:`Inbox`,icon:ri,trailing:sLt,overlay:cLt,order:10}]:[],surfaceResolvers:[{id:`${n9}.surface`,kind:a9,source:`builtin`,resolve(e){let t=typeof e.meta==`object`&&e.meta&&typeof e.meta.sessionId==`string`?e.meta.sessionId:void 0;return{component:r9,id:r9,title:i9,params:{questionId:e.target,sessionId:t}}}}]})}uLt();var S9=`boring-automation`,C9=`Automations`,dLt=`/api/v1/boring-automation`;function w9(e){return Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)}function T9(e,t){return e.y===t.y&&e.m===t.m&&e.d===t.d&&e.h===t.h&&e.i===t.i&&e.s===t.s}function fLt(e,t){let n=new Date(Date.parse(e));if(isNaN(n))throw Error(`Invalid ISO8601 passed to timezone parser.`);let r=e.substring(9);return r.includes(`Z`)||r.includes(`+`)||r.includes(`-`)?D9(n.getUTCFullYear(),n.getUTCMonth()+1,n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),`Etc/UTC`):D9(n.getFullYear(),n.getMonth()+1,n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),t)}function pLt(e,t,n){return mLt(fLt(e,t),n)}function mLt(e,t){let n=new Date(w9(e)),r=E9(n,e.tz),i=w9(e)-w9(r),a=new Date(n.getTime()+i),o=E9(a,e.tz);if(T9(o,e)){let t=new Date(a.getTime()-36e5);return T9(E9(t,e.tz),e)?t:a}let s=new Date(a.getTime()+w9(e)-w9(o));if(T9(E9(s,e.tz),e))return s;if(t)throw Error(`Invalid date passed to fromTZ()`);return a.getTime()>s.getTime()?a:s}function E9(e,t){let n,r;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,hour12:!1}),r=n.formatToParts(e)}catch(e){let n=e instanceof Error?e.message:String(e);throw RangeError(`toTZ: Invalid timezone '${t}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${n}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let e of r)(e.type===`year`||e.type===`month`||e.type===`day`||e.type===`hour`||e.type===`minute`||e.type===`second`)&&(i[e.type]=parseInt(e.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw Error(`toTZ: Failed to parse all date components from timezone '${t}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return i.hour===24&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:t}}function D9(e,t,n,r,i,a,o){return{y:e,m:t,d:n,h:r,i,s:a,tz:o}}var hLt=[1,2,4,8,16],gLt=class{pattern;timezone;mode;alternativeWeekdays;sloppyRanges;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;lastWeekday;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,n){this.pattern=e,this.timezone=t,this.mode=n?.mode??`auto`,this.alternativeWeekdays=n?.alternativeWeekdays??!1,this.sloppyRanges=n?.sloppyRanges??!1,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.lastWeekday=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!(typeof this.pattern==`string`||this.pattern instanceof String))throw TypeError(`CronPattern: Pattern has to be of type string.`);this.pattern.indexOf(`@`)>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[``],t=e.length;if(e.length<5||e.length>7)throw TypeError(`CronPattern: invalid configuration format ('`+this.pattern+`'), exactly five, six, or seven space separated parts are required.`);if(this.mode!==`auto`){let e;switch(this.mode){case`5-part`:e=5;break;case`6-part`:e=6;break;case`7-part`:e=7;break;case`5-or-6-parts`:e=[5,6];break;case`6-or-7-parts`:e=[6,7];break;default:e=0}if(!(Array.isArray(e)?e.includes(t):t===e)){let n=Array.isArray(e)?e.join(` or `):e.toString();throw TypeError(`CronPattern: mode '${this.mode}' requires exactly ${n} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift(`0`),e.length===6&&e.push(`*`),e[3].toUpperCase()===`LW`?(this.lastWeekday=!0,e[3]=``):e[3].toUpperCase().indexOf(`L`)>=0&&(e[3]=e[3].replace(/L/gi,``),this.lastDayOfMonth=!0),e[3]==`*`&&(this.starDOM=!0),e[6]==`*`&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.alternativeWeekdays?this.replaceAlphaDaysQuartz(e[5]):this.replaceAlphaDays(e[5])),e[5].startsWith(`+`)&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===``))throw TypeError(`CronPattern: Day-of-week field cannot be empty after '+' modifier.`);switch(e[5]==`*`&&(this.starDOW=!0),this.pattern.indexOf(`?`)>=0&&(e[0]=e[0].replace(/\?/g,`*`),e[1]=e[1].replace(/\?/g,`*`),e[2]=e[2].replace(/\?/g,`*`),e[3]=e[3].replace(/\?/g,`*`),e[4]=e[4].replace(/\?/g,`*`),e[5]=e[5].replace(/\?/g,`*`),e[6]&&=e[6].replace(/\?/g,`*`)),this.mode){case`5-part`:e[0]=`0`,e[6]=`*`;break;case`6-part`:e[6]=`*`;break;case`5-or-6-parts`:e[6]=`*`;break;case`6-or-7-parts`:break;case`7-part`:case`auto`:break}this.throwAtIllegalCharacters(e),this.partToArray(`second`,e[0],0,1),this.partToArray(`minute`,e[1],0,1),this.partToArray(`hour`,e[2],0,1),this.partToArray(`day`,e[3],-1,1),this.partToArray(`month`,e[4],-1,1);let n=this.alternativeWeekdays?-1:0;this.partToArray(`dayOfWeek`,e[5],n,63),this.partToArray(`year`,e[6],0,1),!this.alternativeWeekdays&&this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,n,r){let i=this[e],a=e===`day`&&this.lastDayOfMonth,o=e===`day`&&this.lastWeekday;if(t===``&&!a&&!o)throw TypeError(`CronPattern: configuration entry `+e+` (`+t+`) is empty, check for trailing spaces.`);if(t===`*`)return i.fill(r);let s=t.split(`,`);if(s.length>1)for(let t=0;t<s.length;t++)this.partToArray(e,s[t],n,r);else t.indexOf(`-`)!==-1&&t.indexOf(`/`)!==-1?this.handleRangeWithStepping(t,e,n,r):t.indexOf(`-`)===-1?t.indexOf(`/`)===-1?t!==``&&this.handleNumber(t,e,n,r):this.handleStepping(t,e,n,r):this.handleRange(t,e,n,r)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===3?/[^/*0-9,\-WwLl]+/:t===5?/[^/*0-9,\-#Ll]+/:/[^/*0-9,\-]+/).test(e[t]))throw TypeError(`CronPattern: configuration entry `+t+` (`+e[t]+`) contains illegal characters.`)}handleNumber(e,t,n,r){let i=this.extractNth(e,t),a=e.toUpperCase().includes(`W`);if(t!==`day`&&a)throw TypeError(`CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.`);a&&(t=`nearestWeekdays`);let o=parseInt(i[0],10)+n;if(isNaN(o))throw TypeError(`CronPattern: `+t+` is not a number: '`+e+`'`);this.setPart(t,o,i[1]||r)}setPart(e,t,n){if(!Object.prototype.hasOwnProperty.call(this,e))throw TypeError(`CronPattern: Invalid part specified: `+e);if(e===`dayOfWeek`){if(t===7&&(t=0),t<0||t>6)throw RangeError(`CronPattern: Invalid value for dayOfWeek: `+t);this.setNthWeekdayOfMonth(t,n);return}if(e===`second`||e===`minute`){if(t<0||t>=60)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`hour`){if(t<0||t>=24)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`day`||e===`nearestWeekdays`){if(t<0||t>=31)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`month`){if(t<0||t>=12)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`year`&&(t<1||t>=1e4))throw RangeError(`CronPattern: Invalid value for `+e+`: `+t+` (supported range: 1-9999)`);this[e][t]=n}validateNotNaN(e,t){if(isNaN(e))throw TypeError(t)}validateRange(e,t,n,r,i){if(e>t)throw TypeError(`CronPattern: From value is larger than to value: '`+i+`'`);if(n!==void 0){if(n===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(n>this[r].length)throw TypeError(`CronPattern: Syntax error, steps cannot be greater than maximum value of part (`+this[r].length+`)`)}}handleRangeWithStepping(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in ranges with stepping.`);let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw TypeError(`CronPattern: Syntax error, illegal range with stepping: '`+e+`'`);let[,o,s,c]=a,l=parseInt(o,10)+n,u=parseInt(s,10)+n,d=parseInt(c,10);this.validateNotNaN(l,`CronPattern: Syntax error, illegal lower range (NaN)`),this.validateNotNaN(u,`CronPattern: Syntax error, illegal upper range (NaN)`),this.validateNotNaN(d,`CronPattern: Syntax error, illegal stepping: (NaN)`),this.validateRange(l,u,d,t,e);for(let e=l;e<=u;e+=d)this.setPart(t,e,i[1]||r)}extractNth(e,t){let n=e,r;if(n.includes(`#`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: nth (#) only allowed in day-of-week field`);r=n.split(`#`)[1],n=n.split(`#`)[0]}else if(n.toUpperCase().endsWith(`L`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)`);r=`L`,n=n.slice(0,-1)}return[n,r]}handleRange(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in a range.`);let i=this.extractNth(e,t),a=i[0].split(`-`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal range: '`+e+`'`);let o=parseInt(a[0],10)+n,s=parseInt(a[1],10)+n;this.validateNotNaN(o,`CronPattern: Syntax error, illegal lower range (NaN)`),this.validateNotNaN(s,`CronPattern: Syntax error, illegal upper range (NaN)`),this.validateRange(o,s,void 0,t,e);for(let e=o;e<=s;e++)this.setPart(t,e,i[1]||r)}handleStepping(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in parts with stepping.`);let i=this.extractNth(e,t),a=i[0].split(`/`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal stepping: '`+e+`'`);if(this.sloppyRanges)a[0]===``&&(a[0]=`*`);else{if(a[0]===``)throw TypeError(`CronPattern: Syntax error, stepping with missing prefix ('`+e+`') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.`);if(a[0]!==`*`)throw TypeError(`CronPattern: Syntax error, stepping with numeric prefix ('`+e+`') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.`)}let o=0;a[0]!==`*`&&(o=parseInt(a[0],10)+n);let s=parseInt(a[1],10);this.validateNotNaN(s,`CronPattern: Syntax error, illegal stepping: (NaN)`),this.validateRange(0,this[t].length-1,s,t,e);for(let e=o;e<this[t].length;e+=s)this.setPart(t,e,i[1]||r)}replaceAlphaDays(e){return e.replace(/-sun/gi,`-7`).replace(/sun/gi,`0`).replace(/mon/gi,`1`).replace(/tue/gi,`2`).replace(/wed/gi,`3`).replace(/thu/gi,`4`).replace(/fri/gi,`5`).replace(/sat/gi,`6`)}replaceAlphaDaysQuartz(e){return e.replace(/sun/gi,`1`).replace(/mon/gi,`2`).replace(/tue/gi,`3`).replace(/wed/gi,`4`).replace(/thu/gi,`5`).replace(/fri/gi,`6`).replace(/sat/gi,`7`)}replaceAlphaMonths(e){return e.replace(/jan/gi,`1`).replace(/feb/gi,`2`).replace(/mar/gi,`3`).replace(/apr/gi,`4`).replace(/may/gi,`5`).replace(/jun/gi,`6`).replace(/jul/gi,`7`).replace(/aug/gi,`8`).replace(/sep/gi,`9`).replace(/oct/gi,`10`).replace(/nov/gi,`11`).replace(/dec/gi,`12`)}handleNicknames(e){let t=e.trim().toLowerCase();if(t===`@yearly`||t===`@annually`)return`0 0 1 1 *`;if(t===`@monthly`)return`0 0 1 * *`;if(t===`@weekly`)return`0 0 * * 0`;if(t===`@daily`||t===`@midnight`)return`0 0 * * *`;if(t===`@hourly`)return`0 * * * *`;if(t===`@reboot`)throw TypeError(`CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.`);return e}setNthWeekdayOfMonth(e,t){if(typeof t!=`number`&&t.toUpperCase()===`L`)this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|hLt[t-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}},O9=[31,28,31,30,31,30,31,31,30,31,30,31],k9=[[`month`,`year`,0],[`day`,`month`,-1],[`hour`,`day`,0],[`minute`,`hour`,0],[`second`,`minute`,0]],A9=class e{tz;ms;second;minute;hour;day;month;year;constructor(t,n){if(this.tz=n,t&&t instanceof Date)if(!isNaN(t))this.fromDate(t);else throw TypeError(`CronDate: Invalid date passed to CronDate constructor`);else if(t==null)this.fromDate(new Date);else if(t&&typeof t==`string`)this.fromString(t);else if(t instanceof e)this.fromCronDate(t);else throw TypeError(`CronDate: Invalid type (`+typeof t+`) passed to CronDate constructor`)}getLastDayOfMonth(e,t){return t===1?new Date(Date.UTC(e,t+1,0)).getUTCDate():O9[t]}getLastWeekday(e,t){let n=this.getLastDayOfMonth(e,t),r=new Date(Date.UTC(e,t,n)).getUTCDay();return r===0?n-2:r===6?n-1:n}getNearestWeekday(e,t,n){let r=this.getLastDayOfMonth(e,t);if(n>r)return-1;let i=new Date(Date.UTC(e,t,n)).getUTCDay();return i===0?n===r?n-2:n+1:i===6?n===1?n+2:n-1:n}isNthWeekdayOfMonth(e,t,n,r){let i=new Date(Date.UTC(e,t,n)).getUTCDay(),a=0;for(let r=1;r<=n;r++)new Date(Date.UTC(e,t,r)).getUTCDay()===i&&a++;if(r&63&&hLt[a-1]&r)return!0;if(r&32){let r=this.getLastDayOfMonth(e,t);for(let a=n+1;a<=r;a++)if(new Date(Date.UTC(e,t,a)).getUTCDay()===i)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz==`number`)this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let t=E9(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${t}`)}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.month<0||this.day>O9[this.month]||this.day<1||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz==`number`){let t=pLt(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(pLt(e,this.tz))}findNext(e,t,n,r){return this._findMatch(e,t,n,r,1)}_findMatch(e,t,n,r,i){let a=this[t],o;n.lastDayOfMonth&&(o=this.getLastDayOfMonth(this.year,this.month));let s=!n.starDOW&&t==`day`?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0,c=this[t]+r,l=i===1?e=>e<n[t].length:e=>e>=0;for(let u=c;l(u);u+=i){let i=n[t][u];if(t===`day`&&!i){for(let e=0;e<n.nearestWeekdays.length;e++)if(n.nearestWeekdays[e]){let t=this.getNearestWeekday(this.year,this.month,e-r);if(t===-1)continue;if(t===u-r){i=1;break}}}if(t===`day`&&n.lastWeekday){let e=this.getLastWeekday(this.year,this.month);u-r===e&&(i=1)}if(t===`day`&&n.lastDayOfMonth&&u-r==o&&(i=1),t===`day`&&!n.starDOW){let t=n.dayOfWeek[(s+(u-r-1))%7];if(t&&t&63)t=+!!this.isNthWeekdayOfMonth(this.year,this.month,u-r,t);else if(t)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);n.useAndLogic?i&&=t:!e.domAndDow&&!n.starDOM?i||=t:i&&=t}if(i)return this[t]=u-r,a===this[t]?1:2}return 3}recurse(e,t,n){if(n===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let t=-1;for(let n=this.year+1;n<e.year.length&&n<1e4;n++)if(e.year[n]===1){t=n;break}if(t===-1)return null;this.year=t,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let r=this.findNext(t,k9[n][0],e,k9[n][2]);if(r>1){let i=n+1;for(;i<k9.length;)this[k9[i][0]]=-k9[i][2],i++;if(r===3){if(this[k9[n][1]]++,this[k9[n][0]]=-k9[n][2],this.apply(),n===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}else if(this.apply())return this.recurse(e,t,n-1)}return n+=1,n>=k9.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,t,n)}increment(e,t,n){return this.second+=t.interval!==void 0&&t.interval>1&&n?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}decrement(e,t){return this.second-=t.interval!==void 0&&t.interval>1?t.interval:1,this.ms=0,this.apply(),this.recurseBackward(e,t,0,0)}recurseBackward(e,t,n,r=0){if(r>1e4)return null;if(n===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let t=-1;for(let n=this.year-1;n>=0;n--)if(e.year[n]===1){t=n;break}if(t===-1)return null;this.year=t,this.month=11,this.day=31,this.hour=23,this.minute=59,this.second=59,this.ms=0}if(this.year<0)return null}let i=this.findPrevious(t,k9[n][0],e,k9[n][2]);if(i>1){let a=n+1;for(;a<k9.length;){let t=k9[a][0],n=k9[a][2],r=this.getMaxPatternValue(t,e,n);this[t]=r,a++}if(i===3){if(this[k9[n][1]]--,n===0){let e=this.getLastDayOfMonth(this.year,this.month);this.day>e&&(this.day=e)}if(n===1)if(this.day<=0)this.day=1;else{let e=this.year,t=this.month;for(;t<0;)t+=12,e--;for(;t>11;)t-=12,e++;let n=t===1?new Date(Date.UTC(e,t+1,0)).getUTCDate():O9[t];this.day>n&&(this.day=n)}this.apply();let i=k9[n][0],a=k9[n][2],o=this.getMaxPatternValue(i,e,a);if(i===`day`){let e=this.getLastDayOfMonth(this.year,this.month);this[i]=Math.min(o,e)}else this[i]=o;if(this.apply(),n===0){let t=k9[1][2],n=this.getMaxPatternValue(`day`,e,t),r=this.getLastDayOfMonth(this.year,this.month),i=Math.min(n,r);i!==this.day&&(this.day=i,this.hour=this.getMaxPatternValue(`hour`,e,k9[2][2]),this.minute=this.getMaxPatternValue(`minute`,e,k9[3][2]),this.second=this.getMaxPatternValue(`second`,e,k9[4][2]))}if(n===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0;)this.year--;if(this.year<0)return null}return this.recurseBackward(e,t,0,r+1)}else if(this.apply())return this.recurseBackward(e,t,n-1,r+1)}return n+=1,n>=k9.length?this:this.year<0?null:this.recurseBackward(e,t,n,r+1)}getMaxPatternValue(e,t,n){if(e===`day`&&t.lastDayOfMonth||e===`day`&&!t.starDOW)return this.getLastDayOfMonth(this.year,this.month);for(let r=t[e].length-1;r>=0;r--)if(t[e][r])return r-n;return t[e].length-1-n}findPrevious(e,t,n,r){return this._findMatch(e,t,n,r,-1)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz==`number`?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):mLt(D9(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}match(e,t){if(!e.starYear&&(this.year<0||this.year>=e.year.length||e.year[this.year]===0))return!1;for(let n=0;n<k9.length;n++){let r=k9[n][0],i=k9[n][2],a=this[r];if(a+i<0||a+i>=e[r].length)return!1;let o=e[r][a+i];if(r===`day`){if(!o){for(let t=0;t<e.nearestWeekdays.length;t++)if(e.nearestWeekdays[t]){let e=this.getNearestWeekday(this.year,this.month,t-i);if(e!==-1&&e===a){o=1;break}}}if(e.lastWeekday&&a===this.getLastWeekday(this.year,this.month)&&(o=1),e.lastDayOfMonth&&a===this.getLastDayOfMonth(this.year,this.month)&&(o=1),!e.starDOW){let n=new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),r=e.dayOfWeek[(n+(a-1))%7];r&&r&63&&(r=+!!this.isNthWeekdayOfMonth(this.year,this.month,a,r)),e.useAndLogic?o&&=r:!t.domAndDow&&!e.starDOM?o||=r:o&&=r}}if(!o)return!1}return!0}};function _Lt(e){if(e===void 0&&(e={}),delete e.name,e.legacyMode!==void 0&&e.domAndDow===void 0?e.domAndDow=!e.legacyMode:e.domAndDow===void 0&&(e.domAndDow=!1),e.legacyMode=!e.domAndDow,e.paused=e.paused!==void 0&&e.paused,e.maxRuns=e.maxRuns===void 0?1/0:e.maxRuns,e.catch=e.catch!==void 0&&e.catch,e.interval=e.interval===void 0?0:parseInt(e.interval.toString(),10),e.utcOffset=e.utcOffset===void 0?void 0:parseInt(e.utcOffset.toString(),10),e.dayOffset=e.dayOffset===void 0?0:parseInt(e.dayOffset.toString(),10),e.unref=e.unref!==void 0&&e.unref,e.mode=e.mode===void 0?`auto`:e.mode,e.alternativeWeekdays=e.alternativeWeekdays!==void 0&&e.alternativeWeekdays,e.sloppyRanges=e.sloppyRanges!==void 0&&e.sloppyRanges,![`auto`,`5-part`,`6-part`,`7-part`,`5-or-6-parts`,`6-or-7-parts`].includes(e.mode))throw Error(`CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.`);if(e.startAt&&=new A9(e.startAt,e.timezone),e.stopAt&&=new A9(e.stopAt,e.timezone),e.interval!==null){if(isNaN(e.interval))throw Error(`CronOptions: Supplied value for interval is not a number`);if(e.interval<0)throw Error(`CronOptions: Supplied value for interval can not be negative`)}if(e.utcOffset!==void 0){if(isNaN(e.utcOffset))throw Error(`CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.`);if(e.utcOffset<-870||e.utcOffset>870)throw Error(`CronOptions: utcOffset out of bounds.`);if(e.utcOffset!==void 0&&e.timezone)throw Error(`CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.`)}if(e.unref!==!0&&e.unref!==!1)throw Error(`CronOptions: Unref should be either true, false or undefined(false).`);if(e.dayOffset!==void 0&&e.dayOffset!==0&&isNaN(e.dayOffset))throw Error(`CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.`);return e}function j9(e){return Object.prototype.toString.call(e)===`[object Function]`||typeof e==`function`||e instanceof Function}function vLt(e){return j9(e)}function yLt(e){typeof Deno<`u`&&typeof Deno.unrefTimer<`u`?Deno.unrefTimer(e):e&&typeof e.unref<`u`&&e.unref()}var bLt=30*1e3,M9=[],xLt=class{name;options;_states;fn;getTz(){return this.options.timezone||this.options.utcOffset}applyDayOffset(e){if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let t=this.options.dayOffset*24*60*60*1e3;return new Date(e.getTime()+t)}return e}constructor(e,t,n){let r,i;if(j9(t))i=t;else if(typeof t==`object`)r=t;else if(t!==void 0)throw Error(`Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).`);if(j9(n))i=n;else if(typeof n==`object`)r=n;else if(n!==void 0)throw Error(`Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).`);if(this.name=r?.name,this.options=_Lt(r),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:r?r.maxRuns:void 0,paused:r?r.paused:!1,pattern:new gLt(`* * * * *`,void 0,{mode:`auto`})},e&&(e instanceof Date||typeof e==`string`&&e.indexOf(`:`)>0)?this._states.once=new A9(e,this.getTz()):this._states.pattern=new gLt(e,this.options.timezone,{mode:this.options.mode,alternativeWeekdays:this.options.alternativeWeekdays,sloppyRanges:this.options.sloppyRanges}),this.name){if(M9.find(e=>e.name===this.name))throw Error(`Cron: Tried to initialize new named job '`+this.name+`', but name already taken.`);M9.push(this)}return i!==void 0&&vLt(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?this.applyDayOffset(t.getDate(!1)):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let n=t||this._states.currentRun||void 0;return this._enumerateRuns(e,n,`next`)}previousRuns(e,t){return this._enumerateRuns(e,t||void 0,`previous`)}_enumerateRuns(e,t,n){let r=[],i=t?new A9(t,this.getTz()):null,a=n===`next`?this._next:this._previous;for(;e--;){let e=a.call(this,i);if(!e)break;let t=e.getDate(!1);r.push(this.applyDayOffset(t)),i=e}return r}match(e){if(this._states.once){let t=new A9(e,this.getTz());t.ms=0;let n=new A9(this._states.once,this.getTz());return n.ms=0,t.getTime()===n.getTime()}let t=new A9(e,this.getTz());return t.ms=0,t.match(this._states.pattern,this.options)}getPattern(){if(!this._states.once)return this._states.pattern?this._states.pattern.pattern:void 0}getOnce(){return this._states.once?this._states.once.getDate():null}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,n=this.fn!==void 0,r=!this._states.kill;return t&&n&&r&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof A9||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new A9(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=M9.indexOf(this);e>=0&&M9.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw Error(`Cron: It is not allowed to schedule two functions using the same Croner instance.`);e&&(this.fn=e);let t=this.msToNext(),n=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||n===null?this:(t>bLt&&(t=bLt),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),t),this._states.currentTimeout&&this.options.unref&&yLt(this._states.currentTimeout),this)}async _trigger(e){this._states.blocking=!0,this._states.currentRun=new A9(void 0,this.getTz());try{if(this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){if(j9(this.options.catch))try{this.options.catch(e,this)}catch{}}else this.fn!==void 0&&await this.fn(this,this.options.context)}finally{this._states.previousRun=new A9(e,this.getTz()),this._states.blocking=!1}}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,n=!this._states.paused&&t.getTime()>=e.getTime(),r=this._states.blocking&&this.options.protect;n&&!r?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):n&&r&&j9(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),n=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),n=!e),e=new A9(e,this.getTz()),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let r=this._states.once||new A9(e,this.getTz());return!n&&r!==this._states.once&&(r=r.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||r===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&r.getTime()>=this.options.stopAt.getTime()?null:r}_previous(e){let t=new A9(e,this.getTz());this.options.stopAt&&t.getTime()>this.options.stopAt.getTime()&&(t=this.options.stopAt);let n=new A9(t,this.getTz());return this._states.once?this._states.once.getTime()<t.getTime()?this._states.once:null:(n=n.decrement(this._states.pattern,this.options),n===null||this.options.startAt&&n.getTime()<this.options.startAt.getTime()?null:n)}_calculatePreviousRun(e,t){let n=new A9(void 0,this.getTz()),r=e;if(this.options.startAt.getTime()<=n.getTime()){r=this.options.startAt;let e=r.getTime()+this.options.interval*1e3;for(;e<=n.getTime();)r=new A9(r,this.getTz()).increment(this._states.pattern,this.options,!0),e=r.getTime()+this.options.interval*1e3;t=!0}return r===null&&(r=void 0),[r,t]}},SLt={INVALID_CRON:`Invalid cron schedule. Use exactly five fields, for example 0 9 * * *.`,INVALID_TIMEZONE:`Invalid timezone. Use a valid IANA timezone, for example UTC or America/New_York.`};function CLt(e,t){let n={};return wLt(e)||(n.cron=SLt.INVALID_CRON),TLt(t)||(n.timezone=SLt.INVALID_TIMEZONE),{ok:Object.keys(n).length===0,errors:n}}function wLt(e){let t=ELt(e);if(!t||t.split(` `).length!==5)return!1;try{return new xLt(t),!0}catch{return!1}}function TLt(e){let t=e.trim();if(!t)return!1;try{let e=new Intl.DateTimeFormat(`en-US`,{timeZone:t}).resolvedOptions().timeZone;return e===`UTC`||e.includes(`/`)}catch{return!1}}function ELt(e){return e.trim().replace(/\s+/g,` `)}function DLt(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(t)}function OLt(e){let t=e.durationMs??MLt(e);if(t==null)return`—`;if(t<1e3)return`${t}ms`;let n=Math.round(t/1e3);if(n<60)return`${n}s`;let r=Math.floor(n/60),i=n%60;return i?`${r}m ${i}s`:`${r}m`}function kLt(e){return e.totalTokens==null?e.inputTokens!=null||e.outputTokens!=null?(e.inputTokens??0)+(e.outputTokens??0):null:e.totalTokens}function ALt(e){switch(e){case`queued`:return`Queued`;case`running`:return`Running`;case`succeeded`:return`Succeeded`;case`failed`:return`Failed`;case`cancelled`:return`Cancelled`}}function jLt(e){switch(e){case`succeeded`:return`bg-[color:var(--success-soft)] text-success`;case`failed`:return`bg-destructive/10 text-destructive`;case`running`:return`bg-foreground/[0.07] text-foreground`;case`cancelled`:return`bg-foreground/[0.07] text-muted-foreground`;case`queued`:return`bg-foreground/[0.07] text-muted-foreground`}}function MLt(e){if(!e?.startedAt||!e.completedAt)return null;let t=new Date(e.startedAt).getTime(),n=new Date(e.completedAt).getTime();return Number.isNaN(t)||Number.isNaN(n)||n<t?null:n-t}function NLt({runs:e,loading:t,onOpenRun:n}){return t?(0,L.jsx)(`div`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:`Loading run history…`}):e.length===0?(0,L.jsx)(`div`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:`No runs yet. Future execution slices will write sessions here.`}):(0,L.jsx)(`ul`,{role:`list`,className:`divide-y divide-border/60 bg-card/70`,children:e.map(e=>{let t=kLt(e),r=e.startedAt??e.scheduledFor??e.createdAt,i=e.sessionId?`Open session ${e.sessionId}`:`Run has no session`;return(0,L.jsxs)(`li`,{className:`group flex min-h-12 items-center gap-2 px-4 py-2 text-left text-[12px] focus-within:bg-muted/40 hover:bg-muted/40 motion-reduce:transition-none`,children:[(0,L.jsx)(`span`,{className:C(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-medium`,jLt(e.status)),children:ALt(e.status)}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-foreground`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:e.trigger===`scheduled`?`Scheduled`:`Manual`}),(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Start `,DLt(r)]}),(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Duration `,OLt(e)]}),t==null?null:(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Tokens `,t.toLocaleString()]})]}),e.error?(0,L.jsx)(`div`,{className:`mt-1 line-clamp-2 text-destructive`,children:e.error}):null]}),(0,L.jsxs)(Se,{type:`button`,variant:`ghost`,size:`sm`,disabled:!e.sessionId,"aria-label":i,title:i,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>n(e),children:[(0,L.jsx)(gi,{className:`mr-1 size-3.5`,"aria-hidden":`true`}),`Session`]})]},e.id)})})}function PLt({automation:e,expanded:t,deleting:n,runs:r,runsLoading:i,runningNow:a,onToggle:o,onEdit:s,onRunNow:c,onDeleteRequest:l,onDeleteCancel:u,onDeleteConfirm:d,onOpenRun:f}){let p=`automation-runs-${e.id}`,m=`automation-delete-title-${e.id}`;return(0,L.jsxs)(`article`,{className:`border-b border-border/60 bg-card/80 last:border-b-0`,children:[(0,L.jsxs)(`div`,{className:`group flex min-h-14 w-full items-center gap-3 px-4 py-2 text-sm transition-colors hover:bg-muted/50 focus-within:bg-muted/50 motion-reduce:transition-none`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,"aria-expanded":t,"aria-controls":p,onClick:o,children:[(0,L.jsx)(xr,{className:C(`size-4 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none`,t&&`rotate-180`),"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:C(`size-2 shrink-0 rounded-full`,e.enabled?`bg-[color:var(--success)]`:`bg-muted-foreground/40`),"aria-hidden":`true`}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate font-medium text-foreground`,children:e.title}),(0,L.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[e.cron,` · `,e.timezone,` · `,e.model]})]}),(0,L.jsxs)(`span`,{className:`hidden shrink-0 text-xs text-muted-foreground sm:block`,children:[`Updated `,DLt(e.updatedAt)]})]}),(0,L.jsxs)(Se,{type:`button`,variant:`ghost`,size:`sm`,onClick:c,disabled:a,"aria-label":`Run ${e.title} now`,children:[(0,L.jsx)(ki,{className:`size-3.5`,"aria-hidden":`true`}),a?`Running…`:`Run now`]}),(0,L.jsx)(Se,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,children:`Edit`}),(0,L.jsx)(Se,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.title}`,title:`Delete`,onClick:l,children:(0,L.jsx)(Ji,{className:`size-4`,"aria-hidden":`true`})})]}),n?(0,L.jsxs)(`div`,{className:`border-t border-border/60 bg-background px-4 py-3 text-sm`,role:`region`,"aria-labelledby":m,children:[(0,L.jsx)(`div`,{id:m,className:`font-medium text-foreground`,children:`Delete this automation?`}),(0,L.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Only automation metadata is removed. Prompt Markdown, run records, and Pi chat sessions remain.`}),(0,L.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,L.jsx)(Se,{type:`button`,variant:`destructive`,size:`sm`,onClick:d,children:`Delete`}),(0,L.jsx)(Se,{type:`button`,variant:`ghost`,size:`sm`,onClick:u,children:`Cancel`})]})]}):null,t?(0,L.jsxs)(`div`,{id:p,className:`border-t border-border/60`,children:[(0,L.jsx)(`div`,{className:`px-4 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70`,children:`Run history`}),(0,L.jsx)(NLt,{runs:r,loading:i,onOpenRun:f})]}):null]})}var FLt={title:``,enabled:!0,cron:`0 9 * * *`,timezone:`UTC`,model:``,prompt:``};function ILt(e,t){return{title:e.title,enabled:e.enabled,cron:e.cron,timezone:e.timezone,model:e.model,prompt:t}}function N9(){return{...FLt}}function LLt(e){let t={};e.title.trim()||(t.title=`Title is required.`);let n=CLt(e.cron,e.timezone);n.errors.cron&&(t.cron=n.errors.cron),n.errors.timezone&&(t.timezone=n.errors.timezone);let r=e.model.trim();if(!r)t.model=`Model is required.`;else{let e=r.indexOf(`:`);(e<=0||!r.slice(0,e).trim()||!r.slice(e+1).trim())&&(t.model=`Use provider:model-id syntax.`)}return t}function RLt(e){return{title:e.title.trim(),enabled:e.enabled,cron:e.cron.trim(),timezone:e.timezone.trim(),model:e.model.trim(),prompt:e.prompt}}function zLt(e){return{title:e.title.trim(),enabled:e.enabled,cron:e.cron.trim(),timezone:e.timezone.trim(),model:e.model.trim()}}function BLt({automation:e,prompt:t,mode:n,saving:r,onCancel:i,onSubmit:a}){let[o,s]=(0,I.useState)(()=>e?ILt(e,t):N9()),[c,l]=(0,I.useState)(!1);(0,I.useEffect)(()=>{s(e?ILt(e,t):N9()),l(!1)},[e,t]);let u=(0,I.useMemo)(()=>LLt(o),[o]),d=Object.keys(u).length>0,f=c&&u.cron?`automation-cron-description automation-cron-error`:`automation-cron-description`,p=c&&u.timezone?`automation-timezone-description automation-timezone-error`:`automation-timezone-description`,m=c&&u.model?`automation-model-description automation-model-error`:`automation-model-description`;function h(e){e.preventDefault(),l(!0),!d&&a(o)}return(0,L.jsxs)(`form`,{className:`space-y-4`,onSubmit:h,noValidate:!0,"aria-label":`${n===`create`?`Create`:`Edit`} automation form`,children:[(0,L.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,L.jsxs)(ce,{children:[(0,L.jsx)(ue,{htmlFor:`automation-title`,children:`Title`}),(0,L.jsx)(T,{id:`automation-title`,value:o.title,onChange:e=>s(t=>({...t,title:e.target.value})),"aria-invalid":c&&!!u.title,"aria-describedby":c&&u.title?`automation-title-error`:void 0}),c&&u.title?(0,L.jsx)(se,{id:`automation-title-error`,children:u.title}):null]}),(0,L.jsxs)(ce,{children:[(0,L.jsx)(ue,{htmlFor:`automation-model`,children:`Model`}),(0,L.jsx)(T,{id:`automation-model`,value:o.model,placeholder:`provider:model-id`,onChange:e=>s(t=>({...t,model:e.target.value})),"aria-invalid":c&&!!u.model,"aria-describedby":m}),(0,L.jsx)(x,{id:`automation-model-description`,children:`Explicit provider and model ID, for example anthropic:claude-sonnet-4-5.`}),c&&u.model?(0,L.jsx)(se,{id:`automation-model-error`,children:u.model}):null]}),(0,L.jsxs)(ce,{children:[(0,L.jsx)(ue,{htmlFor:`automation-cron`,children:`Cron`}),(0,L.jsx)(T,{id:`automation-cron`,value:o.cron,onChange:e=>s(t=>({...t,cron:e.target.value})),"aria-invalid":c&&!!u.cron,"aria-describedby":f}),(0,L.jsx)(x,{id:`automation-cron-description`,children:`Five-field cron, for example 0 9 * * *`}),c&&u.cron?(0,L.jsx)(se,{id:`automation-cron-error`,children:u.cron}):null]}),(0,L.jsxs)(ce,{children:[(0,L.jsx)(ue,{htmlFor:`automation-timezone`,children:`Timezone`}),(0,L.jsx)(T,{id:`automation-timezone`,value:o.timezone,onChange:e=>s(t=>({...t,timezone:e.target.value})),"aria-invalid":c&&!!u.timezone,"aria-describedby":p}),(0,L.jsx)(x,{id:`automation-timezone-description`,children:`IANA timezone, for example UTC or America/New_York.`}),c&&u.timezone?(0,L.jsx)(se,{id:`automation-timezone-error`,children:u.timezone}):null]})]}),(0,L.jsxs)(`label`,{className:`flex w-fit items-center gap-2 rounded-md text-sm text-foreground focus-within:ring-2 focus-within:ring-ring/40`,children:[(0,L.jsx)(Te,{checked:o.enabled,onCheckedChange:e=>s(t=>({...t,enabled:e===!0})),"aria-label":`Automation enabled`}),`Enabled`]}),(0,L.jsxs)(ce,{children:[(0,L.jsx)(ue,{htmlFor:`automation-prompt`,children:`Markdown prompt`}),(0,L.jsx)(_,{id:`automation-prompt`,value:o.prompt,onChange:e=>s(t=>({...t,prompt:e.target.value})),rows:12,spellCheck:!1,className:`min-h-64 resize-y font-mono text-[13px] leading-5`,"aria-describedby":`automation-prompt-description`}),(0,L.jsx)(x,{id:`automation-prompt-description`,children:`Saved through the canonical prompt route; local CLI mode writes the Markdown prompt file.`})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,L.jsx)(Se,{type:`button`,variant:`ghost`,onClick:i,disabled:r,children:`Cancel`}),(0,L.jsx)(Se,{type:`submit`,disabled:r,children:r?`Saving…`:n===`create`?`Create automation`:`Save automation`})]})]})}var P9=class extends Error{code;statusCode;constructor(e,t,n=0){super(t),this.code=e,this.statusCode=n,this.name=`AutomationClientError`}};function VLt(e,t){return`${e?.replace(/\/$/,``)??``}${t}`}function HLt(e){return typeof DOMException<`u`?new DOMException(`Automation request timed out after ${e}ms`,`TimeoutError`):Error(`Automation request timed out after ${e}ms`)}function ULt(e,t){let n=typeof t==`number`&&Number.isFinite(t)&&t>0;if(!e&&!n)return{signal:void 0,cleanup:()=>{},timedOut:()=>!1};let r=new AbortController,i=!1,a,o=()=>r.abort(e?.reason);return e?.aborted?r.abort(e.reason):e?.addEventListener(`abort`,o,{once:!0}),n&&(a=setTimeout(()=>{i=!0,r.abort(HLt(t))},t)),{signal:r.signal,cleanup:()=>{a!==void 0&&clearTimeout(a),e?.removeEventListener(`abort`,o)},timedOut:()=>i}}function WLt(e={}){async function t(t,n={}){let r={...n.body?{"Content-Type":`application/json`}:{},...e.headers??{},...n.headers??{}},i=ULt(n.signal??void 0,e.apiTimeout);try{let a=await fetch(VLt(e.apiBaseUrl,`${dLt}${t}`),{...n,headers:r,signal:i.signal});if(a.status===204)return;let o=await a.json().catch(()=>({}));if(!a.ok||o.ok===!1)throw(a.status===401||a.status===403)&&e.onAuthError?.(a.status),new P9(`code`in o&&typeof o.code==`string`?o.code:`BORING_AUTOMATION_ROUTE_ERROR`,`error`in o&&typeof o.error==`string`?o.error:`Automation request failed`,a.status);return o}catch(t){throw i.timedOut()?new P9(`BORING_AUTOMATION_TIMEOUT`,`Automation request timed out after ${e.apiTimeout}ms`):t}finally{i.cleanup()}}return{async listAutomations(e={}){return(await t(`/automations`,{signal:e.signal})).automations},async createAutomation(e){return(await t(`/automations`,{method:`POST`,body:JSON.stringify(e)})).automation},async getAutomation(e,n={}){return(await t(`/automations/${encodeURIComponent(e)}`,{signal:n.signal})).automation},async updateAutomation(e,n){return(await t(`/automations/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(n)})).automation},async deleteAutomation(e){await t(`/automations/${encodeURIComponent(e)}`,{method:`DELETE`})},async getPrompt(e,n={}){return(await t(`/automations/${encodeURIComponent(e)}/prompt`,{signal:n.signal})).prompt},async updatePrompt(e,n){await t(`/automations/${encodeURIComponent(e)}/prompt`,{method:`PUT`,body:JSON.stringify({prompt:n})})},async runNow(e){return(await t(`/automations/${encodeURIComponent(e)}/run`,{method:`POST`})).run},async listRuns(e,n={}){return(await t(`/automations/${encodeURIComponent(e)}/runs`,{signal:n.signal})).runs}}}var GLt=(0,I.createContext)(null);function KLt({apiBaseUrl:e,authHeaders:t,onAuthError:n,apiTimeout:r,children:i}){let a=(0,I.useMemo)(()=>WLt({apiBaseUrl:e,headers:t,onAuthError:n,apiTimeout:r}),[e,t,n,r]);return(0,L.jsx)(GLt.Provider,{value:a,children:i})}function qLt(){let e=(0,I.useContext)(GLt);if(!e)throw Error(`useAutomationClient must be used within AutomationRuntimeProvider`);return e}function F9(e){return e instanceof P9||e instanceof Error?e.message:`Automation request failed`}function JLt(e,t){return{prompt:e?.prompt??``,promptLoading:e?.promptLoading??!1,runs:e?.runs??[],runsLoading:e?.runsLoading??!1,...t}}function I9(e,t,n){return{...e,[t]:JLt(e[t],n)}}function L9(e,t){let n=(e.current[t]??0)+1;return e.current[t]=n,n}function R9(e,t,n,r){return!r?.aborted&&e.current[t]===n}function YLt(){let e=qLt(),t=RQ(),[n,r]=(0,I.useState)([]),[i,a]=(0,I.useState)({}),[o,s]=(0,I.useState)(null),[c,l]=(0,I.useState)({mode:`closed`}),[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(!0),[h,g]=(0,I.useState)(!1),[_,v]=(0,I.useState)(()=>new Set),[y,b]=(0,I.useState)(null),[x,S]=(0,I.useState)(null),[C,w]=(0,I.useState)(null),T=(0,I.useRef)({}),E=(0,I.useRef)({}),D=(0,I.useMemo)(()=>c.mode===`edit`?n.find(e=>e.id===c.automationId)??null:null,[n,c]),O=(0,I.useCallback)(async t=>{m(!0),b(null);try{let n=await e.listAutomations({signal:t});r(n)}catch(e){if(t?.aborted)return;b(F9(e))}finally{t?.aborted||m(!1)}},[e]),k=(0,I.useCallback)(async(t,n)=>{let r=L9(T,t);a(e=>I9(e,t,{promptLoading:!0}));try{let i=await e.getPrompt(t,{signal:n});if(!R9(T,t,r,n))return;a(e=>I9(e,t,{prompt:i,promptLoading:!1}))}catch(e){if(!R9(T,t,r,n))return;b(F9(e)),a(e=>I9(e,t,{promptLoading:!1}))}},[e]),A=(0,I.useCallback)(async(t,n)=>{let r=L9(E,t);a(e=>I9(e,t,{runsLoading:!0}));try{let i=await e.listRuns(t,{signal:n});if(!R9(E,t,r,n))return;a(e=>I9(e,t,{runs:i,runsLoading:!1}))}catch(e){if(!R9(E,t,r,n))return;b(F9(e)),a(e=>I9(e,t,{runsLoading:!1}))}},[e]);(0,I.useEffect)(()=>{let e=new AbortController;return O(e.signal),()=>e.abort()},[O]);let ee=(0,I.useCallback)(()=>{l({mode:`create`}),w(null),S(null)},[]),te=(0,I.useCallback)(e=>{l({mode:`edit`,automationId:e.id}),w(null),S(null),k(e.id)},[k]),ne=(0,I.useCallback)(e=>{let t=o!==e.id;s(t?e.id:null),S(null),t&&A(e.id)},[o,A]);async function j(t){let n=L9(T,t);a(e=>I9(e,t,{promptLoading:!0}));let[i,o]=await Promise.all([e.getAutomation(t),e.getPrompt(t)]);R9(T,t,n)&&(r(e=>e.map(e=>e.id===i.id?i:e)),a(e=>I9(e,i.id,{prompt:o,promptLoading:!1})))}async function M(t){g(!0),b(null),w(null);try{if(c.mode===`create`){let n=await e.createAutomation(RLt(t));L9(T,n.id),r(e=>[n,...e]),a(e=>I9(e,n.id,{prompt:t.prompt,promptLoading:!1,runs:[],runsLoading:!1})),s(n.id),l({mode:`edit`,automationId:n.id}),w({tone:`success`,message:`Automation created.`});return}if(c.mode===`edit`){let n=c.automationId;L9(T,n),await e.updatePrompt(n,t.prompt),a(e=>I9(e,n,{prompt:t.prompt,promptLoading:!1}));try{let i=await e.updateAutomation(n,zLt(t));r(e=>e.map(e=>e.id===i.id?i:e)),w({tone:`success`,message:`Automation saved.`})}catch(e){try{await j(n),w({tone:`warning`,message:`Prompt saved, but automation metadata was not saved: ${F9(e)}. Refreshed latest server state.`})}catch(t){w({tone:`warning`,message:`Prompt saved, but automation metadata was not saved: ${F9(e)}. Refresh failed: ${F9(t)}`})}}}}catch(e){b(F9(e))}finally{g(!1)}}async function N(t){b(null);try{await e.deleteAutomation(t),r(e=>e.filter(e=>e.id!==t)),a(e=>{let n={...e};return delete n[t],n}),o===t&&s(null),c.mode===`edit`&&c.automationId===t&&l({mode:`closed`}),f(null),w({tone:`success`,message:`Automation deleted.`})}catch(e){b(F9(e))}}async function re(t){if(!_.has(t.id)){v(e=>new Set(e).add(t.id)),b(null),w(null),s(t.id);try{let n=await e.runNow(t.id);a(e=>I9(e,t.id,{runs:[n,...(e[t.id]?.runs??[]).filter(e=>e.id!==n.id)],runsLoading:!1})),w({tone:`success`,message:n.sessionId?`Automation finished. Open its session from run history.`:`Automation finished.`})}catch(e){b(F9(e)),await A(t.id)}finally{v(e=>{let n=new Set(e);return n.delete(t.id),n})}}}function ie(e){if(!e.sessionId)return;let n=t.openDetachedChat(e.sessionId,{title:e.modelSnapshot||`Automation run`});S(n.success?null:n.message)}let ae=D?i[D.id]?.prompt??``:N9().prompt,oe=c.mode===`edit`&&D?i[D.id]?.promptLoading===!0:!1;return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background text-sm text-foreground`,children:[(0,L.jsxs)(`header`,{className:`flex min-h-14 shrink-0 items-center justify-between gap-3 border-b border-border/60 px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`grid size-7 place-items-center rounded-lg bg-[color:oklch(from_var(--accent)_l_c_h/0.14)] text-[color:var(--accent)]`,children:(0,L.jsx)(yr,{className:`size-4`,"aria-hidden":`true`})}),(0,L.jsx)(`h2`,{className:`truncate text-sm font-semibold tracking-tight`,children:C9})]}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Local scheduled prompts with Markdown prompt files and Pi session history.`})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,L.jsxs)(Se,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void O(),disabled:p||c.mode!==`closed`,children:[(0,L.jsx)(Fi,{className:`size-4`,"aria-hidden":`true`}),`Refresh`]}),(0,L.jsxs)(Se,{type:`button`,size:`sm`,onClick:ee,children:[(0,L.jsx)(Mi,{className:`size-4`,"aria-hidden":`true`}),`New`]})]})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto bg-[color:oklch(from_var(--background)_calc(l-0.012)_c_h)]`,children:(0,L.jsxs)(`div`,{className:`mx-auto grid w-full max-w-6xl gap-4 p-4 lg:grid-cols-[minmax(0,1fr)_minmax(360px,440px)]`,children:[(0,L.jsx)(`section`,{className:`min-w-0 overflow-hidden rounded-xl border border-border/70 bg-card/60`,"aria-label":`Automation list`,children:p?(0,L.jsxs)(`div`,{className:`flex min-h-48 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(ot,{className:`size-4`}),` Loading automations…`]}):n.length===0?(0,L.jsx)(lt,{title:`No automations yet`,description:`Create a focused scheduled prompt with cron, timezone, model, and canonical Markdown.`,icon:(0,L.jsx)(yr,{className:`size-8`,"aria-hidden":`true`}),actions:(0,L.jsx)(Se,{type:`button`,onClick:ee,children:`Create automation`}),className:`min-h-64`}):(0,L.jsx)(`div`,{children:n.map(e=>{let t=i[e.id];return(0,L.jsx)(PLt,{automation:e,expanded:o===e.id,deleting:d===e.id,runs:t?.runs??[],runsLoading:t?.runsLoading===!0,runningNow:_.has(e.id),onToggle:()=>ne(e),onEdit:()=>te(e),onRunNow:()=>void re(e),onDeleteRequest:()=>f(e.id),onDeleteCancel:()=>f(null),onDeleteConfirm:()=>void N(e.id),onOpenRun:ie},e.id)})})}),(0,L.jsxs)(`aside`,{className:`min-w-0 rounded-xl border border-border/70 bg-card/80 p-4`,"aria-label":`Automation editor`,children:[y?(0,L.jsx)(u,{tone:`destructive`,className:`mb-3`,role:`alert`,children:y}):null,x?(0,L.jsx)(u,{tone:`destructive`,className:`mb-3`,role:`alert`,children:x}):null,C?(0,L.jsx)(u,{tone:C.tone,className:`mb-3`,role:`status`,children:C.message}):null,c.mode===`closed`?(0,L.jsx)(`div`,{className:`flex min-h-80 items-center justify-center px-4 text-center text-sm text-muted-foreground`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`font-medium text-foreground`,children:`Select an automation to edit`}),(0,L.jsx)(`p`,{className:`mt-1 max-w-xs`,children:`Cards expand for read-only run history. The editor saves metadata and Markdown through separate public routes.`})]})}):c.mode===`create`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`New automation`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Define the schedule and canonical Markdown prompt.`})]}),(0,L.jsx)(BLt,{mode:`create`,prompt:``,saving:h,onCancel:()=>l({mode:`closed`}),onSubmit:e=>void M(e)})]}):D?oe?(0,L.jsxs)(`div`,{className:`flex min-h-80 items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(ot,{className:`size-4`}),` Loading prompt…`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Edit automation`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:D.id})]}),(0,L.jsx)(BLt,{automation:D,mode:`edit`,prompt:ae,saving:h,onCancel:()=>l({mode:`closed`}),onSubmit:e=>void M(e)})]}):(0,L.jsx)(u,{tone:`destructive`,children:`Automation not found.`})]})]})})]})}var XLt=zn({id:S9,label:C9,providers:[{id:`${S9}.runtime`,component:KLt}],panels:[{id:`${S9}.panel`,label:C9,icon:yr,component:YLt,placement:`center`,source:`builtin`}],commands:[{id:`${S9}.open`,title:`Open Automations`,panelId:`${S9}.panel`}]}),ZLt=`diagram`,z9=`diagram.panel`;function QLt(e){let t=e.toLowerCase();return t.endsWith(`.excalidraw`)||t.endsWith(`.excalidraw.png`)}function $Lt(e){return e?e.split(`/`).pop()||e:`Diagram`}function eRt(e){return e.toLowerCase().endsWith(`.excalidraw.png`)?e.replace(/\.png$/i,``):e||`untitled.excalidraw`}function tRt(e){let t=eRt(e);return t.toLowerCase().endsWith(`.excalidraw`)?t.replace(/\.excalidraw$/i,`.render.png`):`${t}.render.png`}var nRt=(0,I.lazy)(async()=>({default:(await P(()=>import(`./DiagramPane-DExG3C_B.js`),__vite__mapDeps([286,1,282,285,284,207,287,288,289,290,291]))).DiagramPane}));function rRt(e){return(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading Diagram…`}),children:(0,L.jsx)(nRt,{...e})})}var iRt=zn({id:ZLt,label:`Diagram`,panels:[{id:z9,label:`Diagram`,component:rRt}],commands:[{id:`diagram.open`,title:`Open Diagram`,panelId:z9}],surfaceResolvers:[{id:`diagram.open-file`,kind:iB,resolve:e=>{if(e.kind!==`workspace.open.path`||!QLt(e.target))return null;let t=typeof e.filesystem==`string`&&e.filesystem?e.filesystem:void 0;return{id:`diagram:${encodeURIComponent(t??`user`)}:${encodeURIComponent(e.target)}`,component:z9,title:$Lt(e.target),params:{path:e.target,...t?{filesystem:t}:{}},score:1e3}}}]}),aRt=`tasks`,oRt=`Tasks`,B9=`/api/boring-tasks`;async function sRt(e){try{let t=await e.json(),n=t.error??t.message;if(typeof n==`string`&&n.length>0)return n}catch{}return`${e.status} ${e.statusText}`.trim()}async function cRt(e,t){let n=await fetch(`${B9}${e}`,{credentials:`include`,...t,headers:{...t?.body?{"Content-Type":`application/json`}:{},...t?.headers}});if(!n.ok)throw Error(await sRt(n));return await n.json()}function lRt(e,t){return e?e.getJson(`${B9}${t}`):cRt(t)}function V9(e,t,n){return e?e.postJson(`${B9}${t}`,n):cRt(t,{method:`POST`,body:JSON.stringify(n)})}async function uRt(e){return(await lRt(e,`/sources`)).sources??[]}function dRt(e,t){return{...e,async getBoardConfig(){let n=(await V9(t,`/sources/tasks/list`,{sourceIds:[e.id]})).configs?.[e.id];if(!n)throw Error(`Task source did not return board config: ${e.id}`);return n},async listTasks(){return(await V9(t,`/sources/tasks/list`,{sourceIds:[e.id]})).tasks??[]},moveTask:e.capabilities.move?async({taskId:n,statusId:r})=>{let i=await V9(t,`/sources/tasks/move`,{sourceId:e.id,taskId:n,statusId:r});if(!i.task)throw Error(`Task source did not return moved task: ${e.id}`);return i.task}:void 0,deleteTask:e.capabilities.delete?async({taskId:n})=>{await V9(t,`/sources/tasks/delete`,{sourceId:e.id,taskId:n})}:void 0}}var fRt=`__unmapped__`;function pRt(e,t){let n=new Set(e.columns.map(e=>e.id)),r=e.columns.map(e=>({...e,tasks:[]})),i=new Map(r.map(e=>[e.id,e])),a=[];for(let e of t){let t=i.get(e.statusId);t?t.tasks.push(e):a.push(e)}return a.length>0&&r.push({id:fRt,title:`Unmapped`,description:`Tasks whose adapter status is not in this board config`,acceptsDrop:!1,tasks:a,unmapped:!0}),r.filter(e=>e.tasks.length>0||n.has(e.id))}function mRt(e){return e.id!==fRt&&e.acceptsDrop!==!1}function hRt({className:e}){return(0,L.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M14 5h5v5M19 5l-9 9`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,L.jsx)(`path`,{d:`M11 6H7a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-4`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`})]})}function gRt(e){let t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height,top:t.top,right:t.right,bottom:t.bottom,left:t.left}}function _Rt(e){return[`Let's work on ${e.number}: ${e.title}`,``,`Task ID: ${e.number}`,`Status: ${e.statusId}`,e.url?`URL: ${e.url}`:null].filter(Boolean).join(`
867
+ `;return`${e.block}${n}${t}`}function xFt(e,t,n,r=!1){return TFt(e,t,r)?bFt(n,e):null}function SFt(e){return(q7(e)?.body??e).replace(/```[\s\S]*?```/g,` `).replace(/`[^`]*`/g,` `).replace(/^\s{0,3}#{1,6}\s+/gm,``).replace(/!\[[^\]]*\]\([^)]*\)/g,` `).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/<[^>]+>/g,` `).replace(/^\s{0,3}[-*_]{3,}\s*$/gm,` `).replace(/^\s{0,3}(?:[-*+]\s+|\d+[.)]\s+|>\s?)/gm,``).replace(/^\s{0,3}\|?(?:\s*:?-+:?\s*\|)+\s*$/gm,` `).replace(/\|/g,` `).replace(/[*_~>#]/g,` `).match(/\b[\p{L}\p{N}']+\b/gu)?.length??0}function CFt(e){return`${e} word${e===1?``:`s`}`}function wFt(e){return/^(?:[a-z][a-z0-9+.-]*:|\/|#)/i.test(e)}function TFt(e,t,n=!1){return t||n}function EFt(e,t){let n=e.match(/^([^?#]*)([?#].*)?$/),r=n?.[1]??e,i=n?.[2]??``,a=t?.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)):``,o=`${a?`${a}/`:``}${r}`.split(`/`),s=[];for(let e of o)!e||e===`.`||(e===`..`?s.pop():s.push(e));return`${s.join(`/`)}${i}`}function DFt(e,t,n,r,i){if(!e)return e;let a=ba(i),o=a!==`user`;if(wFt(e)&&!(o&&e.startsWith(`/`)&&!e.startsWith(`//`)))return e;let s=o&&e.startsWith(`/`)?e:o&&t?.startsWith(`/`)?`/${EFt(e,t)}`:EFt(e,t),c=n.replace(/\/$/,``),l=new URLSearchParams({path:s});return r&&l.set(`workspaceId`,r),a!==`user`&&l.set(`filesystem`,a),`${c}/api/v1/files/raw?${l.toString()}`}function OFt(e){return/^(?:[a-z][a-z0-9+.-]*:|\/\/|\/|#|\?)/i.test(e)}function J7(e,t){let n=e.trim();if(!n||OFt(n))return null;let r=n.split(/[?#]/,1)[0];if(!r)return null;let i=t?.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)):``,a=`${i?`${i}/`:``}${r}`.split(`/`),o=[];for(let e of a)if(!(!e||e===`.`)){if(e===`..`){if(o.length===0)return null;o.pop();continue}o.push(e)}return o.join(`/`)||null}function kFt(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey}var AFt=[ijt.configure({codeBlock:!1,link:!1,underline:!1}),lAt,ckt.configure({openOnClick:!0,autolink:!0,linkOnPaste:!0,defaultProtocol:`https`,isAllowedUri:(e,t)=>Z7(e)&&(J7(e)!==null||t.defaultValidate(e)),HTMLAttributes:{rel:`noopener noreferrer nofollow`,target:`_blank`}}),ajt.configure({placeholder:`Start writing...`}),ojt,sjt.configure({nested:!0}),cjt.configure({types:[`heading`,`paragraph`]}),djt,GMt.configure({resizable:!0}),PMt,NMt,MMt,QMt.configure({inline:!1,allowBase64:!0}),sNt.configure({lowlight:hFt}),pFt.configure({markedOptions:{gfm:!0,breaks:!1,pedantic:!1}})];function Y7({onClick:e,active:t,disabled:n,title:r,children:i}){return(0,L.jsx)(Ie,{type:`button`,size:`icon-xs`,onClick:e,disabled:n,title:r,"aria-pressed":t,className:DU(`text-muted-foreground/70`,t&&`bg-[color:var(--accent-soft)] text-[color:var(--accent)]`),children:i})}function X7(){return(0,L.jsx)(Pe,{className:`mx-2 h-3.5`})}function Z7(e){let t=e.trim().toLowerCase();return!t.startsWith(`javascript:`)&&!t.startsWith(`data:text/html`)}function jFt(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error??Error(`Read failed`)),r.readAsDataURL(e)})}function MFt(e){if(!e)return null;for(let t of Array.from(e.files??[]))if(t.type.startsWith(`image/`))return t;for(let t of Array.from(e.items??[])){if(t.kind!==`file`||!t.type.startsWith(`image/`))continue;let e=t.getAsFile();if(e)return e}return null}function NFt({editor:e,onInsertImage:t,rawMode:n,onToggleRawMode:r,uploading:i,allowImageUpload:a}){let o=t=>{if(e){if(e.isActive(`image`)){e.chain().focus().updateAttributes(`image`,{align:t}).run();return}e.chain().focus().setTextAlign(t).run()}},s=(0,I.useRef)(null),c=AEt({editor:e,selector:({editor:e})=>e?{bold:e.isActive(`bold`),italic:e.isActive(`italic`),underline:e.isActive(`underline`),strike:e.isActive(`strike`),h1:e.isActive(`heading`,{level:1}),h2:e.isActive(`heading`,{level:2}),h3:e.isActive(`heading`,{level:3}),bulletList:e.isActive(`bulletList`),orderedList:e.isActive(`orderedList`),taskList:e.isActive(`taskList`),blockquote:e.isActive(`blockquote`),codeBlock:e.isActive(`codeBlock`),link:e.isActive(`link`),highlight:e.isActive(`highlight`),alignLeft:e.isActive(`image`)?(e.getAttributes(`image`).align??`left`)===`left`:e.isActive({textAlign:`left`}),alignCenter:e.isActive(`image`)?e.getAttributes(`image`).align===`center`:e.isActive({textAlign:`center`}),alignRight:e.isActive(`image`)?e.getAttributes(`image`).align===`right`:e.isActive({textAlign:`right`})}:null});if(!e||!c)return null;let l=()=>{let t=window.prompt(`URL:`);t&&Z7(t)&&e.chain().focus().extendMarkRange(`link`).setLink({href:t}).run()},u=()=>{let t=window.prompt(`Image URL:`);t&&Z7(t)&&e.chain().focus().setImage({src:t}).run()};return(0,L.jsxs)(ne,{className:`border-b border-border/60 bg-background px-3 py-1.5`,"aria-label":`Formatting toolbar`,children:[(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleBold().run(),active:c.bold,title:`Bold`,children:(0,L.jsx)(gr,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleItalic().run(),active:c.italic,title:`Italic`,children:(0,L.jsx)(ai,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleUnderline().run(),active:c.underline,title:`Underline`,children:(0,L.jsx)(Xi,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleStrike().run(),active:c.strike,title:`Strikethrough`,children:(0,L.jsx)(Hi,{className:`h-4 w-4`})}),(0,L.jsx)(X7,{}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleHeading({level:1}).run(),active:c.h1,title:`Heading 1`,children:(0,L.jsx)(Qr,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleHeading({level:2}).run(),active:c.h2,title:`Heading 2`,children:(0,L.jsx)($r,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleHeading({level:3}).run(),active:c.h3,title:`Heading 3`,children:(0,L.jsx)(ei,{className:`h-4 w-4`})}),(0,L.jsx)(X7,{}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleBulletList().run(),active:c.bulletList,title:`Bullet list`,children:(0,L.jsx)(ui,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleOrderedList().run(),active:c.orderedList,title:`Ordered list`,children:(0,L.jsx)(ci,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleTaskList().run(),active:c.taskList,title:`Task list`,children:(0,L.jsx)(eee,{className:`h-4 w-4`})}),(0,L.jsx)(X7,{}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleBlockquote().run(),active:c.blockquote,title:`Quote`,children:(0,L.jsx)(Ni,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleCodeBlock().run(),active:c.codeBlock,title:`Code block`,children:(0,L.jsx)(Nr,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:l,active:c.link,title:`Link`,children:(0,L.jsx)(si,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:e=>{if(e?.shiftKey){u();return}a&&s.current?.click()},disabled:!a,title:a?`Image (click to upload, Shift+click for URL)`:`Image upload unavailable for this filesystem`,children:(0,L.jsx)(ni,{className:`h-4 w-4`})}),(0,L.jsx)(T,{ref:s,"data-testid":`image-file-input`,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let n=e.target.files?.[0];e.target.value=``,!(!n||!n.type.startsWith(`image/`))&&await t(n)}}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().toggleHighlight().run(),active:c.highlight,title:`Highlight`,children:(0,L.jsx)(ti,{className:`h-4 w-4`})}),(0,L.jsx)(X7,{}),(0,L.jsx)(Y7,{onClick:()=>o(`left`),active:c.alignLeft,title:`Align left`,children:(0,L.jsx)(qi,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>o(`center`),active:c.alignCenter,title:`Center align`,children:(0,L.jsx)(Gi,{className:`h-4 w-4`})}),(0,L.jsx)(Y7,{onClick:()=>o(`right`),active:c.alignRight,title:`Align right`,children:(0,L.jsx)(Ki,{className:`h-4 w-4`})}),(0,L.jsx)(X7,{}),(0,L.jsx)(Y7,{onClick:()=>e.chain().focus().setHorizontalRule().run(),title:`Horizontal rule`,children:(0,L.jsx)(vi,{className:`h-4 w-4`})}),(0,L.jsx)(X7,{}),i&&(0,L.jsxs)(`span`,{role:`status`,"aria-live":`polite`,className:`ml-auto flex items-center gap-1.5 text-[11px] text-muted-foreground/80`,children:[(0,L.jsx)(di,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),`Uploading…`]}),(0,L.jsx)(Y7,{onClick:r,active:n,title:n?`Rich text`:`Raw markdown`,children:(0,L.jsx)(`span`,{className:`font-mono text-[10px] font-semibold leading-none tracking-[-0.02em]`,children:`MD`})})]})}function PFt({summary:e}){return(0,L.jsx)(`section`,{"aria-label":`Frontmatter`,className:`border-b border-border/60 bg-transparent px-6 py-5`,"data-testid":`markdown-frontmatter-summary`,children:(0,L.jsxs)(`div`,{className:`rounded-xl border border-[#3a3a3a] bg-[#262626] px-6 py-5 shadow-sm`,children:[(0,L.jsx)(`h2`,{className:`mb-5 text-base font-medium text-[#c9c9c9]`,children:`Metadata`}),(0,L.jsx)(`dl`,{className:`grid gap-x-10 gap-y-4 text-sm sm:grid-cols-[minmax(9rem,17rem)_minmax(0,1fr)]`,children:e.entries.map((e,t)=>(0,L.jsxs)(`div`,{className:`contents`,children:[(0,L.jsx)(`dt`,{className:`font-mono text-[#b8b8b8]`,children:e.key}),(0,L.jsx)(`dd`,{className:`min-w-0 whitespace-pre-wrap break-words font-mono text-[#f5f5f5]`,children:e.value})]},`${e.key}-${t}`))})]})})}function FFt({content:e,onChange:t,readOnly:n=!1,placeholder:r,className:i,documentPath:a,filesystem:o}){let s=ba(o),c=Bu(),l=Vu(),u=s===`user`,{upload:d,uploading:f}=bWe(),[p,m]=(0,I.useState)(!1),h=(0,I.useMemo)(()=>{let e=QMt.configure({inline:!1,allowBase64:!0,resizable:!n,resolveSrc:e=>DFt(e,a,c,l,s)}),t=AFt.map(t=>t.name===`image`?e:t);return r?[...t.filter(e=>e.name!==`placeholder`),ajt.configure({placeholder:r})]:t},[c,a,s,r,n,l]),g=(0,I.useRef)(t);g.current=t;let _=(0,I.useRef)(!1),v=(0,I.useRef)(!1),y=(0,I.useRef)(e),b=(0,I.useRef)(null),x=(0,I.useMemo)(()=>SFt(e),[e]),S=(0,I.useMemo)(()=>q7(e),[e]),C=S?.body??e,w=(0,I.useRef)(async()=>{}),T=(0,I.useRef)(S);T.current=S,w.current=async e=>{v.current=!0;let t=b.current;if(!t||!u)return;let n;try{n=await jFt(e)}catch{return}let r=typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`pending-${Date.now()}-${Math.random().toString(36).slice(2)}`,i={src:n,alt:e.name,pendingUploadId:r};t.chain().focus().setImage(i).run();try{let{url:t}=await d(e,{sourcePath:a}),n=b.current;if(!n||n.isDestroyed)return;n.commands.command(({tr:e,state:n})=>(n.doc.descendants((n,i)=>(n.type.name===`image`&&n.attrs.pendingUploadId===r&&e.setNodeMarkup(i,void 0,{...n.attrs,src:t,pendingUploadId:null}),!0)),!0))}catch{let e=b.current;if(!e||e.isDestroyed)return;e.commands.command(({tr:e,state:t})=>(t.doc.descendants((t,n)=>(t.type.name===`image`&&t.attrs.pendingUploadId===r&&e.setNodeMarkup(n,void 0,{...t.attrs,pendingUploadId:null}),!0)),!0))}};let E=(0,I.useMemo)(()=>C||{type:`doc`,content:[{type:`paragraph`}]},[C]),D=C?`markdown`:`json`,O=PEt({extensions:h,content:E,contentType:D,editable:!n,editorProps:{attributes:{class:`tiptap-prose max-w-[68ch] px-8 py-6 focus:outline-none min-h-[200px]`},transformPastedHTML:_Ft,handlePaste:(e,t)=>{if(n)return!1;let r=MFt(t.clipboardData);return r?(t.preventDefault(),w.current(r),!0):!1}},onUpdate:({editor:e})=>{if(_.current)return;let t=xFt(e.getMarkdown?.()??e.getHTML(),e.isFocused,T.current,v.current);t!==null&&(y.current=t,g.current?.(t))}});return b.current=O,(0,I.useEffect)(()=>{!O||O.isDestroyed||O.setEditable(!n)},[O,n]),(0,I.useEffect)(()=>{!O||O.isDestroyed||e!==y.current&&(O.getMarkdown?.()??O.getHTML())!==C&&(_.current=!0,O.commands.setContent(E,{contentType:D}),_.current=!1,y.current=e)},[O,e,E,D,C]),(0,L.jsxs)(`div`,{className:DU(`flex h-full min-h-0 flex-col overflow-hidden`,i),onPointerDownCapture:()=>{v.current=!0},onClickCapture:()=>{v.current=!0},onKeyDownCapture:()=>{v.current=!0},children:[!n&&(0,L.jsx)(NFt,{editor:O,onInsertImage:e=>w.current(e),rawMode:p,onToggleRawMode:()=>m(e=>!e),uploading:f,allowImageUpload:u}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onClickCapture:e=>{if(!kFt(e.nativeEvent))return;let t=(e.target instanceof Element?e.target.closest(`a[href]`):null)?.getAttribute(`href`);if(!t)return;let n=ba(s),r=n!==`user`,i=J7(t,a)??(r&&t.startsWith(`/`)&&!t.startsWith(`//`)?t.split(/[?#]/,1)[0]:null);i&&(e.preventDefault(),e.stopPropagation(),dc({kind:`openFile`,params:{path:r&&a?.startsWith(`/`)&&!i.startsWith(`/`)?`/${i}`:i,...n===`user`?{}:{filesystem:n}}}))},children:p&&!n?(0,L.jsx)(`textarea`,{"aria-label":`Raw markdown`,"data-testid":`markdown-raw-editor`,className:`h-full min-h-[200px] w-full resize-none bg-background px-8 py-6 font-mono text-[13px] leading-6 text-foreground outline-none placeholder:text-muted-foreground/70`,value:e,placeholder:r,spellCheck:!1,onChange:e=>g.current?.(e.target.value)}):(0,L.jsxs)(L.Fragment,{children:[S&&(0,L.jsx)(PFt,{summary:S}),(0,L.jsx)(DEt,{editor:O})]})}),(0,L.jsx)(`div`,{className:`border-t border-border/60 px-4 py-2 text-right text-xs text-muted-foreground`,"data-testid":`markdown-word-count`,children:CFt(x)})]})}function IFt({sessions:e,activeId:t,onSwitch:n,onCreate:r,onDelete:i,className:a}){let[o,s]=(0,I.useState)(null),c=(0,I.useRef)({}),l=(0,I.useMemo)(()=>e.map(e=>e.id),[e]);(0,I.useEffect)(()=>{if(l.length===0){s(null);return}s(e=>e&&l.includes(e)?e:t&&l.includes(t)?t:l[0]??null)},[l,t]);let u=(0,I.useCallback)(e=>{s(e),c.current[e]?.focus()},[]),d=(0,I.useCallback)((e,t)=>{if(e.target!==e.currentTarget)return;if(e.key===`Enter`||e.key===` `){e.preventDefault(),n?.(t);return}let r=l.indexOf(t);if(r<0)return;let i=r;if(e.key===`ArrowDown`)i=Math.min(r+1,l.length-1);else if(e.key===`ArrowUp`)i=Math.max(r-1,0);else if(e.key===`Home`)i=0;else if(e.key===`End`)i=l.length-1;else return;e.preventDefault();let a=l[i];a&&u(a)},[u,n,l]);return(0,L.jsxs)(`div`,{"data-boring-workspace-part":`session-list`,className:DU(`flex h-full flex-col`,a),role:`navigation`,"aria-label":`Sessions`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`Sessions`}),r&&(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:r,"aria-label":`New session`,children:(0,L.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,L.jsx)(`path`,{d:`M8 3v10M3 8h10`})})})]}),(0,L.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,role:`list`,"aria-label":`Session list`,children:[e.length===0&&(0,L.jsx)(`div`,{className:`px-3 py-6 text-center text-sm text-muted-foreground`,children:`No sessions`}),e.map(e=>(0,L.jsx)(RFt,{session:e,isActive:e.id===t,isFocused:e.id===o,onSwitch:n,onDelete:i,onFocus:()=>s(e.id),onKeyDown:d,rowRef:t=>{c.current[e.id]=t}},e.id))]})]})}async function LFt(e){if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}if(typeof document>`u`)return!1;let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-9999px`,t.style.left=`-9999px`,t.style.opacity=`0`,t.style.pointerEvents=`none`,document.body.appendChild(t);try{return t.focus(),t.select(),document.execCommand?.(`copy`)??!1}catch{return!1}finally{document.body.removeChild(t)}}function RFt({session:e,isActive:t,isFocused:n,onSwitch:r,onDelete:i,onFocus:a,onKeyDown:o,rowRef:s}){let[c,l]=(0,I.useState)(!1),u=(0,I.useCallback)(t=>{t.stopPropagation(),LFt(e.id).then(e=>{e&&(l(!0),window.setTimeout(()=>l(!1),1200))})},[e.id]);return(0,L.jsxs)(`div`,{ref:s,role:`listitem`,"data-boring-workspace-part":`session-row`,"data-boring-state":t?`selected`:void 0,"data-focused":n?`true`:`false`,className:DU(`group flex items-center gap-2 border-b border-border px-3 py-2 text-sm cursor-pointer transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1`,t?`bg-accent text-accent-foreground`:`text-foreground hover:bg-accent/50`),onClick:()=>r?.(e.id),onFocus:a,onKeyDown:t=>o(t,e.id),tabIndex:n?0:-1,"aria-current":t?`true`:void 0,children:[(0,L.jsx)(`span`,{className:`flex-1 truncate`,children:e.title}),(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`hidden shrink-0 text-muted-foreground hover:text-foreground group-hover:inline-flex group-data-[focused=true]:inline-flex`,onClick:u,tabIndex:n?0:-1,"aria-label":`Copy Pi session id for ${e.title}`,title:`Copy Pi session id`,children:c?(0,L.jsx)(br,{className:`h-3.5 w-3.5`}):(0,L.jsx)(Fr,{className:`h-3.5 w-3.5`})}),t&&(0,L.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`,"aria-label":`Active`}),i&&(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`hidden shrink-0 text-muted-foreground hover:text-destructive group-hover:inline-flex group-data-[focused=true]:inline-flex`,onClick:t=>{t.stopPropagation(),i(e.id)},tabIndex:n?0:-1,"aria-label":`Delete ${e.title}`,children:(0,L.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,L.jsx)(`path`,{d:`M3.5 3.5l7 7M10.5 3.5l-7 7`})})})]})}var zFt=r({ArtifactSurfacePane:()=>g$,CatalogRegistry:()=>$n,ChatLayout:()=>Fst,CodeEditor:()=>lrt,CodeEditorPane:()=>kQ,CommandPalette:()=>Kit,CommandRegistry:()=>Hrt,DockviewShell:()=>jU,EmptyPane:()=>Gst,FileTree:()=>Lgt,FileTreePane:()=>HU,FileTreeView:()=>VU,IdeLayout:()=>eit,MAX_PANELS:()=>50,MarkdownEditor:()=>FFt,MarkdownEditorPane:()=>frt,PanelChrome:()=>MU,PanelErrorBoundary:()=>Kst,PanelRegistry:()=>tB,PluginError:()=>Ln,PluginErrorBoundary:()=>oa,PluginErrorProvider:()=>ia,RegistryProvider:()=>rr,ResponsiveDockviewShell:()=>Zrt,SessionBrowser:()=>$at,SessionList:()=>IFt,SurfaceResolverRegistry:()=>tr,SurfaceShell:()=>Mot,ThemeProvider:()=>hst,Toaster:()=>h,TopBar:()=>Hst,UI_COMMAND_EVENT:()=>uc,WORKSPACE_ATTENTION_ACTION_EVENT:()=>n$,WORKSPACE_COMPOSER_STOP_EVENT:()=>XQ,WORKSPACE_COMPOSER_STOP_REASONS:()=>ZQ,WORKSPACE_OPEN_PATH_SURFACE_KIND:()=>iB,WORKSPACE_SURFACE_OPEN_SKIPPED_EVENT:()=>zs,WorkbenchLeftPane:()=>m$,WorkspaceFilesProvider:()=>Hu,WorkspaceLink:()=>hc,WorkspaceLoadingState:()=>Wst,WorkspacePluginClientProvider:()=>_a,WorkspaceProvider:()=>Dst,WorkspaceSourceRegistry:()=>er,agentMeta:()=>ic,bindStore:()=>nU,bootstrap:()=>Zn,buildChatLayout:()=>Pst,buildFullPagePanelHref:()=>sit,buildIdeLayout:()=>$rt,closePanelSchema:()=>Os,cn:()=>DU,createBridge:()=>Ms,createBridgeClient:()=>Ls,createShadcnTheme:()=>OQ,createWorkspacePluginClient:()=>ga,createWorkspaceStore:()=>WQ,definePanel:()=>iot,dismissToast:()=>D,emitAgentData:()=>sc,emitFilesystemAgentFileChange:()=>UU,emitWorkspaceAttentionAction:()=>r$,emitWorkspaceComposerStop:()=>QQ,events:()=>lc,expandToFileSchema:()=>js,filesystemEvents:()=>eu,filesystemPlugin:()=>IQ,formatShortcut:()=>VJe,getFileIcon:()=>rB,isWorkspaceComposerStopDetail:()=>$Q,isWorkspaceComposerStopReason:()=>gat,navigateToLineSchema:()=>As,notificationSchema:()=>ks,onFilesystemChanged:()=>MJe,openFileSchema:()=>Es,openPanelSchema:()=>Ds,postUiCommand:()=>dc,readFileRecords:()=>Ku,toast:()=>ie,useActiveFile:()=>xqe,useActivePanel:()=>Sqe,useActivePanels:()=>ur,useApiBaseUrl:()=>Bu,useAppLeftOverlayChrome:()=>LQ,useArtifactPanels:()=>LJe,useArtifactRouting:()=>RJe,useAutoOpenAgentFiles:()=>WU,useCatalogRegistry:()=>sr,useCatalogs:()=>dr,useCommandRegistry:()=>or,useCommands:()=>lr,useDirtyFiles:()=>wqe,useDockviewApi:()=>pJe,useEditorLifecycle:()=>GU,useEvent:()=>oc,useFilePane:()=>XU,useFullPagePanelHref:()=>cit,useHasWorkspaceFilesProvider:()=>aee,useHydrationComplete:()=>sU,useIsFullPagePanel:()=>uit,useKeyboardShortcuts:()=>YU,useOpenPanels:()=>Cqe,usePanelRenderMode:()=>lit,usePluginErrors:()=>aa,useRegistry:()=>ir,useResetLayout:()=>Tqe,useResponsiveSidebarCollapse:()=>JU,useSetSidebar:()=>aU,useSidebarState:()=>iU,useSurfaceResolverRegistry:()=>cr,useTheme:()=>mst,useThemePreference:()=>oU,useViewportBreakpoint:()=>qU,useWorkspaceAttention:()=>a$,useWorkspaceBridge:()=>_st,useWorkspaceChatPanel:()=>yst,useWorkspaceContext:()=>j$,useWorkspaceContextOptional:()=>vst,useWorkspaceLeftPaneActions:()=>oot,useWorkspacePluginClient:()=>va,useWorkspaceRequestId:()=>Vu,useWorkspaceShellCapabilities:()=>RQ,useWorkspaceSourceRegistry:()=>ar,userMeta:()=>rc,workspaceAttentionSessionBadgeForBlocker:()=>i$,workspaceComposerStopAppliesToSession:()=>t$,workspaceComposerStopTargetSessionId:()=>e$,workspaceEvents:()=>nc,workspaceLinkCommand:()=>fc,workspaceLinkHref:()=>pc}),BFt=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/,VFt=/^[A-Za-z0-9][A-Za-z0-9._:-]*$/;function HFt(e){return typeof e==`string`&&e.length>0&&VFt.test(e)}function Q7(e){return typeof e==`string`&&e.length>0&&e!==`.`&&!e.includes(`\0`)&&!e.includes(`\\`)&&!e.startsWith(`/`)&&!e.startsWith(`//`)&&!/^[A-Za-z]:[\\/]/.test(e)&&!e.split(`/`).includes(`..`)}function $7(e,t,n){return{code:e,field:t,message:n}}function e9(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function UFt(e,t,n,r){if(t!==void 0){if(!Array.isArray(t)){e.push($7(`INVALID_FIELD`,n,`${n} must be an array`));return}t.forEach((t,i)=>{let a=`${n}[${i}]`;if(typeof t!=`string`||t.length===0){e.push($7(`INVALID_FIELD`,a,`${a} must be a non-empty string`));return}r&&!Q7(t)&&e.push($7(`INVALID_PATH`,a,`${a} must be a safe relative path`))})}}var WFt=[`outputs`,`panels`,`commands`,`leftTabs`,`surfaceResolvers`,`providers`,`bindings`,`catalogs`];function GFt(e,t){if(t===void 0)return;if(!e9(t)){e.push($7(`INVALID_FIELD`,`boring`,`boring must be an object when provided`));return}for(let n of WFt)t[n]!==void 0&&e.push($7(`INVALID_FIELD`,`boring.${n}`,`boring.${n} is not supported; declare front contributions in boring.front via definePlugin({ ... })`));t.id!==void 0&&(typeof t.id!=`string`||!HFt(t.id))&&e.push($7(`INVALID_ID`,`boring.id`,`boring.id must start with a letter or number and use only letters, numbers, dot, underscore, colon, or dash`));let n=t.front;n!==void 0&&(typeof n!=`string`||!Q7(n))&&e.push($7(`INVALID_PATH`,`boring.front`,`boring.front must be a safe relative path`));let r=t.server;return r!==void 0&&r!==!1&&(typeof r!=`string`||!Q7(r))&&e.push($7(`INVALID_PATH`,`boring.server`,`boring.server must be a safe relative path or false`)),t.label!==void 0&&typeof t.label!=`string`&&e.push($7(`INVALID_FIELD`,`boring.label`,`boring.label must be a string when provided`)),{...typeof t.id==`string`?{id:t.id}:{},...typeof t.front==`string`?{front:t.front}:{},...typeof t.server==`string`||t.server===!1?{server:t.server}:{},...typeof t.label==`string`?{label:t.label}:{}}}var KFt=[`npm:`,`git:`,`github:`,`http:`,`https:`,`ssh:`];function qFt(e){return KFt.some(t=>e.startsWith(t))}function JFt(e){if(e.length===0)return!1;if(qFt(e))return!0;let t=e.startsWith(`file:`)?e.slice(5):e;return t===`.`||t===`./`||Q7(t.startsWith(`./`)?t.slice(2):t)}function YFt(e,t){if(t!==void 0){if(!Array.isArray(t)){e.push($7(`INVALID_FIELD`,`pi.packages`,`pi.packages must be an array when provided`));return}t.forEach((t,n)=>{let r=`pi.packages[${n}]`;if(typeof t==`string`){JFt(t)||e.push($7(`INVALID_PATH`,r,`${r} must be a safe package source`));return}if(!e9(t)){e.push($7(`INVALID_FIELD`,r,`${r} must be a string or package source object`));return}typeof t.source!=`string`||t.source.length===0?e.push($7(`INVALID_FIELD`,`${r}.source`,`${r}.source must be a non-empty string`)):JFt(t.source)||e.push($7(`INVALID_PATH`,`${r}.source`,`${r}.source must be a safe package source`))})}}function XFt(e,t){if(t!==void 0){if(!e9(t)){e.push($7(`INVALID_FIELD`,`pi`,`pi must be an object when provided`));return}return UFt(e,t.extensions,`pi.extensions`,!0),UFt(e,t.skills,`pi.skills`,!0),YFt(e,t.packages),t.systemPrompt!==void 0&&typeof t.systemPrompt!=`string`&&e.push($7(`INVALID_FIELD`,`pi.systemPrompt`,`pi.systemPrompt must be a string when provided`)),t}}function ZFt(e){let t=[];if(!e9(e))return{valid:!1,issues:[$7(`INVALID_FIELD`,`<root>`,`package.json manifest must be an object`)]};e.name!==void 0&&typeof e.name!=`string`&&t.push($7(`INVALID_FIELD`,`name`,`name must be a string when provided`)),e.version!==void 0&&typeof e.version!=`string`?t.push($7(`INVALID_VERSION`,`version`,`version must be a string when provided`)):typeof e.version==`string`&&e.version.length>0&&!BFt.test(e.version)&&t.push($7(`INVALID_VERSION`,`version`,`version must be a valid semver string`));let n=GFt(t,e.boring),r=XFt(t,e.pi);return!n&&!r&&t.push($7(`MISSING_REQUIRED_FIELD`,`boring|pi`,`package.json must include boring and/or pi plugin metadata`)),t.length>0?{valid:!1,issues:t}:{valid:!0,packageJson:{...typeof e.name==`string`?{name:e.name}:{},...typeof e.version==`string`?{version:e.version}:{},...n?{boring:n}:{},...r?{pi:r}:{}}}}var QFt=Symbol.for(`@hachej/boring-workspace:active-ui-bridge`);function $Ft(){return globalThis}function eIt(){return $Ft()[QFt]}var tIt=class extends Error{constructor(){super(`No workspace UI bridge is active. This plugin command must run inside a boring-ui workspace agent (it cannot open panels from a bare Pi CLI).`),this.name=`NoWorkspaceUiBridgeError`}};function nIt(){let e=eIt();if(!e)throw new tIt;return e}async function t9(e){return nIt().postCommand(e)}async function rIt(e){return t9({kind:`openPanel`,params:{id:e.id,component:e.component,params:e.params}})}async function iIt(e,t=`info`){return t9({kind:`showNotification`,params:{msg:e,level:t}})}var aIt=r({NoWorkspaceUiBridgeError:()=>tIt,WORKSPACE_OPEN_PATH_SURFACE_KIND:()=>iB,captureFrontPlugin:()=>Un,createCapturingBoringFrontAPI:()=>Hn,definePlugin:()=>zn,execWorkspaceUi:()=>t9,getWorkspaceUiBridge:()=>eIt,isSafePluginRelativePath:()=>Q7,isValidBoringPluginId:()=>HFt,notify:()=>iIt,openPanel:()=>rIt,useAppLeftOverlayChrome:()=>LQ,useWorkspaceShellCapabilities:()=>RQ,validateBoringPluginManifest:()=>ZFt}),n9=`ask-user`,r9=`ask-user.questions`,i9=`Questions`,a9=`questions`,oIt={PENDING:`questions.pending`},o9={request:`ask-user.v1.request`,answer:`ask-user.v1.answer`,cancel:`ask-user.v1.cancel`,pending:`ask-user.v1.pending`,transcript:`ask-user.v1.transcript`},s9={PENDING_EXISTS:`ASK_USER_PENDING_EXISTS`,QUESTION_NOT_FOUND:`ASK_USER_QUESTION_NOT_FOUND`,QUESTION_ABANDONED:`ASK_USER_QUESTION_ABANDONED`,QUESTION_NOT_READY:`ASK_USER_QUESTION_NOT_READY`,SCHEMA_INVALID:`ASK_USER_SCHEMA_INVALID`,ANSWER_INVALID:`ASK_USER_ANSWER_INVALID`,SESSION_MISMATCH:`ASK_USER_SESSION_MISMATCH`,UI_UNAVAILABLE:`ASK_USER_UI_UNAVAILABLE`,ALREADY_ANSWERED:`ASK_USER_ALREADY_ANSWERED`,ALREADY_CANCELLED:`ASK_USER_ALREADY_CANCELLED`,UNAUTHORIZED:`ASK_USER_UNAUTHORIZED`,UI_ACK_TIMEOUT:`ASK_USER_UI_ACK_TIMEOUT`,RATE_LIMITED:`ASK_USER_RATE_LIMITED`,RUNTIME_UNAVAILABLE:`ASK_USER_RUNTIME_UNAVAILABLE`};Object.values(s9);var sIt=(0,I.createContext)(null),cIt=`space-y-1.5`,c9=`mt-0.5`;function l9(){let e=(0,I.useContext)(sIt);if(!e)throw Error(`useQuestionForm must be used inside QuestionFormProvider`);return e}function lIt({schema:e,status:t=`ready`,disabled:n=!1,submitting:r,initialValues:i,rendererRegistry:a={},onSubmit:o,onCancel:s,children:c}){let[l,u]=(0,I.useState)(()=>vIt(e,i)),[d,f]=(0,I.useState)({}),[p,m]=(0,I.useState)(!1),[h,g]=(0,I.useState)(!1),_={},v=(0,I.useRef)(null);(0,I.useEffect)(()=>{u(t=>{let n=vIt(e,i);for(let r of e?.fields??[])d[r.name]&&t[r.name]!==void 0&&(n[r.name]=t[r.name]);return n})},[e,i,d]);let y=(0,I.useMemo)(()=>{if(!e)return{};let t=d9(e,l).errors;return h?t:Object.fromEntries(Object.entries(t).filter(([e])=>d[e]))},[e,l,h,d]),b=(0,I.useCallback)((e,t)=>{f(t=>({...t,[e]:!0})),u(n=>({...n,[e]:t}))},[]),x=(0,I.useCallback)(e=>f(t=>({...t,[e]:!0})),[]),S=(0,I.useCallback)(async()=>{if(!e||t!==`ready`||n)return;let r=d9(e,l);if(!r.valid){g(!0);let e=Object.keys(r.errors)[0];v.current?.querySelector(`[name="${yIt(e)}"]`)?.focus();return}m(!0);try{await o?.(l)}finally{m(!1)}},[e,t,n,l,o]),C=(0,I.useCallback)(()=>{Object.keys(d).length>0&&!window.confirm(`Discard your answer?`)||s?.()},[s,d]),w={schema:e,status:t,values:l,touched:d,errors:y,submitting:r??p,disabled:n,dirtyHints:_,setValue:b,touch:x,submit:S,cancel:C,rendererRegistry:a,formRef:v};return(0,L.jsx)(sIt.Provider,{value:w,children:c})}function uIt({children:e,"aria-label":t=`Question form`,className:n}){let{submit:r,cancel:i,status:a,formRef:o}=l9();return(0,L.jsxs)(`form`,{ref:o,"data-question-form":!0,"aria-label":t,className:n,onSubmit:e=>{e.preventDefault(),r()},onKeyDown:e=>{e.key===`Enter`&&dIt(e)&&(e.preventDefault(),r()),e.key===`Escape`&&(e.preventDefault(),i())},children:[(0,L.jsx)(`div`,{"aria-live":`polite`,className:`sr-only`,children:a===`ready`?`Question ready`:`Question ${a}`}),e]})}function dIt(e){if(e.metaKey||e.ctrlKey)return!0;if(e.shiftKey)return!1;let t=e.target;if(!t)return!0;let n=t.tagName.toLowerCase();return!(n===`textarea`||n===`button`||n===`a`||t.isContentEditable)}function fIt(){let{schema:e}=l9();return e?(0,L.jsx)(L.Fragment,{children:e.fields.map(e=>(0,L.jsx)(pIt,{field:e},e.name))}):null}function pIt({field:e}){let{values:t,errors:n,disabled:r,submitting:i,setValue:a,touch:o,rendererRegistry:s,dirtyHints:c}=l9(),l=n[e.name],u=`${e.name}-help`,d=`${e.name}-error`,f=`${e.name}-hint`,p=[e.helpText?u:void 0,l?d:void 0,c[e.name]?f:void 0].filter(Boolean).join(` `),m=s[e.type]??gIt[e.type]??s.unsupported??_It;return(0,L.jsxs)(ce,{"data-field":e.name,className:cIt,children:[m({field:e,value:t[e.name],error:l,disabled:r||i,describedBy:p,onChange:t=>a(e.name,t),onBlur:()=>o(e.name)}),e.helpText?(0,L.jsx)(x,{id:u,children:e.helpText}):null,c[e.name]?(0,L.jsx)(x,{id:f,children:c[e.name]}):null,l?(0,L.jsx)(se,{id:d,role:`alert`,children:l}):null]})}function mIt(e){let{status:t,submitting:n,disabled:r}=l9();return(0,L.jsx)(`button`,{...e,type:`submit`,disabled:r||n||t!==`ready`,children:e.children??`Submit`})}function hIt(e){let{cancel:t,disabled:n,submitting:r}=l9();return(0,L.jsx)(`button`,{...e,type:`button`,disabled:n||r,onClick:n=>{e.onClick?.(n),n.defaultPrevented||t()},children:e.children??`Cancel`})}var gIt={text:({field:e,value:t,disabled:n,describedBy:r,error:i,onChange:a,onBlur:o})=>e.type===`text`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ue,{htmlFor:e.name,children:u9(e)}),(0,L.jsx)(T,{id:e.name,name:e.name,value:typeof t==`string`?t:``,placeholder:e.placeholder,minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,disabled:n,"aria-describedby":r||void 0,"aria-invalid":!!i,"aria-errormessage":i?`${e.name}-error`:void 0,onChange:e=>a(e.target.value),onBlur:o})]}),textarea:({field:e,value:t,disabled:n,describedBy:r,error:i,onChange:a,onBlur:o})=>e.type===`textarea`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ue,{htmlFor:e.name,children:u9(e)}),(0,L.jsx)(_,{id:e.name,name:e.name,value:typeof t==`string`?t:``,placeholder:e.placeholder,minLength:e.minLength,maxLength:e.maxLength,disabled:n,"aria-describedby":r||void 0,"aria-invalid":!!i,"aria-errormessage":i?`${e.name}-error`:void 0,onChange:e=>a(e.target.value),onBlur:o})]}),select:({field:e,value:t,disabled:n,describedBy:r,error:i,onChange:a,onBlur:o})=>(e.type===`select`||e.type===`radio`)&&(0,L.jsxs)(Ge,{"aria-describedby":e.type===`radio`&&r||void 0,"aria-invalid":e.type===`radio`?!!i:void 0,"aria-errormessage":e.type===`radio`&&i?`${e.name}-error`:void 0,children:[(0,L.jsx)(ze,{children:u9(e)}),e.options.map(r=>e.type===`select`?null:(0,L.jsxs)(ke,{children:[(0,L.jsx)(xe,{className:c9,name:e.name,checked:t===r.value,disabled:n,onChange:()=>a(r.value),onBlur:o}),(0,L.jsxs)(De,{children:[(0,L.jsx)(nt,{children:r.label}),r.description?(0,L.jsx)(me,{children:r.description}):null]})]},r.value)),e.type===`select`?(0,L.jsxs)(tt,{name:e.name,value:typeof t==`string`?t:``,disabled:n,onValueChange:e=>a(e),children:[(0,L.jsx)(Ke,{className:`w-full`,"aria-describedby":r||void 0,"aria-invalid":!!i,"aria-errormessage":i?`${e.name}-error`:void 0,onBlur:o,children:(0,L.jsx)(Be,{placeholder:`Select…`})}),(0,L.jsx)(Ce,{children:e.options.map(e=>(0,L.jsx)(Ee,{value:e.value,children:e.label},e.value))})]}):null]}),radio:e=>gIt.select?.(e),multiselect:({field:e,value:t,disabled:n,describedBy:r,error:i,onChange:a,onBlur:o})=>e.type===`multiselect`&&(0,L.jsxs)(Ge,{"aria-describedby":r||void 0,"aria-invalid":!!i,"aria-errormessage":i?`${e.name}-error`:void 0,children:[(0,L.jsx)(ze,{children:u9(e)}),e.options.map(r=>{let i=Array.isArray(t)?t:[];return(0,L.jsxs)(ke,{children:[(0,L.jsx)(Te,{className:c9,name:e.name,checked:i.includes(r.value),disabled:n,onCheckedChange:e=>a(e?[...i,r.value]:i.filter(e=>e!==r.value)),onBlur:o}),(0,L.jsxs)(De,{children:[(0,L.jsx)(nt,{children:r.label}),r.description?(0,L.jsx)(me,{children:r.description}):null]})]},r.value)})]}),checkbox:({field:e,value:t,disabled:n,describedBy:r,error:i,onChange:a,onBlur:o})=>e.type===`checkbox`&&(0,L.jsxs)(ke,{children:[(0,L.jsx)(Te,{className:c9,name:e.name,checked:t===!0,disabled:n,"aria-describedby":r||void 0,"aria-invalid":!!i,"aria-errormessage":i?`${e.name}-error`:void 0,onCheckedChange:e=>a(e===!0),onBlur:o}),(0,L.jsx)(nt,{children:e.label})]}),number:({field:e,value:t,disabled:n,describedBy:r,error:i,onChange:a,onBlur:o})=>e.type===`number`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ue,{htmlFor:e.name,children:u9(e)}),(0,L.jsx)(T,{id:e.name,type:`number`,name:e.name,value:typeof t==`number`?String(t):``,min:e.min,max:e.max,step:e.integer?1:e.step,disabled:n,"aria-describedby":r||void 0,"aria-invalid":!!i,"aria-errormessage":i?`${e.name}-error`:void 0,onChange:e=>a(e.target.value===``?null:Number(e.target.value)),onBlur:o})]}),unsupported:_It};function _It({field:e}){return(0,L.jsxs)(x,{role:`note`,children:[`Unsupported question field: `,e.type]})}function u9(e){return(0,L.jsxs)(L.Fragment,{children:[e.label,`required`in e&&e.required?(0,L.jsx)(`span`,{className:`text-destructive`,"aria-hidden":`true`,children:` *`}):null]})}function vIt(e,t){let n={...t??{}};for(let t of e?.fields??[])n[t.name]===void 0&&`defaultValue`in t&&(n[t.name]=t.defaultValue);return n}function d9(e,t){let n={};for(let r of e.fields){let e=t[r.name],i=e==null||e===``||Array.isArray(e)&&e.length===0;if(`required`in r&&r.required&&i){n[r.name]=`This field is required.`;continue}i||(r.type===`text`||r.type===`textarea`?typeof e==`string`?r.minLength!==void 0&&e.length<r.minLength?n[r.name]=`Must be at least ${r.minLength} characters.`:r.maxLength!==void 0&&e.length>r.maxLength?n[r.name]=`Must be at most ${r.maxLength} characters.`:r.type===`text`&&r.pattern&&!new RegExp(r.pattern).test(e)&&(n[r.name]=`Invalid format.`):n[r.name]=`Enter text.`:(r.type===`select`||r.type===`radio`)&&(typeof e!=`string`||!r.options.some(t=>t.value===e))?n[r.name]=`Choose a valid option.`:r.type===`multiselect`?Array.isArray(e)?r.minSelections!==void 0&&e.length<r.minSelections?n[r.name]=`Choose at least ${r.minSelections}.`:r.maxSelections!==void 0&&e.length>r.maxSelections?n[r.name]=`Choose at most ${r.maxSelections}.`:e.some(e=>!r.options.some(t=>t.value===e))&&(n[r.name]=`Choose valid options.`):n[r.name]=`Choose valid options.`:r.type===`checkbox`&&typeof e!=`boolean`?n[r.name]=`Must be checked or unchecked.`:r.type===`number`&&(typeof e!=`number`||!Number.isFinite(e)?n[r.name]=`Enter a number.`:r.integer&&!Number.isInteger(e)?n[r.name]=`Enter a whole number.`:r.min!==void 0&&e<r.min?n[r.name]=`Must be at least ${r.min}.`:r.max!==void 0&&e>r.max&&(n[r.name]=`Must be at most ${r.max}.`)))}return{valid:Object.keys(n).length===0,errors:n}}function yIt(e){return globalThis.CSS?.escape?.(e)??e.replace(/[^A-Za-z0-9_-]/g,`\\$&`)}var f9=class extends Error{code;statusCode;constructor(e,t,n=0){super(t),this.code=e,this.statusCode=n}};function bIt(e){let t=e?.[oIt.PENDING];if(!t||typeof t!=`object`)return[];let n=new Map,r=t,i=p9(r.hint)??p9(r.question);if(i&&n.set(i.sessionId,i),r.hintsBySession&&typeof r.hintsBySession==`object`&&!Array.isArray(r.hintsBySession))for(let[e,t]of Object.entries(r.hintsBySession)){let r=p9(t);r&&r.sessionId===e&&n.set(e,r)}return[...n.values()]}function p9(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.questionId!=`string`||typeof t.sessionId!=`string`)return null;let n=wIt(t.status);return{questionId:t.questionId,sessionId:t.sessionId,...n===`abandoned`&&t.status===void 0?{}:{status:n}}}function m9(e={}){async function t(t,n,r,i){let a=await fetch(`${e.apiBaseUrl??``}/api/v1/workspace-bridge/call`,{method:`POST`,headers:{"Content-Type":`application/json`,...e.headers??{},...r?{"x-boring-session-id":r}:{}},body:JSON.stringify({op:t,input:n,...i?{idempotencyKey:i}:{}})}),o=await a.json().catch(()=>({}));if(!a.ok){let e=`error`in o?o.error:void 0;throw new f9(e?.code??s9.UI_UNAVAILABLE,e?.message??`Question bridge call failed`,a.status)}if(!o.ok)throw new f9(o.error?.code??s9.UI_UNAVAILABLE,o.error?.message??`Question bridge call failed`,a.status);return o.output}return{async pending(e){return xIt((await t(o9.pending,{sessionId:e},e)).pending)},async cancel(e){return TIt(e),await t(o9.cancel,{questionId:e.questionId,sessionId:e.sessionId,answerToken:e.answerToken},e.sessionId,await SIt(o9.cancel,{questionId:e.questionId,sessionId:e.sessionId,answerToken:e.answerToken}))},async submit(e,n){if(TIt(e),!e.schema)throw new f9(s9.QUESTION_NOT_READY,`Question is not ready`);let r=d9(e.schema,n);if(!r.valid)throw new f9(s9.ANSWER_INVALID,EIt(r));return await t(o9.answer,{questionId:e.questionId,sessionId:e.sessionId,answerToken:e.answerToken,values:n},e.sessionId,await SIt(o9.answer,{questionId:e.questionId,sessionId:e.sessionId,answerToken:e.answerToken,values:n}))}}}function xIt(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.questionId!=`string`||typeof t.sessionId!=`string`)return null;let n=DIt(t.schema)?t.schema:void 0;return{questionId:t.questionId,sessionId:t.sessionId,ownerPrincipalId:typeof t.ownerPrincipalId==`string`?t.ownerPrincipalId:`anonymous`,status:wIt(t.status),title:typeof t.title==`string`?t.title:void 0,context:typeof t.context==`string`?t.context:void 0,schema:n,answerToken:typeof t.answerToken==`string`?t.answerToken:``,createdAt:typeof t.createdAt==`string`?t.createdAt:new Date(0).toISOString(),updatedAt:typeof t.updatedAt==`string`?t.updatedAt:new Date(0).toISOString()}}async function SIt(e,t){let n=`${e}:${h9(t)}`,r=globalThis.crypto?.subtle;if(r&&typeof r.digest==`function`){let e=new TextEncoder().encode(n),t=await r.digest(`SHA-256`,e);return`ask-user-idem:${Array.from(new Uint8Array(t),e=>e.toString(16).padStart(2,`0`)).join(``)}`}return`ask-user-idem:${CIt(n)}`}function CIt(e){let t=3735928559^e.length,n=1103547991^e.length,r=3235826430^e.length,i=2654435769^e.length;for(let a=0;a<e.length;a+=1){let o=e.charCodeAt(a);t=Math.imul(t^o,2654435761),n=Math.imul(n^o,1597334677),r=Math.imul(r^o,2246822507),i=Math.imul(i^o,3266489909)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(i^i>>>13,3266489909),i=Math.imul(i^i>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),[t,n,r,i].map(e=>(e>>>0).toString(16).padStart(8,`0`)).join(``)}function h9(e){return typeof e!=`object`||!e?JSON.stringify(e):Array.isArray(e)?`[${e.map(h9).join(`,`)}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${h9(e[t])}`).join(`,`)}}`}function wIt(e){return e===`pending`||e===`ready`?`ready`:e===`answered`||e===`cancelled`||e===`abandoned`?e:`abandoned`}function TIt(e){if(!e.answerToken)throw new f9(s9.QUESTION_NOT_READY,`Question answer token is missing`)}function EIt(e){return Object.values(e.errors)[0]??`Invalid answer`}function DIt(e){return!!e&&typeof e==`object`&&e.wireVersion===1&&Array.isArray(e.fields)}function OIt(){let e=new Set,t=new Map,n=new Map,r=()=>{for(let t of[...e])t()};return{getPending(e){return e?t.get(e)??null:null},setPending(e,i){e?(t.set(e.sessionId,e),n.set(e.sessionId,{questionId:e.questionId,sessionId:e.sessionId,status:e.status})):i?(t.delete(i),n.delete(i)):(t.clear(),n.clear()),r()},getPendingHints(){return[...n.values()]},getHydratedPendingKeys(){return[...t.values()].map(e=>`${e.sessionId}:${e.questionId}:${e.status}`)},setPendingHints(e){n.clear();let i=new Map;for(let t of e)n.set(t.sessionId,t),i.set(t.sessionId,t);for(let[e,n]of[...t.entries()]){let r=i.get(e);(!r||r.questionId!==n.questionId||r.status&&r.status!==n.status)&&t.delete(e)}r()},subscribe(t){return e.add(t),()=>e.delete(t)}}}var kIt=OIt(),AIt=(0,I.createContext)(null);function jIt(){let e=(0,I.useContext)(AIt);if(!e)throw Error(`askUserPlugin QuestionsPane must be rendered under AskUserProvider`);return e}function MIt(e){let t=e.getPendingHints().map(e=>`${e.sessionId}:${e.questionId}:${e.status??`ready`}`).sort(),n=e.getHydratedPendingKeys().sort();return`${t.length?t.join(`|`):`none`}#hydrated=${n.join(`|`)}`}function g9(e,t){return e.openSessionIds?e.openSessionIds.includes(t):e.activeSessionId===t}function NIt(e,t){let{addBlocker:n,removeBlocker:r}=a$();(0,I.useEffect)(()=>{let t=[];for(let r of e.getPendingHints()){if(r.status&&r.status!==`ready`)continue;let i=`${n9}:${r.sessionId}:${r.questionId}`;t.push(i);let a=e.getPending(r.sessionId),o=e.activeSessionId===r.sessionId&&g9(e,r.sessionId),s=a?[{id:`open`,label:`Open Questions`},{id:`cancel`,label:`Cancel question`}]:o?[{id:`open`,label:`Open Questions`}]:void 0;n({id:i,reason:`ask-user.question`,surfaceKind:a9,target:r.questionId,label:a?.title??`Answer the question in Questions to continue`,sessionId:r.sessionId,sessionBadge:{kind:`question`,label:`question`,tone:`attention`,priority:10},pruneWhenSessionMissing:!0,focus:{closeWorkbenchLeftPane:!0},inbox:{kind:`question`,sourceLabel:`question`,createdAt:a?.createdAt,updatedAt:a?.updatedAt??a?.createdAt,priority:10},actions:s})}return()=>{for(let e of t)r(e)}},[n,r,e,t])}function PIt(e,t,n){let r=(0,I.useRef)(new Set);(0,I.useEffect)(()=>{for(let t of e.getPendingHints())g9(e,t.sessionId)||r.current.delete(`${t.sessionId}:${t.questionId}`);if(!t||!g9(e,t))return;let n=e.getPendingHints().find(e=>e.sessionId===t);if(!n||n.status&&n.status!==`ready`)return;let i=e.getPending(t);if(!i||i.questionId!==n.questionId||i.status!==`ready`)return;let a=`${n.sessionId}:${n.questionId}`;r.current.has(a)||(r.current.add(a),dc({kind:`openSurface`,params:{kind:a9,target:n.questionId,meta:{sessionId:n.sessionId,openOnlyWhenSessionOpen:!0}}}))},[t,e,n])}function FIt(e){(0,I.useEffect)(()=>{let t=t=>{let n=t.detail;if(!n||n.actionId!==`cancel`||n.blocker.reason!==`ask-user.question`)return;let r=n.blocker.sessionId??n.sessionId??e.activeSessionId,i=e.getPending(r);!i||n.blocker.target&&i.questionId!==n.blocker.target||(e.setPending(null,i.sessionId),m9({apiBaseUrl:e.apiBaseUrl,headers:e.authHeaders}).cancel(i).catch(()=>void 0))};return window.addEventListener(n$,t),()=>window.removeEventListener(n$,t)},[e])}function IIt(e){(0,I.useEffect)(()=>{let t=t=>{let n=t.detail,r=e$(n,e.activeSessionId),i=e.getPending(r);!i||!t$(n,i.sessionId,{fallbackSessionId:e.activeSessionId})||(e.setPending(null,i.sessionId),m9({apiBaseUrl:e.apiBaseUrl,headers:e.authHeaders}).cancel(i).catch(()=>void 0))};return window.addEventListener(XQ,t),()=>window.removeEventListener(XQ,t)},[e])}function LIt(e,t){let{activeSessionId:n,apiBaseUrl:r,authHeaders:i}=t;(0,I.useEffect)(()=>{let t=!1;async function a(){let a=[];try{let n=await(await fetch(`${r}/api/v1/ui/state`,{headers:i})).json().catch(()=>null);a=bIt(n),!t&&RIt(n)&&e.setPendingHints(a)}catch{}let o=new Set;n&&o.add(n);for(let e of a)o.add(e.sessionId);await Promise.all([...o].map(async n=>{try{await e.refreshPending(n)}catch{t||e.setPending(null,n)}}))}let o=()=>{document.visibilityState===`visible`&&a()},s=()=>{a()},c=e=>{e.detail?.kind===`questions`&&a()},l=null,u=lc.on(nc.agentData,()=>{l||=setTimeout(()=>{l=null,a()},1200)}),d=lc.on(nc.uiCommand,s);return a(),window.addEventListener(`focus`,a),document.addEventListener(`visibilitychange`,o),window.addEventListener(uc,s),window.addEventListener(zs,c),()=>{t=!0,l&&clearTimeout(l),u(),d(),window.removeEventListener(`focus`,a),document.removeEventListener(`visibilitychange`,o),window.removeEventListener(uc,s),window.removeEventListener(zs,c)}},[n,r,i,e])}function RIt(e){return!!e&&Object.prototype.hasOwnProperty.call(e,oIt.PENDING)}var zIt=`1970-01-01T00:00:00.000Z`;function _9(e){if(e==null)return null;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()}function BIt(e){return _9(e.inbox?.updatedAt)??_9(e.inbox?.createdAt)??zIt}function VIt(e){if(e.inbox?.kind)return e.inbox.kind;let t=i$(e);return t?.kind===`question`||t?.kind===`review`||t?.kind===`approval`||t?.kind===`notice`?t.kind:`notice`}function HIt(e){return e.label||e.reason||`Workspace item`}function UIt(e){return e.inbox?.sourceLabel??i$(e)?.label??`workspace`}function WIt(e){return!!e.inbox}function GIt(e){let t=BIt(e);return{id:e.id,kind:VIt(e),status:`open`,title:HIt(e),description:e.reason,source:{type:`plugin`,pluginId:e.reason,label:UIt(e)},sessionId:e.sessionId??null,chatAvailable:e.pruneWhenSessionMissing===!0&&!!e.sessionId,targetLabel:e.target??``,artifact:e.surfaceKind?{type:`surface`,surfaceKind:e.surfaceKind,target:e.target,params:e.sessionId?{sessionId:e.sessionId}:void 0}:null,createdAt:_9(e.inbox?.createdAt)??t,updatedAt:t,priority:e.inbox?.priority??i$(e)?.priority??0,actions:e.actions?.map(e=>({id:e.id,label:e.label}))??[]}}function KIt({filter:e,counts:t,onFilterChange:n}){return(0,L.jsx)(`div`,{className:`flex shrink-0 gap-1 border-b border-border/60 bg-[color:oklch(from_var(--background)_calc(l-0.012)_c_h)] px-4 py-2`,children:[[`all`,`All`,t.all],[`questions`,`Questions`,t.questions],[`reviews`,`Reviews`,t.reviews]].map(([t,r,i])=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>n(t),className:DU(`rounded-full px-2.5 py-1 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,e===t?`bg-[color:oklch(from_var(--accent)_l_c_h/0.14)] text-[color:var(--accent)]`:`bg-transparent text-muted-foreground hover:bg-foreground/[0.06] hover:text-foreground`),children:[r,` `,(0,L.jsx)(`span`,{className:`ml-1 opacity-70`,children:i})]},t))})}function v9(e){let t=new Date(e.updatedAt||e.createdAt);return Number.isNaN(t.getTime())?new Date(0):t}function qIt(e,t=Date.now()){let n=v9(e),r=t-n.getTime();if(r<6e4)return`now`;let i=Math.floor(r/6e4);if(i<60)return`${i}m`;let a=Math.floor(i/60);if(a<24)return`${a}h`;let o=Math.floor(a/24);return o<7?`${o}d`:n.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function JIt(e){return e.source.label||e.source.type}function y9(e,t){return t===`all`?[...e]:e.filter(e=>t===`questions`?e.kind===`question`:e.kind===`review`)}function YIt(e){return[...e].sort((e,t)=>{let n=v9(t).getTime()-v9(e).getTime();if(n!==0)return n;let r=t.priority-e.priority;return r===0?e.title.localeCompare(t.title):r})}function XIt(e,t){return e.map(e=>({...e,pinned:t.has(e.id)}))}function ZIt(e){switch(e){case`review`:return`bg-amber-500/12 text-amber-700 dark:text-amber-300`;case`approval`:return`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`;case`notice`:return`bg-foreground/[0.07] text-muted-foreground`;default:return`bg-[color:var(--accent)]/12 text-[color:var(--accent)]`}}function QIt({item:e,onTogglePinned:t,onOpenArtifact:n,onOpenChat:r}){let i=[e.sessionId?`Session ${e.sessionId}`:null,e.targetLabel||null].filter(Boolean).join(` · `);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`div`,{role:`button`,tabIndex:0,className:`group flex h-11 w-full items-center gap-2 overflow-hidden px-4 text-left text-[12px] transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,onClick:()=>n(e),onKeyDown:t=>{t.currentTarget===t.target&&(t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),n(e)))},children:[(0,L.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-[color:var(--accent)]`}),(0,L.jsx)(`span`,{className:`max-w-28 shrink-0 truncate font-semibold text-foreground`,children:JIt(e)}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-hidden whitespace-nowrap text-foreground`,children:[(0,L.jsx)(`span`,{className:`truncate font-medium`,children:e.title}),(0,L.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`—`}),(0,L.jsx)(`span`,{className:`truncate text-muted-foreground`,children:i||e.description})]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:DU(`rounded-full px-2 py-0.5 text-[10px] font-medium`,ZIt(e.kind)),children:e.kind}),(0,L.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,title:v9(e).toLocaleString(),children:qIt(e)})]}),e.sessionId&&e.chatAvailable?(0,L.jsx)(`button`,{type:`button`,"aria-label":`Open chat session ${e.sessionId}`,title:`Open chat session`,className:`grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:bg-foreground/[0.06] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 group-hover:opacity-100 group-focus-visible:opacity-100`,onClick:t=>{t.stopPropagation(),r(e)},children:(0,L.jsx)(gi,{className:`size-3.5`,strokeWidth:1.75})}):null,(0,L.jsx)(`button`,{type:`button`,"aria-label":`${e.pinned?`Unpin`:`Pin`} ${e.title}`,title:e.pinned?`Unpin`:`Pin`,className:DU(`grid size-6 shrink-0 place-items-center rounded-md transition-colors hover:bg-foreground/[0.06] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,e.pinned?`text-[color:var(--accent)] opacity-100`:`text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100`),onClick:n=>{n.stopPropagation(),t(e.id)},children:(0,L.jsx)(Vi,{className:DU(`size-3.5`,e.pinned&&`fill-current`),strokeWidth:1.75})})]})})}function $It({title:e,items:t,onTogglePinned:n,onOpenArtifact:r,onOpenChat:i}){return t.length===0?null:(0,L.jsxs)(`section`,{className:`py-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70`,children:[e===`Pinned`?(0,L.jsx)(Di,{className:`size-3`,strokeWidth:1.75}):null,e]}),(0,L.jsx)(`ul`,{role:`list`,className:`divide-y divide-border/60 bg-card/80`,children:t.map(e=>(0,L.jsx)(QIt,{item:e,onTogglePinned:n,onOpenArtifact:r,onOpenChat:i},e.id))})]})}function eLt(){let e=RQ();return(0,I.useMemo)(()=>({openInboxArtifact:t=>e.openArtifact(t.artifact,{sessionId:null,title:t.title,instanceId:t.id}),openDetachedChat:e.openDetachedChat}),[e])}function tLt(e){if(!e)return new Set;try{let t=globalThis.localStorage?.getItem(e),n=t?JSON.parse(t):null;return new Set(Array.isArray(n?.ids)?n.ids.filter(e=>typeof e==`string`&&e.length>0):[])}catch{return new Set}}function nLt(e,t){if(e)try{let n=Array.from(t);n.length===0?globalThis.localStorage?.removeItem(e):globalThis.localStorage?.setItem(e,JSON.stringify({ids:n}))}catch{}}function rLt({onClose:e,pinStorageKey:t}){let{headerInsetStart:n,headerInsetEnd:r}=LQ(),{blockers:i}=a$(),a=eLt(),[o,s]=(0,I.useState)(`all`),[c,l]=(0,I.useState)(null),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(()=>tLt(t));(0,I.useEffect)(()=>{p(tLt(t))},[t]);let m=(0,I.useMemo)(()=>YIt(i.filter(WIt).map(GIt)),[i]),h=(0,I.useMemo)(()=>y9(m,o),[o,m]),g=(0,I.useMemo)(()=>XIt(h,f),[h,f]),_=(0,I.useMemo)(()=>g.filter(e=>e.pinned),[g]),v=(0,I.useMemo)(()=>g.filter(e=>!e.pinned),[g]),y=(0,I.useMemo)(()=>g.find(e=>e.id===u)??null,[g,u]),x=(0,I.useMemo)(()=>y?i.find(e=>e.id===y.id):void 0,[i,y]),S=(0,I.useMemo)(()=>({all:m.length,questions:y9(m,`questions`).length,reviews:y9(m,`reviews`).length}),[m]),C=(0,I.useCallback)(e=>{p(n=>{let r=new Set(n);return r.has(e)?r.delete(e):r.add(e),nLt(t,r),r})},[t]),w=(0,I.useCallback)(e=>{l(e.success?null:e.message)},[]),T=(0,I.useCallback)(e=>{if(!e.artifact){d(e.id),l(null);return}let t=a.openInboxArtifact(e);w(t),d(t.success?null:e.id)},[w,a]),E=(0,I.useCallback)(e=>{e.sessionId&&w(a.openDetachedChat(e.sessionId,{title:e.title}))},[w,a]),D=(0,I.useCallback)(e=>{!y||!x||(r$({blockerId:x.id,actionId:e,blocker:x,sessionId:y.sessionId??void 0}),e===`open`&&(y.artifact?T(y):l(`This inbox item has no artifact target.`)))},[T,x,y]);return(0,L.jsxs)(`div`,{"data-boring-workspace-part":`inbox-overlay`,className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,L.jsxs)(`header`,{className:DU(`flex h-12 shrink-0 items-center justify-between border-b border-border/60`,n?`pl-12`:`pl-4`,r?`pr-16`:`pr-4`),children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`grid size-7 place-items-center rounded-lg bg-[color:oklch(from_var(--accent)_l_c_h/0.14)] text-[color:var(--accent)]`,children:(0,L.jsx)(ri,{className:`h-4 w-4`,strokeWidth:1.75,"aria-hidden":`true`})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h2`,{className:`truncate text-sm font-semibold tracking-tight text-foreground`,children:`Inbox`}),(0,L.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:`Questions, reviews, and owner decisions`})]})]}),(0,L.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:e,"aria-label":`Close inbox`,title:`Close`,className:`text-muted-foreground hover:text-foreground`,children:(0,L.jsx)(ea,{className:`size-3`,strokeWidth:1.75})})})]}),(0,L.jsx)(KIt,{filter:o,counts:S,onFilterChange:s}),c?(0,L.jsx)(`div`,{className:`border-b border-border/60 bg-destructive/10 px-4 py-2 text-xs text-destructive`,children:c}):null,y?(0,L.jsxs)(`div`,{className:`border-b border-border/60 bg-background px-4 py-3 text-xs`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`truncate font-medium text-foreground`,children:y.title}),(0,L.jsx)(`div`,{className:`mt-1 line-clamp-2 text-muted-foreground`,children:y.description})]}),(0,L.jsx)(`button`,{type:`button`,className:`shrink-0 text-muted-foreground hover:text-foreground`,onClick:()=>d(null),children:`Close`})]}),y.actions.length>0&&x?(0,L.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:y.actions.map(e=>(0,L.jsx)(`button`,{type:`button`,className:`rounded-md border border-border/80 bg-background px-2 py-1 text-[11px] font-medium hover:bg-muted/60`,onClick:()=>D(e.id),children:e.label},e.id))}):null]}):null,(0,L.jsx)(`div`,{className:`boring-scrollbar-discreet min-h-0 flex-1 overflow-y-auto bg-[color:oklch(from_var(--background)_calc(l-0.012)_c_h)] py-2`,"aria-live":`polite`,children:g.length===0?(0,L.jsx)(`div`,{className:`flex h-full min-h-[180px] items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(fi,{className:`mx-auto mb-3 size-8 text-muted-foreground/70`,strokeWidth:1.75}),(0,L.jsx)(`div`,{className:`font-medium text-foreground/80`,children:`Inbox zero`}),(0,L.jsx)(`p`,{className:`mt-1 max-w-xs`,children:`When plugins or external harnesses ask for a decision, it appears here.`})]})}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)($It,{title:`Pinned`,items:_,onTogglePinned:C,onOpenArtifact:T,onOpenChat:E}),(0,L.jsx)($It,{title:`Inbox`,items:v,onTogglePinned:C,onOpenArtifact:T,onOpenChat:E})]})})]})}function iLt({apiBaseUrl:e,authHeaders:t,activeSessionId:n,openSessionIds:r,children:i}){let a=(0,I.useMemo)(()=>({...kIt,apiBaseUrl:e,authHeaders:t,activeSessionId:n,openSessionIds:r,async refreshPending(n){let r=await m9({apiBaseUrl:e,headers:t}).pending(n);return kIt.setPending(r,n),r}}),[n,e,t,r]),o=(0,I.useSyncExternalStore)(a.subscribe,()=>MIt(a),()=>`none`);return NIt(a,o),PIt(a,n,o),FIt(a),IIt(a),LIt(a,{activeSessionId:n,apiBaseUrl:e,authHeaders:t}),(0,L.jsx)(AIt.Provider,{value:a,children:i})}function aLt(e,t){let n=e.activeSessionId??null;return n&&b9(e,n)&&x9(e,n)?n:t?.sessionId&&x9(e,t.sessionId)?t.sessionId:e.getPendingHints().find(e=>!e.status||e.status===`ready`)?.sessionId||(t?.sessionId&&b9(e,t.sessionId)?t.sessionId:n&&b9(e,n)?n:null)}function b9(e,t){return!e.openSessionIds||g9(e,t)}function oLt(e,t){return!!e.openSessionIds&&!g9(e,t)}function x9(e,t){return e.getPending(t)?.status===`ready`||e.getPendingHints().some(e=>e.sessionId===t&&(!e.status||e.status===`ready`))}function sLt(){let{blockers:e}=a$(),t=e.filter(WIt).length;if(t===0)return null;let n=t>99?`99+`:String(t);return(0,L.jsx)(`span`,{"data-boring-workspace-part":`app-left-inbox-count`,"aria-label":`${t} inbox item${t===1?``:`s`}`,className:`inline-flex min-w-5 items-center justify-center rounded-full bg-[color:var(--accent)] px-1.5 py-0.5 text-[10px] font-semibold leading-none text-white shadow-sm`,children:n})}function cLt({onClose:e}){let{workspaceId:t}=j$();return(0,L.jsx)(rLt,{onClose:e,pinStorageKey:`boring-workspace:inbox-pins:${t??`workspace`}`})}function lLt({api:e,params:t,className:n}){let r=jIt();(0,I.useSyncExternalStore)(r.subscribe,()=>MIt(r),()=>`none`);let i=aLt(r,t),a=(0,I.useSyncExternalStore)(r.subscribe,()=>r.getPending(i),()=>r.getPending(i)),[o,s]=(0,I.useState)(null),c=(0,I.useRef)(null),[l,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(!1),m=a?.questionId===o?null:a,h=(0,I.useMemo)(()=>m9({apiBaseUrl:r.apiBaseUrl,headers:r.authHeaders}),[r.apiBaseUrl,r.authHeaders]);return(0,I.useEffect)(()=>{if(!t?.sessionId||!oLt(r,t.sessionId)||x9(r,t.sessionId)||r.getPendingHints().length===0)return;let n=r.activeSessionId??null;n&&b9(r,n)&&x9(r,n)||e.close()},[e,t?.sessionId,r]),(0,I.useEffect)(()=>{let t=t=>{let n=t.detail;!m||!t$(n,m.sessionId)||(s(m.questionId),r.setPending(null,m.sessionId),e.close())};return window.addEventListener(XQ,t),()=>window.removeEventListener(XQ,t)},[e,m,r]),(0,I.useEffect)(()=>{if(!i)return;let e=t?.questionId;if(!a){c.current=null,r.refreshPending(i).catch(()=>void 0);return}if(!e||a.questionId===e){c.current=null;return}let n=`${i}:${e}`;c.current!==n&&(c.current=n,r.refreshPending(i).catch(()=>void 0))},[i,t?.questionId,a,r]),(0,L.jsx)(`div`,{className:n?`${n} min-h-0 overflow-hidden`:`h-full min-h-0 overflow-hidden`,children:(0,L.jsxs)(we,{className:`h-full min-h-0 overflow-hidden border-0 bg-background text-sm`,children:[(0,L.jsx)(Ye,{className:`border-b bg-background/95`,children:(0,L.jsx)(`div`,{children:(0,L.jsxs)(Me,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Dr,{className:`h-4 w-4 text-muted-foreground`}),` Agent needs input`]})})}),m?null:(0,L.jsx)($e,{className:`overflow-auto p-4`,children:(0,L.jsx)(lt,{icon:(0,L.jsx)(Dr,{className:`h-5 w-5`}),title:`No pending questions`,description:`When the agent needs a decision, the form will appear here.`,className:`border border-dashed bg-muted/20`})}),m?.status===`ready`&&m.schema?(0,L.jsx)(lIt,{schema:m.schema,submitting:f,onSubmit:async n=>{p(!0),d(null);try{await h.submit(m,n),s(m.questionId),r.setPending(null,m.sessionId),e.close(),t?.__closeWorkbenchOnDone?.()}catch(e){d(e instanceof f9?e.message:String(e))}finally{p(!1)}},onCancel:async()=>{p(!0),d(null);try{await h.cancel(m),s(m.questionId),r.setPending(null,m.sessionId),e.close(),t?.__closeWorkbenchOnDone?.()}catch(e){d(e instanceof f9?e.message:String(e))}finally{p(!1)}},children:(0,L.jsxs)(uIt,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsx)($e,{className:`overflow-auto p-4`,children:(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`section`,{className:`rounded-md border border-border/60 bg-muted/30 p-4`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Waiting for answer`}),(0,L.jsx)(`h2`,{className:`mt-2 text-balance text-sm font-semibold leading-5 text-foreground`,children:m.title??`Question`}),m.context?(0,L.jsx)(`p`,{className:`mt-2 max-w-prose text-sm leading-6 text-muted-foreground`,children:m.context}):null]}),(0,L.jsx)(`div`,{className:`space-y-4`,children:(0,L.jsx)(fIt,{})}),l?(0,L.jsx)(u,{tone:`destructive`,role:`alert`,children:l}):null]})}),(0,L.jsxs)(He,{className:`justify-between border-t bg-background px-4 py-3`,children:[(0,L.jsx)(`p`,{className:`min-w-0 text-xs text-muted-foreground`,children:`Sends answers and closes the pane.`}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(Se,{asChild:!0,variant:`outline`,size:`sm`,children:(0,L.jsx)(hIt,{children:`Cancel`})}),(0,L.jsx)(Se,{asChild:!0,size:`sm`,children:(0,L.jsx)(mIt,{children:m.schema.submitLabel??`Send answers`})})]})]})]})},m.questionId):null,m&&m.status!==`ready`?(0,L.jsx)($e,{className:`p-5`,children:(0,L.jsx)(u,{children:(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Or,{className:`h-4 w-4 text-muted-foreground`}),`Question `,m.status]})})}):null]})})}function uLt(e={}){return zn({id:n9,label:i9,providers:[{id:`${n9}.provider`,component:iLt}],panels:[{id:r9,label:i9,icon:Dr,component:lLt,placement:`center`,source:`builtin`,chromeless:!0}],appLeftActions:e.appLeftInbox?[{id:`inbox`,label:`Inbox`,icon:ri,trailing:sLt,overlay:cLt,order:10}]:[],surfaceResolvers:[{id:`${n9}.surface`,kind:a9,source:`builtin`,resolve(e){let t=typeof e.meta==`object`&&e.meta&&typeof e.meta.sessionId==`string`?e.meta.sessionId:void 0;return{component:r9,id:r9,title:i9,params:{questionId:e.target,sessionId:t}}}}]})}uLt();var S9=`boring-automation`,C9=`Automations`,dLt=`/api/v1/boring-automation`;function w9(e){return Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)}function T9(e,t){return e.y===t.y&&e.m===t.m&&e.d===t.d&&e.h===t.h&&e.i===t.i&&e.s===t.s}function fLt(e,t){let n=new Date(Date.parse(e));if(isNaN(n))throw Error(`Invalid ISO8601 passed to timezone parser.`);let r=e.substring(9);return r.includes(`Z`)||r.includes(`+`)||r.includes(`-`)?D9(n.getUTCFullYear(),n.getUTCMonth()+1,n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),`Etc/UTC`):D9(n.getFullYear(),n.getMonth()+1,n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),t)}function pLt(e,t,n){return mLt(fLt(e,t),n)}function mLt(e,t){let n=new Date(w9(e)),r=E9(n,e.tz),i=w9(e)-w9(r),a=new Date(n.getTime()+i),o=E9(a,e.tz);if(T9(o,e)){let t=new Date(a.getTime()-36e5);return T9(E9(t,e.tz),e)?t:a}let s=new Date(a.getTime()+w9(e)-w9(o));if(T9(E9(s,e.tz),e))return s;if(t)throw Error(`Invalid date passed to fromTZ()`);return a.getTime()>s.getTime()?a:s}function E9(e,t){let n,r;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,hour12:!1}),r=n.formatToParts(e)}catch(e){let n=e instanceof Error?e.message:String(e);throw RangeError(`toTZ: Invalid timezone '${t}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${n}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let e of r)(e.type===`year`||e.type===`month`||e.type===`day`||e.type===`hour`||e.type===`minute`||e.type===`second`)&&(i[e.type]=parseInt(e.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw Error(`toTZ: Failed to parse all date components from timezone '${t}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return i.hour===24&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:t}}function D9(e,t,n,r,i,a,o){return{y:e,m:t,d:n,h:r,i,s:a,tz:o}}var hLt=[1,2,4,8,16],gLt=class{pattern;timezone;mode;alternativeWeekdays;sloppyRanges;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;lastWeekday;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(e,t,n){this.pattern=e,this.timezone=t,this.mode=n?.mode??`auto`,this.alternativeWeekdays=n?.alternativeWeekdays??!1,this.sloppyRanges=n?.sloppyRanges??!1,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.lastWeekday=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!(typeof this.pattern==`string`||this.pattern instanceof String))throw TypeError(`CronPattern: Pattern has to be of type string.`);this.pattern.indexOf(`@`)>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.match(/\S+/g)||[``],t=e.length;if(e.length<5||e.length>7)throw TypeError(`CronPattern: invalid configuration format ('`+this.pattern+`'), exactly five, six, or seven space separated parts are required.`);if(this.mode!==`auto`){let e;switch(this.mode){case`5-part`:e=5;break;case`6-part`:e=6;break;case`7-part`:e=7;break;case`5-or-6-parts`:e=[5,6];break;case`6-or-7-parts`:e=[6,7];break;default:e=0}if(!(Array.isArray(e)?e.includes(t):t===e)){let n=Array.isArray(e)?e.join(` or `):e.toString();throw TypeError(`CronPattern: mode '${this.mode}' requires exactly ${n} parts, but pattern '${this.pattern}' has ${t} parts.`)}}if(e.length===5&&e.unshift(`0`),e.length===6&&e.push(`*`),e[3].toUpperCase()===`LW`?(this.lastWeekday=!0,e[3]=``):e[3].toUpperCase().indexOf(`L`)>=0&&(e[3]=e[3].replace(/L/gi,``),this.lastDayOfMonth=!0),e[3]==`*`&&(this.starDOM=!0),e[6]==`*`&&(this.starYear=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.alternativeWeekdays?this.replaceAlphaDaysQuartz(e[5]):this.replaceAlphaDays(e[5])),e[5].startsWith(`+`)&&(this.useAndLogic=!0,e[5]=e[5].substring(1),e[5]===``))throw TypeError(`CronPattern: Day-of-week field cannot be empty after '+' modifier.`);switch(e[5]==`*`&&(this.starDOW=!0),this.pattern.indexOf(`?`)>=0&&(e[0]=e[0].replace(/\?/g,`*`),e[1]=e[1].replace(/\?/g,`*`),e[2]=e[2].replace(/\?/g,`*`),e[3]=e[3].replace(/\?/g,`*`),e[4]=e[4].replace(/\?/g,`*`),e[5]=e[5].replace(/\?/g,`*`),e[6]&&=e[6].replace(/\?/g,`*`)),this.mode){case`5-part`:e[0]=`0`,e[6]=`*`;break;case`6-part`:e[6]=`*`;break;case`5-or-6-parts`:e[6]=`*`;break;case`6-or-7-parts`:break;case`7-part`:case`auto`:break}this.throwAtIllegalCharacters(e),this.partToArray(`second`,e[0],0,1),this.partToArray(`minute`,e[1],0,1),this.partToArray(`hour`,e[2],0,1),this.partToArray(`day`,e[3],-1,1),this.partToArray(`month`,e[4],-1,1);let n=this.alternativeWeekdays?-1:0;this.partToArray(`dayOfWeek`,e[5],n,63),this.partToArray(`year`,e[6],0,1),!this.alternativeWeekdays&&this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,n,r){let i=this[e],a=e===`day`&&this.lastDayOfMonth,o=e===`day`&&this.lastWeekday;if(t===``&&!a&&!o)throw TypeError(`CronPattern: configuration entry `+e+` (`+t+`) is empty, check for trailing spaces.`);if(t===`*`)return i.fill(r);let s=t.split(`,`);if(s.length>1)for(let t=0;t<s.length;t++)this.partToArray(e,s[t],n,r);else t.indexOf(`-`)!==-1&&t.indexOf(`/`)!==-1?this.handleRangeWithStepping(t,e,n,r):t.indexOf(`-`)===-1?t.indexOf(`/`)===-1?t!==``&&this.handleNumber(t,e,n,r):this.handleStepping(t,e,n,r):this.handleRange(t,e,n,r)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===3?/[^/*0-9,\-WwLl]+/:t===5?/[^/*0-9,\-#Ll]+/:/[^/*0-9,\-]+/).test(e[t]))throw TypeError(`CronPattern: configuration entry `+t+` (`+e[t]+`) contains illegal characters.`)}handleNumber(e,t,n,r){let i=this.extractNth(e,t),a=e.toUpperCase().includes(`W`);if(t!==`day`&&a)throw TypeError(`CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.`);a&&(t=`nearestWeekdays`);let o=parseInt(i[0],10)+n;if(isNaN(o))throw TypeError(`CronPattern: `+t+` is not a number: '`+e+`'`);this.setPart(t,o,i[1]||r)}setPart(e,t,n){if(!Object.prototype.hasOwnProperty.call(this,e))throw TypeError(`CronPattern: Invalid part specified: `+e);if(e===`dayOfWeek`){if(t===7&&(t=0),t<0||t>6)throw RangeError(`CronPattern: Invalid value for dayOfWeek: `+t);this.setNthWeekdayOfMonth(t,n);return}if(e===`second`||e===`minute`){if(t<0||t>=60)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`hour`){if(t<0||t>=24)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`day`||e===`nearestWeekdays`){if(t<0||t>=31)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`month`){if(t<0||t>=12)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`year`&&(t<1||t>=1e4))throw RangeError(`CronPattern: Invalid value for `+e+`: `+t+` (supported range: 1-9999)`);this[e][t]=n}validateNotNaN(e,t){if(isNaN(e))throw TypeError(t)}validateRange(e,t,n,r,i){if(e>t)throw TypeError(`CronPattern: From value is larger than to value: '`+i+`'`);if(n!==void 0){if(n===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(n>this[r].length)throw TypeError(`CronPattern: Syntax error, steps cannot be greater than maximum value of part (`+this[r].length+`)`)}}handleRangeWithStepping(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in ranges with stepping.`);let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw TypeError(`CronPattern: Syntax error, illegal range with stepping: '`+e+`'`);let[,o,s,c]=a,l=parseInt(o,10)+n,u=parseInt(s,10)+n,d=parseInt(c,10);this.validateNotNaN(l,`CronPattern: Syntax error, illegal lower range (NaN)`),this.validateNotNaN(u,`CronPattern: Syntax error, illegal upper range (NaN)`),this.validateNotNaN(d,`CronPattern: Syntax error, illegal stepping: (NaN)`),this.validateRange(l,u,d,t,e);for(let e=l;e<=u;e+=d)this.setPart(t,e,i[1]||r)}extractNth(e,t){let n=e,r;if(n.includes(`#`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: nth (#) only allowed in day-of-week field`);r=n.split(`#`)[1],n=n.split(`#`)[0]}else if(n.toUpperCase().endsWith(`L`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)`);r=`L`,n=n.slice(0,-1)}return[n,r]}handleRange(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in a range.`);let i=this.extractNth(e,t),a=i[0].split(`-`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal range: '`+e+`'`);let o=parseInt(a[0],10)+n,s=parseInt(a[1],10)+n;this.validateNotNaN(o,`CronPattern: Syntax error, illegal lower range (NaN)`),this.validateNotNaN(s,`CronPattern: Syntax error, illegal upper range (NaN)`),this.validateRange(o,s,void 0,t,e);for(let e=o;e<=s;e++)this.setPart(t,e,i[1]||r)}handleStepping(e,t,n,r){if(e.toUpperCase().includes(`W`))throw TypeError(`CronPattern: Syntax error, W is not allowed in parts with stepping.`);let i=this.extractNth(e,t),a=i[0].split(`/`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal stepping: '`+e+`'`);if(this.sloppyRanges)a[0]===``&&(a[0]=`*`);else{if(a[0]===``)throw TypeError(`CronPattern: Syntax error, stepping with missing prefix ('`+e+`') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.`);if(a[0]!==`*`)throw TypeError(`CronPattern: Syntax error, stepping with numeric prefix ('`+e+`') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.`)}let o=0;a[0]!==`*`&&(o=parseInt(a[0],10)+n);let s=parseInt(a[1],10);this.validateNotNaN(s,`CronPattern: Syntax error, illegal stepping: (NaN)`),this.validateRange(0,this[t].length-1,s,t,e);for(let e=o;e<this[t].length;e+=s)this.setPart(t,e,i[1]||r)}replaceAlphaDays(e){return e.replace(/-sun/gi,`-7`).replace(/sun/gi,`0`).replace(/mon/gi,`1`).replace(/tue/gi,`2`).replace(/wed/gi,`3`).replace(/thu/gi,`4`).replace(/fri/gi,`5`).replace(/sat/gi,`6`)}replaceAlphaDaysQuartz(e){return e.replace(/sun/gi,`1`).replace(/mon/gi,`2`).replace(/tue/gi,`3`).replace(/wed/gi,`4`).replace(/thu/gi,`5`).replace(/fri/gi,`6`).replace(/sat/gi,`7`)}replaceAlphaMonths(e){return e.replace(/jan/gi,`1`).replace(/feb/gi,`2`).replace(/mar/gi,`3`).replace(/apr/gi,`4`).replace(/may/gi,`5`).replace(/jun/gi,`6`).replace(/jul/gi,`7`).replace(/aug/gi,`8`).replace(/sep/gi,`9`).replace(/oct/gi,`10`).replace(/nov/gi,`11`).replace(/dec/gi,`12`)}handleNicknames(e){let t=e.trim().toLowerCase();if(t===`@yearly`||t===`@annually`)return`0 0 1 1 *`;if(t===`@monthly`)return`0 0 1 * *`;if(t===`@weekly`)return`0 0 * * 0`;if(t===`@daily`||t===`@midnight`)return`0 0 * * *`;if(t===`@hourly`)return`0 * * * *`;if(t===`@reboot`)throw TypeError(`CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.`);return e}setNthWeekdayOfMonth(e,t){if(typeof t!=`number`&&t.toUpperCase()===`L`)this.dayOfWeek[e]=this.dayOfWeek[e]|32;else if(t===63)this.dayOfWeek[e]=63;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|hLt[t-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}},O9=[31,28,31,30,31,30,31,31,30,31,30,31],k9=[[`month`,`year`,0],[`day`,`month`,-1],[`hour`,`day`,0],[`minute`,`hour`,0],[`second`,`minute`,0]],A9=class e{tz;ms;second;minute;hour;day;month;year;constructor(t,n){if(this.tz=n,t&&t instanceof Date)if(!isNaN(t))this.fromDate(t);else throw TypeError(`CronDate: Invalid date passed to CronDate constructor`);else if(t==null)this.fromDate(new Date);else if(t&&typeof t==`string`)this.fromString(t);else if(t instanceof e)this.fromCronDate(t);else throw TypeError(`CronDate: Invalid type (`+typeof t+`) passed to CronDate constructor`)}getLastDayOfMonth(e,t){return t===1?new Date(Date.UTC(e,t+1,0)).getUTCDate():O9[t]}getLastWeekday(e,t){let n=this.getLastDayOfMonth(e,t),r=new Date(Date.UTC(e,t,n)).getUTCDay();return r===0?n-2:r===6?n-1:n}getNearestWeekday(e,t,n){let r=this.getLastDayOfMonth(e,t);if(n>r)return-1;let i=new Date(Date.UTC(e,t,n)).getUTCDay();return i===0?n===r?n-2:n+1:i===6?n===1?n+2:n-1:n}isNthWeekdayOfMonth(e,t,n,r){let i=new Date(Date.UTC(e,t,n)).getUTCDay(),a=0;for(let r=1;r<=n;r++)new Date(Date.UTC(e,t,r)).getUTCDay()===i&&a++;if(r&63&&hLt[a-1]&r)return!0;if(r&32){let r=this.getLastDayOfMonth(e,t);for(let a=n+1;a<=r;a++)if(new Date(Date.UTC(e,t,a)).getUTCDay()===i)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz==`number`)this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else try{let t=E9(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${t}`)}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.month<0||this.day>O9[this.month]||this.day<1||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz==`number`){let t=pLt(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(pLt(e,this.tz))}findNext(e,t,n,r){return this._findMatch(e,t,n,r,1)}_findMatch(e,t,n,r,i){let a=this[t],o;n.lastDayOfMonth&&(o=this.getLastDayOfMonth(this.year,this.month));let s=!n.starDOW&&t==`day`?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0,c=this[t]+r,l=i===1?e=>e<n[t].length:e=>e>=0;for(let u=c;l(u);u+=i){let i=n[t][u];if(t===`day`&&!i){for(let e=0;e<n.nearestWeekdays.length;e++)if(n.nearestWeekdays[e]){let t=this.getNearestWeekday(this.year,this.month,e-r);if(t===-1)continue;if(t===u-r){i=1;break}}}if(t===`day`&&n.lastWeekday){let e=this.getLastWeekday(this.year,this.month);u-r===e&&(i=1)}if(t===`day`&&n.lastDayOfMonth&&u-r==o&&(i=1),t===`day`&&!n.starDOW){let t=n.dayOfWeek[(s+(u-r-1))%7];if(t&&t&63)t=+!!this.isNthWeekdayOfMonth(this.year,this.month,u-r,t);else if(t)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);n.useAndLogic?i&&=t:!e.domAndDow&&!n.starDOM?i||=t:i&&=t}if(i)return this[t]=u-r,a===this[t]?1:2}return 3}recurse(e,t,n){if(n===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let t=-1;for(let n=this.year+1;n<e.year.length&&n<1e4;n++)if(e.year[n]===1){t=n;break}if(t===-1)return null;this.year=t,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let r=this.findNext(t,k9[n][0],e,k9[n][2]);if(r>1){let i=n+1;for(;i<k9.length;)this[k9[i][0]]=-k9[i][2],i++;if(r===3){if(this[k9[n][1]]++,this[k9[n][0]]=-k9[n][2],this.apply(),n===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=e.year.length)return null}return this.recurse(e,t,0)}else if(this.apply())return this.recurse(e,t,n-1)}return n+=1,n>=k9.length?this:(e.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(e,t,n)}increment(e,t,n){return this.second+=t.interval!==void 0&&t.interval>1&&n?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}decrement(e,t){return this.second-=t.interval!==void 0&&t.interval>1?t.interval:1,this.ms=0,this.apply(),this.recurseBackward(e,t,0,0)}recurseBackward(e,t,n,r=0){if(r>1e4)return null;if(n===0&&!e.starYear){if(this.year>=0&&this.year<e.year.length&&e.year[this.year]===0){let t=-1;for(let n=this.year-1;n>=0;n--)if(e.year[n]===1){t=n;break}if(t===-1)return null;this.year=t,this.month=11,this.day=31,this.hour=23,this.minute=59,this.second=59,this.ms=0}if(this.year<0)return null}let i=this.findPrevious(t,k9[n][0],e,k9[n][2]);if(i>1){let a=n+1;for(;a<k9.length;){let t=k9[a][0],n=k9[a][2],r=this.getMaxPatternValue(t,e,n);this[t]=r,a++}if(i===3){if(this[k9[n][1]]--,n===0){let e=this.getLastDayOfMonth(this.year,this.month);this.day>e&&(this.day=e)}if(n===1)if(this.day<=0)this.day=1;else{let e=this.year,t=this.month;for(;t<0;)t+=12,e--;for(;t>11;)t-=12,e++;let n=t===1?new Date(Date.UTC(e,t+1,0)).getUTCDate():O9[t];this.day>n&&(this.day=n)}this.apply();let i=k9[n][0],a=k9[n][2],o=this.getMaxPatternValue(i,e,a);if(i===`day`){let e=this.getLastDayOfMonth(this.year,this.month);this[i]=Math.min(o,e)}else this[i]=o;if(this.apply(),n===0){let t=k9[1][2],n=this.getMaxPatternValue(`day`,e,t),r=this.getLastDayOfMonth(this.year,this.month),i=Math.min(n,r);i!==this.day&&(this.day=i,this.hour=this.getMaxPatternValue(`hour`,e,k9[2][2]),this.minute=this.getMaxPatternValue(`minute`,e,k9[3][2]),this.second=this.getMaxPatternValue(`second`,e,k9[4][2]))}if(n===0&&!e.starYear){for(;this.year>=0&&this.year<e.year.length&&e.year[this.year]===0;)this.year--;if(this.year<0)return null}return this.recurseBackward(e,t,0,r+1)}else if(this.apply())return this.recurseBackward(e,t,n-1,r+1)}return n+=1,n>=k9.length?this:this.year<0?null:this.recurseBackward(e,t,n,r+1)}getMaxPatternValue(e,t,n){if(e===`day`&&t.lastDayOfMonth||e===`day`&&!t.starDOW)return this.getLastDayOfMonth(this.year,this.month);for(let r=t[e].length-1;r>=0;r--)if(t[e][r])return r-n;return t[e].length-1-n}findPrevious(e,t,n,r){return this._findMatch(e,t,n,r,-1)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz==`number`?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):mLt(D9(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}match(e,t){if(!e.starYear&&(this.year<0||this.year>=e.year.length||e.year[this.year]===0))return!1;for(let n=0;n<k9.length;n++){let r=k9[n][0],i=k9[n][2],a=this[r];if(a+i<0||a+i>=e[r].length)return!1;let o=e[r][a+i];if(r===`day`){if(!o){for(let t=0;t<e.nearestWeekdays.length;t++)if(e.nearestWeekdays[t]){let e=this.getNearestWeekday(this.year,this.month,t-i);if(e!==-1&&e===a){o=1;break}}}if(e.lastWeekday&&a===this.getLastWeekday(this.year,this.month)&&(o=1),e.lastDayOfMonth&&a===this.getLastDayOfMonth(this.year,this.month)&&(o=1),!e.starDOW){let n=new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),r=e.dayOfWeek[(n+(a-1))%7];r&&r&63&&(r=+!!this.isNthWeekdayOfMonth(this.year,this.month,a,r)),e.useAndLogic?o&&=r:!t.domAndDow&&!e.starDOM?o||=r:o&&=r}}if(!o)return!1}return!0}};function _Lt(e){if(e===void 0&&(e={}),delete e.name,e.legacyMode!==void 0&&e.domAndDow===void 0?e.domAndDow=!e.legacyMode:e.domAndDow===void 0&&(e.domAndDow=!1),e.legacyMode=!e.domAndDow,e.paused=e.paused!==void 0&&e.paused,e.maxRuns=e.maxRuns===void 0?1/0:e.maxRuns,e.catch=e.catch!==void 0&&e.catch,e.interval=e.interval===void 0?0:parseInt(e.interval.toString(),10),e.utcOffset=e.utcOffset===void 0?void 0:parseInt(e.utcOffset.toString(),10),e.dayOffset=e.dayOffset===void 0?0:parseInt(e.dayOffset.toString(),10),e.unref=e.unref!==void 0&&e.unref,e.mode=e.mode===void 0?`auto`:e.mode,e.alternativeWeekdays=e.alternativeWeekdays!==void 0&&e.alternativeWeekdays,e.sloppyRanges=e.sloppyRanges!==void 0&&e.sloppyRanges,![`auto`,`5-part`,`6-part`,`7-part`,`5-or-6-parts`,`6-or-7-parts`].includes(e.mode))throw Error(`CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.`);if(e.startAt&&=new A9(e.startAt,e.timezone),e.stopAt&&=new A9(e.stopAt,e.timezone),e.interval!==null){if(isNaN(e.interval))throw Error(`CronOptions: Supplied value for interval is not a number`);if(e.interval<0)throw Error(`CronOptions: Supplied value for interval can not be negative`)}if(e.utcOffset!==void 0){if(isNaN(e.utcOffset))throw Error(`CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.`);if(e.utcOffset<-870||e.utcOffset>870)throw Error(`CronOptions: utcOffset out of bounds.`);if(e.utcOffset!==void 0&&e.timezone)throw Error(`CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.`)}if(e.unref!==!0&&e.unref!==!1)throw Error(`CronOptions: Unref should be either true, false or undefined(false).`);if(e.dayOffset!==void 0&&e.dayOffset!==0&&isNaN(e.dayOffset))throw Error(`CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.`);return e}function j9(e){return Object.prototype.toString.call(e)===`[object Function]`||typeof e==`function`||e instanceof Function}function vLt(e){return j9(e)}function yLt(e){typeof Deno<`u`&&typeof Deno.unrefTimer<`u`?Deno.unrefTimer(e):e&&typeof e.unref<`u`&&e.unref()}var bLt=30*1e3,M9=[],xLt=class{name;options;_states;fn;getTz(){return this.options.timezone||this.options.utcOffset}applyDayOffset(e){if(this.options.dayOffset!==void 0&&this.options.dayOffset!==0){let t=this.options.dayOffset*24*60*60*1e3;return new Date(e.getTime()+t)}return e}constructor(e,t,n){let r,i;if(j9(t))i=t;else if(typeof t==`object`)r=t;else if(t!==void 0)throw Error(`Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).`);if(j9(n))i=n;else if(typeof n==`object`)r=n;else if(n!==void 0)throw Error(`Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).`);if(this.name=r?.name,this.options=_Lt(r),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:r?r.maxRuns:void 0,paused:r?r.paused:!1,pattern:new gLt(`* * * * *`,void 0,{mode:`auto`})},e&&(e instanceof Date||typeof e==`string`&&e.indexOf(`:`)>0)?this._states.once=new A9(e,this.getTz()):this._states.pattern=new gLt(e,this.options.timezone,{mode:this.options.mode,alternativeWeekdays:this.options.alternativeWeekdays,sloppyRanges:this.options.sloppyRanges}),this.name){if(M9.find(e=>e.name===this.name))throw Error(`Cron: Tried to initialize new named job '`+this.name+`', but name already taken.`);M9.push(this)}return i!==void 0&&vLt(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?this.applyDayOffset(t.getDate(!1)):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let n=t||this._states.currentRun||void 0;return this._enumerateRuns(e,n,`next`)}previousRuns(e,t){return this._enumerateRuns(e,t||void 0,`previous`)}_enumerateRuns(e,t,n){let r=[],i=t?new A9(t,this.getTz()):null,a=n===`next`?this._next:this._previous;for(;e--;){let e=a.call(this,i);if(!e)break;let t=e.getDate(!1);r.push(this.applyDayOffset(t)),i=e}return r}match(e){if(this._states.once){let t=new A9(e,this.getTz());t.ms=0;let n=new A9(this._states.once,this.getTz());return n.ms=0,t.getTime()===n.getTime()}let t=new A9(e,this.getTz());return t.ms=0,t.match(this._states.pattern,this.options)}getPattern(){if(!this._states.once)return this._states.pattern?this._states.pattern.pattern:void 0}getOnce(){return this._states.once?this._states.once.getDate():null}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,n=this.fn!==void 0,r=!this._states.kill;return t&&n&&r&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof A9||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new A9(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=M9.indexOf(this);e>=0&&M9.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw Error(`Cron: It is not allowed to schedule two functions using the same Croner instance.`);e&&(this.fn=e);let t=this.msToNext(),n=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||n===null?this:(t>bLt&&(t=bLt),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),t),this._states.currentTimeout&&this.options.unref&&yLt(this._states.currentTimeout),this)}async _trigger(e){this._states.blocking=!0,this._states.currentRun=new A9(void 0,this.getTz());try{if(this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){if(j9(this.options.catch))try{this.options.catch(e,this)}catch{}}else this.fn!==void 0&&await this.fn(this,this.options.context)}finally{this._states.previousRun=new A9(e,this.getTz()),this._states.blocking=!1}}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,n=!this._states.paused&&t.getTime()>=e.getTime(),r=this._states.blocking&&this.options.protect;n&&!r?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):n&&r&&j9(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),n=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),n=!e),e=new A9(e,this.getTz()),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let r=this._states.once||new A9(e,this.getTz());return!n&&r!==this._states.once&&(r=r.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||r===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&r.getTime()>=this.options.stopAt.getTime()?null:r}_previous(e){let t=new A9(e,this.getTz());this.options.stopAt&&t.getTime()>this.options.stopAt.getTime()&&(t=this.options.stopAt);let n=new A9(t,this.getTz());return this._states.once?this._states.once.getTime()<t.getTime()?this._states.once:null:(n=n.decrement(this._states.pattern,this.options),n===null||this.options.startAt&&n.getTime()<this.options.startAt.getTime()?null:n)}_calculatePreviousRun(e,t){let n=new A9(void 0,this.getTz()),r=e;if(this.options.startAt.getTime()<=n.getTime()){r=this.options.startAt;let e=r.getTime()+this.options.interval*1e3;for(;e<=n.getTime();)r=new A9(r,this.getTz()).increment(this._states.pattern,this.options,!0),e=r.getTime()+this.options.interval*1e3;t=!0}return r===null&&(r=void 0),[r,t]}},SLt={INVALID_CRON:`Invalid cron schedule. Use exactly five fields, for example 0 9 * * *.`,INVALID_TIMEZONE:`Invalid timezone. Use a valid IANA timezone, for example UTC or America/New_York.`};function CLt(e,t){let n={};return wLt(e)||(n.cron=SLt.INVALID_CRON),TLt(t)||(n.timezone=SLt.INVALID_TIMEZONE),{ok:Object.keys(n).length===0,errors:n}}function wLt(e){let t=ELt(e);if(!t||t.split(` `).length!==5)return!1;try{return new xLt(t),!0}catch{return!1}}function TLt(e){let t=e.trim();if(!t)return!1;try{let e=new Intl.DateTimeFormat(`en-US`,{timeZone:t}).resolvedOptions().timeZone;return e===`UTC`||e.includes(`/`)}catch{return!1}}function ELt(e){return e.trim().replace(/\s+/g,` `)}function DLt(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(t)}function OLt(e){let t=e.durationMs??MLt(e);if(t==null)return`—`;if(t<1e3)return`${t}ms`;let n=Math.round(t/1e3);if(n<60)return`${n}s`;let r=Math.floor(n/60),i=n%60;return i?`${r}m ${i}s`:`${r}m`}function kLt(e){return e.totalTokens==null?e.inputTokens!=null||e.outputTokens!=null?(e.inputTokens??0)+(e.outputTokens??0):null:e.totalTokens}function ALt(e){switch(e){case`queued`:return`Queued`;case`running`:return`Running`;case`succeeded`:return`Succeeded`;case`failed`:return`Failed`;case`cancelled`:return`Cancelled`}}function jLt(e){switch(e){case`succeeded`:return`bg-[color:var(--success-soft)] text-success`;case`failed`:return`bg-destructive/10 text-destructive`;case`running`:return`bg-foreground/[0.07] text-foreground`;case`cancelled`:return`bg-foreground/[0.07] text-muted-foreground`;case`queued`:return`bg-foreground/[0.07] text-muted-foreground`}}function MLt(e){if(!e?.startedAt||!e.completedAt)return null;let t=new Date(e.startedAt).getTime(),n=new Date(e.completedAt).getTime();return Number.isNaN(t)||Number.isNaN(n)||n<t?null:n-t}function NLt({runs:e,loading:t,onOpenRun:n}){return t?(0,L.jsx)(`div`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:`Loading run history…`}):e.length===0?(0,L.jsx)(`div`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:`No runs yet. Future execution slices will write sessions here.`}):(0,L.jsx)(`ul`,{role:`list`,className:`divide-y divide-border/60 bg-card/70`,children:e.map(e=>{let t=kLt(e),r=e.startedAt??e.scheduledFor??e.createdAt,i=e.sessionId?`Open session ${e.sessionId}`:`Run has no session`;return(0,L.jsxs)(`li`,{className:`group flex min-h-12 items-center gap-2 px-4 py-2 text-left text-[12px] focus-within:bg-muted/40 hover:bg-muted/40 motion-reduce:transition-none`,children:[(0,L.jsx)(`span`,{className:C(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-medium`,jLt(e.status)),children:ALt(e.status)}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-foreground`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:e.trigger===`scheduled`?`Scheduled`:`Manual`}),(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Start `,DLt(r)]}),(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Duration `,OLt(e)]}),t==null?null:(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Tokens `,t.toLocaleString()]})]}),e.error?(0,L.jsx)(`div`,{className:`mt-1 line-clamp-2 text-destructive`,children:e.error}):null]}),(0,L.jsxs)(Se,{type:`button`,variant:`ghost`,size:`sm`,disabled:!e.sessionId,"aria-label":i,title:i,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>n(e),children:[(0,L.jsx)(gi,{className:`mr-1 size-3.5`,"aria-hidden":`true`}),`Session`]})]},e.id)})})}function PLt({automation:e,expanded:t,deleting:n,runs:r,runsLoading:i,runningNow:a,onToggle:o,onEdit:s,onRunNow:c,onDeleteRequest:l,onDeleteCancel:u,onDeleteConfirm:d,onOpenRun:f}){let p=`automation-runs-${e.id}`,m=`automation-delete-title-${e.id}`;return(0,L.jsxs)(`article`,{className:`border-b border-border/60 bg-card/80 last:border-b-0`,children:[(0,L.jsxs)(`div`,{className:`group flex min-h-14 w-full items-center gap-3 px-4 py-2 text-sm transition-colors hover:bg-muted/50 focus-within:bg-muted/50 motion-reduce:transition-none`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,"aria-expanded":t,"aria-controls":p,onClick:o,children:[(0,L.jsx)(xr,{className:C(`size-4 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none`,t&&`rotate-180`),"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:C(`size-2 shrink-0 rounded-full`,e.enabled?`bg-[color:var(--success)]`:`bg-muted-foreground/40`),"aria-hidden":`true`}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate font-medium text-foreground`,children:e.title}),(0,L.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[e.cron,` · `,e.timezone,` · `,e.model]})]}),(0,L.jsxs)(`span`,{className:`hidden shrink-0 text-xs text-muted-foreground sm:block`,children:[`Updated `,DLt(e.updatedAt)]})]}),(0,L.jsxs)(Se,{type:`button`,variant:`ghost`,size:`sm`,onClick:c,disabled:a,"aria-label":`Run ${e.title} now`,children:[(0,L.jsx)(ki,{className:`size-3.5`,"aria-hidden":`true`}),a?`Running…`:`Run now`]}),(0,L.jsx)(Se,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,children:`Edit`}),(0,L.jsx)(Se,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.title}`,title:`Delete`,onClick:l,children:(0,L.jsx)(Ji,{className:`size-4`,"aria-hidden":`true`})})]}),n?(0,L.jsxs)(`div`,{className:`border-t border-border/60 bg-background px-4 py-3 text-sm`,role:`region`,"aria-labelledby":m,children:[(0,L.jsx)(`div`,{id:m,className:`font-medium text-foreground`,children:`Delete this automation?`}),(0,L.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Only automation metadata is removed. Prompt Markdown, run records, and Pi chat sessions remain.`}),(0,L.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,L.jsx)(Se,{type:`button`,variant:`destructive`,size:`sm`,onClick:d,children:`Delete`}),(0,L.jsx)(Se,{type:`button`,variant:`ghost`,size:`sm`,onClick:u,children:`Cancel`})]})]}):null,t?(0,L.jsxs)(`div`,{id:p,className:`border-t border-border/60`,children:[(0,L.jsx)(`div`,{className:`px-4 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70`,children:`Run history`}),(0,L.jsx)(NLt,{runs:r,loading:i,onOpenRun:f})]}):null]})}var FLt={title:``,enabled:!0,cron:`0 9 * * *`,timezone:`UTC`,model:``,prompt:``};function ILt(e,t){return{title:e.title,enabled:e.enabled,cron:e.cron,timezone:e.timezone,model:e.model,prompt:t}}function N9(){return{...FLt}}function LLt(e){let t={};e.title.trim()||(t.title=`Title is required.`);let n=CLt(e.cron,e.timezone);n.errors.cron&&(t.cron=n.errors.cron),n.errors.timezone&&(t.timezone=n.errors.timezone);let r=e.model.trim();if(!r)t.model=`Model is required.`;else{let e=r.indexOf(`:`);(e<=0||!r.slice(0,e).trim()||!r.slice(e+1).trim())&&(t.model=`Use provider:model-id syntax.`)}return t}function RLt(e){return{title:e.title.trim(),enabled:e.enabled,cron:e.cron.trim(),timezone:e.timezone.trim(),model:e.model.trim(),prompt:e.prompt}}function zLt(e){return{title:e.title.trim(),enabled:e.enabled,cron:e.cron.trim(),timezone:e.timezone.trim(),model:e.model.trim()}}function BLt({automation:e,prompt:t,mode:n,saving:r,onCancel:i,onSubmit:a}){let[o,s]=(0,I.useState)(()=>e?ILt(e,t):N9()),[c,l]=(0,I.useState)(!1);(0,I.useEffect)(()=>{s(e?ILt(e,t):N9()),l(!1)},[e,t]);let u=(0,I.useMemo)(()=>LLt(o),[o]),d=Object.keys(u).length>0,f=c&&u.cron?`automation-cron-description automation-cron-error`:`automation-cron-description`,p=c&&u.timezone?`automation-timezone-description automation-timezone-error`:`automation-timezone-description`,m=c&&u.model?`automation-model-description automation-model-error`:`automation-model-description`;function h(e){e.preventDefault(),l(!0),!d&&a(o)}return(0,L.jsxs)(`form`,{className:`space-y-4`,onSubmit:h,noValidate:!0,"aria-label":`${n===`create`?`Create`:`Edit`} automation form`,children:[(0,L.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,L.jsxs)(ce,{children:[(0,L.jsx)(ue,{htmlFor:`automation-title`,children:`Title`}),(0,L.jsx)(T,{id:`automation-title`,value:o.title,onChange:e=>s(t=>({...t,title:e.target.value})),"aria-invalid":c&&!!u.title,"aria-describedby":c&&u.title?`automation-title-error`:void 0}),c&&u.title?(0,L.jsx)(se,{id:`automation-title-error`,children:u.title}):null]}),(0,L.jsxs)(ce,{children:[(0,L.jsx)(ue,{htmlFor:`automation-model`,children:`Model`}),(0,L.jsx)(T,{id:`automation-model`,value:o.model,placeholder:`provider:model-id`,onChange:e=>s(t=>({...t,model:e.target.value})),"aria-invalid":c&&!!u.model,"aria-describedby":m}),(0,L.jsx)(x,{id:`automation-model-description`,children:`Explicit provider and model ID, for example anthropic:claude-sonnet-4-5.`}),c&&u.model?(0,L.jsx)(se,{id:`automation-model-error`,children:u.model}):null]}),(0,L.jsxs)(ce,{children:[(0,L.jsx)(ue,{htmlFor:`automation-cron`,children:`Cron`}),(0,L.jsx)(T,{id:`automation-cron`,value:o.cron,onChange:e=>s(t=>({...t,cron:e.target.value})),"aria-invalid":c&&!!u.cron,"aria-describedby":f}),(0,L.jsx)(x,{id:`automation-cron-description`,children:`Five-field cron, for example 0 9 * * *`}),c&&u.cron?(0,L.jsx)(se,{id:`automation-cron-error`,children:u.cron}):null]}),(0,L.jsxs)(ce,{children:[(0,L.jsx)(ue,{htmlFor:`automation-timezone`,children:`Timezone`}),(0,L.jsx)(T,{id:`automation-timezone`,value:o.timezone,onChange:e=>s(t=>({...t,timezone:e.target.value})),"aria-invalid":c&&!!u.timezone,"aria-describedby":p}),(0,L.jsx)(x,{id:`automation-timezone-description`,children:`IANA timezone, for example UTC or America/New_York.`}),c&&u.timezone?(0,L.jsx)(se,{id:`automation-timezone-error`,children:u.timezone}):null]})]}),(0,L.jsxs)(`label`,{className:`flex w-fit items-center gap-2 rounded-md text-sm text-foreground focus-within:ring-2 focus-within:ring-ring/40`,children:[(0,L.jsx)(Te,{checked:o.enabled,onCheckedChange:e=>s(t=>({...t,enabled:e===!0})),"aria-label":`Automation enabled`}),`Enabled`]}),(0,L.jsxs)(ce,{children:[(0,L.jsx)(ue,{htmlFor:`automation-prompt`,children:`Markdown prompt`}),(0,L.jsx)(_,{id:`automation-prompt`,value:o.prompt,onChange:e=>s(t=>({...t,prompt:e.target.value})),rows:12,spellCheck:!1,className:`min-h-64 resize-y font-mono text-[13px] leading-5`,"aria-describedby":`automation-prompt-description`}),(0,L.jsx)(x,{id:`automation-prompt-description`,children:`Saved through the canonical prompt route; local CLI mode writes the Markdown prompt file.`})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,L.jsx)(Se,{type:`button`,variant:`ghost`,onClick:i,disabled:r,children:`Cancel`}),(0,L.jsx)(Se,{type:`submit`,disabled:r,children:r?`Saving…`:n===`create`?`Create automation`:`Save automation`})]})]})}var P9=class extends Error{code;statusCode;constructor(e,t,n=0){super(t),this.code=e,this.statusCode=n,this.name=`AutomationClientError`}};function VLt(e,t){return`${e?.replace(/\/$/,``)??``}${t}`}function HLt(e){return typeof DOMException<`u`?new DOMException(`Automation request timed out after ${e}ms`,`TimeoutError`):Error(`Automation request timed out after ${e}ms`)}function ULt(e,t){let n=typeof t==`number`&&Number.isFinite(t)&&t>0;if(!e&&!n)return{signal:void 0,cleanup:()=>{},timedOut:()=>!1};let r=new AbortController,i=!1,a,o=()=>r.abort(e?.reason);return e?.aborted?r.abort(e.reason):e?.addEventListener(`abort`,o,{once:!0}),n&&(a=setTimeout(()=>{i=!0,r.abort(HLt(t))},t)),{signal:r.signal,cleanup:()=>{a!==void 0&&clearTimeout(a),e?.removeEventListener(`abort`,o)},timedOut:()=>i}}function WLt(e={}){async function t(t,n={}){let r={...n.body?{"Content-Type":`application/json`}:{},...e.headers??{},...n.headers??{}},i=ULt(n.signal??void 0,e.apiTimeout);try{let a=await fetch(VLt(e.apiBaseUrl,`${dLt}${t}`),{...n,headers:r,signal:i.signal});if(a.status===204)return;let o=await a.json().catch(()=>({}));if(!a.ok||o.ok===!1)throw(a.status===401||a.status===403)&&e.onAuthError?.(a.status),new P9(`code`in o&&typeof o.code==`string`?o.code:`BORING_AUTOMATION_ROUTE_ERROR`,`error`in o&&typeof o.error==`string`?o.error:`Automation request failed`,a.status);return o}catch(t){throw i.timedOut()?new P9(`BORING_AUTOMATION_TIMEOUT`,`Automation request timed out after ${e.apiTimeout}ms`):t}finally{i.cleanup()}}return{async listAutomations(e={}){return(await t(`/automations`,{signal:e.signal})).automations},async createAutomation(e){return(await t(`/automations`,{method:`POST`,body:JSON.stringify(e)})).automation},async getAutomation(e,n={}){return(await t(`/automations/${encodeURIComponent(e)}`,{signal:n.signal})).automation},async updateAutomation(e,n){return(await t(`/automations/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(n)})).automation},async deleteAutomation(e){await t(`/automations/${encodeURIComponent(e)}`,{method:`DELETE`})},async getPrompt(e,n={}){return(await t(`/automations/${encodeURIComponent(e)}/prompt`,{signal:n.signal})).prompt},async updatePrompt(e,n){await t(`/automations/${encodeURIComponent(e)}/prompt`,{method:`PUT`,body:JSON.stringify({prompt:n})})},async runNow(e){return(await t(`/automations/${encodeURIComponent(e)}/run`,{method:`POST`})).run},async listRuns(e,n={}){return(await t(`/automations/${encodeURIComponent(e)}/runs`,{signal:n.signal})).runs}}}var GLt=(0,I.createContext)(null);function KLt({apiBaseUrl:e,authHeaders:t,onAuthError:n,apiTimeout:r,children:i}){let a=(0,I.useMemo)(()=>WLt({apiBaseUrl:e,headers:t,onAuthError:n,apiTimeout:r}),[e,t,n,r]);return(0,L.jsx)(GLt.Provider,{value:a,children:i})}function qLt(){let e=(0,I.useContext)(GLt);if(!e)throw Error(`useAutomationClient must be used within AutomationRuntimeProvider`);return e}function F9(e){return e instanceof P9||e instanceof Error?e.message:`Automation request failed`}function JLt(e,t){return{prompt:e?.prompt??``,promptLoading:e?.promptLoading??!1,runs:e?.runs??[],runsLoading:e?.runsLoading??!1,...t}}function I9(e,t,n){return{...e,[t]:JLt(e[t],n)}}function L9(e,t){let n=(e.current[t]??0)+1;return e.current[t]=n,n}function R9(e,t,n,r){return!r?.aborted&&e.current[t]===n}function YLt(){let e=qLt(),t=RQ(),[n,r]=(0,I.useState)([]),[i,a]=(0,I.useState)({}),[o,s]=(0,I.useState)(null),[c,l]=(0,I.useState)({mode:`closed`}),[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(!0),[h,g]=(0,I.useState)(!1),[_,v]=(0,I.useState)(()=>new Set),[y,b]=(0,I.useState)(null),[x,S]=(0,I.useState)(null),[C,w]=(0,I.useState)(null),T=(0,I.useRef)({}),E=(0,I.useRef)({}),D=(0,I.useMemo)(()=>c.mode===`edit`?n.find(e=>e.id===c.automationId)??null:null,[n,c]),O=(0,I.useCallback)(async t=>{m(!0),b(null);try{let n=await e.listAutomations({signal:t});r(n)}catch(e){if(t?.aborted)return;b(F9(e))}finally{t?.aborted||m(!1)}},[e]),k=(0,I.useCallback)(async(t,n)=>{let r=L9(T,t);a(e=>I9(e,t,{promptLoading:!0}));try{let i=await e.getPrompt(t,{signal:n});if(!R9(T,t,r,n))return;a(e=>I9(e,t,{prompt:i,promptLoading:!1}))}catch(e){if(!R9(T,t,r,n))return;b(F9(e)),a(e=>I9(e,t,{promptLoading:!1}))}},[e]),A=(0,I.useCallback)(async(t,n)=>{let r=L9(E,t);a(e=>I9(e,t,{runsLoading:!0}));try{let i=await e.listRuns(t,{signal:n});if(!R9(E,t,r,n))return;a(e=>I9(e,t,{runs:i,runsLoading:!1}))}catch(e){if(!R9(E,t,r,n))return;b(F9(e)),a(e=>I9(e,t,{runsLoading:!1}))}},[e]);(0,I.useEffect)(()=>{let e=new AbortController;return O(e.signal),()=>e.abort()},[O]);let ee=(0,I.useCallback)(()=>{l({mode:`create`}),w(null),S(null)},[]),te=(0,I.useCallback)(e=>{l({mode:`edit`,automationId:e.id}),w(null),S(null),k(e.id)},[k]),ne=(0,I.useCallback)(e=>{let t=o!==e.id;s(t?e.id:null),S(null),t&&A(e.id)},[o,A]);async function j(t){let n=L9(T,t);a(e=>I9(e,t,{promptLoading:!0}));let[i,o]=await Promise.all([e.getAutomation(t),e.getPrompt(t)]);R9(T,t,n)&&(r(e=>e.map(e=>e.id===i.id?i:e)),a(e=>I9(e,i.id,{prompt:o,promptLoading:!1})))}async function M(t){g(!0),b(null),w(null);try{if(c.mode===`create`){let n=await e.createAutomation(RLt(t));L9(T,n.id),r(e=>[n,...e]),a(e=>I9(e,n.id,{prompt:t.prompt,promptLoading:!1,runs:[],runsLoading:!1})),s(n.id),l({mode:`edit`,automationId:n.id}),w({tone:`success`,message:`Automation created.`});return}if(c.mode===`edit`){let n=c.automationId;L9(T,n),await e.updatePrompt(n,t.prompt),a(e=>I9(e,n,{prompt:t.prompt,promptLoading:!1}));try{let i=await e.updateAutomation(n,zLt(t));r(e=>e.map(e=>e.id===i.id?i:e)),w({tone:`success`,message:`Automation saved.`})}catch(e){try{await j(n),w({tone:`warning`,message:`Prompt saved, but automation metadata was not saved: ${F9(e)}. Refreshed latest server state.`})}catch(t){w({tone:`warning`,message:`Prompt saved, but automation metadata was not saved: ${F9(e)}. Refresh failed: ${F9(t)}`})}}}}catch(e){b(F9(e))}finally{g(!1)}}async function N(t){b(null);try{await e.deleteAutomation(t),r(e=>e.filter(e=>e.id!==t)),a(e=>{let n={...e};return delete n[t],n}),o===t&&s(null),c.mode===`edit`&&c.automationId===t&&l({mode:`closed`}),f(null),w({tone:`success`,message:`Automation deleted.`})}catch(e){b(F9(e))}}async function re(t){if(!_.has(t.id)){v(e=>new Set(e).add(t.id)),b(null),w(null),s(t.id);try{let n=await e.runNow(t.id);a(e=>I9(e,t.id,{runs:[n,...(e[t.id]?.runs??[]).filter(e=>e.id!==n.id)],runsLoading:!1})),w({tone:`success`,message:n.sessionId?`Automation finished. Open its session from run history.`:`Automation finished.`})}catch(e){b(F9(e)),await A(t.id)}finally{v(e=>{let n=new Set(e);return n.delete(t.id),n})}}}function ie(e){if(!e.sessionId)return;let n=t.openDetachedChat(e.sessionId,{title:e.modelSnapshot||`Automation run`});S(n.success?null:n.message)}let ae=D?i[D.id]?.prompt??``:N9().prompt,oe=c.mode===`edit`&&D?i[D.id]?.promptLoading===!0:!1;return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background text-sm text-foreground`,children:[(0,L.jsxs)(`header`,{className:`flex min-h-14 shrink-0 items-center justify-between gap-3 border-b border-border/60 px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`grid size-7 place-items-center rounded-lg bg-[color:oklch(from_var(--accent)_l_c_h/0.14)] text-[color:var(--accent)]`,children:(0,L.jsx)(yr,{className:`size-4`,"aria-hidden":`true`})}),(0,L.jsx)(`h2`,{className:`truncate text-sm font-semibold tracking-tight`,children:C9})]}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Local scheduled prompts with Markdown prompt files and Pi session history.`})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,L.jsxs)(Se,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void O(),disabled:p||c.mode!==`closed`,children:[(0,L.jsx)(Fi,{className:`size-4`,"aria-hidden":`true`}),`Refresh`]}),(0,L.jsxs)(Se,{type:`button`,size:`sm`,onClick:ee,children:[(0,L.jsx)(Mi,{className:`size-4`,"aria-hidden":`true`}),`New`]})]})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto bg-[color:oklch(from_var(--background)_calc(l-0.012)_c_h)]`,children:(0,L.jsxs)(`div`,{className:`mx-auto grid w-full max-w-6xl gap-4 p-4 lg:grid-cols-[minmax(0,1fr)_minmax(360px,440px)]`,children:[(0,L.jsx)(`section`,{className:`min-w-0 overflow-hidden rounded-xl border border-border/70 bg-card/60`,"aria-label":`Automation list`,children:p?(0,L.jsxs)(`div`,{className:`flex min-h-48 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(ot,{className:`size-4`}),` Loading automations…`]}):n.length===0?(0,L.jsx)(lt,{title:`No automations yet`,description:`Create a focused scheduled prompt with cron, timezone, model, and canonical Markdown.`,icon:(0,L.jsx)(yr,{className:`size-8`,"aria-hidden":`true`}),actions:(0,L.jsx)(Se,{type:`button`,onClick:ee,children:`Create automation`}),className:`min-h-64`}):(0,L.jsx)(`div`,{children:n.map(e=>{let t=i[e.id];return(0,L.jsx)(PLt,{automation:e,expanded:o===e.id,deleting:d===e.id,runs:t?.runs??[],runsLoading:t?.runsLoading===!0,runningNow:_.has(e.id),onToggle:()=>ne(e),onEdit:()=>te(e),onRunNow:()=>void re(e),onDeleteRequest:()=>f(e.id),onDeleteCancel:()=>f(null),onDeleteConfirm:()=>void N(e.id),onOpenRun:ie},e.id)})})}),(0,L.jsxs)(`aside`,{className:`min-w-0 rounded-xl border border-border/70 bg-card/80 p-4`,"aria-label":`Automation editor`,children:[y?(0,L.jsx)(u,{tone:`destructive`,className:`mb-3`,role:`alert`,children:y}):null,x?(0,L.jsx)(u,{tone:`destructive`,className:`mb-3`,role:`alert`,children:x}):null,C?(0,L.jsx)(u,{tone:C.tone,className:`mb-3`,role:`status`,children:C.message}):null,c.mode===`closed`?(0,L.jsx)(`div`,{className:`flex min-h-80 items-center justify-center px-4 text-center text-sm text-muted-foreground`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`font-medium text-foreground`,children:`Select an automation to edit`}),(0,L.jsx)(`p`,{className:`mt-1 max-w-xs`,children:`Cards expand for read-only run history. The editor saves metadata and Markdown through separate public routes.`})]})}):c.mode===`create`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`New automation`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Define the schedule and canonical Markdown prompt.`})]}),(0,L.jsx)(BLt,{mode:`create`,prompt:``,saving:h,onCancel:()=>l({mode:`closed`}),onSubmit:e=>void M(e)})]}):D?oe?(0,L.jsxs)(`div`,{className:`flex min-h-80 items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(ot,{className:`size-4`}),` Loading prompt…`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Edit automation`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:D.id})]}),(0,L.jsx)(BLt,{automation:D,mode:`edit`,prompt:ae,saving:h,onCancel:()=>l({mode:`closed`}),onSubmit:e=>void M(e)})]}):(0,L.jsx)(u,{tone:`destructive`,children:`Automation not found.`})]})]})})]})}var XLt=zn({id:S9,label:C9,providers:[{id:`${S9}.runtime`,component:KLt}],panels:[{id:`${S9}.panel`,label:C9,icon:yr,component:YLt,placement:`center`,source:`builtin`}],commands:[{id:`${S9}.open`,title:`Open Automations`,panelId:`${S9}.panel`}]}),ZLt=`diagram`,z9=`diagram.panel`;function QLt(e){let t=e.toLowerCase();return t.endsWith(`.excalidraw`)||t.endsWith(`.excalidraw.png`)}function $Lt(e){return e?e.split(`/`).pop()||e:`Diagram`}function eRt(e){return e.toLowerCase().endsWith(`.excalidraw.png`)?e.replace(/\.png$/i,``):e||`untitled.excalidraw`}function tRt(e){let t=eRt(e);return t.toLowerCase().endsWith(`.excalidraw`)?t.replace(/\.excalidraw$/i,`.render.png`):`${t}.render.png`}var nRt=(0,I.lazy)(async()=>({default:(await P(()=>import(`./DiagramPane-Vzg5nzB5.js`),__vite__mapDeps([286,1,282,285,284,207,287,288,289,290,291]))).DiagramPane}));function rRt(e){return(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading Diagram…`}),children:(0,L.jsx)(nRt,{...e})})}var iRt=zn({id:ZLt,label:`Diagram`,panels:[{id:z9,label:`Diagram`,component:rRt}],commands:[{id:`diagram.open`,title:`Open Diagram`,panelId:z9}],surfaceResolvers:[{id:`diagram.open-file`,kind:iB,resolve:e=>{if(e.kind!==`workspace.open.path`||!QLt(e.target))return null;let t=typeof e.filesystem==`string`&&e.filesystem?e.filesystem:void 0;return{id:`diagram:${encodeURIComponent(t??`user`)}:${encodeURIComponent(e.target)}`,component:z9,title:$Lt(e.target),params:{path:e.target,...t?{filesystem:t}:{}},score:1e3}}}]}),aRt=`tasks`,oRt=`Tasks`,B9=`/api/boring-tasks`;async function sRt(e){try{let t=await e.json(),n=t.error??t.message;if(typeof n==`string`&&n.length>0)return n}catch{}return`${e.status} ${e.statusText}`.trim()}async function cRt(e,t){let n=await fetch(`${B9}${e}`,{credentials:`include`,...t,headers:{...t?.body?{"Content-Type":`application/json`}:{},...t?.headers}});if(!n.ok)throw Error(await sRt(n));return await n.json()}function lRt(e,t){return e?e.getJson(`${B9}${t}`):cRt(t)}function V9(e,t,n){return e?e.postJson(`${B9}${t}`,n):cRt(t,{method:`POST`,body:JSON.stringify(n)})}async function uRt(e){return(await lRt(e,`/sources`)).sources??[]}function dRt(e,t){return{...e,async getBoardConfig(){let n=(await V9(t,`/sources/tasks/list`,{sourceIds:[e.id]})).configs?.[e.id];if(!n)throw Error(`Task source did not return board config: ${e.id}`);return n},async listTasks(){return(await V9(t,`/sources/tasks/list`,{sourceIds:[e.id]})).tasks??[]},moveTask:e.capabilities.move?async({taskId:n,statusId:r})=>{let i=await V9(t,`/sources/tasks/move`,{sourceId:e.id,taskId:n,statusId:r});if(!i.task)throw Error(`Task source did not return moved task: ${e.id}`);return i.task}:void 0,deleteTask:e.capabilities.delete?async({taskId:n})=>{await V9(t,`/sources/tasks/delete`,{sourceId:e.id,taskId:n})}:void 0}}var fRt=`__unmapped__`;function pRt(e,t){let n=new Set(e.columns.map(e=>e.id)),r=e.columns.map(e=>({...e,tasks:[]})),i=new Map(r.map(e=>[e.id,e])),a=[];for(let e of t){let t=i.get(e.statusId);t?t.tasks.push(e):a.push(e)}return a.length>0&&r.push({id:fRt,title:`Unmapped`,description:`Tasks whose adapter status is not in this board config`,acceptsDrop:!1,tasks:a,unmapped:!0}),r.filter(e=>e.tasks.length>0||n.has(e.id))}function mRt(e){return e.id!==fRt&&e.acceptsDrop!==!1}function hRt({className:e}){return(0,L.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M14 5h5v5M19 5l-9 9`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,L.jsx)(`path`,{d:`M11 6H7a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-4`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`})]})}function gRt(e){let t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height,top:t.top,right:t.right,bottom:t.bottom,left:t.left}}function _Rt(e){return[`Let's work on ${e.number}: ${e.title}`,``,`Task ID: ${e.number}`,`Status: ${e.statusId}`,e.url?`URL: ${e.url}`:null].filter(Boolean).join(`
868
868
  `)}function vRt({task:e,draggable:t,unmapped:n=!1,deleteEnabled:r=!1,compact:i=!1,onDelete:a,onDragStart:o,onDragEnd:s}){let[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!1),f=RQ(),p=va(),m=e.tags?.slice(0,4)??[],h=Math.max((e.tags?.length??0)-m.length,0),g=e.pullRequests?.slice(0,2)??[],_=Math.max((e.pullRequests?.length??0)-g.length,0),v=e=>e.stopPropagation(),y=t=>{v(t);let n=gRt(t.currentTarget),r=`${e.number}: ${e.title}`;d(!0),p.postJson(`/api/v1/agent/pi-chat/sessions`,{title:r}).then(t=>{if(typeof t.id!=`string`||t.id.length===0)throw Error(`Chat session was not created.`);let i=_Rt(e);f.openDetachedChat(t.id,{anchor:n,title:r,initialDraft:i,composingEnabled:!0}),window.dispatchEvent(new CustomEvent(`boring-workspace:open-detached-chat`,{detail:{sessionId:t.id,title:r,initialDraft:i,composingEnabled:!0}}))}).catch(e=>console.error(`Failed to open task chat`,e)).finally(()=>d(!1))},b=t=>{v(t),l(!1),a?.(e)};return i?(0,L.jsxs)(`article`,{draggable:t,onDragStart:t=>o(t,e),onDragEnd:s,className:[`group flex min-w-0 items-center gap-2 rounded-xl border bg-background px-3 py-2 shadow-sm transition`,t?`cursor-grab hover:border-foreground/30 hover:shadow-md active:cursor-grabbing`:`cursor-default`,n?`border-dashed border-amber-400/60 bg-amber-500/5`:`border-border`].join(` `),"data-task-id":e.id,children:[(0,L.jsx)(`span`,{className:`shrink-0 rounded-full border border-border bg-muted/50 px-2 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.number}),(0,L.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,title:e.title,children:e.title}),e.epic?(0,L.jsx)(`span`,{className:`hidden max-w-36 shrink-0 truncate rounded-full border border-primary/20 bg-primary/10 px-2 py-0.5 text-[10px] font-medium text-primary sm:inline-block`,children:e.epic.title}):null,m.slice(0,2).map(e=>(0,L.jsx)(`span`,{className:`hidden max-w-28 shrink-0 truncate rounded-full border border-border bg-muted/30 px-2 py-0.5 text-[10px] font-medium text-muted-foreground md:inline-block`,children:e},e)),g.slice(0,1).map(e=>e.url?(0,L.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,draggable:!1,onClick:e=>e.stopPropagation(),className:`hidden max-w-64 shrink-0 truncate rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-semibold text-emerald-700 hover:bg-emerald-500/15 dark:text-emerald-300 lg:inline-block`,title:e.title,"aria-label":`Open pull request ${e.number}: ${e.title}`,children:[`PR `,e.number,` `,(0,L.jsx)(`span`,{className:`font-medium`,children:e.title})]},e.id):(0,L.jsxs)(`span`,{className:`hidden max-w-64 shrink-0 truncate rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-semibold text-emerald-700 dark:text-emerald-300 lg:inline-block`,title:e.title,children:[`PR `,e.number,` `,(0,L.jsx)(`span`,{className:`font-medium`,children:e.title})]},e.id)),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,L.jsx)(`button`,{type:`button`,draggable:!1,onClick:y,className:`grid size-7 place-items-center rounded-lg text-muted-foreground opacity-80 hover:bg-muted hover:text-foreground group-hover:opacity-100`,"aria-label":`Open chat for ${e.number}`,title:`Open task chat`,disabled:u,children:(0,L.jsx)(gi,{className:[`size-3.5`,u?`animate-pulse`:``].join(` `),strokeWidth:1.75})}),e.url?(0,L.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,draggable:!1,onClick:e=>e.stopPropagation(),className:`grid size-7 place-items-center rounded-lg text-muted-foreground opacity-80 hover:bg-muted hover:text-foreground group-hover:opacity-100`,"aria-label":`Open ${e.number} in native task system`,title:`Open in native task system`,children:(0,L.jsx)(hRt,{className:`size-3.5`})}):null,(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`button`,{type:`button`,draggable:!1,onClick:e=>{v(e),l(e=>!e)},className:`grid size-7 place-items-center rounded-lg text-muted-foreground opacity-80 hover:bg-muted hover:text-foreground group-hover:opacity-100`,"aria-label":`Open actions for ${e.number}`,"aria-expanded":c,title:`Task actions`,children:(0,L.jsx)(Rr,{className:`size-3.5`,strokeWidth:1.75})}),c?(0,L.jsx)(`div`,{className:`absolute right-0 z-30 mt-1 w-40 overflow-hidden rounded-xl border border-border bg-popover p-1 text-sm text-popover-foreground shadow-xl`,children:(0,L.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-destructive hover:bg-destructive/10 disabled:cursor-not-allowed disabled:opacity-50`,disabled:!r,onClick:b,title:r?`Delete issue`:`This task source cannot delete issues`,children:[(0,L.jsx)(Ji,{className:`size-3.5`,strokeWidth:1.75}),`Delete issue`]})}):null]})]})]}):(0,L.jsxs)(`article`,{draggable:t,onDragStart:t=>o(t,e),onDragEnd:s,className:[`group rounded-xl border bg-background p-3 shadow-sm transition`,t?`cursor-grab hover:-translate-y-0.5 hover:border-foreground/30 hover:shadow-md active:cursor-grabbing`:`cursor-default`,n?`border-dashed border-amber-400/60 bg-amber-500/5`:`border-border`].join(` `),"data-task-id":e.id,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(`span`,{className:`mt-0.5 shrink-0 rounded-full border border-border bg-muted/50 px-2 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.number}),(0,L.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm font-semibold leading-snug text-foreground`,title:e.title,children:e.title}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,L.jsx)(`button`,{type:`button`,draggable:!1,onClick:y,className:`grid size-7 place-items-center rounded-lg text-muted-foreground opacity-80 hover:bg-muted hover:text-foreground group-hover:opacity-100`,"aria-label":`Open chat for ${e.number}`,title:`Open task chat`,disabled:u,children:(0,L.jsx)(gi,{className:[`size-3.5`,u?`animate-pulse`:``].join(` `),strokeWidth:1.75})}),e.url?(0,L.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,draggable:!1,onClick:e=>e.stopPropagation(),className:`grid size-7 place-items-center rounded-lg text-muted-foreground opacity-80 hover:bg-muted hover:text-foreground group-hover:opacity-100`,"aria-label":`Open ${e.number} in native task system`,title:`Open in native task system`,children:(0,L.jsx)(hRt,{className:`size-3.5`})}):null,(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`button`,{type:`button`,draggable:!1,onClick:e=>{v(e),l(e=>!e)},className:`grid size-7 place-items-center rounded-lg text-muted-foreground opacity-80 hover:bg-muted hover:text-foreground group-hover:opacity-100`,"aria-label":`Open actions for ${e.number}`,"aria-expanded":c,title:`Task actions`,children:(0,L.jsx)(Rr,{className:`size-3.5`,strokeWidth:1.75})}),c?(0,L.jsx)(`div`,{className:`absolute right-0 z-30 mt-1 w-40 overflow-hidden rounded-xl border border-border bg-popover p-1 text-sm text-popover-foreground shadow-xl`,children:(0,L.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-destructive hover:bg-destructive/10 disabled:cursor-not-allowed disabled:opacity-50`,disabled:!r,onClick:b,title:r?`Delete issue`:`This task source cannot delete issues`,children:[(0,L.jsx)(Ji,{className:`size-3.5`,strokeWidth:1.75}),`Delete issue`]})}):null]})]})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[n?(0,L.jsx)(`span`,{className:`rounded-full border border-amber-400/50 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-amber-600 dark:text-amber-300`,children:`Unmapped`}):null,e.epic?(0,L.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/10 px-2 py-0.5 text-[10px] font-medium text-primary`,children:e.epic.title}):null,m.map(e=>(0,L.jsx)(`span`,{className:`rounded-full border border-border bg-muted/30 px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,children:e},e)),h>0?(0,L.jsxs)(`span`,{className:`rounded-full border border-border bg-muted/30 px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,children:[`+`,h]}):null]}),g.length>0?(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 border-t border-border/60 pt-2`,children:[g.map(e=>e.url?(0,L.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,draggable:!1,onClick:e=>e.stopPropagation(),className:`inline-flex max-w-full items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-semibold text-emerald-700 hover:bg-emerald-500/15 dark:text-emerald-300`,title:e.title,"aria-label":`Open pull request ${e.number}: ${e.title}`,children:[(0,L.jsxs)(`span`,{className:`shrink-0`,children:[`PR `,e.number]}),(0,L.jsx)(`span`,{className:`truncate font-medium`,children:e.title})]},e.id):(0,L.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-semibold text-emerald-700 dark:text-emerald-300`,title:e.title,children:[(0,L.jsxs)(`span`,{className:`shrink-0`,children:[`PR `,e.number]}),(0,L.jsx)(`span`,{className:`truncate font-medium`,children:e.title})]},e.id)),_>0?(0,L.jsxs)(`span`,{className:`rounded-full border border-border bg-muted/30 px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,children:[`+`,_,` PR`]}):null]}):null]})}function yRt({column:e,moveEnabled:t,activeTaskRef:n,onTaskDragStart:r,onTaskDragEnd:i,onTaskDrop:a,onTaskDelete:o,canDragTask:s=()=>t,canDeleteTask:c=()=>!1}){let l=t&&mRt(e),u=e=>{let t=Array.from(e.dataTransfer.types);return t.includes(`application/x-boring-task-ref`)||t.includes(`application/x-boring-task-id`)};return(0,L.jsxs)(`section`,{className:[`flex min-h-0 w-72 shrink-0 flex-col rounded-2xl border bg-muted/20`,e.unmapped?`border-dashed border-amber-400/50`:`border-border/80`].join(` `),onDragOver:e=>{!l||!u(e)||(e.preventDefault(),e.dataTransfer.dropEffect=`move`)},onDrop:t=>{if(!l||!u(t))return;t.preventDefault();let r=t.dataTransfer.getData(`application/x-boring-task-ref`),i=t.dataTransfer.getData(`application/x-boring-task-id`),o;try{o=r?JSON.parse(r):void 0}catch{o=void 0}let s=typeof o?.taskId==`string`?o.taskId:i||n?.taskId,c=typeof o?.adapterId==`string`?o.adapterId:n?.adapterId;s&&c&&a(s,c,e.id)},"aria-label":`${e.title} column`,children:[(0,L.jsxs)(`header`,{className:`border-b border-border/70 p-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h2`,{className:`truncate text-sm font-semibold text-foreground`,children:e.title}),e.description?(0,L.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] leading-4 text-muted-foreground`,children:e.description}):null]}),(0,L.jsx)(`span`,{className:`rounded-full border border-border bg-background px-2 py-0.5 text-xs tabular-nums text-muted-foreground`,children:e.tasks.length})]}),e.color?(0,L.jsx)(`div`,{className:`mt-3 h-1 rounded-full`,style:{backgroundColor:e.color}}):null]}),(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-2`,children:e.tasks.length===0?(0,L.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/80 p-3 text-center text-xs text-muted-foreground`,children:`Drop tasks here`}):e.tasks.map(t=>(0,L.jsx)(vRt,{task:t,draggable:!e.unmapped&&s(t),unmapped:e.unmapped,deleteEnabled:c(t),onDelete:o,onDragStart:r,onDragEnd:i},`${t.adapterId}:${t.id}`))})]})}var bRt=120*1e3;function xRt(e,t){return t===e.length?`All sources`:t===1?e.find(e=>e.id)?.description??`1 source`:`${t} sources`}function SRt(e){return[...new Set(e.flatMap(e=>e.tags??[]))].sort((e,t)=>e.localeCompare(t))}function CRt(e){let t=new Map;for(let n of e){if(!n.epic)continue;let e=`${n.adapterId}:${n.epic.id}`;t.has(e)||t.set(e,{id:e,title:n.epic.title})}return[...t.values()].sort((e,t)=>e.title.localeCompare(t.title))}function wRt(e){return e.epic?`${e.adapterId}:${e.epic.id}`:void 0}function TRt(e,t){let n=new Map;for(let r of e)for(let e of r.columns)!t.has(e.id)||n.has(e.id)||n.set(e.id,e);return[...n.values()]}function ERt(e){if(typeof window>`u`)return null;try{let t=window.localStorage.getItem(e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!=`object`||!n.configs||!Array.isArray(n.tasks)?null:{configs:n.configs,tasks:n.tasks,cachedAt:typeof n.cachedAt==`number`?n.cachedAt:0}}catch{return null}}function DRt(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,JSON.stringify({...t,cachedAt:Date.now()}))}catch{}}function ORt(e){if(typeof window>`u`)return`kanban`;try{return window.localStorage.getItem(`${e}:view`)===`list`?`list`:`kanban`}catch{return`kanban`}}function kRt(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(`${e}:view`,t)}catch{}}function ARt({adapters:e}){let t=(0,I.useMemo)(()=>e.map(e=>e.id),[e]),n=(0,I.useMemo)(()=>`boring-tasks:board-cache:v1:${t.join(`|`)}`,[t]),r=(0,I.useMemo)(()=>ERt(n),[n]),i=(0,I.useMemo)(()=>r?new Set(Object.values(r.configs).flatMap(e=>e.columns.map(e=>e.id))):new Set,[r]),[a,o]=(0,I.useState)(()=>new Set(t)),[s,c]=(0,I.useState)(()=>r?{configs:r.configs,tasks:r.tasks}:null),[l,u]=(0,I.useState)(i),[d,f]=(0,I.useState)(`all`),[p,m]=(0,I.useState)(`all`),[h,g]=(0,I.useState)(!r),[_,v]=(0,I.useState)(null),[y,b]=(0,I.useState)(null),[x,S]=(0,I.useState)(null),[C,w]=(0,I.useState)(null),[T,E]=(0,I.useState)(null),[D,O]=(0,I.useState)(()=>ORt(n)),[k,A]=(0,I.useState)(new Set),ee=(0,I.useRef)(0),te=(0,I.useRef)(null),ne=(0,I.useMemo)(()=>new Map(e.map(e=>[e.id,e])),[e]),j=e=>{O(e),kRt(n,e)};(0,I.useEffect)(()=>{o(e=>{let n=new Set([...e].filter(e=>ne.has(e)));if(n.size===0)for(let e of t)n.add(e);return n})},[ne,t]);let M=(0,I.useCallback)(async(t={})=>{if(e.length===0){c(null),g(!1),v(`No task adapters are registered.`);return}let r=ERt(n),i=r&&Date.now()-r.cachedAt<bRt;if(r&&!t.force){let e=new Set(Object.values(r.configs).flatMap(e=>e.columns.map(e=>e.id)));if(c({configs:r.configs,tasks:r.tasks}),u(t=>t.size>0?t:e),i){g(!1),v(null);return}}let a=ee.current+1;ee.current=a,g(!0),v(null);try{let t=await Promise.all(e.map(async e=>{let[t,n]=await Promise.all([e.getBoardConfig(),e.listTasks()]);return{adapterId:e.id,config:t,tasks:n}}));if(ee.current!==a)return;let r=Object.fromEntries(t.map(e=>[e.adapterId,e.config])),i=t.flatMap(e=>e.tasks),o=new Set(t.flatMap(e=>e.config.columns.map(e=>e.id))),s={configs:r,tasks:i};c(s),DRt(n,s),u(o),f(`all`),m(`all`)}catch(e){ee.current===a&&(v(e instanceof Error?e.message:String(e)),c(e=>e??null))}finally{ee.current===a&&g(!1)}},[e,n]);(0,I.useEffect)(()=>{M()},[M]),(0,I.useEffect)(()=>{let e=e=>{te.current?.contains(e.target)||E(null)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[]);let N=(0,I.useMemo)(()=>s?s.tasks.filter(e=>a.has(e.adapterId)):[],[a,s]),re=(0,I.useMemo)(()=>SRt(N),[N]),ie=(0,I.useMemo)(()=>CRt(N),[N]),ae=(0,I.useMemo)(()=>s?[...a].map(e=>s.configs[e]).filter(e=>!!e):[],[a,s]),oe=(0,I.useMemo)(()=>TRt(ae,new Set(ae.flatMap(e=>e.columns.map(e=>e.id)))),[ae]),se=(0,I.useMemo)(()=>{let e=new Set(oe.map(e=>e.id));return N.filter(t=>d!==`all`&&!(t.tags??[]).includes(d)||p!==`all`&&wRt(t)!==p?!1:!e.has(t.statusId)||l.has(t.statusId))},[oe,p,N,d,l]),ce=(0,I.useMemo)(()=>s?{adapterId:`combined`,columns:TRt(ae,l)}:null,[ae,s,l]),le=(0,I.useMemo)(()=>ce?pRt(ce,se):[],[se,ce]),ue=(e,t)=>{b({taskId:t.id,adapterId:t.adapterId}),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`application/x-boring-task-ref`,JSON.stringify({taskId:t.id,adapterId:t.adapterId})),e.dataTransfer.setData(`application/x-boring-task-id`,t.id),e.dataTransfer.setData(`text/plain`,t.number)},de=async(e,t,n)=>{if(!s)return;let r=s.tasks.find(n=>n.id===e&&n.adapterId===t);if(!r||r.statusId===n){b(null);return}let i=ne.get(r.adapterId);if(!i?.capabilities.move||!i.moveTask){b(null);return}let o=s.tasks,l=r.adapterId;S(e),v(null),c(r=>r&&{...r,tasks:r.tasks.map(r=>r.id===e&&r.adapterId===t?{...r,statusId:n}:r)});try{let r=await i.moveTask({taskId:e,statusId:n});c(n=>n&&{...n,tasks:n.tasks.map(n=>n.id===e&&n.adapterId===t?r:n)})}catch(e){c(e=>e&&{...e,tasks:o}),a.has(l)&&v(e instanceof Error?e.message:String(e))}finally{S(null),b(null)}},fe=async e=>{let t=ne.get(e.adapterId);if(!t?.capabilities.delete||!t.deleteTask){v(`Task source does not support issue deletion: ${e.adapterId}`);return}let n=s?.tasks??[];w(e.id),v(null),c(t=>t&&{...t,tasks:t.tasks.filter(t=>!(t.id===e.id&&t.adapterId===e.adapterId))});try{await t.deleteTask({taskId:e.id})}catch(t){c(e=>e&&{...e,tasks:n}),a.has(e.adapterId)&&v(t instanceof Error?t.message:String(t))}finally{w(null)}},pe=e=>{u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},me=e=>{o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n.size===0?t:n})},he=()=>{u(new Set(oe.map(e=>e.id)))},ge=()=>{o(new Set(t))},_e=e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ve=a.size,ye=l.size,be=oe.length;return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-3`,children:[(0,L.jsxs)(`div`,{ref:te,className:`flex flex-wrap items-center gap-2 rounded-xl border border-border bg-card/70 p-2 shadow-sm`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex h-8 items-center rounded-lg border border-border bg-background px-3 text-sm font-medium text-foreground shadow-sm hover:bg-muted`,onClick:()=>E(e=>e===`sources`?null:`sources`),"aria-expanded":T===`sources`,children:[`Sources `,ve,`/`,e.length]}),T===`sources`?(0,L.jsxs)(`div`,{className:`absolute left-0 z-20 mt-2 w-72 rounded-xl border border-border bg-popover p-2 text-sm text-popover-foreground shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 border-b border-border pb-2`,children:[(0,L.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Task sources`}),(0,L.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-primary hover:underline`,onClick:ge,children:`All`})]}),(0,L.jsx)(`div`,{className:`flex max-h-72 flex-col gap-1 overflow-y-auto`,children:e.map(e=>(0,L.jsxs)(`label`,{className:`flex items-start gap-2 rounded-lg px-2 py-1.5 hover:bg-muted/70`,children:[(0,L.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:a.has(e.id),onChange:()=>me(e.id)}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:`block truncate font-medium text-foreground`,children:e.label}),(0,L.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.description??e.id})]})]},e.id))})]}):null]}),(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[`Tag`,(0,L.jsxs)(`select`,{className:`h-8 rounded-lg border border-border bg-background px-2 text-sm text-foreground shadow-sm outline-none focus:border-foreground/40`,value:d,onChange:e=>f(e.target.value),children:[(0,L.jsx)(`option`,{value:`all`,children:`All tags`}),re.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))]})]}),(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[`Epic`,(0,L.jsxs)(`select`,{className:`h-8 rounded-lg border border-border bg-background px-2 text-sm text-foreground shadow-sm outline-none focus:border-foreground/40`,value:p,onChange:e=>m(e.target.value),children:[(0,L.jsx)(`option`,{value:`all`,children:`All epics`}),ie.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex h-8 items-center rounded-lg border border-border bg-background px-3 text-sm font-medium text-foreground shadow-sm hover:bg-muted`,onClick:()=>E(e=>e===`columns`?null:`columns`),"aria-expanded":T===`columns`,children:[`Columns `,ye,`/`,be]}),T===`columns`?(0,L.jsxs)(`div`,{className:`absolute left-0 z-20 mt-2 w-64 rounded-xl border border-border bg-popover p-2 text-sm text-popover-foreground shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 border-b border-border pb-2`,children:[(0,L.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Visible columns`}),(0,L.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-primary hover:underline`,onClick:he,children:`All`})]}),(0,L.jsx)(`div`,{className:`flex max-h-72 flex-col gap-1 overflow-y-auto`,children:oe.map(e=>(0,L.jsxs)(`label`,{className:`flex items-start gap-2 rounded-lg px-2 py-1.5 hover:bg-muted/70`,children:[(0,L.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:l.has(e.id),onChange:()=>pe(e.id)}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:`block truncate font-medium text-foreground`,children:e.title}),e.description?(0,L.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.description}):null]})]},e.id))})]}):null]}),(0,L.jsx)(`button`,{type:`button`,className:`h-8 rounded-lg border border-border bg-background px-3 text-sm font-medium text-foreground shadow-sm hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void M({force:!0}),disabled:h,children:h?`Refreshing…`:`Refresh`}),(0,L.jsxs)(`div`,{className:`inline-flex h-8 overflow-hidden rounded-lg border border-border bg-background shadow-sm`,"aria-label":`Task view mode`,children:[(0,L.jsx)(`button`,{type:`button`,className:[`grid w-8 place-items-center`,D===`kanban`?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/70 hover:text-foreground`].join(` `),onClick:()=>j(`kanban`),"aria-label":`Show kanban view`,title:`Kanban view`,children:(0,L.jsx)(Pr,{className:`size-3.5`,strokeWidth:1.75})}),(0,L.jsx)(`button`,{type:`button`,className:[`grid w-8 place-items-center`,D===`list`?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/70 hover:text-foreground`].join(` `),onClick:()=>j(`list`),"aria-label":`Show list view`,title:`List view`,children:(0,L.jsx)(ui,{className:`size-3.5`,strokeWidth:1.75})})]}),(0,L.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`rounded-full border border-border bg-muted/40 px-2 py-1`,children:xRt(e,ve)}),x?(0,L.jsx)(`span`,{className:`rounded-full border border-border bg-muted/40 px-2 py-1`,children:`Moving…`}):null,C?(0,L.jsx)(`span`,{className:`rounded-full border border-border bg-muted/40 px-2 py-1`,children:`Deleting…`}):null]})]}),_?(0,L.jsx)(`div`,{className:`rounded-xl border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:_}):null,(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:h&&!s?(0,L.jsx)(`div`,{className:`grid h-full place-items-center rounded-2xl border border-dashed border-border text-sm text-muted-foreground`,children:`Loading task board…`}):le.length===0?(0,L.jsx)(`div`,{className:`grid h-full place-items-center rounded-2xl border border-dashed border-border text-sm text-muted-foreground`,children:`No tasks match the current filters.`}):D===`list`?(0,L.jsx)(`div`,{className:`boring-scrollbar-discreet flex h-full flex-col gap-3 overflow-y-auto pr-1`,children:le.map(e=>{let t=k.has(e.id);return(0,L.jsxs)(`section`,{className:[`rounded-2xl border bg-muted/20`,e.unmapped?`border-dashed border-amber-400/50`:`border-border/80`].join(` `),children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 border-b border-border/70 p-3 text-left hover:bg-muted/50`,onClick:()=>_e(e.id),"aria-expanded":!t,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2`,children:[e.color?(0,L.jsx)(`span`,{className:`mt-1.5 h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color},"aria-hidden":`true`}):null,(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsxs)(`span`,{className:`block truncate text-sm font-semibold text-foreground`,children:[t?`▸`:`▾`,` `,e.title]}),e.description?(0,L.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-[11px] leading-4 text-muted-foreground`,children:e.description}):null]})]}),(0,L.jsx)(`span`,{className:`shrink-0 rounded-full border border-border bg-background px-2 py-0.5 text-xs tabular-nums text-muted-foreground`,children:e.tasks.length})]}),t?null:(0,L.jsx)(`div`,{className:`flex flex-col gap-2 p-2`,children:e.tasks.length===0?(0,L.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/80 p-3 text-center text-xs text-muted-foreground`,children:`No tasks`}):e.tasks.map(t=>(0,L.jsx)(vRt,{task:t,draggable:!1,unmapped:e.unmapped,compact:!0,deleteEnabled:!!(ne.get(t.adapterId)?.capabilities.delete&&ne.get(t.adapterId)?.deleteTask),onDelete:e=>void fe(e),onDragStart:ue,onDragEnd:()=>b(null)},`${t.adapterId}:${t.id}`))})]},e.id)})}):(0,L.jsx)(`div`,{className:`flex h-full gap-3 overflow-x-auto pb-2`,children:le.map(e=>(0,L.jsx)(yRt,{column:e,moveEnabled:!0,activeTaskRef:y,onTaskDragStart:ue,onTaskDragEnd:()=>b(null),onTaskDrop:(e,t,n)=>void de(e,t,n),onTaskDelete:e=>void fe(e),canDragTask:e=>!!(ne.get(e.adapterId)?.capabilities.move&&ne.get(e.adapterId)?.moveTask),canDeleteTask:e=>!!(ne.get(e.adapterId)?.capabilities.delete&&ne.get(e.adapterId)?.deleteTask)},e.id))})})]})}function jRt({className:e}){return(0,L.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M7 7h10M7 12h10M7 17h6`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`}),(0,L.jsx)(`path`,{d:`M4.75 6.9l.45.45 1.05-1.2M4.75 11.9l.45.45 1.05-1.2M4.75 16.9l.45.45 1.05-1.2`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function MRt({onClose:e}){let{headerInsetStart:t,headerInsetEnd:n}=LQ(),r=va(),[i,a]=(0,I.useState)(null);(0,I.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await uRt(r);e||a(t.map(e=>dRt(e,r)))}catch{e||a([])}})(),()=>{e=!0}},[r]);let o=(0,I.useMemo)(()=>i===null?null:i,[i]);return(0,L.jsxs)(`div`,{"data-boring-workspace-part":`tasks-overlay`,className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,L.jsxs)(`header`,{className:[`flex h-12 shrink-0 items-center justify-between border-b border-border/60`,t?`pl-12`:`pl-4`,n?`pr-16`:`pr-4`].join(` `),children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`grid size-7 place-items-center rounded-lg bg-primary/10 text-primary`,children:(0,L.jsx)(jRt,{className:`size-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h2`,{className:`truncate text-sm font-semibold tracking-tight text-foreground`,children:`Tasks`}),(0,L.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:`Adapter-mapped Kanban board`})]})]}),(0,L.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:e,"aria-label":`Close tasks`,title:`Close`,className:`text-muted-foreground hover:text-foreground`,children:(0,L.jsx)(ea,{className:`size-3`,strokeWidth:1.75})})})]}),o?(0,L.jsx)(ARt,{adapters:o}):(0,L.jsx)(`div`,{className:`grid min-h-0 flex-1 place-items-center p-4 text-sm text-muted-foreground`,children:`Loading task sources…`})]})}function NRt(){return zn({id:aRt,label:oRt,appLeftActions:[{id:`tasks`,label:oRt,icon:jRt,overlay:MRt,order:40}]})}NRt();function PRt({part:e,icon:t,title:n,description:r,actions:i,headerInsetStart:a=!1,headerInsetEnd:o=!1,children:s}){return(0,L.jsxs)(`div`,{"data-boring-workspace-part":e,className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,L.jsxs)(`header`,{className:DU(`flex h-12 shrink-0 items-center justify-between border-b border-border/60`,a?`pl-12`:`pl-4`,o?`pr-16`:`pr-4`),children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[t,(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h2`,{className:`truncate text-sm font-semibold tracking-tight text-foreground`,children:n}),(0,L.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:r})]})]}),i?(0,L.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:i}):null]}),s]})}function FRt({onClose:e,headerInsetStart:t=!1,headerInsetEnd:n=!1}){let r=va(),[i,a]=(0,I.useState)({status:`loading`,skills:[]}),o=(0,I.useCallback)(e=>{e.filePath&&dc({kind:`openFile`,params:{path:e.filePath,mode:`view`}})},[]),s=(0,I.useCallback)(async(e=!1)=>{a(e=>({status:`loading`,skills:e.skills}));try{let t=await r.getJson(`/api/v1/agent/skills${e?`?refresh=1`:``}`,{missingMessage:`Failed to load workspace skills.`}),n=Array.isArray(t.skills)?t.skills.filter(e=>typeof e?.name==`string`&&e.name.length>0):[];a({status:`ready`,skills:n})}catch(e){a(t=>({status:`error`,skills:t.skills,error:e instanceof Error?e.message:`Failed to load workspace skills.`}))}},[r]);(0,I.useEffect)(()=>{s(!1)},[s]);let c=(0,I.useMemo)(()=>[...i.skills].sort((e,t)=>e.name.localeCompare(t.name)),[i.skills]);return(0,L.jsx)(PRt,{part:`skills-page`,title:`Skills`,description:`Workspace skills available to slash commands`,headerInsetStart:t,headerInsetEnd:n,icon:(0,L.jsx)(`span`,{className:`grid size-7 place-items-center rounded-lg bg-[color:oklch(from_var(--accent)_l_c_h/0.12)] text-[color:var(--accent)]`,children:(0,L.jsx)(Ri,{className:`h-4 w-4`,strokeWidth:1.75,"aria-hidden":`true`})}),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:()=>void s(!0),disabled:i.status===`loading`,"aria-label":`Refresh skills`,title:`Refresh skills`,className:`text-muted-foreground hover:text-foreground`,children:(0,L.jsx)(Fi,{className:DU(`size-3`,i.status===`loading`&&`animate-spin`),strokeWidth:1.75})}),e?(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:e,"aria-label":`Close skills`,title:`Close`,className:`text-muted-foreground hover:text-foreground`,children:(0,L.jsx)(ea,{className:`size-3`,strokeWidth:1.75})}):null]}),children:(0,L.jsxs)(`div`,{className:`boring-scrollbar-discreet min-h-0 flex-1 overflow-y-auto p-4`,"aria-live":`polite`,children:[i.status===`error`?(0,L.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/30 bg-destructive/8 px-3 py-2 text-sm text-destructive`,children:i.error}):null,i.status===`loading`&&c.length===0?(0,L.jsx)(`div`,{className:`flex h-full min-h-[180px] items-center justify-center text-sm text-muted-foreground`,children:`Loading skills…`}):c.length===0?(0,L.jsx)(`div`,{className:`flex h-full min-h-[180px] items-center justify-center text-center text-sm text-muted-foreground`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`font-medium text-foreground/80`,children:`No skills found`}),(0,L.jsx)(`p`,{className:`mt-1 max-w-xs`,children:`Reload plugins or add workspace skills to make them available in chat.`})]})}):(0,L.jsx)(`ul`,{role:`list`,className:`grid gap-2`,children:c.map(e=>(0,L.jsx)(`li`,{className:`rounded-xl border border-border/60 bg-card/70 px-3 py-2.5 cursor-pointer transition-colors hover:border-border hover:bg-muted/60`,children:(0,L.jsx)(`button`,{type:`button`,onClick:()=>o(e),title:`Open skill`,"aria-label":`Open skill ${e.name} in workspace`,className:`block w-full text-left`,children:(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:[`/`,e.name]}),e.description?(0,L.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-muted-foreground`,children:e.description}):null]}),(0,L.jsx)(Gr,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`,strokeWidth:1.75,"aria-hidden":`true`})]})})},e.name))})]})})}var IRt={width:520,height:720},H9=16;function LRt(e,t,n){return Math.max(t,Math.min(n,e))}function U9(e,t){if(typeof window>`u`)return e;let n=Math.max(H9,window.innerWidth-t.width-H9),r=Math.max(H9,window.innerHeight-t.height-H9);return{left:LRt(e.left,H9,n),top:LRt(e.top,H9,r)}}function RRt(e,t={}){let n={...IRt,...t},[r,i]=(0,I.useState)(()=>U9(e,n)),a=(0,I.useRef)(null),o=(0,I.useCallback)(()=>{a.current&&(a.current=null,document.body.style.cursor=``,document.body.style.userSelect=``)},[]),s=(0,I.useCallback)(e=>{let t=a.current;if(!t)return;let r=e.clientX-t.x,o=e.clientY-t.y;a.current={x:e.clientX,y:e.clientY},i(e=>U9({left:e.left+r,top:e.top+o},n))},[n.height,n.width]),c=(0,I.useCallback)(e=>{e.target?.closest(`button,a,input,textarea,select`)||(a.current={x:e.clientX,y:e.clientY},document.body.style.cursor=`grabbing`,document.body.style.userSelect=`none`)},[]);return(0,I.useEffect)(()=>(window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,o),()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,o),o()}),[s,o]),(0,I.useEffect)(()=>{i(e=>U9(e,n))},[n.height,n.width]),{position:r,size:n,startDrag:c}}function zRt({title:e,subtitle:t,icon:n,initialPosition:r,size:i,ariaLabel:a,onClose:o,onDock:s,children:c,footer:l}){let{position:u,size:d,startDrag:f}=RRt(r,i);return(0,L.jsxs)(`div`,{"data-boring-workspace-part":`detached-panel-popover`,className:`absolute z-[90] flex max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] flex-col overflow-hidden rounded-2xl border border-border/70 bg-background shadow-2xl`,style:{left:u.left,top:u.top,width:`min(${d.width}px, calc(100vw - 2rem))`,height:`min(${d.height}px, calc(100vh - 2rem))`},role:`dialog`,"aria-label":a,children:[(0,L.jsxs)(`div`,{className:`flex h-11 shrink-0 cursor-grab items-center justify-between border-b border-border/60 bg-[color:oklch(from_var(--background)_calc(l-0.01)_c_h)] px-3 active:cursor-grabbing`,onPointerDown:f,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[n?(0,L.jsx)(`span`,{className:`grid size-7 place-items-center rounded-lg bg-[color:oklch(from_var(--accent)_l_c_h/0.14)] text-[color:var(--accent)]`,children:n}):null,(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold tracking-tight text-foreground`,children:e}),t?(0,L.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:t}):null]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[s?(0,L.jsx)(`button`,{type:`button`,"aria-label":`Dock panel`,title:`Dock`,className:DU(`grid size-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-foreground/[0.06] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`),onClick:s,children:(0,L.jsx)(pi,{className:`size-3.5`,strokeWidth:1.75})}):null,(0,L.jsx)(`button`,{type:`button`,"aria-label":`Close panel`,title:`Close`,className:`grid size-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-foreground/[0.06] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,onClick:o,children:(0,L.jsx)(ea,{className:`size-3.5`,strokeWidth:1.75})})]})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,children:c}),l?(0,L.jsx)(`div`,{className:`shrink-0 border-t border-border/60`,children:l}):null]})}var BRt={id:`detached-chat-read-only`,reason:`detached-chat.read-only`,label:`Dock this chat to reply.`,sessionBadge:{kind:`detached-chat`,label:`read only`,tone:`neutral`,priority:-10}};function VRt({sessionId:e,title:t,chatParams:n,initialPosition:r,onClose:i,onDock:a,composingEnabled:o=!1}){let s=o?n:{...n,composerBlockers:[BRt,...n.composerBlockers??[]]};return(0,L.jsx)(zRt,{title:t,subtitle:o?`Detached chat`:`Detached chat · dock to reply`,icon:(0,L.jsx)(gi,{className:`size-4`,strokeWidth:1.75,"aria-hidden":`true`}),ariaLabel:`Chat session ${t||e}`,initialPosition:r,size:{width:520,height:720},onClose:i,onDock:a,children:(0,L.jsx)(bat,{...s,sessionId:e},e)})}function HRt(e,t){return`${e}.${t.replace(/[^A-Za-z0-9_.:-]/g,`_`).slice(0,96)||`item`}`}function URt({setFloatingChatSession:e,openChatPane:t,surfaceDispatch:n}){return(0,I.useMemo)(()=>({openArtifact:(e,r)=>e?e.type===`panel`?(qs({kind:`openPanel`,params:{id:HRt(e.panelComponentId,r?.instanceId??e.panelComponentId),component:e.panelComponentId,title:r?.title??e.panelComponentId,params:e.params}},n),{success:!0}):e.target?(r?.sessionId&&t(r.sessionId),qs({kind:`openSurface`,params:{kind:e.surfaceKind,target:e.target,meta:{...e.params??{},...r?.sessionId?{sessionId:r.sessionId}:{}}}},n),{success:!0}):{success:!1,reason:`open-failed`,message:`This item has no surface target.`}:{success:!1,reason:`no-artifact`,message:`This item has no artifact target.`},openDetachedChat:(t,n)=>t?(e({sessionId:t,title:n?.title,initialDraft:n?.initialDraft,composingEnabled:n?.composingEnabled}),{success:!0}):{success:!1,reason:`invalid-session`,message:`Missing chat session id.`}}),[t,e,n])}function WRt({appLeftPaneCollapsed:e,workspaceId:t,effectiveAppLeftPaneWidth:n,sessionTitleById:r,defaultSessionTitle:i,makeCenterParams:a,openChatPane:o,surfaceDispatch:s,onDockOverlay:c}){let[l,u]=(0,I.useState)(null);(0,I.useEffect)(()=>{u(null)},[t]);let d=URt({setFloatingChatSession:u,openChatPane:o,surfaceDispatch:s});(0,I.useEffect)(()=>{let e=e=>{let t=e.detail;!t||typeof t.sessionId!=`string`||d.openDetachedChat(t.sessionId,{...typeof t.title==`string`?{title:t.title}:{},...typeof t.initialDraft==`string`?{initialDraft:t.initialDraft}:{},...typeof t.composingEnabled==`boolean`?{composingEnabled:t.composingEnabled}:{}})};return window.addEventListener(`boring-workspace:open-detached-chat`,e),()=>window.removeEventListener(`boring-workspace:open-detached-chat`,e)},[d]);let f=l?.sessionId??null,p=f?l?.title??r.get(f)??(f==="default"?i:f):null,m=f?{...a(f,{bridgeEnabled:!1}),...l?.initialDraft===void 0?{}:{initialDraft:l.initialDraft}}:null;return{floatingChatNode:f&&m?(0,L.jsx)(VRt,{sessionId:f,title:p??f,chatParams:m,initialPosition:{left:e?24:n+24,top:72},composingEnabled:l?.composingEnabled??!1,onClose:()=>u(null),onDock:()=>{o(f),u(null),c?.()}},f):null,shellCapabilities:d}}function W9(e){return e.boring?.label||e.boring?.id||e.id}function GRt(e,t){let n=e.filter(e=>e.id!==t.id);return n.push(t),n.sort((e,t)=>W9(e).localeCompare(W9(t)))}function KRt({onClose:e,onReloadExternalPlugins:t,headerInsetStart:n=!1,headerInsetEnd:r=!1}){let i=va(),[a,o]=(0,I.useState)({status:`loading`,plugins:[]}),[s,c]=(0,I.useState)(()=>new Set),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),p=(0,I.useCallback)(async()=>{o(e=>({status:`loading`,plugins:e.plugins}));try{let e=await i.getJson(`/api/v1/agent-plugins?external=1`,{missingMessage:`Failed to load external plugins.`}),t=Array.isArray(e)?[...e].sort((e,t)=>W9(e).localeCompare(W9(t))):[];o({status:`ready`,plugins:t})}catch(e){let t=e instanceof Error?e.message:`Failed to load external plugins.`;if(/\(404\)/.test(t)){o({status:`ready`,plugins:[]});return}o(e=>({status:`error`,plugins:e.plugins,error:t}))}},[i]);(0,I.useEffect)(()=>{p()},[p]),(0,I.useEffect)(()=>{let e=e=>{let t=e.detail;if(!(!t||typeof t!=`object`))switch(t.type){case`boring.plugin.load`:o(e=>({...e,plugins:GRt(e.plugins,t)})),c(e=>{let n=new Set(e);return n.delete(t.id),n});break;case`boring.plugin.unload`:o(e=>({...e,plugins:e.plugins.filter(e=>e.id!==t.id)})),c(e=>{let n=new Set(e);return n.delete(t.id),n});break;case`boring.plugin.front-pending`:c(e=>new Set(e).add(t.id));break;case`boring.plugin.front-settled`:c(e=>{let n=new Set(e);return n.delete(t.id),n});break;case`boring.plugin.error`:case`boring.plugin.front-error`:f(t.message?`${t.id}: ${t.message}`:`${t.id} failed to reload`),c(e=>{let n=new Set(e);return n.delete(t.id),n});break;case`boring.plugin.replay-complete`:p();break}};return window.addEventListener(w$,e),()=>window.removeEventListener(w$,e)},[p]);let m=(0,I.useMemo)(()=>[...a.plugins].sort((e,t)=>W9(e).localeCompare(W9(t))),[a.plugins]),h=(0,I.useCallback)(async()=>{u(!0),f(null);try{let e=t?await t():void 0;f(e||`External plugins reloaded.`),await p()}catch(e){f(e instanceof Error?e.message:`External plugin reload failed.`)}finally{u(!1)}},[p,t]);return(0,L.jsx)(PRt,{part:`plugins-overlay`,title:`Plugins`,description:`External plugins loaded for this workspace`,headerInsetStart:n,headerInsetEnd:r,icon:(0,L.jsx)(`span`,{className:`grid size-7 place-items-center rounded-lg bg-foreground/[0.06] text-muted-foreground`,children:(0,L.jsx)(Ai,{className:`h-4 w-4`,strokeWidth:1.75,"aria-hidden":`true`})}),actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:()=>void h(),disabled:l||a.status===`loading`,"aria-label":`Reload plugins`,title:`Reload plugins`,className:`text-muted-foreground hover:text-foreground`,children:(0,L.jsx)(Fi,{className:DU(`size-3`,(l||a.status===`loading`)&&`animate-spin`),strokeWidth:1.75})}),(0,L.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:e,"aria-label":`Close plugins`,title:`Close`,className:`text-muted-foreground hover:text-foreground`,children:(0,L.jsx)(ea,{className:`size-3`,strokeWidth:1.75})})]}),children:(0,L.jsxs)(`div`,{className:`boring-scrollbar-discreet min-h-0 flex-1 overflow-y-auto p-4`,"aria-live":`polite`,children:[a.status===`error`?(0,L.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/30 bg-destructive/8 px-3 py-2 text-sm text-destructive`,children:a.error}):null,d?(0,L.jsx)(`div`,{className:`mb-4 rounded-lg border border-border/70 bg-muted/40 px-3 py-2 text-xs text-muted-foreground`,children:d}):null,a.status===`loading`&&m.length===0?(0,L.jsx)(`div`,{className:`flex h-full min-h-[180px] items-center justify-center text-sm text-muted-foreground`,children:`Loading external plugins…`}):m.length===0?(0,L.jsx)(`div`,{className:`flex h-full min-h-[180px] items-center justify-center text-center text-sm text-muted-foreground`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`font-medium text-foreground/80`,children:`No external plugins loaded`}),(0,L.jsx)(`p`,{className:`mt-1 max-w-xs`,children:`Create or install an external plugin, then reload external plugins.`})]})}):(0,L.jsx)(`ul`,{role:`list`,className:`grid gap-2`,children:m.map(e=>{let t=s.has(e.id);return(0,L.jsxs)(`li`,{className:`rounded-xl border border-border/60 bg-card/70 px-3 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:W9(e)}),(0,L.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground/80`,children:e.id})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[t?(0,L.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,children:`loading`}):null,e.frontTarget?(0,L.jsx)(`span`,{className:`rounded bg-foreground/[0.06] px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,children:`front`}):null,typeof e.revision==`number`?(0,L.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,children:[`r`,e.revision]}):null]})]}),e.version?(0,L.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Version `,e.version]}):null]},e.id)})})]})})}function qRt({appTitle:e,workspaceLabel:t,topSlot:n,showBrand:r=!0}){let i=e||`Boring UI`;return(0,L.jsxs)(`div`,{className:`shrink-0 px-2 pb-2 pt-2`,children:[r?(0,L.jsxs)(`div`,{className:`flex h-8 min-w-0 items-center gap-2 pr-1`,style:{paddingLeft:`2.5rem`},children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7 shrink-0 place-items-center rounded-lg bg-foreground text-[12px] font-semibold text-background`,children:(i[0]??`B`).toUpperCase()}),(0,L.jsx)(`span`,{className:`truncate text-[15px] font-semibold tracking-tight text-foreground`,"data-boring-workspace-part":`app-left-pane-brand`,children:i})]}):null,n?(0,L.jsx)(`div`,{className:r?`mt-1 min-w-0`:`min-w-0 pr-1`,style:r?void 0:{paddingLeft:`2.5rem`},"data-boring-workspace-part":`app-left-pane-workspace`,children:n}):t?(0,L.jsx)(`div`,{className:`mt-0.5 flex min-h-8 items-center gap-2 rounded-md px-2 text-[13px] text-foreground/72`,"data-boring-workspace-part":`app-left-pane-workspace`,children:(0,L.jsx)(`span`,{className:`truncate`,children:t})}):null]})}function G9({icon:e,label:t,onClick:n,emphasis:r=!1,active:i=!1,trailing:a}){return(0,L.jsxs)(`button`,{type:`button`,onClick:n,className:DU(`flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[13px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,i?`bg-foreground/[0.08] text-foreground shadow-sm ring-1 ring-border/60`:r?`bg-foreground/[0.06] text-foreground hover:bg-foreground/[0.1]`:`text-foreground/82 hover:bg-foreground/[0.055] hover:text-foreground`),children:[(0,L.jsx)(`span`,{className:DU(`grid size-5 shrink-0 place-items-center`,i||r?`text-foreground/90`:`text-muted-foreground`),"aria-hidden":`true`,children:e}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),a?(0,L.jsx)(`span`,{className:`shrink-0`,children:a}):null]})}function JRt({keys:e}){return(0,L.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded border border-border/60 bg-foreground/[0.08] px-1.5 py-px text-[10px] font-medium leading-[1.4] tracking-wide text-muted-foreground`,children:e})}function YRt(e){switch(e){case`danger`:return`bg-destructive/12 text-destructive`;case`warning`:return`bg-amber-500/12 text-amber-700 dark:text-amber-300`;case`neutral`:return`bg-foreground/[0.07] text-muted-foreground`;default:return`bg-[color:var(--accent)]/12 text-[color:var(--accent)]`}}function XRt(e){switch(e){case`danger`:return`bg-destructive`;case`warning`:return`bg-amber-500`;case`neutral`:return`bg-muted-foreground/70`;default:return`bg-[color:var(--accent)]`}}function ZRt({session:e,state:t,pinned:n,canSplit:r=!0,canPin:i=!0,working:a=!1,attentionBadge:o,onSwitch:s,onOpenAsPane:c,onTogglePinned:l,onDelete:u}){let d=e.title||`Untitled`,f=()=>{t!==`active`&&s(e.id)};return(0,L.jsxs)(`div`,{"data-boring-workspace-part":`app-session-row`,"data-boring-session-state":t,draggable:r,onDragStart:r?t=>{t.dataTransfer.setData(c$,e.id),t.dataTransfer.setData(`text/plain`,d),t.dataTransfer.effectAllowed=`copyMove`}:void 0,onClick:f,className:DU(`group flex min-h-8 w-full items-center gap-2 rounded-md border px-2.5 py-1 text-left transition-colors`,t===`active`?`border-transparent bg-[color:oklch(from_var(--accent)_l_c_h/0.14)] text-foreground`:t===`open`?`cursor-pointer border-transparent bg-foreground/[0.05] text-foreground/90 hover:bg-foreground/[0.07]`:`cursor-pointer border-transparent text-foreground/78 hover:bg-foreground/[0.055] hover:text-foreground`),children:[(0,L.jsx)(Ar,{className:DU(`h-3.5 w-3.5 shrink-0`,t===`active`?`text-[color:var(--accent)]`:`text-muted-foreground/65`),strokeWidth:1.75,"aria-hidden":`true`}),(0,L.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),f()},disabled:t===`active`,className:`min-w-0 flex-1 truncate rounded text-left text-[13px] font-medium leading-5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 disabled:cursor-default`,title:d,children:d}),o?(0,L.jsxs)(`span`,{"data-boring-workspace-part":`app-session-badge`,"data-boring-badge":o.kind,className:DU(`pointer-events-none inline-flex shrink-0 items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none`,YRt(o.tone)),children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:DU(`h-1.5 w-1.5 animate-pulse rounded-full`,XRt(o.tone))}),o.label]}):a?(0,L.jsxs)(`span`,{"data-boring-workspace-part":`app-session-badge`,"data-boring-badge":`working`,className:`pointer-events-none inline-flex shrink-0 items-center gap-1 rounded-full bg-foreground/[0.07] px-1.5 py-0.5 text-[10px] font-medium leading-none text-muted-foreground`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 animate-pulse rounded-full bg-[color:var(--accent)]`}),`working`]}):null,i?(0,L.jsx)(`span`,{"data-boring-workspace-part":`app-session-pin-action`,className:DU(`flex w-0 shrink-0 items-center overflow-hidden opacity-0 transition-[width,opacity,margin] group-hover:ml-1 group-hover:w-auto group-hover:opacity-100 group-focus-within:ml-1 group-focus-within:w-auto group-focus-within:opacity-100`,n&&`ml-1 w-auto opacity-100`),children:(0,L.jsx)(`button`,{type:`button`,"aria-label":n?`Unpin ${d}`:`Pin ${d}`,title:n?`Unpin`:`Pin`,"aria-pressed":n,onClick:t=>{t.stopPropagation(),l(e.id)},className:DU(`grid size-6 place-items-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,n&&`text-[color:var(--accent)]`),children:(0,L.jsx)(Di,{className:DU(`h-3.5 w-3.5`,n&&`fill-current`),strokeWidth:1.75})})}):null,t===`normal`&&r||u?(0,L.jsxs)(`span`,{"data-boring-workspace-part":`app-session-actions`,className:`flex w-0 shrink-0 items-center gap-0.5 overflow-hidden opacity-0 transition-[width,opacity,margin] group-hover:ml-1 group-hover:w-auto group-hover:opacity-100 group-focus-within:ml-1 group-focus-within:w-auto group-focus-within:opacity-100`,children:[t===`normal`&&r?(0,L.jsx)(`button`,{type:`button`,"aria-label":`Open ${d} in new chat pane`,title:`Open in new chat pane`,onClick:t=>{t.stopPropagation(),c(e.id)},className:`grid size-6 place-items-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,children:(0,L.jsx)(hi,{className:`h-3.5 w-3.5`,strokeWidth:1.75})}):null,u?(0,L.jsx)(`button`,{type:`button`,"aria-label":`Delete ${d}`,title:`Delete`,onClick:t=>{t.stopPropagation(),u(e.id)},className:`grid size-6 place-items-center rounded-md text-muted-foreground hover:bg-background hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,children:(0,L.jsx)(ea,{className:`h-3.5 w-3.5`,strokeWidth:1.75})}):null]}):null]})}var QRt=`boring-workspace:pinned-projects`;function $Rt(){try{let e=globalThis.localStorage?.getItem(QRt);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t?.ids)?t.ids.filter(e=>typeof e==`string`):[]}catch{return[]}}function ezt(e){try{globalThis.localStorage?.setItem(QRt,JSON.stringify({ids:e}))}catch{}}function tzt(){let[e,t]=(0,I.useState)(()=>$Rt());return[e,e=>t(t=>{let n=t.includes(e)?t.filter(t=>t!==e):[...t,e];return ezt(n),n})]}function nzt({projects:e,activeProjectId:t,fallbackName:n,expandedIds:r,onToggleExpanded:i,pinnedProjectIds:a,onTogglePinnedProject:o,onOpenProjectSession:s,onShowMoreProjectSessions:c,onCreateProjectSession:l,onOpenProjectSettings:u,onOpenProjectInNewTab:d,renderProjectSession:f}){let p=t??e[0]?.id??null;return(0,L.jsx)(`div`,{className:`space-y-0.5`,children:e.map(e=>(0,L.jsx)(rzt,{project:e,fallbackName:n,active:e.id===p,expanded:r.has(e.id),pinned:a.has(e.id),onTogglePinned:()=>o(e.id),onToggleExpanded:()=>i(e.id),onActivate:()=>i(e.id),onOpenSession:s,onShowMore:c,onCreateSession:l,onOpenSettings:u,onOpenInNewTab:d,renderProjectSession:f},e.id))})}function rzt({project:e,fallbackName:t,active:n,expanded:r,pinned:i,onTogglePinned:a,onToggleExpanded:o,onActivate:s,onOpenSession:c,onShowMore:l,onCreateSession:u,onOpenSettings:d,onOpenInNewTab:f,renderProjectSession:p}){let[m,h]=(0,I.useState)(!1),g=e.sessions??[],_=e.blockedCount??0,y=e.available===!1,b=e.name||t;return(0,L.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,L.jsxs)(`div`,{className:DU(`group relative flex min-h-8 w-full items-center gap-2 rounded-md py-1 pl-2 pr-2 transition-colors`,n?`bg-foreground/[0.07] text-foreground`:y?`text-muted-foreground/45`:`text-foreground/82 hover:bg-foreground/[0.05] hover:text-foreground`),children:[(0,L.jsx)(`button`,{type:`button`,"aria-label":r?`Collapse ${b}`:`Expand ${b}`,"aria-expanded":r,onClick:o,className:`grid size-5 shrink-0 place-items-center rounded text-muted-foreground/55 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,children:(0,L.jsx)(Cr,{className:DU(`h-3.5 w-3.5 transition-transform duration-150`,r&&`rotate-90`),strokeWidth:2,"aria-hidden":`true`})}),(0,L.jsx)(`button`,{type:`button`,"aria-current":n?`page`:void 0,disabled:y,onClick:()=>{y||s()},className:`min-w-0 flex-1 truncate rounded text-left text-[13px] font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 disabled:cursor-default`,children:b}),(0,L.jsxs)(`span`,{className:`relative flex h-6 w-[3.25rem] shrink-0 items-center justify-end`,children:[_>0?(0,L.jsx)(`span`,{className:DU(`pointer-events-none absolute inset-0 flex items-center justify-end transition-opacity`,`group-hover:opacity-0 group-focus-within:opacity-0`,m&&`opacity-0`),children:(0,L.jsx)(`span`,{title:`${_} session${_===1?``:`s`} waiting`,className:`grid min-w-5 place-items-center rounded-full bg-[color:oklch(from_var(--accent)_l_c_h/0.18)] px-1.5 py-0.5 text-[11px] font-semibold text-[color:var(--accent)]`,children:_>99?`99+`:_})}):null,(0,L.jsxs)(`span`,{className:DU(`flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100`,m&&`opacity-100`),children:[u?(0,L.jsx)(`button`,{type:`button`,"aria-label":`New chat in ${b}`,title:`New chat`,onClick:t=>{t.stopPropagation(),u(e.id)},className:`grid size-6 place-items-center rounded-md text-muted-foreground hover:bg-foreground/[0.08] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,children:(0,L.jsx)(Mi,{className:`h-3.5 w-3.5`,strokeWidth:2})}):null,(0,L.jsxs)(j,{open:m,onOpenChange:h,children:[(0,L.jsx)(re,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`${b} options`,title:`More`,onClick:e=>e.stopPropagation(),className:`grid size-6 place-items-center rounded-md text-muted-foreground hover:bg-foreground/[0.08] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,children:(0,L.jsx)(Rr,{className:`h-3.5 w-3.5`,strokeWidth:2})})}),(0,L.jsxs)(v,{align:`end`,sideOffset:6,className:`w-48 border-border/50 shadow-[0_12px_28px_-6px_rgba(0,0,0,0.55)]`,children:[(0,L.jsxs)(S,{onSelect:a,className:`gap-2 text-[13px]`,children:[i?(0,L.jsx)(Oi,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}):(0,L.jsx)(Di,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),i?`Unpin project`:`Pin project`]}),u?(0,L.jsxs)(S,{onSelect:()=>u(e.id),className:`gap-2 text-[13px]`,children:[(0,L.jsx)(hi,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`New chat`]}):null,d?(0,L.jsxs)(S,{onSelect:()=>d(e.id),className:`gap-2 text-[13px]`,children:[(0,L.jsx)(Li,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`Workspace settings`]}):null,f?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(E,{}),(0,L.jsxs)(S,{onSelect:()=>f(e.id),className:`gap-2 text-[13px]`,children:[(0,L.jsx)(zr,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`Open in new tab`]})]}):null]})]})]})]})]}),r?(0,L.jsxs)(`div`,{className:`space-y-0.5 pl-6`,children:[e.loadingSessions&&g.length===0?(0,L.jsx)(`div`,{className:`px-1 py-1.5 text-xs text-muted-foreground`,children:`Loading chats…`}):g.length===0?(0,L.jsx)(`div`,{className:`px-1 py-1.5 text-xs text-muted-foreground`,children:`No chats yet.`}):g.map(t=>(0,L.jsx)(`div`,{children:p?p(e,t):(0,L.jsx)(ZRt,{session:t,state:`normal`,pinned:!1,onSwitch:()=>c?.(e.id,t.id),onOpenAsPane:()=>c?.(e.id,t.id),onTogglePinned:()=>void 0})},t.id)),e.hasMoreSessions?(0,L.jsx)(`button`,{type:`button`,onClick:()=>l?.(e.id),className:`rounded-md px-1 py-1 text-left text-[13px] text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,children:`Show more`}):null]}):null]})}function K9({title:e,empty:t,children:n}){let r=Array.isArray(n)?n.length>0:!!n;return!r&&!t?null:(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`div`,{className:`px-2 pb-0.5 text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/65`,children:e}),(0,L.jsx)(`div`,{className:`space-y-0.5`,children:r?n:(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground/60`,children:t})})]})}var izt=`boring:chat-session-status`;function azt(){let[e,t]=(0,I.useState)(()=>new Set);return(0,I.useEffect)(()=>{let e=e=>{let n=e.detail;if(typeof n?.sessionId!=`string`)return;let r=n.working===!0;t(e=>{if(e.has(n.sessionId)===r)return e;let t=new Set(e);return r?t.add(n.sessionId):t.delete(n.sessionId),t})};return window.addEventListener(izt,e),()=>window.removeEventListener(izt,e)},[]),e}function ozt({width:e=268,appTitle:t,workspaceLabel:n,workspaceSectionTitle:r=`Workspaces`,projects:i,activeProjectId:a,onOpenProjectSession:o,onShowMoreProjectSessions:s,onCreateProject:c,onCreateProjectSession:l,onOpenProjectSettings:u,onOpenProjectInNewTab:d,topSlot:f,bottomSlot:p,headerMode:m=`full`,sessions:h,activeSessionId:g,openSessionIds:_,pinnedSessionIds:v,onCreateSession:y,onOpenCommandPalette:b,onSwitchSession:x,onOpenSessionAsPane:S,onToggleSessionPinned:C,onDeleteSession:w,actions:T=[],layoutMode:E=`single-project`}){let D=(0,I.useMemo)(()=>new Set(_),[_]),O=(0,I.useMemo)(()=>new Set(v),[v]),k=azt(),{blockers:A}=a$(),ee=(0,I.useMemo)(()=>{let e=new Map;for(let t of A){if(!t.sessionId)continue;let n=i$(t);if(!n)continue;let r=e.get(t.sessionId);(!r||(n.priority??0)>(r.priority??0))&&e.set(t.sessionId,n)}return e},[A]),te=(0,I.useMemo)(()=>v.map(e=>h.find(t=>t.id===e)).filter(e=>!!e),[v,h]),ne=(0,I.useMemo)(()=>h.filter(e=>!O.has(e.id)),[O,h]),j=(0,I.useMemo)(()=>{let e=i??[];return E===`multi-project`?e.map(e=>e.id===a?{...e,sessions:e.sessions??ne.map(e=>({id:e.id,title:e.title,updatedAt:e.updatedAt})),sessionCount:e.sessionCount??ne.length}:e):e},[a,E,i,ne]),[M,N]=(0,I.useState)(()=>{let e=a??i?.[0]?.id;return new Set(e?[e]:[])}),re=e=>N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[ie,ae]=tzt(),oe=(0,I.useMemo)(()=>new Set(ie),[ie]),se=(0,I.useMemo)(()=>ie.map(e=>j.find(t=>t.id===e)).filter(e=>!!e),[ie,j]),ce=(0,I.useMemo)(()=>j.filter(e=>!oe.has(e.id)),[j,oe]),le=m!==`hidden`&&(E!==`multi-project`||m===`workspace`),ue=m===`full`&&E!==`multi-project`,de=(e,t,n=a??void 0)=>{let r=!n||n===a;return(0,L.jsx)(ZRt,{session:e,state:r&&e.id===g?`active`:r&&D.has(e.id)?`open`:`normal`,pinned:t,canSplit:r,canPin:r,working:r&&k.has(e.id),attentionBadge:r?ee.get(e.id):void 0,onSwitch:r?x:()=>o?.(n,e.id),onOpenAsPane:r?S:()=>o?.(n,e.id),onTogglePinned:C,onDelete:r?w:void 0},e.id)},fe=e=>(0,L.jsx)(nzt,{projects:e,activeProjectId:a,fallbackName:n||t||`Boring UI`,expandedIds:M,onToggleExpanded:re,pinnedProjectIds:oe,onTogglePinnedProject:ae,onOpenProjectSession:(e,t)=>{e===a?x(t):o?.(e,t)},onShowMoreProjectSessions:s,onCreateProjectSession:l,onOpenProjectSettings:u,onOpenProjectInNewTab:d,renderProjectSession:(e,t)=>de({id:t.id,title:t.title,updatedAt:t.updatedAt},O.has(t.id),e.id)});return(0,L.jsxs)(`aside`,{"data-boring-workspace-part":`app-left-pane`,className:`flex h-full min-h-0 shrink-0 flex-col border-r border-border bg-[color:oklch(from_var(--background)_calc(l-0.012)_c_h)] text-sm`,style:{width:e,minWidth:e,maxWidth:e},"aria-label":`App navigation`,children:[le?(0,L.jsx)(qRt,{appTitle:t,workspaceLabel:n,topSlot:f,showBrand:ue}):(0,L.jsx)(`div`,{className:`h-12 shrink-0`,"aria-hidden":`true`}),(0,L.jsxs)(`nav`,{className:`shrink-0 space-y-0.5 px-2 pb-1 pt-1`,"aria-label":`Primary workspace actions`,children:[(0,L.jsx)(G9,{icon:(0,L.jsx)(Mi,{className:`h-4 w-4`,strokeWidth:2}),label:`New chat`,onClick:y,emphasis:!0}),(0,L.jsx)(G9,{icon:(0,L.jsx)(Ii,{className:`h-4 w-4`,strokeWidth:1.75}),label:`Search`,onClick:b,trailing:(0,L.jsx)(JRt,{keys:`⌘K`})}),T.map(e=>(0,L.jsx)(G9,{icon:e.icon,label:e.label,onClick:e.onClick,trailing:e.trailing,emphasis:e.emphasis,active:e.active},e.id))]}),(0,L.jsx)(`div`,{className:`boring-scrollbar-discreet min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:E===`multi-project`?(0,L.jsxs)(`div`,{className:`space-y-3 py-1`,children:[te.length>0||se.length>0?(0,L.jsxs)(K9,{title:`Pinned`,children:[te.map(e=>de(e,!0)),se.length>0?fe(se):null]}):null,(0,L.jsxs)(`section`,{"data-boring-workspace-part":`app-left-pane-section`,className:`space-y-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-1 px-2 pb-0.5`,children:[(0,L.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/65`,children:r}),c?(0,L.jsx)(`button`,{type:`button`,"aria-label":`New project`,title:`New project`,onClick:c,className:`grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-foreground/[0.055] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,children:(0,L.jsx)(Mi,{className:`h-3.5 w-3.5`,strokeWidth:2,"aria-hidden":`true`})}):null]}),fe(ce)]})]}):(0,L.jsxs)(`div`,{className:`space-y-4 py-1`,children:[te.length>0?(0,L.jsx)(K9,{title:`Pinned`,children:te.map(e=>de(e,!0))}):null,(0,L.jsx)(K9,{title:`Chats`,empty:`No chats yet.`,children:ne.map(e=>de(e,!1))})]})}),p?(0,L.jsx)(`footer`,{className:`shrink-0 border-t border-border/40 p-2`,children:p}):null]})}function szt({width:e,minWidth:t,maxWidth:n,onResize:r}){let i=(0,I.useRef)(null),a=(0,I.useCallback)(e=>{if(i.current==null)return;let t=e.clientX-i.current;i.current=e.clientX,t!==0&&r(t)},[r]),o=(0,I.useCallback)(()=>{i.current=null,document.body.style.cursor=``,document.body.style.userSelect=``,window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o)},[a]),s=(0,I.useCallback)(e=>{e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),i.current=e.clientX,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o)},[a,o]);return(0,L.jsx)(`div`,{role:`separator`,"aria-label":`Resize app navigation`,"aria-orientation":`vertical`,"aria-valuemin":t,"aria-valuemax":n,"aria-valuenow":e,tabIndex:0,onKeyDown:(0,I.useCallback)(i=>{i.key===`ArrowLeft`?(i.preventDefault(),r(i.shiftKey?-48:-16)):i.key===`ArrowRight`?(i.preventDefault(),r(i.shiftKey?48:16)):i.key===`Home`?(i.preventDefault(),r(t-e)):i.key===`End`&&(i.preventDefault(),r(n-e))},[n,t,r,e]),onPointerDown:s,className:`group relative z-20 -ml-px w-1 shrink-0 cursor-col-resize touch-none bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,children:(0,L.jsx)(`span`,{className:`absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-transparent transition-colors group-hover:bg-foreground/30 group-active:bg-foreground/45`})})}function czt({collapsed:e,leftPane:t,children:n,onExpand:r,onCollapse:i,onResizeLeftPane:a,leftPaneWidth:o,minLeftPaneWidth:s=220,maxLeftPaneWidth:c=420,className:l,mobileShellEnabled:u}){let[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(!1),h=M$(),g=u===!0&&h<640,_=g?!p:e;return(0,L.jsxs)(`div`,{"data-boring-workspace-part":`plugin-tabs-shell`,"data-boring-state":_?`collapsed`:`expanded`,"data-mobile-shell":g?`true`:`false`,className:DU(`relative flex h-full min-h-0 w-full overflow-hidden bg-background`,l),children:[g||e?null:t,!g&&!e&&a&&o!=null?(0,L.jsx)(szt,{width:o,minWidth:s,maxWidth:c,onResize:a}):null,(0,L.jsx)(`div`,{className:`relative min-w-0 flex-1`,children:n}),g?p?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{"aria-hidden":`true`,"data-boring-workspace-part":`app-left-mobile-scrim`,className:`absolute inset-0 z-[64] bg-foreground/30`,onClick:()=>m(!1)}),(0,L.jsx)(`div`,{"data-boring-workspace-part":`app-left-mobile-overlay`,"data-boring-state":`open`,onClick:e=>{e.target?.closest(`button`)&&m(!1)},className:`absolute inset-y-0 left-0 z-[65] flex w-[min(86vw,360px)] max-w-[360px] shadow-2xl`,children:t})]}):null:e?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{"data-boring-workspace-part":`app-left-peek-trigger`,className:`absolute inset-y-0 left-0 z-[60] w-3`,onMouseEnter:()=>f(!0),"aria-hidden":`true`}),d?(0,L.jsx)(`div`,{"data-boring-workspace-part":`app-left-peek`,"data-boring-state":`open`,onMouseLeave:()=>f(!1),className:`absolute inset-y-0 left-0 z-[65] flex shadow-2xl`,children:t}):null]}):null,(0,L.jsx)(`div`,{className:`pointer-events-none absolute left-1.5 top-2 z-[70]`,children:(0,L.jsx)(p$,{label:_?`Open app navigation`:`Hide app navigation`,side:`right`,onClick:g?()=>m(e=>!e):e?r:i,children:_?(0,L.jsx)(Si,{className:`h-4 w-4`,strokeWidth:1.75}):(0,L.jsx)(xi,{className:`h-4 w-4`,strokeWidth:1.75})})})]})}var lzt=new Set([`plugins`,`skills`]);function uzt({plugins:e,excludeDefaults:t}){let n=(t??[]).includes(IQ.pluginId)?[]:[IQ],r=Xn({plugins:e??[],defaults:n,excludeDefaults:t});for(let e of r)for(let t of e.registrations.appLeftActions)if(lzt.has(t.id))throw new Ln(`duplicate-id`,`app-left action "${t.id}" from plugin "${e.id}" collides with a reserved workspace app-left action`);return r}function dzt(){let e=`s${Date.now()}`;return{sessions:[{id:e,title:`New session`,updatedAt:Date.now()}],activeId:e}}function fzt(e,t){if(typeof localStorage>`u`)return t();try{let t=localStorage.getItem(e);if(t){let e=JSON.parse(t),n=Array.isArray(e.sessions)?e.sessions:Array.isArray(e.items)?e.items:null;if(n)return{sessions:n,activeId:e.activeId??n[0]?.id??``}}}catch{}return t()}function pzt(e,t){if(!(typeof localStorage>`u`))try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function mzt(e={}){let t=e.storageKey??`workspace:sessions`,n=fzt(t,e.initial??dzt),r=new Set,i=e=>{n=e,pzt(t,n),r.forEach(e=>e())};return{getState:()=>n,subscribe(e){return r.add(e),()=>{r.delete(e)}},switchTo(e){i({...n,activeId:e})},create(){let e=`s${Date.now()}`;i({sessions:[{id:e,title:`New session`,updatedAt:Date.now()},...n.sessions],activeId:e})},remove(e){let t=n.sessions.filter(t=>t.id!==e),r=n.activeId===e?t[0]?.id??``:n.activeId;i({sessions:t,activeId:r})}}}function hzt(e){return(0,I.useSyncExternalStore)(e.subscribe,e.getState,e.getState)}var gzt=500,_zt=1e4;function vzt(e){return new Promise((t,n)=>{let r,i=()=>{r&&globalThis.clearTimeout(r),e.removeEventListener(`abort`,a)},a=()=>{i(),n(new DOMException(`Warmup aborted`,`AbortError`))};if(e.aborted){a();return}r=globalThis.setTimeout(()=>{i(),t()},gzt),e.addEventListener(`abort`,a,{once:!0})})}async function yzt(e){let t=e.body;if(!t)return JQ(await YQ(e));let n=t.getReader(),r=new TextDecoder,i=``;try{for(;;){let{done:e,value:t}=await n.read();if(t){i+=r.decode(t,{stream:!e});let n=JQ(i);if(n)return n}if(e)return i+=r.decode(),JQ(i)}}finally{await n.cancel().catch(()=>void 0)}}function bzt(e){if(!(e?.runtimeDependenciesState!==`preparing`&&e?.runtimeDependenciesState!==`ready`&&e?.runtimeDependenciesState!==`failed`))return{state:e.runtimeDependenciesState,...e.runtimeDependenciesMessage?{message:e.runtimeDependenciesMessage}:{},...e.runtimeDependenciesRequirement?{requirement:e.runtimeDependenciesRequirement}:{}}}async function xzt(e){if(!e.ok){let t=await YQ(e);if(lat(t))return{status:`preparing`};throw Error(pat(t)??`/api/v1/ready-status failed with ${e.status}`)}let t=await yzt(e),n=bzt(t),r=hat(t);if(t?.state===`degraded`||t?.state===`failed`){if(r&&n?.state===`failed`)return{status:`ready`,runtimeDependencies:n};throw Error(t.message??`Workspace failed to prepare`)}return r?{status:`ready`,...n?{runtimeDependencies:n}:{}}:{status:`preparing`,...n?{runtimeDependencies:n}:{}}}async function Szt({apiBaseUrl:e,path:t,headers:n,signal:r,workspaceId:i}){let a=new AbortController,o=globalThis.setTimeout(()=>a.abort(new DOMException(`Warmup attempt timed out`,`TimeoutError`)),_zt),s=()=>a.abort(r.reason);r.aborted&&s(),r.addEventListener(`abort`,s,{once:!0});try{let r=await fetch(iat(e,t),{headers:n,signal:a.signal});if(dat(t))return await xzt(r);let o=await YQ(r);if(!r.ok){let e=lat(o);if(e)return{status:`preparing`,...e};throw Error(pat(o)??`${t} failed with ${r.status}`)}return o&&typeof o==`object`&&oat(e,n[`x-boring-workspace-id`]??i,t,o),{status:`ready`}}catch(e){if(r.aborted)throw e;if(a.signal.aborted||e instanceof TypeError)return{status:`preparing`};throw e}finally{globalThis.clearTimeout(o),r.removeEventListener(`abort`,s)}}function Czt({workspaceId:e,requestHeaders:t,apiBaseUrl:n,preloadPaths:r=tat,provisionWorkspace:i=!0,onStatusChange:a}){return(0,I.useEffect)(()=>{let o=!1,s=new AbortController,c=qQ(e,t);async function l(){a?.({status:`preparing`});try{let t=fat(r,i),l=t=>Szt({apiBaseUrl:n,path:t,headers:c,signal:s.signal,workspaceId:e}),u=await Promise.all(t.map(async e=>({path:e,result:await l(e)})));if(o||s.signal.aborted)return;let d=u.find(e=>e.result.runtimeDependencies)?.result.runtimeDependencies,f=u.filter(e=>e.result.status===`preparing`);for(;f.length>0;){let e;for(let t of f)if(t.result.status===`preparing`&&t.result.requirement){e=t.result.requirement;break}if(a?.({status:`preparing`,message:`Workspace is still preparing`,...e?{requirement:e}:{}}),await vzt(s.signal),o||s.signal.aborted||(u=await Promise.all(f.map(async e=>({path:e.path,result:await l(e.path)}))),o||s.signal.aborted))return;d=u.find(e=>e.result.runtimeDependencies)?.result.runtimeDependencies??d,f=u.filter(e=>e.result.status===`preparing`)}for(a?.({status:`ready`,...d?{runtimeDependencies:d}:{}});d?.state===`preparing`;){if(await vzt(s.signal),o||s.signal.aborted)return;let e=await l(`/api/v1/ready-status`);if(o||s.signal.aborted)return;d=e.runtimeDependencies,d&&a?.({status:`ready`,runtimeDependencies:d})}}catch(e){if(o||s.signal.aborted)return;a?.({status:`failed`,message:e instanceof Error?e.message:`Workspace failed to prepare`})}}return l(),()=>{o=!0,s.abort()}},[n,a,r,i,t,e]),null}function wzt({status:e}){let t=e.status===`ready`?void 0:e.requirement,n=e.status!==`failed`,r=n?t===`workspace-fs`?`Preparing files…`:t===`sandbox-exec`?`Preparing secure runtime…`:t===`ui-bridge`?`Connecting workspace…`:`Preparing workspace…`:`Workspace workbench failed`,i=e.status===`failed`?e.message:`Chat is ready while files, tools, and workspace panels finish warming up.`;return(0,L.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background px-6 text-center`,children:(0,L.jsxs)(`div`,{className:`max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm`,children:[n?(0,L.jsx)(`div`,{className:`mx-auto mb-3 h-7 w-7 rounded-full border-2 border-muted-foreground/20 border-t-foreground animate-spin`,"aria-hidden":`true`}):null,(0,L.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:r}),(0,L.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:i}),e.status===`failed`?(0,L.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Reload the workspace to retry.`}):null]})})}function Tzt(){return(0,L.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background px-6 text-center`,children:(0,L.jsxs)(`div`,{className:`max-w-sm rounded-2xl border border-border bg-card p-5 shadow-sm`,children:[(0,L.jsx)(`div`,{className:`mx-auto mb-3 h-7 w-7 rounded-full border-2 border-muted-foreground/20 border-t-foreground animate-spin`,"aria-hidden":`true`}),(0,L.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`Loading sessions…`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Finding this workspace’s saved chats.`})]})})}function Ezt(e){if(!e)return`/api/v1/ui`;let t=e.replace(/\/$/,``),n=`/api/v1/ui`;return t.endsWith(n)?t:`${t}${n}`}function Dzt(e){return`${Ezt(e)}/state`}function Ozt(e){let t=e.openTabs.find(t=>t.id===e.activeTab)?.params?.path;return typeof t==`string`?t:null}function kzt({bridgeEndpoint:e,requestHeaders:t,navOpen:n,surfaceOpen:r,surfaceReady:i,snapshot:a}){let o=ir(),s=cr(),c=(0,I.useSyncExternalStore)(o.subscribe,o.getSnapshot,o.getSnapshot),l=(0,I.useSyncExternalStore)(s.subscribe,s.getSnapshot,s.getSnapshot),u=(0,I.useRef)(null);return(0,I.useEffect)(()=>{if(e===null||r&&!i)return;u.current?.abort();let o=new AbortController;u.current=o;let s={v:1,drawerOpen:n,workbenchOpen:r,openTabs:a.openTabs,activeTab:a.activeTab,activeFile:Ozt(a),availablePanels:c.map(e=>e.id),availableSurfaces:l.flatMap(e=>{let t=DWe(e);return t?[t]:[]})};return fetch(Dzt(e),{method:`PUT`,headers:{...t,"Content-Type":`application/json`},body:JSON.stringify({state:s,causedBy:`user`}),signal:o.signal}).catch(()=>{}),()=>{o.abort()}},[e,n,c,t,a,r,i,l]),null}function Azt(e){return new Set(e.flatMap(e=>e.registrations.appLeftActions.map(e=>e.id)))}function jzt(e){let t=new Map;for(let n of e){let e=t.get(n.id);if(e)throw Error(`duplicate app-left action id "${n.id}" registered by ${e} and ${n.label}`);t.set(n.id,n.label)}}function Mzt({plugins:e,activeOverlay:t,setActiveOverlay:n}){return(0,I.useMemo)(()=>e.flatMap(e=>e.registrations.appLeftActions.map(t=>({plugin:e,action:t}))).sort((e,t)=>(e.action.order??0)-(t.action.order??0)||(e.plugin.label??e.plugin.id).localeCompare(t.plugin.label??t.plugin.id)||e.action.label.localeCompare(t.action.label)||e.action.id.localeCompare(t.action.id)).map(({plugin:e,action:r})=>{let i=r.icon,a=r.trailing;return{id:r.id,label:r.label,icon:i?(0,I.createElement)(oa,{pluginId:e.id,contributionKind:`app-left-action`,contributionId:`${r.id}:icon`},(0,I.createElement)(i,{className:`h-4 w-4`})):null,trailing:a?(0,I.createElement)(oa,{pluginId:e.id,contributionKind:`app-left-action`,contributionId:`${r.id}:trailing`},(0,I.createElement)(a)):void 0,emphasis:r.emphasis,active:t===r.id,onClick:()=>{n(e=>e===r.id?null:r.id)}}}),[e,n])}function Nzt({plugins:e,activeOverlay:t,onClose:n,headerInsetStart:r,headerInsetEnd:i}){if(!t)return null;let a=e.flatMap(e=>e.registrations.appLeftActions.map(t=>({plugin:e,action:t}))).find(({action:e})=>e.id===t);return a?.action.overlay?(0,I.createElement)(Wrt,{value:{headerInsetStart:!!r,headerInsetEnd:!!i}},(0,I.createElement)(oa,{pluginId:a.plugin.id,contributionKind:`app-left-action`,contributionId:a.action.id},(0,I.createElement)(a.action.overlay,{onClose:n}))):null}function Pzt({activeSessionId:e,onAttentionOpen:t}){let{blockers:n}=a$(),r=n.some(t=>t.sessionId&&e&&t.sessionId!==e?!1:t.focus?.closeWorkbenchLeftPane===!0),i=(0,I.useRef)(!1);return(0,I.useEffect)(()=>{r&&!i.current&&t(),i.current=r},[r,t]),null}function Fzt(e){return typeof e?.id==`string`?e.id:null}function q9(e,t,n){if(e.includes(n))return e;let r=t?e.indexOf(t):-1,i=r>=0?r+1:e.length;return[...e.slice(0,i),n,...e.slice(i)]}function J9(e,t,n){if(e.includes(n))return e;if(e.length===0)return[n];let r=t?e.indexOf(t):-1,i=r>=0?r:0;return e.map((e,t)=>t===i?n:e)}function Izt(e,t){return e.endsWith(`:surface`)?e.slice(0,-8):t}function Lzt(e,t,n){let[r,i]=(0,I.useState)(()=>BQ(e,t,n));return(0,I.useEffect)(()=>{i(BQ(e,t,n))},[e,t,n]),[r,(0,I.useCallback)(t=>{i(r=>{let i=typeof t==`function`?t(r):t;return rit(e,i,n),i})},[n,e])]}function Y9(e,t,n){let[r,i]=(0,I.useState)(()=>tit(e,t,n));return(0,I.useEffect)(()=>{i(tit(e,t,n))},[e,t,n]),[r,(0,I.useCallback)(t=>{i(t),nit(e,t,n)},[n,e])]}function Rzt(e,t,n){if(!n||typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return n===null?t:n||null}catch{return t}}function zzt(e,t,n){if(!(!n||typeof window>`u`))try{t?window.localStorage.setItem(e,t):window.localStorage.removeItem(e)}catch{}}function Bzt(e,t,n){let[r,i]=(0,I.useState)(()=>Rzt(e,t,n));return(0,I.useEffect)(()=>{i(Rzt(e,t,n))},[n,t,e]),[r,(0,I.useCallback)(t=>{i(r=>{let i=typeof t==`function`?t(r):t;return zzt(e,i,n),i})},[n,e])]}var X9={},Vzt=[],Hzt={status:`preparing`};function Uzt(e,t,n){return Math.min(n,Math.max(t,e))}var Wzt={openTabs:[],activeTab:null};function Gzt(e){let t=e.workspaceId??Kzt(e.requestHeaders)??e.storageKey,n=Ev({apiBaseUrl:e.apiBaseUrl,workspaceId:t,storageScope:t,requestHeaders:e.requestHeaders,enabled:e.enabled,connectActiveSession:!1,refreshKey:e.refreshKey});return{...n,workspaceId:n.dataStorageScope}}function Kzt(e){return e?.[`x-boring-workspace-id`]??e?.[`X-Boring-Workspace-Id`]??null}function qzt(e){let t=e.reloaded?`Extensions reloaded.`:`Extensions will reload on the next message.`,n=Array.isArray(e.diagnostics)?e.diagnostics.map(e=>e.message).filter(e=>!!e):[];return n.length>0?`${t}\n\nWarnings:\n${n.join(`
869
869
  `)}`:t}function Jzt(e){try{return globalThis.localStorage?.getItem(e)??null}catch{return null}}function Yzt(e,t){try{let n=globalThis.localStorage?.getItem(e);if(!n)return null;let r=JSON.parse(n),i=Array.isArray(r.ids)?r.ids.filter(e=>typeof e==`string`&&e.length>0):[];return i.length===0?null:{workspaceId:t,ids:i,activeId:typeof r.activeId==`string`&&i.includes(r.activeId)?r.activeId:i[0]}}catch{return null}}function Xzt(e,t){try{if(t.ids.length===0){globalThis.localStorage?.removeItem(e);return}globalThis.localStorage?.setItem(e,JSON.stringify({ids:t.ids,activeId:t.activeId}))}catch{}}function Zzt(e,t){try{let n=globalThis.localStorage?.getItem(e);if(!n)return null;let r=JSON.parse(n);return{workspaceId:t,ids:Array.isArray(r.ids)?r.ids.filter(e=>typeof e==`string`&&e.length>0):[]}}catch{return null}}function Qzt(e,t){try{if(t.length===0){globalThis.localStorage?.removeItem(e);return}globalThis.localStorage?.setItem(e,JSON.stringify({ids:t}))}catch{}}function $zt({workspaceId:e,chatPanel:t,useSessions:n,requestHeaders:r,sessionStorageKey:i,providerStorageKey:a,surfaceStorageKey:o,beforeShell:s,afterShell:c,panels:l,commands:u,catalogs:d,plugins:f,excludeDefaults:p,capabilities:m,apiBaseUrl:h,authHeaders:g,apiTimeout:_,defaultTheme:v,onThemeChange:y,persistenceEnabled:b,debug:x,bridgeEndpoint:S,fullPageBasePath:C,onAuthError:w,sessions:T,activeSessionId:E,onSwitchSession:D,onCreateSession:O,onDeleteSession:k,onActiveSessionIdChange:A,appTitle:ee=`Boring UI`,workspaceLabel:te,workspaceSectionTitle:ne=`Workspaces`,appLeftLayoutMode:j=`single-project`,appLeftHeaderMode:M=`full`,appLeftProjects:N,appLeftActiveProjectId:re,onSwitchAppLeftProject:ie,onOpenAppLeftProjectSession:ae,onShowMoreAppLeftProjectSessions:oe,onCreateAppLeftProject:se,onOpenAppLeftProjectSettings:ce,onOpenAppLeftProjectInNewTab:le,defaultSessionTitle:ue=`New session`,workspaceLayout:de=`classic`,navEnabled:fe=!0,defaultNavOpen:pe=!1,defaultAppLeftPaneCollapsed:me,defaultSurfaceOpen:he,defaultWorkbenchLeftTab:ge,defaultWorkbenchLeftOpen:_e,surfaceInitialPanels:ve,topBarLeft:ye,topBarRight:be,showThemeToggle:xe=!0,defaultLeftOverlay:Se=null,showSkills:Ce=!0,showPlugins:we=!0,appLeftActions:Te,appLeftOverlayActions:Ee,chatParams:De,externalPlugins:Oe,hotReloadEnabled:ke,frontPluginHotReload:Ae,extraPanels:je,extraCommands:Me,provisionWorkspace:Ne,bootPreloadPaths:Pe,onWorkspaceWarmupStatusChange:Fe,onOpenNav:Ie,onOpenSurface:Le,surfaceButtonBottomOffset:Re,mobileShellEnabled:ze=!0,className:Be}){let Ve=M$(),He=ze&&Ve<640,Ue=Oe!==!1,We=Ue?Ae:!1,Ge=Ue?ke:!1,Ke=a??`boring-ui-v2:layout:${e}`,qe=o??`${Ke}:surface`,Je=Izt(qe,Ke),Ye=b!==!1,Xe=de===`plugin-tabs`,Ze=Ce!==!1,Qe=we!==!1,$e=l,et=i??`boring-workspace:sessions:${e}`,tt=(0,I.useMemo)(()=>qQ(e,r??X9),[r,e]),nt=(0,I.useMemo)(()=>qQ(e,{...r??X9,...g??X9}),[g,r,e]),rt=(0,I.useMemo)(()=>mzt({storageKey:et}),[et]),it=hzt(rt),[at,ot]=(0,I.useState)(()=>({workspaceId:e,status:Hzt})),[st,ct]=(0,I.useState)(()=>({workspaceId:e,expired:!1})),[lt,P]=(0,I.useState)(()=>({workspaceId:e,creating:!1})),[F,ut]=(0,I.useState)(()=>({workspaceId:e,failed:!1})),dt=`boring-workspace:chat-panes:${e}`,[ft,pt]=(0,I.useState)(()=>(Ye?Yzt(dt,e):null)??{workspaceId:e,ids:[],activeId:null}),[mt,ht]=(0,I.useState)(null);(0,I.useEffect)(()=>{if(!mt)return;let e=setTimeout(()=>ht(null),700);return()=>clearTimeout(e)},[mt]);let gt=`boring-workspace:pinned-sessions:${e}`,[_t,vt]=(0,I.useState)(()=>(Ye?Zzt(gt,e):null)??{workspaceId:e,ids:[]}),yt=_t.workspaceId===e?_t.ids:Vzt;(0,I.useEffect)(()=>{vt(t=>t.workspaceId===e?t:(Ye?Zzt(gt,e):null)??{workspaceId:e,ids:[]})},[gt,Ye,e]);let bt=(0,I.useCallback)(t=>{vt(n=>{let r=n.workspaceId===e?n.ids:[],i=r.includes(t)?r.filter(e=>e!==t):[t,...r];return Ye&&Qzt(gt,i),{workspaceId:e,ids:i}})},[gt,Ye,e]);(0,I.useEffect)(()=>{Ye&&ft.workspaceId===e&&Xzt(dt,ft)},[ft,dt,Ye,e]),(0,I.useEffect)(()=>{pt(t=>t.workspaceId===e?t:(Ye?Yzt(dt,e):null)??{workspaceId:e,ids:[],activeId:null})},[dt,Ye,e]);let xt=at.workspaceId===e?at.status:Hzt,St=t??yWe,Ct=n??Gzt,wt=!t||!!n,Tt=wt&&Ne!==!1,Et=()=>void 0,Dt=Ct({requestHeaders:tt,storageKey:et,workspaceId:e,apiBaseUrl:h,enabled:Tt}),[Ot,kt]=(0,I.useState)(()=>({workspaceId:e,sessions:[],activeSessionId:null})),At=Tt&&Dt.workspaceId!=null&&Dt.workspaceId!==e,jt=Tt&&!Dt.loading&&!Dt.error&&!At,Mt=Tt&&!jt;(0,I.useEffect)(()=>{jt&&kt(t=>{let n=t.workspaceId===e,r=t.activeSessionId===Dt.activeSessionId,i=t.sessions.length===Dt.sessions.length&&t.sessions.every((e,t)=>e.id===Dt.sessions[t]?.id);return n&&r&&i?t:{workspaceId:e,sessions:Dt.sessions,activeSessionId:Dt.activeSessionId}})},[Dt.activeSessionId,Dt.sessions,jt,e]);let Nt=Mt&&Ot.workspaceId===e&&Ot.sessions.length>0,Pt=Mt?Jzt(et):null,Ft=Mt&&!At?Dt.activeSessionId??null:null,It=jt?Dt.sessions:Nt?Ot.sessions:[],Lt=jt?Dt.activeSessionId:Nt?Ot.activeSessionId:null,Rt=wt&&(jt||Nt)?Dt:void 0,zt=T!==void 0||E!==void 0||D!==void 0||O!==void 0||k!==void 0,Bt=st.workspaceId===e&&st.expired,Vt=(0,I.useRef)(!1),Ht=!!(jt&&Rt&&!zt&&It.length===0&&!Bt),Ut=lt.workspaceId===e&&lt.creating,Wt=F.workspaceId===e&&F.failed,Gt=!!(jt&&Rt&&!zt&&It.length===0&&Bt&&!Vt.current&&!Wt),Kt=!!(Mt&&Dt.loading&&!Dt.error&&wt&&!zt&&!Nt&&!Pt&&!Ft)||Ht||Ut||Gt;(0,I.useEffect)(()=>{if(!Ht){st.workspaceId!==e&&ct({workspaceId:e,expired:!1});return}ct({workspaceId:e,expired:!1});let t=globalThis.setTimeout(()=>{ct({workspaceId:e,expired:!0})},2e3);return()=>globalThis.clearTimeout(t)},[st.workspaceId,Ht,e]);let qt=Rt?It.map(e=>({...e,title:e.title??`New session`})):void 0,Jt=Pt?[{id:Pt,title:`Loading sessions…`,createdAt:new Date(0).toISOString(),updatedAt:new Date(0).toISOString(),turnCount:0}]:[],Yt=Rt?qt??[]:Mt?Jt:zt?T??[]:it.sessions,Xt=Rt?Lt??null:Mt?Pt??Ft:zt?E??null:it.activeId,Zt=De?.autoSubmitInitialDraft===!0,Qt=Zt&&wt&&!zt,[$t,en]=(0,I.useState)(()=>Qt?null:void 0),tn=(0,I.useRef)(e),nn=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(tn.current!==e){tn.current=e,nn.current=!1,en(Qt?null:void 0);return}Qt&&$t===void 0&&(nn.current=!1,en(null))},[$t,Qt,e]),(0,I.useEffect)(()=>{!Rt||$t!==null||nn.current||(nn.current=!0,Promise.resolve(Rt.create({title:ue})).then(e=>{if(typeof e?.id!=`string`)throw Error(`auto_submit_session_create_failed`);en(e.id)}).catch(()=>{nn.current=!1,en(void 0)}))},[$t,ue,Rt]);let rn=$t===void 0?Xt:$t??null,an=Mt?Et:Rt?.switch??D??rt.switchTo,on=(0,I.useCallback)(e=>(rn&&e!==rn&&QQ({sessionId:rn,reason:ZQ.sessionSwitch}),an(e)),[rn,an]),sn=Mt?Et:Rt?()=>Rt.create():O?()=>O():()=>rt.create(),cn=Mt?Et:Rt?.delete??k??rt.remove,ln=(0,I.useCallback)(t=>{if(Rt&&Mt&&It.length<=1)return Vt.current=!0,cn(t);if(Rt&&!Mt&&It.length<=1){if(Rt.hasMore)return Vt.current=!0,cn(t);if(Pn.current.has(t))return Promise.resolve();Pn.current.add(t),Nn.current=!0,ut({workspaceId:e,failed:!1});let n=Rt.create({title:ue});return Promise.resolve(n&&typeof n.then==`function`?Promise.resolve(n).then(()=>cn(t)):cn(t)).catch(t=>{throw Nn.current=!1,ut({workspaceId:e,failed:!0}),t}).finally(()=>{Pn.current.delete(t)})}return cn(t)},[It.length,ue,cn,Mt,Rt,e]),un=Yt.find(e=>e.id===rn)?.title??void 0,[dn,fn]=Y9(`${Je}:drawer`,pe,Ye),[pn,mn]=Y9(`${Je}:appLeftPaneCollapsed`,me??!1,Ye),[hn,gn]=Lzt(`${Je}:appLeftPaneWidth`,268,Ye),_n=Uzt(hn,220,420),vn=(0,I.useMemo)(()=>uzt({plugins:f,excludeDefaults:p}),[p,f]),[yn,bn]=Bzt(`${Je}:appLeftOverlay`,Se,Ye),xn=(0,I.useMemo)(()=>Azt(vn),[vn]);(0,I.useEffect)(()=>{let e=!!(yn&&Ee?.some(e=>e.id===yn));(yn===`skills`&&!Ze||yn===`plugins`&&!Qe||yn!==null&&yn!==`skills`&&yn!==`plugins`&&!xn.has(yn)&&!e)&&bn(null)},[Ee,yn,xn,Qe,Ze]);let Sn=fe&&dn,[Cn,wn]=Y9(`${Je}:workbenchOpen`,he??!1,Ye),[Tn,En]=(0,I.useState)(!1),[Dn,On]=Y9(`${Je}:workbenchLeftOpen`,_e??!1,Ye),[kn,An]=(0,I.useState)(()=>_e??!1),jn=_e===!1?kn:Dn,Mn=(0,I.useCallback)(()=>{On(!1),An(!1),bn(null)},[On]),Nn=(0,I.useRef)(!1),Pn=(0,I.useRef)(new Set),Fn=(0,I.useRef)(null),In=(0,I.useRef)(Cn),Ln=(0,I.useRef)(qe),Rn=(0,I.useRef)(null),zn=(0,I.useRef)([]);Ln.current=qe;let[Bn,Vn]=(0,I.useState)(()=>({key:qe,snapshot:Wzt})),Hn=Bn.key===qe?Bn.snapshot:Wzt;(0,I.useEffect)(()=>{Nn.current=!1,Pn.current.clear(),Vt.current=!1,P({workspaceId:e,creating:!1}),ut({workspaceId:e,failed:!1})},[e]),(0,I.useEffect)(()=>{En(!1),zn.current=[]},[qe]),(0,I.useEffect)(()=>{if(!(!Rt||Rt.loading)&&!Ht&&$t===void 0){if(It.length>0){Nn.current=!1,Vt.current=!1,P(t=>t.workspaceId===e&&t.creating?{workspaceId:e,creating:!1}:t),ut(t=>t.workspaceId===e&&t.failed?{workspaceId:e,failed:!1}:t);return}Vt.current||Nn.current||(Nn.current=!0,P({workspaceId:e,creating:!0}),ut({workspaceId:e,failed:!1}),Promise.resolve(Rt.create({title:ue})).catch(()=>{Nn.current=!1,P({workspaceId:e,creating:!1}),ut({workspaceId:e,failed:!0})}))}},[It.length,$t,ue,Ht,Rt,e]),(0,I.useEffect)(()=>{In.current=Cn},[Cn]);let Un=(0,I.useCallback)(e=>{Rn.current={key:qe,api:e},En(!0),Vn({key:qe,snapshot:e.getSnapshot()});let t=zn.current.splice(0);for(let n of t)n(e)},[qe]),Wn=(0,I.useCallback)(e=>{zn.current.push(e)},[]),Gn=(0,I.useCallback)(e=>{Vn({key:qe,snapshot:e})},[qe]),Kn=(0,I.useCallback)(()=>{let e=Rn.current;return e?.key===Ln.current?e.api:null},[]),qn=(0,I.useCallback)(()=>In.current,[]),Jn=(0,I.useCallback)(()=>{In.current=!0,wn(!0)},[wn]),Yn=(0,I.useCallback)(()=>{In.current=!0,wn(!0),On(!0),An(!0)},[wn,On]),Xn=(0,I.useCallback)(()=>{In.current=!1,Rn.current=null,En(!1),wn(!1)},[wn]),Zn=(0,I.useRef)(new Set),Qn=(0,I.useRef)(()=>void 0),$n=(0,I.useCallback)(e=>{let t=e.meta;if(!t||t.openOnlyWhenSessionOpen!==!0)return!0;let n=typeof t.sessionId==`string`?t.sessionId:null;return n?(Zn.current.has(n)||Qn.current(n),!0):!1},[]),er=(0,I.useMemo)(()=>({surface:Kn,isWorkbenchOpen:qn,openWorkbench:Jn,openWorkbenchSources:Yn,closeWorkbench:Xn,enqueue:Wn,shouldOpenSurface:$n}),[Kn,qn,Jn,Yn,Xn,Wn,$n]);(0,I.useCallback)(e=>{if(In.current=!0,wn(!0),Le?.(),!e)return;let t=t=>t.openPanel(e),n=Kn();n?t(n):Wn(t)},[Wn,Kn,Le,wn]);let tr=(0,I.useMemo)(()=>({openFile:async(e,t)=>(qs({kind:`openFile`,params:{path:e,...t?.filesystem?{filesystem:t.filesystem}:{}}},er),{seq:0,status:`ok`}),getActiveFile:()=>Kn()?.getSnapshot().activeTab??null,select:()=>()=>{}}),[Kn,er]),nr=(0,I.useMemo)(()=>!Xe&&vn.some(e=>e.registrations.workspaceSources.length>0),[vn,Xe]),rr=(0,I.useMemo)(()=>vn.flatMap(e=>e.registrations.panels.map(e=>e.id)),[vn]),ir=(0,I.useMemo)(()=>{let e={};for(let t of vn)for(let n of t.registrations.toolRenderers)e[n.id]=n.render;return e},[vn]),ar=(0,I.useMemo)(()=>[...je??[],...rr],[je,rr]),or=wt&&!n&&Ot.workspaceId!==e?`default`:rn??($t===void 0?Yt[0]?.id??`default`:`default`),sr=!Rt?.hasMore&&!Mt;(0,I.useEffect)(()=>{if(Kt)return;let t=Fn.current,n=new Set(Yt.map(e=>e.id)),r=t?t.createdId??(n.has(or)&&!t.knownIds.has(or)?or:Yt.find(e=>!t.knownIds.has(e.id))?.id??null):null;r&&n.has(r)&&(Fn.current=null);let i=or==="default"&&$t!==void 0,a=sr&&n.size>0&&!i,o=r??(a&&!n.has(or)?Yt[0]?.id??or:or);pt(i=>{let s=i.workspaceId===e?i:{workspaceId:e,ids:[],activeId:null};if(Mt&&s.ids.length>0&&!r)return s;let c=s.ids.length>0?s.ids:[o],l=a?c.filter(e=>n.has(e)||e===r):c,u=l.length>0?l:[o],d=s.activeId&&u.includes(s.activeId)?s.activeId:u[0]??o,f=r?q9(u,t?.afterId,r):o===d||u.includes(o)?u:J9(u,d,o),p=f.includes(o)?o:f[0]??o;return i.workspaceId===e&&i.activeId===p&&i.ids.length===f.length&&i.ids.every((e,t)=>e===f[t])?i:{workspaceId:e,ids:f,activeId:p}})},[$t,or,Mt,Kt,Yt,sr,e]);let cr=(0,I.useMemo)(()=>{let e=new Map;for(let t of Yt)e.set(t.id,t.title);return e},[Yt]),[lr,ur]=(0,I.useState)(()=>({workspaceId:e,ids:new Set})),dr=(0,I.useMemo)(()=>{let t=new Set;if(!jt)return t;let n=lr.workspaceId===e?lr.ids:new Set;for(let e of It)e.turnCount===0&&!n.has(e.id)&&t.add(e.id);return t},[It,lr,jt,e]);(0,I.useEffect)(()=>{ur(t=>t.workspaceId===e?t:{workspaceId:e,ids:new Set})},[e]);let fr=ft.workspaceId===e?ft:{workspaceId:e,ids:[],activeId:null},pr=fr.ids.length>0?fr.ids:[or];(0,I.useEffect)(()=>{Zn.current=new Set(pr)},[pr]);let mr=fr.activeId??pr[0]??or,hr=(0,I.useCallback)(t=>{bn(null);let n=(ft.workspaceId===e?ft:{workspaceId:e,ids:[or],activeId:or}).ids.includes(t);return pt(n=>{let r=n.workspaceId===e?n:{workspaceId:e,ids:[or],activeId:or};return{workspaceId:e,ids:r.ids.includes(t)?r.ids:J9(r.ids,r.activeId,t),activeId:t}}),n?an(t):on(t)},[ft,or,an,on,e]);(0,I.useEffect)(()=>{Qn.current=hr},[hr]);let gr=(0,I.useCallback)(t=>(bn(null),pt(n=>{let r=n.workspaceId===e?n:{workspaceId:e,ids:[or],activeId:or};return{workspaceId:e,ids:r.ids.includes(t)?r.ids:q9(r.ids,r.activeId,t),activeId:t}}),an(t)),[or,an,e]),_r=(0,I.useCallback)(t=>(bn(null),(ft.workspaceId===e?ft:{workspaceId:e,ids:[or],activeId:or}).ids.includes(t)&&ht({workspaceId:e,id:t}),pt(n=>{let r=n.workspaceId===e?n:{workspaceId:e,ids:[or],activeId:or};return{workspaceId:e,ids:q9(r.ids,r.activeId,t),activeId:t}}),an(t)),[ft,or,an,e]),vr=(0,I.useCallback)(t=>{let n=ft.workspaceId===e?ft:{workspaceId:e,ids:[or],activeId:or};if(n.ids.length<=1)return;let r=n.ids.indexOf(t);if(r<0)return;let i=n.ids.filter(e=>e!==t),a=n.activeId===t?i[Math.max(0,r-1)]??i[0]??null:n.activeId;pt({workspaceId:e,ids:i,activeId:a}),a&&n.activeId===t&&an(a)},[ft,or,an,e]),yr=(0,I.useCallback)(()=>{let t=sn();return Promise.resolve(t).then(t=>{let n=Fzt(t);n&&(pt(t=>{let r=t.workspaceId===e?t:{workspaceId:e,ids:[or],activeId:or},i=r.ids.length>0?r.ids:[or];return{workspaceId:e,ids:J9(i,r.activeId??i[0]??or,n),activeId:n}}),an(n))}).catch(()=>{}),t},[or,an,sn,e]),br=(0,I.useCallback)(t=>{let n={afterId:t,knownIds:new Set(Yt.map(e=>e.id))};Fn.current=n;let r=sn();return Promise.resolve(r).then(r=>{let i=Fzt(r);i&&(Fn.current===n&&(Fn.current={...n,createdId:i}),pt(n=>({workspaceId:e,ids:q9((n.workspaceId===e?n:{workspaceId:e,ids:[or],activeId:or}).ids,t,i),activeId:i})))}).catch(()=>{Fn.current===n&&(Fn.current=null)}),r},[or,sn,Yt,e]),xr=(0,I.useCallback)(t=>{let n=ft.workspaceId===e?ft:{workspaceId:e,ids:[or],activeId:or},r=n.ids.indexOf(t),i=n.activeId;if(r>=0){let a=n.ids.filter(e=>e!==t);i=n.activeId===t?a[Math.max(0,r-1)]??a[0]??null:n.activeId,pt({workspaceId:e,ids:a,activeId:i}),i&&n.activeId===t&&on(i)}return ln(t)},[ft,or,ln,on,e]),Sr=(0,I.useCallback)(()=>pr.length>=2?br(mr):yr(),[mr,pr.length,br,yr]),[Cr,wr]=(0,I.useState)(Zt),Tr=(0,I.useRef)(e);(0,I.useEffect)(()=>{if(Tr.current!==e){Tr.current=e,wr(Zt);return}Zt&&wr(!0)},[Zt,e]);let Er=Zt&&wt&&!rn,Dr=!Cr&&Ne!==!1&&(!wt||!!rn),Or=(0,I.useCallback)(t=>{ot({workspaceId:e,status:t}),Fe?.(t)},[Fe,e]);(0,I.useEffect)(()=>{let e=e=>{let t=e.detail;!t||typeof t!=`object`||qs(t,er)};return globalThis.addEventListener?.(uc,e),()=>globalThis.removeEventListener?.(uc,e)},[er]),(0,I.useEffect)(()=>{Mt||A?.(rn??null)},[rn,A,Mt]);let kr=xt.status!==`ready`,Ar=kr?(0,L.jsx)(wzt,{status:xt}):void 0,jr=(0,I.useCallback)(async e=>{let t=`${h?.replace(/\/$/,``)??``}/api/v1/agent/reload`;try{let n=await fetch(t,{method:`POST`,headers:{...tt,"content-type":`application/json`},body:JSON.stringify({sessionId:e})});if(!n.ok)return(await n.json().catch(()=>({}))).error||`reload failed (${n.status})`;let r=await n.json().catch(()=>({}));return window.dispatchEvent(new CustomEvent(w$,{detail:r})),qzt(r)}catch(e){return e instanceof Error?e.message:`Agent plugin reload failed.`}},[h,tt]),Mr=(0,I.useMemo)(()=>{let e=De?.remoteSessionOptions&&typeof De.remoteSessionOptions==`object`?De.remoteSessionOptions:void 0;return _?{...e??{},requestTimeoutMs:_}:e},[_,De?.remoteSessionOptions]),Nr=(0,I.useCallback)((t,n={})=>{let r=n.bridgeEnabled??!0,i=De?.toolRenderers&&typeof De.toolRenderers==`object`?De.toolRenderers:void 0;return{...De,...Er?{autoSubmitInitialDraft:!1,initialDraft:void 0}:{},sessionId:t,apiBaseUrl:h,workspaceId:e,storageScope:e,requestHeaders:tt,remoteSessionOptions:Mr,showSessions:!1,onReloadAgentPlugins:De?.onReloadAgentPlugins??(()=>jr(t)),toolRenderers:{...ir,...i??{}},bridgeEndpoint:r?S:null,surfaceDispatch:er,extraCommands:Me,workspaceWarmupStatus:xt,hydrateMessages:Dr,allowPromptDuringInitialHydration:dr.has(t),onPromptSubmitStarted:({sessionId:t})=>{ur(n=>{let r=n.workspaceId===e?n.ids:new Set;if(r.has(t))return n.workspaceId===e?n:{workspaceId:e,ids:r};let i=new Set(r);return i.add(t),{workspaceId:e,ids:i}})},onTurnComplete:()=>{Rt?.refresh?.({background:!0});let e=De?.onTurnComplete;typeof e==`function`&&e()},onAutoSubmitInitialDraftSettled:()=>{nn.current=!1,wr(!1),en(void 0);let e=De?.onAutoSubmitInitialDraftSettled;typeof e==`function`&&e()},...Ge===void 0?{}:{hotReloadEnabled:Ge}}},[h,De,Mr,Er,tt,S,er,Me,xt,Dr,dr,Ge,ir,jr,Rt,e]),Pr=(0,I.useMemo)(()=>Nr(or),[or,Nr]),Fr=(0,I.useRef)(null),Ir=(0,I.useMemo)(()=>{(!Fr.current||Fr.current.make!==Nr)&&(Fr.current={make:Nr,cache:new Map});let{cache:e}=Fr.current;return pr.map(t=>{let n=t===mr,r=`${t}:${n}`,i=e.get(r);return i||(i=Nr(t,{bridgeEnabled:n}),e.set(r,i)),{id:t,title:cr.get(t)??(t==="default"?ue:t),panel:`chat`,params:i}})},[mr,pr,ue,Nr,cr]),Lr=(0,I.useMemo)(()=>{let e=new Set;for(let t of Yt)e.add(t.id);for(let t of pr)e.add(t);return rn&&e.add(rn),[...e]},[pr,rn,Yt]),Rr=!Mt&&!(Rt?.hasMore??!1),zr=(0,I.useMemo)(()=>({storageKey:qe,defaultLeftTab:ge,initialPanels:ve,extraPanels:ar,onReloadAgentPlugins:()=>jr(rn??or),onReady:Un,onChange:Gn,onClose:Xn,showCloseAction:!1}),[Xn,ge,ve,jr,rn,or,Gn,Un,qe,ar,wn]),Br=()=>{document.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0,ctrlKey:!0,bubbles:!0,cancelable:!0}))},Vr=(0,L.jsxs)(L.Fragment,{children:[xe?(0,L.jsx)(Ust,{}):null,be]}),Hr={sessions:Yt,activeId:mr,openIds:pr,pinnedIds:yt,onTogglePin:bt,onSwitch:hr,onOpenAsTab:_r,onCreate:sn,onDelete:xr,onLoadMore:Rt?.loadMore,hasMore:Rt?.hasMore,loadingMore:Rt?.loadingMore,onClose:()=>fn(!1)},Ur=!!(Rt||k||!zt),Wr=(0,I.useMemo)(()=>Xe?{sessions:Yt,activeId:mr,openIds:pr,search:(e,t)=>zue(e,t,{limit:8}),onSwitch:hr,onOpenAsTab:_r}:void 0,[mr,pr,Xe,_r,Yt,hr]),Gr=WRt({appLeftPaneCollapsed:pn,workspaceId:e,effectiveAppLeftPaneWidth:_n,sessionTitleById:cr,defaultSessionTitle:ue,makeCenterParams:Nr,openChatPane:_r,surfaceDispatch:er,onDockOverlay:()=>bn(null)}),Kr=$e,qr=Mzt({plugins:vn,activeOverlay:yn,setActiveOverlay:bn}),Jr=(0,I.useMemo)(()=>!Xe||!Ee?.length?null:(0,L.jsx)(`div`,{className:`flex items-center gap-1`,children:Ee.map(e=>(0,L.jsxs)(`button`,{type:`button`,"data-boring-workspace-part":`chat-pane-control`,className:`inline-flex h-5 items-center gap-1 rounded-md px-1.5 text-[11px] font-medium text-muted-foreground/80 transition-colors hover:bg-muted/70 hover:text-foreground aria-pressed:bg-muted aria-pressed:text-foreground`,"aria-label":e.label,"aria-pressed":yn===e.id,title:e.label,onPointerDownCapture:e=>e.nativeEvent.stopPropagation(),onMouseDownCapture:e=>e.nativeEvent.stopPropagation(),onClick:t=>{t.preventDefault(),t.stopPropagation(),bn(t=>t===e.id?null:e.id)},children:[e.icon?(0,L.jsx)(`span`,{className:`grid size-3.5 place-items-center`,children:e.icon}):null,(0,L.jsx)(`span`,{children:e.label})]},e.id))}),[Ee,Xe,yn]),Yr=(0,I.useMemo)(()=>{let e=[...qr,...Te??[]];for(let t of Ee??[])e.push({id:t.id,label:t.label,icon:t.icon,trailing:t.trailing,emphasis:t.emphasis,onClick:()=>bn(e=>e===t.id?null:t.id)});return Qe&&e.push({id:`plugins`,label:`Plugins`,icon:(0,L.jsx)(Ai,{className:`h-4 w-4`,strokeWidth:1.75}),onClick:()=>bn(e=>e===`plugins`?null:`plugins`)}),Ze&&e.push({id:`skills`,label:`Skills`,icon:(0,L.jsx)(Ri,{className:`h-4 w-4`,strokeWidth:1.75}),onClick:()=>bn(e=>e===`skills`?null:`skills`)}),jzt(e),e},[Te,Ee,qr,Qe,Ze]),Xr=Nzt({plugins:vn,activeOverlay:yn,onClose:()=>bn(null),headerInsetStart:pn,headerInsetEnd:!Cn}),Zr=(0,I.useMemo)(()=>{let t=Ee?.find(e=>e.id===yn);return t?t.render({onClose:()=>bn(null),headerInsetStart:pn,headerInsetEnd:!Cn,workspaceId:e}):null},[Ee,pn,yn,Cn,e]),Qr=Xr??Zr??(yn===`skills`&&Ze?(0,L.jsx)(FRt,{onClose:()=>bn(null),headerInsetStart:pn,headerInsetEnd:!Cn}):yn===`plugins`&&Qe?(0,L.jsx)(KRt,{onClose:()=>bn(null),onReloadExternalPlugins:()=>jr(rn??or),headerInsetStart:pn,headerInsetEnd:!Cn}):null),$r=Kt?(0,L.jsx)(Tzt,{}):(0,L.jsx)(Fst,{className:Be,nav:Xe?null:Sn?`session-list`:null,navParams:Hr,center:`chat`,centerParams:Pr,chatPanes:Ir,chatTopActions:Jr,activeChatPaneId:mr,onActiveChatPaneChange:gr,onCloseChatPane:vr,onCreateChatPaneAfter:Xe?void 0:br,onDropChatSession:_r,flashChatPaneId:mt?.workspaceId===e?mt.id:null,surface:Cn?`artifact-surface`:null,surfaceParams:zr,chatOverlay:Xe?Qr:null,onCloseChatOverlay:()=>bn(null),surfaceOverlay:Ar,sidebar:Cn&&!kr&&nr&&jn?`workbench-left`:null,sidebarParams:Cn&&!kr&&nr?{...ge?{defaultTab:ge}:{},bridge:tr,onClose:()=>{On(!1),An(!1)},onCollapse:()=>{On(!1),An(!1)}}:void 0,storageKey:Ye?Je:void 0,onOpenNav:!Xe&&fe?()=>{fn(!0),Ie?.()}:void 0,onOpenSurface:()=>{In.current=!0,wn(!0),Le?.()},surfaceButtonBottomOffset:Re,mobileShellEnabled:ze,onOpenSidebar:nr?()=>{In.current=!0,wn(!0),On(!0),An(!0)}:void 0}),ei=Xe?(0,L.jsx)(czt,{collapsed:pn,onExpand:()=>mn(!1),onCollapse:()=>mn(!0),onResizeLeftPane:e=>gn(t=>Uzt(t+e,220,420)),leftPaneWidth:_n,minLeftPaneWidth:220,maxLeftPaneWidth:420,mobileShellEnabled:ze,leftPane:(0,L.jsx)(ozt,{width:_n,appTitle:ee,workspaceLabel:te,workspaceSectionTitle:ne,layoutMode:j,headerMode:M,projects:N,activeProjectId:re??e,onOpenProjectSession:ae,onShowMoreProjectSessions:oe,onCreateProject:se,onCreateProjectSession:t=>{t===(re??e)?(bn(null),Sr()):ie?.(t)},onOpenProjectSettings:ce,onOpenProjectInNewTab:le,sessionTitle:Kt?`Loading sessions…`:un??ue,topSlot:ye,bottomSlot:xe||be!=null?(0,L.jsx)(`div`,{className:`flex w-full min-w-0 items-center gap-2`,children:Vr}):void 0,sessions:Yt,activeSessionId:mr,openSessionIds:pr,pinnedSessionIds:yt,onCreateSession:()=>{bn(null),Sr()},onOpenCommandPalette:Br,onSwitchSession:hr,onOpenSessionAsPane:_r,onToggleSessionPinned:bt,onDeleteSession:Ur?xr:void 0,actions:Yr}),children:$r}):(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsx)(Hst,{appTitle:ee,sessionTitle:Kt?`Loading sessions…`:un??ue,onCommandPalette:Br,topBarLeft:ye,topBarRight:Vr}),$r]}),ti=Gr.floatingChatNode,ni=Xe?!pn:Sn;return(0,L.jsx)(`div`,{className:`relative h-full bg-background text-foreground`,children:(0,L.jsx)(qrt,{value:Gr.shellCapabilities,children:(0,L.jsxs)(Dst,{chatPanel:St,panels:Kr,commands:u,catalogs:d,plugins:f,capturedPlugins:vn,excludeDefaults:p,capabilities:m,apiBaseUrl:h,authHeaders:nt,apiTimeout:_,activeSessionId:mr,openSessionIds:pr,attentionSessionIds:Lr,attentionSessionsAuthoritative:Rr,defaultTheme:v,onThemeChange:y,workspaceId:e,workspaceLabel:te,appTitle:ee,storageKey:Ke,persistenceEnabled:b,debug:!He&&x,bridgeEndpoint:null,onAuthError:w,frontPluginHotReload:We,fullPageBasePath:C,commandPaletteSessionSearch:Wr,children:[s,(0,L.jsx)(Czt,{workspaceId:e,requestHeaders:tt,apiBaseUrl:h,preloadPaths:Pe,provisionWorkspace:Ne,onStatusChange:Or}),(0,L.jsx)(kzt,{bridgeEndpoint:S,requestHeaders:tt,navOpen:ni,surfaceOpen:Cn,surfaceReady:Tn,snapshot:Hn}),(0,L.jsx)(Pzt,{activeSessionId:mr,onAttentionOpen:Mn}),ei,ti,c]})})})}function eBt(e){return(e.trim()[0]??`W`).toUpperCase()}function tBt({className:e}){return(0,L.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M15 3h6v6`}),(0,L.jsx)(`path`,{d:`M10 14 21 3`}),(0,L.jsx)(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`})]})}function nBt(e,t,n){if(e.length===0)return-1;for(let r=1;r<=e.length;r++){let i=(t+n*r+e.length)%e.length;if(e[i]?.available!==!1)return i}return-1}function rBt({appTitle:e=`Boring`,displayMode:t=`full`,workspaces:n,activeWorkspaceId:r,emptyLabel:i=`Create your first workspace`,createLabel:a=`Create workspace`,createDescription:o=`Start a clean project space`,settingsLabel:s=`Workspace settings`,settingsDescription:c=`Rename, runtime, deletion`,onSelectWorkspace:l,getWorkspaceHref:u,onCreateWorkspace:d,onOpenWorkspaceSettings:f}){let p=(0,I.useRef)(null),m=(0,I.useRef)([]),[h,g]=(0,I.useState)(!1),_=n.find(e=>e.id===r)??null,y=_?.name??`Select workspace`,b=(0,I.useMemo)(()=>n.findIndex(e=>e.id===r&&e.available!==!1),[r,n]),x=(0,I.useMemo)(()=>n.findIndex(e=>e.available!==!1),[n]),[C,w]=(0,I.useState)(()=>b>=0?b:x);(0,I.useEffect)(()=>{let e=e=>{e.isComposing||!e.metaKey||!e.shiftKey||e.altKey||e.ctrlKey||e.key.toLowerCase()!==`k`&&e.code!==`KeyK`||(e.preventDefault(),e.stopPropagation(),p.current?.focus(),w(b>=0?b:x),g(!0))};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[b,x]),(0,I.useEffect)(()=>{if(!h)return;let e=b>=0?b:x;w(e),window.setTimeout(()=>m.current[e]?.focus(),0)},[b,x,h]);let T=(0,I.useCallback)(e=>{e&&w(b>=0?b:x),g(e)},[b,x]),D=(0,I.useCallback)(()=>{let e=n[C];!e||e.available===!1||(l(e.id),g(!1))},[C,l,n]),O=(0,I.useCallback)(e=>{w(t=>{let r=nBt(n,t>=0?t:b>=0?b:x,e);return window.setTimeout(()=>m.current[r]?.focus(),0),r})},[b,x,n]),k=(0,I.useCallback)(e=>{if(h&&!(e.target instanceof Element&&e.target.closest(`[data-workspace-new-tab-button="true"]`))&&!(e.metaKey||e.altKey||e.ctrlKey)){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),e.stopPropagation(),O(e.key===`ArrowDown`?1:-1);return}if(e.key===`Enter`){e.preventDefault(),e.stopPropagation(),D();return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),g(!1),p.current?.focus())}},[O,h,D]);(0,I.useEffect)(()=>{if(!h)return;let e=e=>k(e);return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[k,h]);let A=(0,I.useCallback)(e=>{k(e)},[k]),ee=(0,I.useCallback)(e=>{let t=u?.(e)??`/workspace/${encodeURIComponent(e)}`;window.open(t,`_blank`,`noopener,noreferrer`)},[u]);if(n.length===0)return(0,L.jsxs)(Se,{type:`button`,variant:`ghost`,onClick:d,disabled:!d,className:`-ml-1 h-8 gap-2 rounded-md px-1 pr-2.5 hover:bg-muted/60 focus-visible:ring-1 focus-visible:ring-ring`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,style:{width:28,height:28},className:`flex shrink-0 items-center justify-center rounded-md bg-foreground text-[12px] font-semibold text-background`,children:e.charAt(0).toUpperCase()}),(0,L.jsx)(`span`,{className:`text-[13px] font-medium text-foreground`,children:i})]});let te=t===`workspace`;return(0,L.jsxs)(`div`,{className:te?`flex h-8 min-w-0 items-center`:`-ml-1 flex h-8 min-w-0 items-center gap-1.5`,children:[te?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,style:{width:28,height:28},className:`flex shrink-0 items-center justify-center rounded-md bg-foreground text-[12px] font-semibold text-background`,children:e.charAt(0).toUpperCase()}),(0,L.jsx)(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:e}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground/30`,children:`/`})]}),(0,L.jsxs)(j,{open:h,onOpenChange:T,children:[(0,L.jsx)(re,{asChild:!0,children:(0,L.jsxs)(Se,{ref:p,type:`button`,variant:`ghost`,"aria-label":`Workspace menu: ${y}`,title:`Workspace picker (⌘⇧K)`,className:te?`h-8 w-full min-w-0 justify-start gap-1.5 rounded-lg border border-transparent px-2 text-left hover:bg-foreground/[0.06] focus-visible:ring-1 focus-visible:ring-ring`:`group h-8 min-w-0 justify-start gap-1.5 rounded-md px-1.5 py-1 text-left hover:bg-muted/60 focus-visible:ring-1 focus-visible:ring-ring`,children:[(0,L.jsx)(`span`,{className:te?`min-w-0 flex-1 truncate text-[13px] font-medium text-foreground/85`:`max-w-[15rem] truncate text-[13px] font-normal text-muted-foreground`,children:y}),te?null:(0,L.jsx)(pe,{className:`ml-1 border-0 bg-transparent p-0 text-[10px] leading-none text-muted-foreground/60 shadow-none group-hover:text-muted-foreground`,children:`⌘⇧K`}),(0,L.jsx)(wr,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground/50`,"aria-hidden":`true`})]})}),(0,L.jsxs)(v,{align:`start`,side:`bottom`,sideOffset:6,onKeyDownCapture:A,alignOffset:te?-40:0,className:`w-80 rounded-lg border-border/70 bg-popover p-2 text-popover-foreground shadow-2xl supports-[background:color-mix(in_oklch,white,black)]:bg-[color:var(--surface-workbench-left,var(--popover))]`,children:[(0,L.jsx)(`div`,{className:`px-2 pb-2 pt-1`,children:(0,L.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,L.jsx)(oi,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`Workspaces`]})}),(0,L.jsx)(`div`,{className:`max-h-72 overflow-y-auto pr-1`,children:n.map((e,t)=>{let n=_?.id===e.id,r=C===t,i=e.available!==!1;return(0,L.jsxs)(`div`,{className:`group relative w-full`,children:[(0,L.jsxs)(S,{ref:e=>{m.current[t]=e},"aria-label":i?e.name:`${e.name}. Folder unavailable.`,"data-current":n?`true`:`false`,"data-active":r?`true`:`false`,disabled:!i,onFocus:()=>w(t),onPointerMove:()=>{i&&w(t)},onSelect:()=>l(e.id),style:{paddingRight:72,backgroundColor:r?`color-mix(in oklch, var(--foreground) 10%, transparent)`:n?`color-mix(in oklch, var(--foreground) 5%, transparent)`:void 0},className:`relative gap-3 rounded-md px-2.5 py-2 pl-3 text-[13px] focus:bg-foreground/[0.06] focus:text-foreground data-[active=true]:text-foreground data-[current=true]:text-foreground`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,style:{backgroundColor:r?`var(--foreground)`:`transparent`},className:`absolute bottom-2 left-1 top-2 w-0.5 rounded-full`}),(0,L.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-border/60 bg-background text-xs font-semibold text-muted-foreground`,children:eBt(e.name)}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),i?e.path?(0,L.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.path}):null:(0,L.jsx)(`span`,{className:`truncate text-xs text-destructive`,children:`Folder unavailable`})]})]}),i?(0,L.jsx)(`button`,{type:`button`,tabIndex:-1,"data-workspace-new-tab-button":`true`,"aria-label":`Open ${e.name} in new tab`,title:`Open in new tab`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:t=>{t.preventDefault(),t.stopPropagation(),ee(e.id)},style:{right:6,top:`50%`,transform:`translateY(-50%)`},className:`absolute z-10 flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground opacity-0 transition hover:bg-foreground/10 hover:text-foreground focus:opacity-100 focus:outline-none focus-visible:ring-1 focus-visible:ring-ring group-hover:opacity-100 group-focus-within:opacity-100`,children:(0,L.jsx)(tBt,{className:`h-3.5 w-3.5`})}):null]},e.id)})}),d||_&&f?(0,L.jsx)(E,{className:`-mx-1.5 my-1`}):null,d?(0,L.jsxs)(S,{"aria-label":a,onSelect:e=>{e.preventDefault(),d()},className:`gap-3 rounded-lg px-2.5 py-2.5 text-[13px] focus:bg-foreground/[0.06] focus:text-foreground`,children:[(0,L.jsx)(Mi,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,L.jsx)(`span`,{children:a}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o})]})]}):null,_&&f?(0,L.jsxs)(S,{"aria-label":s,onSelect:()=>f(_.id),className:`gap-3 rounded-lg px-2.5 py-2.5 text-[13px] focus:bg-foreground/[0.06] focus:text-foreground`,children:[(0,L.jsx)(Li,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,L.jsx)(`span`,{children:s}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:c})]})]}):null]})]})]})}globalThis.__BORING_RUNTIME_SINGLETONS__={...globalThis.__BORING_RUNTIME_SINGLETONS__,react:I,"react-dom":Pn,"react-dom/client":Fn,"react/jsx-dev-runtime":In,"react/jsx-runtime":L,"@hachej/boring-workspace":zFt,"@hachej/boring-workspace/events":cc,"@hachej/boring-workspace/plugin":aIt};var Z9=5,iBt=25;function Q9(e){let t=e.match(/^\/workspace\/([^/?#]+)/);if(!t?.[1])return null;try{return decodeURIComponent(t[1])}catch{return t[1]}}var $9=`session`;function aBt(e){return new URLSearchParams(e).get($9)?.trim()||null}function oBt(e){return`/workspace/${encodeURIComponent(e)}`}function sBt(e){let t=oBt(e);`${window.location.pathname}${window.location.search}`!==t&&window.history.replaceState(null,``,t)}function cBt(){let e=new URLSearchParams(window.location.search);if(!e.has($9))return;e.delete($9);let t=e.toString(),n=`${window.location.pathname}${t?`?${t}`:``}`;window.history.replaceState(null,``,n)}function lBt(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return r&&e.id===r.id&&e.name===r.name&&e.path===r.path&&e.available===r.available})}function uBt(e){return`boring-agent:v2:${e}:activeSessionId`}function dBt(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.id!=`string`||t.id.length===0?null:{id:t.id,title:typeof t.title==`string`?t.title:`Untitled`,updatedAt:typeof t.updatedAt==`string`||typeof t.updatedAt==`number`?t.updatedAt:void 0}}async function fBt(e){let t=new URLSearchParams({limit:String(iBt)}),n=await fetch(`/api/v1/agent/pi-chat/sessions?${t.toString()}`,{headers:{"x-boring-workspace-id":e}});if(!n.ok)throw Error(`sessions ${n.status}`);let r=await n.json();return Array.isArray(r)?r.map(dBt).filter(e=>!!e):[]}function pBt({version:e}){let t=e?.trim();return t?(0,L.jsxs)(`span`,{"aria-label":`Boring UI CLI version ${t}`,title:`Boring UI CLI ${t}`,className:`rounded-full border border-border/60 bg-muted/40 px-2 py-0.5 text-[10px] font-medium leading-none tracking-tight text-muted-foreground`,children:[`v`,t]}):null}function mBt(){let[e,t]=(0,I.useState)(`Workspace`),[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(null),[o,s]=(0,I.useState)([]),[c,l]=(0,I.useState)(null),[u]=(0,I.useState)(()=>aBt(window.location.search)),[d]=(0,I.useState)(()=>Q9(window.location.pathname)),[f,p]=(0,I.useState)(!1),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(!1),[v,y]=(0,I.useState)({}),[b,x]=(0,I.useState)({}),S=(0,I.useRef)(null),C=(0,I.useCallback)(()=>{fetch(`/api/v1/local-workspaces`).then(async e=>{if(!e.ok)throw Error(`local-workspaces ${e.status}`);return await e.json()}).then(e=>{let t=e.workspaces??[];h(!0),s(e=>lBt(e,t)?e:t),l(e=>{let n=Q9(window.location.pathname),r=window.localStorage.getItem(`boring-ui:local-workspace-id`);if(n)return t.some(e=>e.id===n&&e.available)&&window.localStorage.setItem(`boring-ui:local-workspace-id`,n),n;let i=e??r,a=(i?t.find(e=>e.id===i&&e.available):null)??t.find(e=>e.available)??null;return a&&window.localStorage.setItem(`boring-ui:local-workspace-id`,a.id),a?.id??null})}).catch(()=>{window.setTimeout(()=>S.current?.(),1500)})},[]);S.current=C,(0,I.useEffect)(()=>{let e=!1;return fetch(`/api/v1/workspace/meta`).then(async e=>e.ok?await e.json():null).then(n=>{if(e)return;let i=n?.projectName?.trim();i&&(t(i),document.title=i);let o=n?.version?.trim();o&&a(o);let s=n?.workspacesMode===!0,c=n?.runtimePluginFrontLoadingEnabled===!0;r(s),_(c),s&&C(),p(!0)}).catch(()=>{e||p(!0)}),()=>{e=!0}},[C]),(0,I.useEffect)(()=>{cBt()},[]),(0,I.useEffect)(()=>{if(!n)return;let e=()=>C(),t=()=>{l(Q9(window.location.pathname))};return window.addEventListener(`focus`,e),window.addEventListener(`popstate`,t),()=>{window.removeEventListener(`focus`,e),window.removeEventListener(`popstate`,t)}},[C,n]),(0,I.useEffect)(()=>{!n||!c||sBt(c)},[c,n]);let w=(0,I.useRef)(0);(0,I.useEffect)(()=>{if(!n||!c)return;if(o.some(e=>e.id===c&&e.available)){w.current=0;return}let e=window.setInterval(()=>{if(w.current+=1,w.current>10){window.clearInterval(e),l(e=>{let t=o.find(e=>e.available);return t?(window.localStorage.setItem(`boring-ui:local-workspace-id`,t.id),t.id):e});return}C()},1500);return()=>window.clearInterval(e)},[n,c,o,C]);let T=(0,I.useMemo)(()=>[uLt({appLeftInbox:!0}),...n?[]:[XLt],iRt,NRt()],[n]),E=(0,I.useMemo)(()=>c?{"x-boring-workspace-id":c}:null,[c]),D=(0,I.useMemo)(()=>o.filter(e=>e.available).map(e=>e.id).sort().join(`
870
870
  `),[o]);(0,I.useEffect)(()=>{if(!n||!D)return;let e=D.split(`